Eclipse SUMO - Simulation of Urban MObility
GNERoute.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2016-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 /****************************************************************************/
15 // A class for visualizing routes in Netedit
16 /****************************************************************************/
17 #ifndef GNERoute_h
18 #define GNERoute_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 
26 
27 #include "GNEDemandElement.h"
28 #include "GNERouteHandler.h"
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class GNEEdge;
35 class GNEConnection;
36 class GNEVehicle;
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
41 
42 class GNERoute : public GNEDemandElement, public Parameterised {
43 
44 public:
45 
48  FXDECLARE(GNERoutePopupMenu)
49 
50  public:
58 
61 
63  long onCmdApplyDistance(FXObject*, FXSelector, void*);
64 
65  protected:
68  };
69 
73  GNERoute(GNEViewNet* viewNet);
74 
79  GNERoute(GNEViewNet* viewNet, const GNERouteHandler::RouteParameter& routeParameters);
80 
86  GNERoute(GNEViewNet* viewNet, GNEDemandElement* vehicleParent, const GNERouteHandler::RouteParameter& routeParameters);
87 
89  GNERoute(GNEDemandElement* route);
90 
92  ~GNERoute();
93 
97  void writeDemandElement(OutputDevice& device) const;
98 
100  bool isDemandElementValid() const;
101 
103  std::string getDemandElementProblem() const;
104 
107 
111  GNEEdge* getFromEdge() const;
112 
114  GNEEdge* getToEdge() const;
115 
117  SUMOVehicleClass getVClass() const;
118 
120  const RGBColor& getColor() const;
121 
123  void compute();
124 
126 
130  void startGeometryMoving();
131 
133  void endGeometryMoving();
134 
138  void moveGeometry(const Position& offset);
139 
143  void commitGeometryMoving(GNEUndoList* undoList);
144 
146  void updateGeometry();
147 
149  Position getPositionInView() const;
151 
154 
163 
167  std::string getParentName() const;
168 
173 
178  void drawGL(const GUIVisualizationSettings& s) const;
180 
184  void selectAttributeCarrier(bool changeFlag = true);
185 
187  void unselectAttributeCarrier(bool changeFlag = true);
188 
189  /* @brief method for getting the Attribute of an XML key
190  * @param[in] key The attribute key
191  * @return string with the value associated to key
192  */
193  std::string getAttribute(SumoXMLAttr key) const;
194 
195  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
196  * @param[in] key The attribute key
197  * @return double with the value associated to key
198  */
199  double getAttributeDouble(SumoXMLAttr key) const;
200 
201  /* @brief method for setting the attribute and letting the object perform additional changes
202  * @param[in] key The attribute key
203  * @param[in] value The new value
204  * @param[in] undoList The undoList on which to register changes
205  * @param[in] net optionally the GNENet to inform about gui updates
206  */
207  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
208 
209  /* @brief method for setting the attribute and letting the object perform additional changes
210  * @param[in] key The attribute key
211  * @param[in] value The new value
212  * @param[in] undoList The undoList on which to register changes
213  */
214  bool isValid(SumoXMLAttr key, const std::string& value);
215 
216  /* @brief method for enabling attribute
217  * @param[in] key The attribute key
218  * @param[in] undoList The undoList on which to register changes
219  * @note only certain attributes can be enabled, and can produce the disabling of other attributes
220  */
221  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
222 
223  /* @brief method for check if the value for certain attribute is set
224  * @param[in] key The attribute key
225  */
226  bool isAttributeEnabled(SumoXMLAttr key) const;
227 
229  std::string getPopUpID() const;
230 
232  std::string getHierarchyName() const;
234 
238  std::string getGenericParametersStr() const;
239 
241  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
242 
244  void setGenericParametersStr(const std::string& value);
245 
247 
248 protected:
251 
254 
255 private:
257  void setAttribute(SumoXMLAttr key, const std::string& value);
258 
260  void setEnabledAttribute(const int enabledAttributes);
261 
263  GNERoute(GNERoute*) = delete;
264 
266  GNERoute& operator=(GNERoute*) = delete;
267 };
268 
269 
270 #endif
271 
272 /****************************************************************************/
273 
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNERoute.cpp:378
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNERoute.cpp:459
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNERoute.cpp:434
GNERoute & operator=(GNERoute *)=delete
Invalidated assignment operator.
Position getPositionInView() const
Returns position of additional in view.
Definition: GNERoute.cpp:350
struct for saving route parameters
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNERoute.cpp:147
Stores the information about how to visualize structures.
const RGBColor & getColor() const
get color
Definition: GNERoute.cpp:229
void startGeometryMoving()
Definition: GNERoute.cpp:241
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
long onCmdApplyDistance(FXObject *, FXSelector, void *)
Called to modify edge distance values along the route.
Definition: GNERoute.cpp:62
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute) ...
Definition: GNERoute.cpp:591
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(...)
Definition: GNERoute.cpp:259
GNEEdge * getToEdge() const
obtain to edge of this demand element
Definition: GNERoute.cpp:217
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNERoute.cpp:501
void endGeometryMoving()
end geometry movement
Definition: GNERoute.cpp:247
std::string getAttribute(SumoXMLAttr key) const
Definition: GNERoute.cpp:415
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GNERoutePopupMenu()
default constructor needed by FOX
Definition: GNERoute.h:67
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNERoute.cpp:399
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes ...
Definition: GNERoute.cpp:440
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children) ...
Definition: GNERoute.cpp:205
~GNERoute()
destructor
Definition: GNERoute.cpp:116
~GNERoutePopupMenu()
Destructor.
Definition: GNERoute.cpp:58
An upper class for objects with additional parameters.
Definition: Parameterised.h:43
SUMOVehicleClass myVClass
SUMOVehicleClass (Only used for drawing)
Definition: GNERoute.h:253
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
GNEEdge * getFromEdge() const
Definition: GNERoute.cpp:211
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNERoute.cpp:120
bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNERoute.cpp:169
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNERoute.cpp:533
The popup menu of a globject.
class used in GUIGLObjectPopupMenu for routes
Definition: GNERoute.h:47
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNERoute.cpp:522
void updateGeometry()
update pre-computed geometry information
Definition: GNERoute.cpp:265
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNERoute.cpp:223
GNERoute(GNEViewNet *viewNet)
default constructor
Definition: GNERoute.cpp:80
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNERoute.cpp:489
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNERoute.cpp:362
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERoute.cpp:483
RGBColor myColor
route color
Definition: GNERoute.h:250
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNERoute.cpp:188
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNERoute.cpp:495
void compute()
compute demand element
Definition: GNERoute.cpp:235
void selectAttributeCarrier(bool changeFlag=true)
inherited from GNEAttributeCarrier
Definition: GNERoute.cpp:384
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNERoute.cpp:507
std::string getParentName() const
Returns the name of the parent object.
Definition: GNERoute.cpp:356
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNERoute.cpp:253