Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/demand/GNERoute.h
185836 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2016-2025 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
/****************************************************************************/
14
/// @file GNERoute.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Jan 2019
17
///
18
// A class for visualizing routes in Netedit
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
23
24
#include "GNEDemandElement.h"
25
26
// ===========================================================================
27
// class declarations
28
// ===========================================================================
29
30
class GNEEdge;
31
class GNEVehicle;
32
33
// ===========================================================================
34
// class definitions
35
// ===========================================================================
36
37
class GNERoute : public GNEDemandElement, public Parameterised {
38
39
public:
40
41
/// @brief class used in GUIGLObjectPopupMenu for routes
42
class GNERoutePopupMenu : public GUIGLObjectPopupMenu {
43
FXDECLARE(GNERoutePopupMenu)
44
45
public:
46
/** @brief Constructor
47
* @param[in] app The main window for instantiation of other windows
48
* @param[in] parent The parent view for changing it
49
* @param[in] o The object of interest
50
* @param[in, out] additionalVisualizations Information which additional visualisations are enabled (per view)
51
*/
52
GNERoutePopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject* o);
53
54
/// @brief Destructor
55
~GNERoutePopupMenu();
56
57
/// @brief Called to modify edge distance values along the route
58
long onCmdApplyDistance(FXObject*, FXSelector, void*);
59
60
protected:
61
/// @brief default constructor needed by FOX
62
GNERoutePopupMenu() {}
63
};
64
65
/// @brief default constructor
66
GNERoute(SumoXMLTag tag, GNENet* net);
67
68
/// @brief calibrator constructor (used in calibrators)
69
GNERoute(GNEAdditional* calibrator);
70
71
/// @brief copy constructor (used in copy vehicles)
72
GNERoute(const std::string& id, const GNEDemandElement* originalRoute);
73
74
/// @brief copy constructor (used in copy embedded vehicles)
75
GNERoute(GNEVehicle* vehicleParent, const GNEDemandElement* originalRoute);
76
77
/**@brief parameter constructor for routes
78
* @param[in] id route ID
79
* @param[in] net net in which this Route is placed
80
* @param[in] fileBucket file in which this element is stored
81
* @param[in] vClass vehicle class
82
* @param[in] edges route edges
83
* @param[in] color route color
84
* @param[in] repeat the number of times that the edges of this route shall be repeated
85
* @param[in] cycleType the times will be shifted forward by 'cycleTime' on each repeat
86
* @param[in] probability default probability for vType distributions
87
* @param[in] parameters generic parameters
88
*/
89
GNERoute(const std::string& id, GNENet* net, FileBucket* fileBucket, SUMOVehicleClass vClass, const std::vector<GNEEdge*>& edges,
90
const RGBColor& color, const int repeat, const SUMOTime cycleTime, const double probability, const Parameterised::Map& parameters);
91
92
/**@brief parameter constructor for embedded routes
93
* @param[in] vehicleParent vehicle parent of this embedded route
94
* @param[in] edges route edges
95
* @param[in] color route color
96
* @param[in] repeat the number of times that the edges of this route shall be repeated
97
* @param[in] cycleType the times will be shifted forward by 'cycleTime' on each repeat
98
* @param[in] parameters generic parameters
99
*/
100
GNERoute(GNEDemandElement* vehicleParent, const std::vector<GNEEdge*>& edges, const RGBColor& color,
101
const int repeat, const SUMOTime cycleTime, const Parameterised::Map& parameters);
102
103
/// @brief destructor
104
~GNERoute();
105
106
/// @brief methods to retrieve the elements linked to this route
107
/// @{
108
109
/// @brief get GNEMoveElement associated with this route
110
GNEMoveElement* getMoveElement() const override;
111
112
/// @brief get parameters associated with this route
113
Parameterised* getParameters() override;
114
115
/// @brief get parameters associated with this route (constant)
116
const Parameterised* getParameters() const override;
117
118
/// @}
119
120
/**@brief write demand element element into a xml file
121
* @param[in] device device in which write parameters of demand element element
122
*/
123
void writeDemandElement(OutputDevice& device) const override;
124
125
/// @brief check if current demand element is valid to be written into XML (by default true, can be reimplemented in children)
126
Problem isDemandElementValid() const override;
127
128
/// @brief return a string with the current demand element problem (by default empty, can be reimplemented in children)
129
std::string getDemandElementProblem() const override;
130
131
/// @brief fix demand element problem (by default throw an exception, has to be reimplemented in children)
132
void fixDemandElementProblem() override;
133
134
/// @name members and functions relative to elements common to all demand elements
135
/// @{
136
/// @brief obtain VClass related with this demand element
137
SUMOVehicleClass getVClass() const override;
138
139
/// @brief get color
140
const RGBColor& getColor() const override;
141
142
/// @}
143
144
/// @name Functions related with geometry of element
145
/// @{
146
/// @brief update pre-computed geometry information
147
void updateGeometry() override;
148
149
/// @brief Returns position of additional in view
150
Position getPositionInView() const override;
151
/// @}
152
153
/// @name inherited from GUIGlObject
154
/// @{
155
156
/**@brief Returns an own popup-menu
157
*
158
* @param[in] app The application needed to build the popup-menu
159
* @param[in] parent The parent window needed to build the popup-menu
160
* @return The built popup-menu
161
* @see GUIGlObject::getPopUpMenu
162
*/
163
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
164
165
/**@brief Returns the name of the parent object
166
* @return This object's parent id
167
*/
168
std::string getParentName() const override;
169
170
/// @brief return exaggeration associated with this GLObject
171
double getExaggeration(const GUIVisualizationSettings& s) const override;
172
173
/**@brief Returns the boundary to which the view shall be centered in order to show the object
174
* @return The boundary the object is within
175
*/
176
Boundary getCenteringBoundary() const override;
177
178
/// @brief split geometry
179
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) override;
180
181
/**@brief Draws the object
182
* @param[in] s The settings for the current view (may influence drawing)
183
* @see GUIGlObject::drawGL
184
*/
185
void drawGL(const GUIVisualizationSettings& s) const override;
186
187
/// @}
188
189
/// @name inherited from GNEPathElement
190
/// @{
191
192
/// @brief compute pathElement
193
void computePathElement() override;
194
195
/**@brief Draws partial object over lane
196
* @param[in] s The settings for the current view (may influence drawing)
197
* @param[in] segment lane segment
198
* @param[in] offsetFront front offset
199
*/
200
void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;
201
202
/**@brief Draws partial object over junction
203
* @param[in] s The settings for the current view (may influence drawing)
204
* @param[in] segment junction segment
205
* @param[in] offsetFront front offset
206
*/
207
void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;
208
209
/// @brief get first path lane
210
GNELane* getFirstPathLane() const override;
211
212
/// @brief get last path lane
213
GNELane* getLastPathLane() const override;
214
/// @}
215
216
/// @brief inherited from GNEAttributeCarrier
217
/// @{
218
/* @brief method for getting the Attribute of an XML key
219
* @param[in] key The attribute key
220
* @return string with the value associated to key
221
*/
222
std::string getAttribute(SumoXMLAttr key) const override;
223
224
/* @brief method for getting the Attribute of an XML key in double format
225
* @param[in] key The attribute key
226
* @return double with the value associated to key
227
*/
228
double getAttributeDouble(SumoXMLAttr key) const override;
229
230
/* @brief method for getting the Attribute of an XML key in position format
231
* @param[in] key The attribute key
232
* @return position with the value associated to key
233
*/
234
Position getAttributePosition(SumoXMLAttr key) const override;
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
* @param[in] net optionally the GNENet to inform about gui updates
241
*/
242
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
243
244
/* @brief method for setting the attribute and letting the object perform additional changes
245
* @param[in] key The attribute key
246
* @param[in] value The new value
247
* @param[in] undoList The undoList on which to register changes
248
*/
249
bool isValid(SumoXMLAttr key, const std::string& value) override;
250
251
/// @brief get PopPup ID (Used in AC Hierarchy)
252
std::string getPopUpID() const override;
253
254
/// @brief get Hierarchy Name (Used in AC Hierarchy)
255
std::string getHierarchyName() const override;
256
257
/// @}
258
259
/** @brief check if a route is valid
260
* @param[in] edges vector with the route's edges
261
* @return an empty string if route is valid, or a string with the problem
262
*/
263
static std::string isRouteValid(const std::vector<GNEEdge*>& edges);
264
265
/// @brief create a copy of the given route
266
static GNEDemandElement* copyRoute(const GNERoute* originalRoute);
267
268
protected:
269
/// @brief route color
270
RGBColor myColor = RGBColor::INVISIBLE;
271
272
/// @brief repeat
273
int myRepeat = 0;
274
275
/// @brief cycleTime
276
SUMOTime myCycleTime = 0;
277
278
/// @brief probability
279
double myProbability = DEFAULT_VEH_PROB;
280
281
/// @brief SUMOVehicleClass (Only used for drawing)
282
SUMOVehicleClass myVClass = SVC_PASSENGER;
283
284
private:
285
/// @brief draw route partial lane
286
void drawRoutePartialLane(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
287
const GNESegment* segment, const double offsetFront,
288
const GUIGeometry& geometry, const double exaggeration) const;
289
290
/// @brief draw route partial junction
291
void drawRoutePartialJunction(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
292
const double offsetFront, const GUIGeometry& geometry, const double exaggeration) const;
293
294
/// @brief method for setting the attribute and nothing else
295
void setAttribute(SumoXMLAttr key, const std::string& value) override;
296
297
/// @brief check if we're creating a vehicle or flow over route
298
bool checkCreatingVehicleOverRoute() const;
299
300
/// @brief Invalidated copy constructor.
301
GNERoute(GNERoute*) = delete;
302
303
/// @brief Invalidated assignment operator.
304
GNERoute& operator=(GNERoute*) = delete;
305
};
306
307