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-2022 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 class GNEEdge;
32 class GNEConnection;
33 class GNEVehicle;
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
38 
39 class GNERoute : public GNEDemandElement, public Parameterised {
40 
41 public:
42 
45  FXDECLARE(GNERoutePopupMenu)
46 
47  public:
55 
58 
60  long onCmdApplyDistance(FXObject*, FXSelector, void*);
61 
62  protected:
65  };
66 
68  GNERoute(SumoXMLTag tag, GNENet* net);
69 
71  GNERoute(GNENet* net);
72 
83  GNERoute(GNENet* net, const std::string& id, SUMOVehicleClass vClass, const std::vector<GNEEdge*>& edges, const RGBColor& color,
84  const int repeat, const SUMOTime cycleTime, const std::map<std::string, std::string>& parameters);
85 
95  GNERoute(GNENet* net, GNEDemandElement* vehicleParent, const std::vector<GNEEdge*>& edges, const RGBColor& color,
96  const int repeat, const SUMOTime cycleTime, const std::map<std::string, std::string>& parameters);
97 
99  GNERoute(GNEDemandElement* route);
100 
102  ~GNERoute();
103 
108 
112  void writeDemandElement(OutputDevice& device) const;
113 
116 
118  std::string getDemandElementProblem() const;
119 
122 
126  SUMOVehicleClass getVClass() const;
127 
129  const RGBColor& getColor() const;
130 
132 
136  void updateGeometry();
137 
139  Position getPositionInView() const;
141 
144 
153 
157  std::string getParentName() const;
158 
160  double getExaggeration(const GUIVisualizationSettings& s) 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 
177 
180 
182  void computePathElement();
183 
190  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const;
191 
199  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const;
200 
202  GNELane* getFirstPathLane() const;
203 
205  GNELane* getLastPathLane() const;
207 
210  /* @brief method for getting the Attribute of an XML key
211  * @param[in] key The attribute key
212  * @return string with the value associated to key
213  */
214  std::string getAttribute(SumoXMLAttr key) const;
215 
216  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
217  * @param[in] key The attribute key
218  * @return double with the value associated to key
219  */
220  double getAttributeDouble(SumoXMLAttr key) const;
221 
222  /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
223  * @param[in] key The attribute key
224  * @return double with the value associated to key
225  */
227 
228  /* @brief method for setting the attribute and letting the object perform additional changes
229  * @param[in] key The attribute key
230  * @param[in] value The new value
231  * @param[in] undoList The undoList on which to register changes
232  * @param[in] net optionally the GNENet to inform about gui updates
233  */
234  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
235 
236  /* @brief method for setting the attribute and letting the object perform additional changes
237  * @param[in] key The attribute key
238  * @param[in] value The new value
239  * @param[in] undoList The undoList on which to register changes
240  */
241  bool isValid(SumoXMLAttr key, const std::string& value);
242 
243  /* @brief method for enable attribute
244  * @param[in] key The attribute key
245  * @param[in] undoList The undoList on which to register changes
246  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
247  */
248  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
249 
250  /* @brief method for disable attribute
251  * @param[in] key The attribute key
252  * @param[in] undoList The undoList on which to register changes
253  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
254  */
255  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
256 
257  /* @brief method for check if the value for certain attribute is set
258  * @param[in] key The attribute key
259  */
260  bool isAttributeEnabled(SumoXMLAttr key) const;
261 
263  std::string getPopUpID() const;
264 
266  std::string getHierarchyName() const;
268 
270  const std::map<std::string, std::string>& getACParametersMap() const;
271 
276  static std::string isRouteValid(const std::vector<GNEEdge*>& edges);
277 
278 protected:
281 
284 
286  int myRepeat;
287 
290 
293 
294 private:
296  void setAttribute(SumoXMLAttr key, const std::string& value);
297 
299  void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters);
300 
302  void setMoveShape(const GNEMoveResult& moveResult);
303 
305  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
306 
308  GNERoute(GNERoute*) = delete;
309 
312 };
long long int SUMOTime
Definition: SUMOTime.h:32
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
An Element which don't belongs to GNENet but has influency in the simulation.
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:44
~GNERoutePopupMenu()
Destructor.
Definition: GNERoute.cpp:52
GNERoutePopupMenu()
default constructor needed by FOX
Definition: GNERoute.h:64
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:713
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNERoute.cpp:260
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GNERoute.cpp:311
GNELane * getLastPathLane() const
get last path lane
Definition: GNERoute.cpp:540
Position getPositionInView() const
Returns position of additional in view.
Definition: GNERoute.cpp:299
SUMOVehicleClass myVClass
SUMOVehicleClass (Only used for drawing)
Definition: GNERoute.h:292
std::string getParentName() const
Returns the name of the parent object.
Definition: GNERoute.cpp:305
SUMOTime myCycleTime
cycleTime
Definition: GNERoute.h:289
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNERoute.cpp:707
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition: GNERoute.cpp:550
Position getAttributePosition(SumoXMLAttr key) const
Definition: GNERoute.cpp:590
void updateGeometry()
update pre-computed geometry information
Definition: GNERoute.cpp:286
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNERoute.cpp:154
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNERoute.cpp:719
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNERoute.cpp:333
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNERoute.cpp:809
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERoute.cpp:689
GNELane * getFirstPathLane() const
get first path lane
Definition: GNERoute.cpp:530
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNERoute.cpp:577
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNERoute.cpp:148
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNERoute.cpp:815
SUMOVehicleClass getVClass() const
Definition: GNERoute.cpp:266
GNERoute & operator=(GNERoute *)=delete
Invalidated assignment operator.
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERoute.cpp:695
GNERoute(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNERoute.cpp:73
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object.
Definition: GNERoute.cpp:385
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNERoute.cpp:317
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNERoute.cpp:653
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNERoute.cpp:344
static std::string isRouteValid(const std::vector< GNEEdge * > &edges)
check if a route is valid
Definition: GNERoute.cpp:725
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:603
int myRepeat
repeat
Definition: GNERoute.h:286
void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNERoute.cpp:803
void computePathElement()
compute pathElement
Definition: GNERoute.cpp:350
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNERoute.cpp:242
RGBColor myColor
route color
Definition: GNERoute.h:280
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNERoute.cpp:181
~GNERoute()
destructor
Definition: GNERoute.cpp:144
GNERoute(GNERoute *)=delete
Invalidated copy constructor.
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNERoute.cpp:701
const RGBColor & getColor() const
get color
Definition: GNERoute.cpp:272
Problem isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNERoute.cpp:212
bool myCustomColor
flag for enable/disable color
Definition: GNERoute.h:283
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
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37