Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/demand/GNERouteRef.h
185790 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 GNERouteRef.h
15
/// @author Pablo Alvarez Lopez
16
/// @date April 2025
17
///
18
// A class for route references
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include "GNEDemandElement.h"
24
25
// ===========================================================================
26
// class declarations
27
// ===========================================================================
28
29
class GNERouteDistribution;
30
31
// ===========================================================================
32
// class definitions
33
// ===========================================================================
34
35
class GNERouteRef : public GNEDemandElement {
36
37
public:
38
/// @brief default constructor
39
GNERouteRef(GNENet* net);
40
41
/// @brief parameter constructor
42
GNERouteRef(GNEDemandElement* distributionParent, GNEDemandElement* routeParent);
43
44
/// @brief parameter constructor
45
GNERouteRef(GNEDemandElement* distributionParent, GNEDemandElement* routeParent, const double probability);
46
47
/// @brief destructor
48
~GNERouteRef();
49
50
/// @brief methods to retrieve the elements linked to this routeRef
51
/// @{
52
53
/// @brief get GNEMoveElement associated with this routeRef
54
GNEMoveElement* getMoveElement() const override;
55
56
/// @brief get parameters associated with this routeRef
57
Parameterised* getParameters() override;
58
59
/// @brief get parameters associated with this routeRef (constant)
60
const Parameterised* getParameters() const override;
61
62
/// @}
63
64
/**@brief write demand element element into a xml file
65
* @param[in] device device in which write parameters of demand element element
66
*/
67
void writeDemandElement(OutputDevice& device) const override;
68
69
/// @brief check if current demand element is valid to be written into XML (by default true, can be reimplemented in children)
70
Problem isDemandElementValid() const override;
71
72
/// @brief return a string with the current demand element problem (by default empty, can be reimplemented in children)
73
std::string getDemandElementProblem() const override;
74
75
/// @brief fix demand element problem (by default throw an exception, has to be reimplemented in children)
76
void fixDemandElementProblem() override;
77
78
/// @name members and functions relative to elements common to all demand elements
79
/// @{
80
/// @brief obtain VClass related with this demand element
81
SUMOVehicleClass getVClass() const override;
82
83
/// @brief get color
84
const RGBColor& getColor() const override;
85
86
/// @}
87
88
/// @name Functions related with geometry of element
89
/// @{
90
/// @brief update pre-computed geometry information
91
void updateGeometry() override;
92
93
/// @brief Returns position of additional in view
94
Position getPositionInView() const override;
95
/// @}
96
97
/// @name inherited from GUIGlObject
98
/// @{
99
100
/**@brief Returns an own popup-menu
101
*
102
* @param[in] app The application needed to build the popup-menu
103
* @param[in] parent The parent window needed to build the popup-menu
104
* @return The built popup-menu
105
* @see GUIGlObject::getPopUpMenu
106
*/
107
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
108
109
/**@brief Returns the name of the parent object
110
* @return This object's parent id
111
*/
112
std::string getParentName() const override;
113
114
/// @brief return exaggeration associated with this GLObject
115
double getExaggeration(const GUIVisualizationSettings& s) const override;
116
117
/**@brief Returns the boundary to which the view shall be centered in order to show the object
118
* @return The boundary the object is within
119
*/
120
Boundary getCenteringBoundary() const override;
121
122
/// @brief split geometry
123
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) override;
124
125
/**@brief Draws the object
126
* @param[in] s The settings for the current view (may influence drawing)
127
* @see GUIGlObject::drawGL
128
*/
129
void drawGL(const GUIVisualizationSettings& s) const override;
130
131
/// @}
132
133
/// @name inherited from GNEPathElement
134
/// @{
135
136
/// @brief compute pathElement
137
void computePathElement() override;
138
139
/**@brief Draws partial object over lane
140
* @param[in] s The settings for the current view (may influence drawing)
141
* @param[in] segment lane segment
142
* @param[in] offsetFront front offset
143
*/
144
void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;
145
146
/**@brief Draws partial object over junction
147
* @param[in] s The settings for the current view (may influence drawing)
148
* @param[in] segment junction segment
149
* @param[in] offsetFront front offset
150
*/
151
void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;
152
153
/// @brief get first path lane
154
GNELane* getFirstPathLane() const override;
155
156
/// @brief get last path lane
157
GNELane* getLastPathLane() const override;
158
/// @}
159
160
/// @brief inherited from GNEAttributeCarrier
161
/// @{
162
/* @brief method for getting the Attribute of an XML key
163
* @param[in] key The attribute key
164
* @return string with the value associated to key
165
*/
166
std::string getAttribute(SumoXMLAttr key) const override;
167
168
/* @brief method for getting the Attribute of an XML key in double format
169
* @param[in] key The attribute key
170
* @return double with the value associated to key
171
*/
172
double getAttributeDouble(SumoXMLAttr key) const override;
173
174
/* @brief method for getting the Attribute of an XML key in position format
175
* @param[in] key The attribute key
176
* @return position with the value associated to key
177
*/
178
Position getAttributePosition(SumoXMLAttr key) const override;
179
180
/* @brief method for check if the value for certain attribute is set
181
* @param[in] key The attribute key
182
*/
183
bool isAttributeEnabled(SumoXMLAttr key) const override;
184
185
/* @brief method for setting the attribute and letting the object perform additional changes
186
* @param[in] key The attribute key
187
* @param[in] value The new value
188
* @param[in] undoList The undoList on which to register changes
189
* @param[in] net optionally the GNENet to inform about gui updates
190
*/
191
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
192
193
/* @brief method for setting the attribute and letting the object perform additional changes
194
* @param[in] key The attribute key
195
* @param[in] value The new value
196
* @param[in] undoList The undoList on which to register changes
197
*/
198
bool isValid(SumoXMLAttr key, const std::string& value) override;
199
200
/* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
201
* @param[in] key The attribute key
202
*/
203
bool isAttributeComputed(SumoXMLAttr key) const override;
204
205
/// @brief get PopPup ID (Used in AC Hierarchy)
206
std::string getPopUpID() const override;
207
208
/// @brief get Hierarchy Name (Used in AC Hierarchy)
209
std::string getHierarchyName() const override;
210
211
/// @}
212
213
protected:
214
/// @brief probability
215
double myProbability = INVALID_DOUBLE;
216
217
private:
218
/// @brief method for setting the attribute and nothing else
219
void setAttribute(SumoXMLAttr key, const std::string& value) override;
220
221
/// @brief Invalidated copy constructor.
222
GNERouteRef(GNERouteRef*) = delete;
223
224
/// @brief Invalidated assignment operator.
225
GNERouteRef& operator=(GNERouteRef*) = delete;
226
};
227
228