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.dev/sumo
3 // Copyright (C) 2016-2024 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
21 #include <config.h>
23 
24 #include "GNEDemandElement.h"
25 #include "GNERouteHandler.h"
26 
27 
28 // ===========================================================================
29 // class declarations
30 // ===========================================================================
31 
32 class GNEEdge;
33 class GNEConnection;
34 class GNEVehicle;
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
39 
40 class GNERoute : public GNEDemandElement, public Parameterised {
41 
42 public:
43 
46  FXDECLARE(GNERoutePopupMenu)
47 
48  public:
56 
59 
61  long onCmdApplyDistance(FXObject*, FXSelector, void*);
62 
63  protected:
66  };
67 
69  GNERoute(SumoXMLTag tag, GNENet* net);
70 
72  GNERoute(GNENet* net);
73 
75  GNERoute(GNENet* net, const std::string& id, const GNEDemandElement* originalRoute);
76 
78  GNERoute(GNENet* net, GNEVehicle* vehicleParent, const GNEDemandElement* originalRoute);
79 
90  GNERoute(GNENet* net, const std::string& id, SUMOVehicleClass vClass, const std::vector<GNEEdge*>& edges, const RGBColor& color,
91  const int repeat, const SUMOTime cycleTime, const Parameterised::Map& parameters);
92 
102  GNERoute(GNENet* net, GNEDemandElement* vehicleParent, const std::vector<GNEEdge*>& edges, const RGBColor& color,
103  const int repeat, const SUMOTime cycleTime, const Parameterised::Map& parameters);
104 
106  ~GNERoute();
107 
112 
116  void writeDemandElement(OutputDevice& device) const;
117 
120 
122  std::string getDemandElementProblem() const;
123 
126 
130  SUMOVehicleClass getVClass() const;
131 
133  const RGBColor& getColor() const;
134 
136 
140  void updateGeometry();
141 
143  Position getPositionInView() const;
145 
148 
157 
161  std::string getParentName() const;
162 
164  double getExaggeration(const GUIVisualizationSettings& s) const;
165 
170 
172  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
173 
178  void drawGL(const GUIVisualizationSettings& s) const;
179 
181 
184 
186  void computePathElement();
187 
193  void drawLanePartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const;
194 
200  void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const;
201 
203  GNELane* getFirstPathLane() const;
204 
206  GNELane* getLastPathLane() const;
208 
211  /* @brief method for getting the Attribute of an XML key
212  * @param[in] key The attribute key
213  * @return string with the value associated to key
214  */
215  std::string getAttribute(SumoXMLAttr key) const;
216 
217  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
218  * @param[in] key The attribute key
219  * @return double with the value associated to key
220  */
221  double getAttributeDouble(SumoXMLAttr key) const;
222 
223  /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
224  * @param[in] key The attribute key
225  * @return double with the value associated to key
226  */
228 
229  /* @brief method for check if the value for certain attribute is set
230  * @param[in] key The attribute key
231  */
232  bool isAttributeEnabled(SumoXMLAttr key) const;
233 
234  /* @brief method for setting the attribute and letting the object perform additional changes
235  * @param[in] key The attribute key
236  * @param[in] value The new value
237  * @param[in] undoList The undoList on which to register changes
238  * @param[in] net optionally the GNENet to inform about gui updates
239  */
240  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
241 
242  /* @brief method for setting the attribute and letting the object perform additional changes
243  * @param[in] key The attribute key
244  * @param[in] value The new value
245  * @param[in] undoList The undoList on which to register changes
246  */
247  bool isValid(SumoXMLAttr key, const std::string& value);
248 
250  std::string getPopUpID() const;
251 
253  std::string getHierarchyName() const;
255 
257  const Parameterised::Map& getACParametersMap() const;
258 
263  static std::string isRouteValid(const std::vector<GNEEdge*>& edges);
264 
266  static GNEDemandElement* copyRoute(const GNERoute* originalRoute);
267 
268 protected:
271 
273  int myRepeat;
274 
277 
280 
281 private:
284  const GNEPathManager::Segment* segment, const double offsetFront,
285  const GUIGeometry& geometry, const double exaggeration) const;
286 
289  const double offsetFront, const GUIGeometry& geometry, const double exaggeration) const;
290 
292  void setAttribute(SumoXMLAttr key, const std::string& value);
293 
295  void setMoveShape(const GNEMoveResult& moveResult);
296 
298  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
299 
301  GNERoute(GNERoute*) = delete;
302 
305 };
long long int SUMOTime
Definition: GUI.h:35
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
Problem
enum class for demandElement problems
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
class used in GUIGLObjectPopupMenu for routes
Definition: GNERoute.h:45
~GNERoutePopupMenu()
Destructor.
Definition: GNERoute.cpp:55
GNERoutePopupMenu()
default constructor needed by FOX
Definition: GNERoute.h:65
long onCmdApplyDistance(FXObject *, FXSelector, void *)
Called to modify edge distance values along the route.
Definition: GNERoute.cpp:59
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNERoute.cpp:663
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNERoute.cpp:294
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition: GNERoute.cpp:345
GNELane * getLastPathLane() const
get last path lane
Definition: GNERoute.cpp:494
Position getPositionInView() const
Returns position of additional in view.
Definition: GNERoute.cpp:333
SUMOVehicleClass myVClass
SUMOVehicleClass (Only used for drawing)
Definition: GNERoute.h:279
std::string getParentName() const
Returns the name of the parent object.
Definition: GNERoute.cpp:339
SUMOTime myCycleTime
cycleTime
Definition: GNERoute.h:276
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNERoute.cpp:657
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition: GNERoute.cpp:504
Position getAttributePosition(SumoXMLAttr key) const
Definition: GNERoute.cpp:547
void updateGeometry()
update pre-computed geometry information
Definition: GNERoute.cpp:320
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNERoute.cpp:165
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over lane.
Definition: GNERoute.cpp:396
void drawRoutePartialJunction(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double offsetFront, const GUIGeometry &geometry, const double exaggeration) const
draw route partial junction
Definition: GNERoute.cpp:767
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNERoute.cpp:367
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNERoute.cpp:840
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition: GNERoute.cpp:669
static GNEDemandElement * copyRoute(const GNERoute *originalRoute)
create a copy of the given route
Definition: GNERoute.cpp:706
GNELane * getFirstPathLane() const
get first path lane
Definition: GNERoute.cpp:484
void drawRoutePartialLane(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEPathManager::Segment *segment, const double offsetFront, const GUIGeometry &geometry, const double exaggeration) const
draw route partial lane
Definition: GNERoute.cpp:727
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNERoute.cpp:534
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNERoute.cpp:159
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNERoute.cpp:846
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNERoute.cpp:300
GNERoute & operator=(GNERoute *)=delete
Invalidated assignment operator.
GNERoute(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNERoute.cpp:76
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNERoute.cpp:351
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNERoute.cpp:621
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNERoute.cpp:378
static std::string isRouteValid(const std::vector< GNEEdge * > &edges)
check if a route is valid
Definition: GNERoute.cpp:675
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:571
int myRepeat
repeat
Definition: GNERoute.h:273
void computePathElement()
compute pathElement
Definition: GNERoute.cpp:384
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNERoute.cpp:265
RGBColor myColor
route color
Definition: GNERoute.h:270
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
Definition: GNERoute.cpp:198
~GNERoute()
destructor
Definition: GNERoute.cpp:155
GNERoute(GNERoute *)=delete
Invalidated copy constructor.
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNERoute.cpp:560
const RGBColor & getColor() const
get color
Definition: GNERoute.cpp:306
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over junction.
Definition: GNERoute.cpp:454
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
Definition: GNERoute.cpp:231
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:61
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37