Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/demand/GNEStop.h
185790 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-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 GNEStop.h
15
/// @author Pablo Alvarez Lopez
16
/// @date March 2019
17
///
18
// Representation of Stops in netedit
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include "GNEDemandElement.h"
24
#include "GNEDemandElementPlan.h"
25
26
// ===========================================================================
27
// class declaration
28
// ===========================================================================
29
30
class GNEMoveElementLaneDouble;
31
32
// ===========================================================================
33
// class definitions
34
// ===========================================================================
35
36
class GNEStop : public GNEDemandElement, public SUMOVehicleParameter::Stop, public GNEDemandElementPlan {
37
38
public:
39
/// @brief default constructor
40
GNEStop(SumoXMLTag tag, GNENet* net);
41
42
/// @brief constructor used for stops over stoppingPlaces
43
GNEStop(SumoXMLTag tag, GNEDemandElement* stopParent, GNEAdditional* stoppingPlace, const SUMOVehicleParameter::Stop& stopParameter);
44
45
/// @brief constructor used for stops over lane (only for vehicle/route stops)
46
GNEStop(SumoXMLTag tag, GNEDemandElement* stopParent, GNELane* lane, const SUMOVehicleParameter::Stop& stopParameter);
47
48
/// @brief destructor
49
~GNEStop();
50
51
/// @brief methods to retrieve the elements linked to this stop
52
/// @{
53
54
/// @brief get GNEMoveElement associated with this stop
55
GNEMoveElement* getMoveElement() const override;
56
57
/// @brief get parameters associated with this stop
58
Parameterised* getParameters() override;
59
60
/// @brief get parameters associated with this stop (constant)
61
const Parameterised* getParameters() const override;
62
63
/// @}
64
65
/**@brief write demand element element into a xml file
66
* @param[in] device device in which write parameters of demand element element
67
*/
68
void writeDemandElement(OutputDevice& device) const override;
69
70
/// @brief check if current demand element is valid to be written into XML (by default true, can be reimplemented in children)
71
Problem isDemandElementValid() const override;
72
73
/// @brief return a string with the current demand element problem (by default empty, can be reimplemented in children)
74
std::string getDemandElementProblem() const override;
75
76
/// @brief fix demand element problem (by default throw an exception, has to be reimplemented in children)
77
void fixDemandElementProblem() override;
78
79
/// @name members and functions relative to elements common to all demand elements
80
/// @{
81
/// @brief obtain VClass related with this demand element
82
SUMOVehicleClass getVClass() const override;
83
84
/// @brief get color
85
const RGBColor& getColor() const override;
86
87
/// @}
88
89
/// @name Functions related with geometry of element
90
/// @{
91
/// @brief update pre-computed geometry information
92
void updateGeometry() override;
93
94
/// @brief Returns position of demand element in view
95
Position getPositionInView() const override;
96
/// @}
97
98
/// @name inherited from GUIGlObject
99
/// @{
100
/**@brief Returns the name of the parent object
101
* @return This object's parent id
102
*/
103
std::string getParentName() const override;
104
105
/// @brief return exaggeration associated with this GLObject
106
double getExaggeration(const GUIVisualizationSettings& s) const override;
107
108
/**@brief Returns the boundary to which the view shall be centered in order to show the object
109
* @return The boundary the object is within
110
*/
111
Boundary getCenteringBoundary() const override;
112
113
/// @brief split geometry
114
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) override;
115
116
/**@brief Draws the object
117
* @param[in] s The settings for the current view (may influence drawing)
118
* @see GUIGlObject::drawGL
119
*/
120
void drawGL(const GUIVisualizationSettings& s) const override;
121
122
/// @}
123
124
/// @name inherited from GNEPathElement
125
/// @{
126
127
/// @brief compute pathElement
128
void computePathElement() override;
129
130
/**@brief Draws partial object over lane
131
* @param[in] s The settings for the current view (may influence drawing)
132
* @param[in] segment lane segment
133
* @param[in] offsetFront front offset
134
*/
135
void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;
136
137
/**@brief Draws partial object over junction
138
* @param[in] s The settings for the current view (may influence drawing)
139
* @param[in] segment junction segment
140
* @param[in] offsetFront front offset
141
*/
142
void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;
143
144
/// @brief get first path lane
145
GNELane* getFirstPathLane() const override;
146
147
/// @brief get last path lane
148
GNELane* getLastPathLane() const override;
149
/// @}
150
151
/// @brief inherited from GNEAttributeCarrier
152
/// @{
153
/* @brief method for getting the Attribute of an XML key
154
* @param[in] key The attribute key
155
* @return string with the value associated to key
156
*/
157
std::string getAttribute(SumoXMLAttr key) const override;
158
159
/* @brief method for getting the Attribute of an XML key in double format
160
* @param[in] key The attribute key
161
* @return double with the value associated to key
162
*/
163
double getAttributeDouble(SumoXMLAttr key) const override;
164
165
/* @brief method for getting the Attribute of an XML key in position format
166
* @param[in] key The attribute key
167
* @return position with the value associated to key
168
*/
169
Position getAttributePosition(SumoXMLAttr key) const override;
170
171
/* @brief method for setting the attribute and letting the object perform demand element changes
172
* @param[in] key The attribute key
173
* @param[in] value The new value
174
* @param[in] undoList The undoList on which to register changes
175
* @param[in] net optionally the GNENet to inform about gui updates
176
*/
177
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
178
179
/* @brief method for setting the attribute and letting the object perform demand element changes
180
* @param[in] key The attribute key
181
* @param[in] value The new value
182
* @param[in] undoList The undoList on which to register changes
183
*/
184
bool isValid(SumoXMLAttr key, const std::string& value) override;
185
186
/* @brief method for enable attribute
187
* @param[in] key The attribute key
188
* @param[in] undoList The undoList on which to register changes
189
* @note certain attributes can be only enabled, and can produce the disabling of other attributes
190
*/
191
void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList) override;
192
193
/* @brief method for disable attribute
194
* @param[in] key The attribute key
195
* @param[in] undoList The undoList on which to register changes
196
* @note certain attributes can be only enabled, and can produce the disabling of other attributes
197
*/
198
void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList) override;
199
200
/* @brief method for check if the value for certain attribute is set
201
* @param[in] key The attribute key
202
*/
203
bool isAttributeEnabled(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
/// @brief get start position over lane that is applicable to the shape
214
double getStartGeometryPositionOverLane() const;
215
216
/// @brief get end position over lane that is applicable to the shape
217
double getEndGeometryPositionOverLane() const;
218
219
protected:
220
/// @brief move element lane double
221
GNEMoveElementLaneDouble* myMoveElementLaneDouble = nullptr;
222
223
/// @brief variable used for draw contours
224
GNEContour myStopContour;
225
226
/// @brief boundary used during moving of elements (to avoid insertion in RTREE)
227
Boundary myMovingGeometryBoundary;
228
229
/// @brief value for saving first original position over lane before moving
230
Position myOriginalViewPosition;
231
232
/// @brief value for saving first original position over lane before moving
233
std::string myFirstOriginalLanePosition;
234
235
/// @brief value for saving second original position over lane before moving
236
std::string mySecondOriginalPosition;
237
238
/// @brief creation index (using for saving sorted)
239
const int myCreationIndex;
240
241
/// @brief check if vehicle stop can be draw
242
bool canDrawVehicleStop() const;
243
244
/// @brief draw index
245
bool drawIndex() const;
246
247
/// @brief draw stop over lane
248
void drawStopOverLane(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
249
const RGBColor& color, const double width, const double exaggeration) const;
250
251
/// @brief draw stop over stoppingPlace
252
void drawStopOverStoppingPlace(const GUIVisualizationSettings::Detail d, const RGBColor& color,
253
const double width, const double exaggeration) const;
254
255
void drawStopLabel(const GUIVisualizationSettings& s) const;
256
257
private:
258
/// @brief method for setting the attribute and nothing else
259
void setAttribute(SumoXMLAttr key, const std::string& value) override;
260
261
/// @brief method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
262
void toggleAttribute(SumoXMLAttr key, const bool value) override;
263
264
/// @brief draw geometry points
265
void drawGeometryPoints(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const RGBColor& baseColor) const;
266
267
/// @brief get pathStopIndex
268
int getPathStopIndex() const;
269
270
/// @brief set stop microsim ID
271
void setStopMicrosimID();
272
273
/// @brief Invalidated copy constructor.
274
GNEStop(const GNEStop&) = delete;
275
276
/// @brief Invalidated assignment operator
277
GNEStop& operator=(const GNEStop&) = delete;
278
};
279
280