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 /****************************************************************************/
14 // A class for visualizing routes in Netedit
15 /****************************************************************************/
16 #ifndef GNERoute_h
17 #define GNERoute_h
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 
25 
26 #include "GNEDemandElement.h"
27 #include "GNERouteHandler.h"
28 
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class GNEEdge;
34 class GNEConnection;
35 class GNEVehicle;
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
40 
41 class GNERoute : public GNEDemandElement, public Parameterised {
42 
43 public:
44 
47  FXDECLARE(GNERoutePopupMenu)
48 
49  public:
57 
60 
62  long onCmdApplyDistance(FXObject*, FXSelector, void*);
63 
64  protected:
67  };
68 
72  GNERoute(GNEViewNet* viewNet);
73 
78  GNERoute(GNEViewNet* viewNet, const GNERouteHandler::RouteParameter& routeParameters);
79 
85  GNERoute(GNEViewNet* viewNet, GNEDemandElement* vehicleParent, const GNERouteHandler::RouteParameter& routeParameters);
86 
88  GNERoute(GNEDemandElement* route);
89 
91  ~GNERoute();
92 
96  void writeDemandElement(OutputDevice& device) const;
97 
99  bool isDemandElementValid() const;
100 
102  std::string getDemandElementProblem() const;
103 
106 
110  GNEEdge* getFromEdge() const;
111 
113  GNEEdge* getToEdge() const;
114 
116  SUMOVehicleClass getVClass() const;
117 
119  const RGBColor& getColor() const;
120 
122 
126  void startGeometryMoving();
127 
129  void endGeometryMoving();
130 
134  void moveGeometry(const Position& offset);
135 
139  void commitGeometryMoving(GNEUndoList* undoList);
140 
142  void updateGeometry();
143 
145  void updatePartialGeometry(const GNEEdge* edge);
146 
148  void computePath();
149 
151  void invalidatePath();
152 
154  Position getPositionInView() const;
156 
159 
168 
172  std::string getParentName() const;
173 
178 
180  void splitEdgeGeometry(const double splitPosition, const GNENetElement* originalElement, const GNENetElement* newElement, GNEUndoList* undoList);
181 
186  void drawGL(const GUIVisualizationSettings& s) const;
188 
192  void selectAttributeCarrier(bool changeFlag = true);
193 
195  void unselectAttributeCarrier(bool changeFlag = true);
196 
197  /* @brief method for getting the Attribute of an XML key
198  * @param[in] key The attribute key
199  * @return string with the value associated to key
200  */
201  std::string getAttribute(SumoXMLAttr key) const;
202 
203  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
204  * @param[in] key The attribute key
205  * @return double with the value associated to key
206  */
207  double getAttributeDouble(SumoXMLAttr key) const;
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  * @param[in] net optionally the GNENet to inform about gui updates
214  */
215  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
216 
217  /* @brief method for setting the attribute and letting the object perform additional changes
218  * @param[in] key The attribute key
219  * @param[in] value The new value
220  * @param[in] undoList The undoList on which to register changes
221  */
222  bool isValid(SumoXMLAttr key, const std::string& value);
223 
224  /* @brief method for enable attribute
225  * @param[in] key The attribute key
226  * @param[in] undoList The undoList on which to register changes
227  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
228  */
229  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
230 
231  /* @brief method for disable attribute
232  * @param[in] key The attribute key
233  * @param[in] undoList The undoList on which to register changes
234  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
235  */
236  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
237 
238  /* @brief method for check if the value for certain attribute is set
239  * @param[in] key The attribute key
240  */
241  bool isAttributeEnabled(SumoXMLAttr key) const;
242 
244  std::string getPopUpID() const;
245 
247  std::string getHierarchyName() const;
249 
250 protected:
253 
256 
257 private:
259  void setAttribute(SumoXMLAttr key, const std::string& value);
260 
262  void setEnabledAttribute(const int enabledAttributes);
263 
265  GNERoute(GNERoute*) = delete;
266 
269 };
270 
271 
272 #endif
273 
274 /****************************************************************************/
275 
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
GNEDemandElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEDemandElement.h:55
GNERoute::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNERoute.cpp:258
GNERoute::GNERoute
GNERoute(GNERoute *)=delete
Invalidated copy constructor.
GNERoute::setEnabledAttribute
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNERoute.cpp:508
GNERoute::GNERoutePopupMenu::~GNERoutePopupMenu
~GNERoutePopupMenu()
Destructor.
Definition: GNERoute.cpp:57
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:42
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GNERoute::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNERoute.cpp:309
GNERoute::commitGeometryMoving
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNERoute.cpp:252
GNERoute::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
inherited from GNEAttributeCarrier
Definition: GNERoute.cpp:346
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
GNERoute::endGeometryMoving
void endGeometryMoving()
end geometry movement
Definition: GNERoute.cpp:240
GNERoute::moveGeometry
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNERoute.cpp:246
GNERoute::invalidatePath
void invalidatePath()
invalidate path
Definition: GNERoute.cpp:291
GNERoute::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNERoute.cpp:469
GUIGLObjectPopupMenu.h
GNERoute
Definition: GNERoute.h:41
GNERoute::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNERoute.cpp:421
GNERoute::getAttributeDouble
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNERoute.cpp:396
GNEViewNet
Definition: GNEViewNet.h:42
GNERoute::disableAttribute
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERoute.cpp:451
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
GNERoute::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNERoute.cpp:297
GNERoute::fixDemandElementProblem
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNERoute.cpp:204
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:51
GNERoute::myVClass
SUMOVehicleClass myVClass
SUMOVehicleClass (Only used for drawing)
Definition: GNERoute.h:255
GNERoute::writeDemandElement
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNERoute.cpp:146
GNERoute::GNERoutePopupMenu::GNERoutePopupMenu
GNERoutePopupMenu()
default constructor needed by FOX
Definition: GNERoute.h:66
GNERouteHandler::RouteParameter
struct for saving route parameters
Definition: GNERouteHandler.h:53
RGBColor
Definition: RGBColor.h:39
GNERoute::startGeometryMoving
void startGeometryMoving()
Definition: GNERoute.cpp:234
GNERoute::GNERoutePopupMenu::onCmdApplyDistance
long onCmdApplyDistance(FXObject *, FXSelector, void *)
Called to modify edge distance values along the route.
Definition: GNERoute.cpp:61
GNEDemandElement.h
GNERoute::getFromEdge
GNEEdge * getFromEdge() const
Definition: GNERoute.cpp:210
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GNERoute::getToEdge
GNEEdge * getToEdge() const
obtain to edge of this demand element
Definition: GNERoute.cpp:216
GNERoute::isDemandElementValid
bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNERoute.cpp:168
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GNERoute::computePath
void computePath()
compute path
Definition: GNERoute.cpp:285
GNERoute::splitEdgeGeometry
void splitEdgeGeometry(const double splitPosition, const GNENetElement *originalElement, const GNENetElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNERoute.cpp:325
GNERoute::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNERoute.cpp:377
GNENetElement
Definition: GNENetElement.h:43
GUIGlObject
Definition: GUIGlObject.h:65
GNERoute::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNERoute.cpp:361
GNERoute::updatePartialGeometry
void updatePartialGeometry(const GNEEdge *edge)
partial update pre-computed geometry information
Definition: GNERoute.cpp:272
GNERoute::getDemandElementProblem
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNERoute.cpp:187
GNERoute::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNERoute.cpp:457
GUIMainWindow
Definition: GUIMainWindow.h:46
GNERoute::myColor
RGBColor myColor
route color
Definition: GNERoute.h:252
GNERoute::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNERoute.cpp:303
GNERoute::setAttribute
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:402
GNERoute::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNERoute.cpp:463
GNERoute::~GNERoute
~GNERoute()
destructor
Definition: GNERoute.cpp:115
GNEVehicle
Definition: GNEVehicle.h:35
GNERoute::enableAttribute
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERoute.cpp:445
GNEConnection
Definition: GNEConnection.h:38
GNERoute::GNERoutePopupMenu
class used in GUIGLObjectPopupMenu for routes
Definition: GNERoute.h:46
GNERoute::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNERoute.cpp:340
GNERoute::operator=
GNERoute & operator=(GNERoute *)=delete
Invalidated assignment operator.
GNEUndoList
Definition: GNEUndoList.h:48
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
GNERoute::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNERoute.cpp:119
GNERoute::GNERoute
GNERoute(GNEViewNet *viewNet)
default constructor
Definition: GNERoute.cpp:79
GNERoute::getVClass
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNERoute.cpp:222
GNERouteHandler.h
GNERoute::getColor
const RGBColor & getColor() const
get color
Definition: GNERoute.cpp:228