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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A class for visualizing routes in Netedit
19 /****************************************************************************/
20 #pragma once
22 
23 #include "GNEDemandElement.h"
24 #include "GNERouteHandler.h"
25 
26 
27 // ===========================================================================
28 // class declarations
29 // ===========================================================================
30 class GNEEdge;
31 class GNEConnection;
32 class GNEVehicle;
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
37 
38 class GNERoute : public GNEDemandElement, public Parameterised {
39 
40 public:
41 
44  FXDECLARE(GNERoutePopupMenu)
45 
46  public:
54 
57 
59  long onCmdApplyDistance(FXObject*, FXSelector, void*);
60 
61  protected:
64  };
65 
69  GNERoute(GNENet* net);
70 
75  GNERoute(GNENet* net, const GNERouteHandler::RouteParameter& routeParameters);
76 
82  GNERoute(GNENet* net, GNEDemandElement* vehicleParent, const GNERouteHandler::RouteParameter& routeParameters);
83 
85  GNERoute(GNEDemandElement* route);
86 
88  ~GNERoute();
89 
93  void writeDemandElement(OutputDevice& device) const;
94 
96  bool isDemandElementValid() const;
97 
99  std::string getDemandElementProblem() const;
100 
103 
107  SUMOVehicleClass getVClass() const;
108 
110  const RGBColor& getColor() const;
111 
113 
117  void startGeometryMoving();
118 
120  void endGeometryMoving();
121 
125  void moveGeometry(const Position& offset);
126 
130  void commitGeometryMoving(GNEUndoList* undoList);
131 
133  void updateGeometry();
134 
136  void computePath();
137 
139  void invalidatePath();
140 
142  Position getPositionInView() const;
144 
147 
156 
160  std::string getParentName() const;
161 
166 
168  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
169 
174  void drawGL(const GUIVisualizationSettings& s) const;
175 
181  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const double offsetFront) const;
182 
189  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const double offsetFront) const;
191 
194  /* @brief method for getting the Attribute of an XML key
195  * @param[in] key The attribute key
196  * @return string with the value associated to key
197  */
198  std::string getAttribute(SumoXMLAttr key) const;
199 
200  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
201  * @param[in] key The attribute key
202  * @return double with the value associated to key
203  */
204  double getAttributeDouble(SumoXMLAttr key) const;
205 
206  /* @brief method for setting the attribute and letting the object perform additional changes
207  * @param[in] key The attribute key
208  * @param[in] value The new value
209  * @param[in] undoList The undoList on which to register changes
210  * @param[in] net optionally the GNENet to inform about gui updates
211  */
212  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
213 
214  /* @brief method for setting the attribute and letting the object perform additional changes
215  * @param[in] key The attribute key
216  * @param[in] value The new value
217  * @param[in] undoList The undoList on which to register changes
218  */
219  bool isValid(SumoXMLAttr key, const std::string& value);
220 
221  /* @brief method for enable attribute
222  * @param[in] key The attribute key
223  * @param[in] undoList The undoList on which to register changes
224  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
225  */
226  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
227 
228  /* @brief method for disable attribute
229  * @param[in] key The attribute key
230  * @param[in] undoList The undoList on which to register changes
231  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
232  */
233  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
234 
235  /* @brief method for check if the value for certain attribute is set
236  * @param[in] key The attribute key
237  */
238  bool isAttributeEnabled(SumoXMLAttr key) const;
239 
241  std::string getPopUpID() const;
242 
244  std::string getHierarchyName() const;
246 
248  const std::map<std::string, std::string>& getACParametersMap() const;
249 
254  static std::string isRouteValid(const std::vector<GNEEdge*>& edges);
255 
256 protected:
259 
262 
263 private:
265  void setAttribute(SumoXMLAttr key, const std::string& value);
266 
268  void setEnabledAttribute(const int enabledAttributes);
269 
271  GNERoute(GNERoute*) = delete;
272 
275 };
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
An Element which don't belongs to GNENet but has influency in the simulation.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
class used in GUIGLObjectPopupMenu for routes
Definition: GNERoute.h:43
~GNERoutePopupMenu()
Destructor.
Definition: GNERoute.cpp:52
GNERoutePopupMenu()
default constructor needed by FOX
Definition: GNERoute.h:63
long onCmdApplyDistance(FXObject *, FXSelector, void *)
Called to modify edge distance values along the route.
Definition: GNERoute.cpp:56
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNERoute.cpp:501
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNERoute.cpp:578
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNERoute.cpp:191
void endGeometryMoving()
end geometry movement
Definition: GNERoute.cpp:215
void computePath()
compute path
Definition: GNERoute.cpp:248
Position getPositionInView() const
Returns position of additional in view.
Definition: GNERoute.cpp:266
SUMOVehicleClass myVClass
SUMOVehicleClass (Only used for drawing)
Definition: GNERoute.h:261
std::string getParentName() const
Returns the name of the parent object.
Definition: GNERoute.cpp:272
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNERoute.cpp:495
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition: GNERoute.cpp:409
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNERoute.cpp:221
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const double offsetFront) const
Draws partial object.
Definition: GNERoute.cpp:311
void invalidatePath()
invalidate path
Definition: GNERoute.cpp:257
void updateGeometry()
update pre-computed geometry information
Definition: GNERoute.cpp:233
bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNERoute.cpp:170
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNERoute.cpp:121
void startGeometryMoving()
Definition: GNERoute.cpp:209
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNERoute.cpp:507
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNERoute.cpp:294
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERoute.cpp:477
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNERoute.cpp:428
SUMOVehicleClass getVClass() const
Definition: GNERoute.cpp:197
GNERoute & operator=(GNERoute *)=delete
Invalidated assignment operator.
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERoute.cpp:483
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNERoute.cpp:278
GNERoute(GNENet *net)
default constructor
Definition: GNERoute.cpp:73
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNERoute.cpp:453
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNERoute.cpp:305
static std::string isRouteValid(const std::vector< GNEEdge * > &edges)
check if a route is valid
Definition: GNERoute.cpp:513
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:434
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNERoute.cpp:184
RGBColor myColor
route color
Definition: GNERoute.h:258
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNERoute.cpp:148
~GNERoute()
destructor
Definition: GNERoute.cpp:117
GNERoute(GNERoute *)=delete
Invalidated copy constructor.
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNERoute.cpp:489
const RGBColor & getColor() const
get color
Definition: GNERoute.cpp:203
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNERoute.cpp:227
The popup menu of a globject.
Stores the information about how to visualize structures.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
struct for saving route parameters