1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file GNEAdditionalFrame.h 11 /// @author Pablo Alvarez Lopez 12 /// @date Dec 2015 13 /// @version $Id$ 14 /// 15 // The Widget for add additional elements 16 /****************************************************************************/ 17 #ifndef GNEAdditionalFrame_h 18 #define GNEAdditionalFrame_h 19 20 21 // =========================================================================== 22 // included modules 23 // =========================================================================== 24 #include "GNEFrame.h" 25 26 27 // =========================================================================== 28 // class definitions 29 // =========================================================================== 30 /** 31 * @class GNEAdditionalFrame 32 * The Widget for setting internal attributes of additional elements 33 */ 34 class GNEAdditionalFrame : public GNEFrame { 35 36 public: 37 38 // =========================================================================== 39 // class SelectorLaneParents 40 // =========================================================================== 41 42 class SelectorLaneParents : protected FXGroupBox { 43 /// @brief FOX-declaration 44 FXDECLARE(GNEAdditionalFrame::SelectorLaneParents) 45 public: 46 /// @brief constructor 47 SelectorLaneParents(GNEAdditionalFrame* additionalFrameParent); 48 49 /// @brief destructor 50 ~SelectorLaneParents(); 51 52 /// @brief show SelectorLaneParents modul 53 void showSelectorLaneParentsModul(); 54 55 /// @brief hide SelectorLaneParents 56 void hideSelectorLaneParentsModul(); 57 58 /// @brief start selection of consecutive lanes 59 void startConsecutiveLaneSelector(GNELane* lane, const Position& clickedPosition); 60 61 /// @brief stop selection of consecutive lanes 62 bool stopConsecutiveLaneSelector(); 63 64 /// @brief abort selection of consecutive lanes 65 void abortConsecutiveLaneSelector(); 66 67 /// @brief return true if lane can be selected as consecutive lane 68 bool addSelectedLane(GNELane* lane, const Position& clickedPosition); 69 70 /// @brief remove last added point 71 void removeLastSelectedLane(); 72 73 /// @brief return true if modul is selecting lane 74 bool isSelectingLanes() const; 75 76 /// @brief return true if modul is shown 77 bool isShown() const; 78 79 /// @brief get selected lane color 80 const RGBColor& getSelectedLaneColor() const; 81 82 /// @brief get current selected lanes 83 const std::vector<std::pair<GNELane*, double> >& getSelectedLanes() const; 84 85 /// @name FOX-callbacks 86 /// @{ 87 /// @brief Called when the user press stop selection button 88 long onCmdStopSelection(FXObject*, FXSelector, void*); 89 90 /// @brief Called when the user press abort selection button 91 long onCmdAbortSelection(FXObject*, FXSelector, void*); 92 /// @} 93 94 protected: 95 /// @brief FOX needs this SelectorLaneParents()96 SelectorLaneParents() {} 97 98 private: 99 /// @brief pointer to additionalFrameParent 100 GNEAdditionalFrame* myAdditionalFrameParent; 101 102 /// @brief button for stop selecting 103 FXButton* myStopSelectingButton; 104 105 /// @brief button for abort selecting 106 FXButton* myAbortSelectingButton; 107 108 /// @brief Vector with the selected lanes and the clicked position 109 std::vector<std::pair<GNELane*, double> > mySelectedLanes; 110 111 /// @brief Vector with the colored lanes 112 std::vector<GNELane*> myCandidateLanes; 113 114 /// @brief color for candidate lanes 115 RGBColor myCandidateLaneColor; 116 117 /// @brief color for selected lanes 118 RGBColor mySelectedLaneColor; 119 120 /// @brief check if certain lane is selected 121 bool isLaneSelected(GNELane* lane) const; 122 }; 123 124 // =========================================================================== 125 // class SelectorAdditionalParent 126 // =========================================================================== 127 128 class SelectorAdditionalParent : protected FXGroupBox { 129 public: 130 /// @brief constructor 131 SelectorAdditionalParent(GNEAdditionalFrame* additionalFrameParent); 132 133 /// @brief destructor 134 ~SelectorAdditionalParent(); 135 136 /// @brief get currently additional parent selected 137 std::string getIdSelected() const; 138 139 /// @brief select manually a element of the list 140 void setIDSelected(const std::string& id); 141 142 /// @brief Show list of SelectorAdditionalParent Modul 143 bool showSelectorAdditionalParentModul(SumoXMLTag additionalTypeParent); 144 145 /// @brief hide SelectorAdditionalParent Modul 146 void hideSelectorAdditionalParentModul(); 147 148 /// @brief Refresh list of Additional Parents Modul 149 void refreshSelectorAdditionalParentModul(); 150 151 private: 152 /// @brief pointer to Additional Frame Parent 153 GNEAdditionalFrame* myAdditionalFrameParent; 154 155 /// @brief current additional type parent 156 SumoXMLTag myAdditionalTypeParent; 157 158 /// @brief Label with the name of additional 159 FXLabel* myFirstAdditionalParentsLabel; 160 161 /// @brief List of additional sets 162 FXList* myFirstAdditionalParentsList; 163 }; 164 165 // =========================================================================== 166 // class SelectorEdgeChilds 167 // =========================================================================== 168 169 class SelectorEdgeChilds : protected FXGroupBox { 170 /// @brief FOX-declaration 171 FXDECLARE(GNEAdditionalFrame::SelectorEdgeChilds) 172 173 public: 174 /// @brief constructor 175 SelectorEdgeChilds(GNEAdditionalFrame* additionalFrameParent); 176 177 /// @brief destructor 178 ~SelectorEdgeChilds(); 179 180 /// @brief get list of selecte id's in string format 181 std::string getEdgeIdsSelected() const; 182 183 /// @brief Show SelectorEdgeChilds Modul 184 void showSelectorEdgeChildsModul(std::string search = ""); 185 186 /// @brief hide SelectorEdgeChilds Modul 187 void hideSelectorEdgeChildsModul(); 188 189 /// @brief Update use selectedEdges 190 void updateUseSelectedEdges(); 191 192 /// @name FOX-callbacks 193 /// @{ 194 /// @brief called when user trigger checkBox of useSelectedEdges 195 long onCmdUseSelectedEdges(FXObject*, FXSelector, void*); 196 197 /// @brief called when user type in search box 198 long onCmdTypeInSearchBox(FXObject*, FXSelector, void*); 199 200 /// @brief called when user select a edge of the list 201 long onCmdSelectEdge(FXObject*, FXSelector, void*); 202 203 /// @brief called when clear selection button is pressed 204 long onCmdClearSelection(FXObject*, FXSelector, void*); 205 206 /// @brief called when invert selection button is pressed 207 long onCmdInvertSelection(FXObject*, FXSelector, void*); 208 /// @} 209 210 protected: 211 /// @brief FOX needs this SelectorEdgeChilds()212 SelectorEdgeChilds() {} 213 214 private: 215 /// @brief pointer to additional frame parent 216 GNEAdditionalFrame* myAdditionalFrameParent; 217 218 /// @brief CheckBox for selected edges 219 FXCheckButton* myUseSelectedEdgesCheckButton; 220 221 /// @brief List of SelectorEdgeChilds 222 FXList* myList; 223 224 /// @brief text field for search edge IDs 225 FXTextField* myEdgesSearch; 226 227 /// @brief button for clear selection 228 FXButton* myClearEdgesSelection; 229 230 /// @brief button for invert selection 231 FXButton* myInvertEdgesSelection; 232 }; 233 234 // =========================================================================== 235 // class SelectorLaneChilds 236 // =========================================================================== 237 238 class SelectorLaneChilds : protected FXGroupBox { 239 /// @brief FOX-declaration 240 FXDECLARE(GNEAdditionalFrame::SelectorLaneChilds) 241 242 public: 243 /// @brief constructor 244 SelectorLaneChilds(GNEAdditionalFrame* additionalFrameParent); 245 246 /// @brief destructor 247 ~SelectorLaneChilds(); 248 249 /// @brief get list of selecte lane ids in string format 250 std::string getLaneIdsSelected() const; 251 252 /// @brief Show list of SelectorLaneChilds Modul 253 void showSelectorLaneChildsModul(std::string search = ""); 254 255 /// @brief hide SelectorLaneChilds Modul 256 void hideSelectorLaneChildsModul(); 257 258 // @brief Update use selectedLanes 259 void updateUseSelectedLanes(); 260 261 /// @name FOX-callbacks 262 /// @{ 263 /// @brief called when user trigger checkBox of useSelectedLanes 264 long onCmdUseSelectedLanes(FXObject*, FXSelector, void*); 265 266 /// @brief called when user type in search box 267 long onCmdTypeInSearchBox(FXObject*, FXSelector, void*); 268 269 /// @brief called when user select a lane of the list 270 long onCmdSelectLane(FXObject*, FXSelector, void*); 271 272 /// @brief called when clear selection button is pressed 273 long onCmdClearSelection(FXObject*, FXSelector, void*); 274 275 /// @brief called when invert selection button is pressed 276 long onCmdInvertSelection(FXObject*, FXSelector, void*); 277 /// @} 278 279 protected: 280 /// @brief FOX needs this SelectorLaneChilds()281 SelectorLaneChilds() {} 282 283 private: 284 /// @brief pointer to additional frame parent 285 GNEAdditionalFrame* myAdditionalFrameParent; 286 287 /// @brief CheckBox for selected lanes 288 FXCheckButton* myUseSelectedLanesCheckButton; 289 290 /// @brief List of SelectorLaneChilds 291 FXList* myList; 292 293 /// @brief text field for search lane IDs 294 FXTextField* myLanesSearch; 295 296 /// @brief button for clear selection 297 FXButton* clearLanesSelection; 298 299 /// @brief button for invert selection 300 FXButton* invertLanesSelection; 301 }; 302 303 /**@brief Constructor 304 * @brief parent FXHorizontalFrame in which this GNEFrame is placed 305 * @brief viewNet viewNet that uses this GNEFrame 306 */ 307 GNEAdditionalFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet); 308 309 /// @brief Destructor 310 ~GNEAdditionalFrame(); 311 312 /// @brief show Frame 313 void show(); 314 315 /**@brief add additional element 316 * @param objectsUnderCursor collection of objects under cursor after click over view 317 * @return true if additional was sucesfully added 318 */ 319 bool addAdditional(const GNEViewNetHelper::ObjectsUnderCursor& objectsUnderCursor); 320 321 /// @brief show selector lane child and update use selected edges/lanes 322 void showSelectorLaneChildsModul(); 323 324 /// @brief getConsecutive Lane Selector 325 GNEAdditionalFrame::SelectorLaneParents* getConsecutiveLaneSelector() const; 326 327 protected: 328 /// @brief enable moduls depending of item selected in ItemSelector 329 void enableModuls(const GNEAttributeCarrier::TagProperties& tagProperties); 330 331 /// @brief disable moduls if element selected in itemSelector isn't valid 332 void disableModuls(); 333 334 private: 335 /// @brief generate a ID for an additiona element 336 std::string generateID(GNENetElement* netElement) const; 337 338 /// @brief build common additional attributes 339 bool buildAdditionalCommonAttributes(std::map<SumoXMLAttr, std::string>& valuesMap, const GNEAttributeCarrier::TagProperties& tagValues); 340 341 /// @brief build additional with Parent 342 bool buildAdditionalWithParent(std::map<SumoXMLAttr, std::string>& valuesMap, GNEAdditional* parent, const GNEAttributeCarrier::TagProperties& tagValues); 343 344 /// @brief build additional over an edge (parent of lane) 345 bool buildAdditionalOverEdge(std::map<SumoXMLAttr, std::string>& valuesMap, GNELane* lane, const GNEAttributeCarrier::TagProperties& tagValues); 346 347 /// @brief build additional over a single lane 348 bool buildAdditionalOverLane(std::map<SumoXMLAttr, std::string>& valuesMap, GNELane* lane, const GNEAttributeCarrier::TagProperties& tagValues); 349 350 /// @brief build additional over lanes 351 bool buildAdditionalOverLanes(std::map<SumoXMLAttr, std::string>& valuesMap, GNELane* lane, const GNEAttributeCarrier::TagProperties& tagValues); 352 353 /// @brief build additional over view 354 bool buildAdditionalOverView(std::map<SumoXMLAttr, std::string>& valuesMap, const GNEAttributeCarrier::TagProperties& tagValues); 355 356 /// @brief item selector 357 ItemSelector* myItemSelector; 358 359 /// @brief internal additional attributes 360 AttributesCreator* myAdditionalAttributes; 361 362 /// @brief Netedit parameter 363 NeteditAttributes* myNeteditAttributes; 364 365 /// @brief Modul for select lane parents (currently only consecutives) 366 SelectorLaneParents* mySelectorLaneParents; 367 368 /// @brief Modul for select a single additional parent (Used only for first Additional parent) 369 SelectorAdditionalParent* mySelectorAdditionalParent; 370 371 /// @brief Modul for select edge childs 372 SelectorEdgeChilds* mySelectorEdgeChilds; 373 374 /// @brief Modul for select lane childs 375 SelectorLaneChilds* mySelectorLaneChilds; 376 }; 377 378 379 #endif 380 381 /****************************************************************************/ 382