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