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