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// ===========================================================================
31class GNEEdge;
32class GNEConnection;
33class GNEVehicle;
34
35// ===========================================================================
36// class definitions
37// ===========================================================================
38
39class GNERoute : public GNEDemandElement, public Parameterised {
40
41public:
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 Parameterised::Map& parameters);
85
95 GNERoute(GNENet* net, GNEDemandElement* vehicleParent, const std::vector<GNEEdge*>& edges, const RGBColor& color,
96 const int repeat, const SUMOTime cycleTime, const Parameterised::Map& parameters);
97
100
102 ~GNERoute();
103
108
112 void writeDemandElement(OutputDevice& device) const;
113
116
118 std::string getDemandElementProblem() const;
119
122
127
129 const RGBColor& getColor() const;
130
132
136 void updateGeometry();
137
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
244 std::string getPopUpID() const;
245
247 std::string getHierarchyName() const;
249
252
257 static std::string isRouteValid(const std::vector<GNEEdge*>& edges);
258
259protected:
262
265
268
271
272private:
274 void setAttribute(SumoXMLAttr key, const std::string& value);
275
277 void setMoveShape(const GNEMoveResult& moveResult);
278
280 void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
281
283 GNERoute(GNERoute*) = delete;
284
287};
long long int SUMOTime
Definition: GUI.h:36
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 belong to GNENet but has influence 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:57
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:61
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNERoute.cpp:742
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNERoute.cpp:263
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition: GNERoute.cpp:314
GNELane * getLastPathLane() const
get last path lane
Definition: GNERoute.cpp:587
Position getPositionInView() const
Returns position of additional in view.
Definition: GNERoute.cpp:302
SUMOVehicleClass myVClass
SUMOVehicleClass (Only used for drawing)
Definition: GNERoute.h:270
std::string getParentName() const
Returns the name of the parent object.
Definition: GNERoute.cpp:308
SUMOTime myCycleTime
cycleTime
Definition: GNERoute.h:267
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNERoute.cpp:736
GNERoute & operator=(GNERoute *)=delete
Invalidated assignment operator.
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition: GNERoute.cpp:597
Position getAttributePosition(SumoXMLAttr key) const
Definition: GNERoute.cpp:637
void updateGeometry()
update pre-computed geometry information
Definition: GNERoute.cpp:289
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNERoute.cpp:155
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNERoute.cpp:336
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNERoute.cpp:830
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition: GNERoute.cpp:748
GNELane * getFirstPathLane() const
get first path lane
Definition: GNERoute.cpp:577
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNERoute.cpp:624
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNERoute.cpp:149
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNERoute.cpp:836
SUMOVehicleClass getVClass() const
Definition: GNERoute.cpp:269
GNERoute(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNERoute.cpp:78
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object.
Definition: GNERoute.cpp:388
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNERoute.cpp:320
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNERoute.cpp:700
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNERoute.cpp:347
static std::string isRouteValid(const std::vector< GNEEdge * > &edges)
check if a route is valid
Definition: GNERoute.cpp:754
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:650
int myRepeat
repeat
Definition: GNERoute.h:264
void computePathElement()
compute pathElement
Definition: GNERoute.cpp:353
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNERoute.cpp:245
RGBColor myColor
route color
Definition: GNERoute.h:261
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
Definition: GNERoute.cpp:184
~GNERoute()
destructor
Definition: GNERoute.cpp:145
GNERoute(GNERoute *)=delete
Invalidated copy constructor.
const RGBColor & getColor() const
get color
Definition: GNERoute.cpp:275
Problem isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNERoute.cpp:215
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