Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/demand/GNEContainer.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 GNEContainer.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Jun 2021
17
///
18
// Representation of containers in netedit
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netedit/elements/GNEContour.h>
24
#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
25
26
#include "GNEDemandElement.h"
27
#include "GNEDemandElementFlow.h"
28
29
// ===========================================================================
30
// class declaration
31
// ===========================================================================
32
33
class GNEMoveElementPlanParent;
34
35
// ===========================================================================
36
// class definitions
37
// ===========================================================================
38
39
class GNEContainer : public GNEDemandElement, public GNEDemandElementFlow {
40
41
public:
42
/// @brief class used in GUIGLObjectPopupMenu for container transformations
43
class GNEContainerPopupMenu : public GUIGLObjectPopupMenu {
44
FXDECLARE(GNEContainerPopupMenu)
45
46
public:
47
/** @brief Constructor
48
* @param[in] container GNEContainer to be transformed
49
* @param[in] app The main window for instantiation of other windows
50
* @param[in] parent The parent view for changing it
51
*/
52
GNEContainerPopupMenu(GNEContainer* container, GUIMainWindow& app, GUISUMOAbstractView& parent);
53
54
/// @brief Destructor
55
~GNEContainerPopupMenu();
56
57
/// @brief Called to transform the current container to another container type
58
long onCmdTransform(FXObject* obj, FXSelector, void*);
59
60
protected:
61
FOX_CONSTRUCTOR(GNEContainerPopupMenu)
62
63
private:
64
/// @brief current container
65
GNEContainer* myContainer;
66
67
/// @brief menu command for transform to container
68
FXMenuCommand* myTransformToContainer;
69
70
/// @brief menu command for transform to containerFlow
71
FXMenuCommand* myTransformToContainerFlow;
72
};
73
74
/// @brief class used in GUIGLObjectPopupMenu for single container transformations
75
class GNESelectedContainersPopupMenu : public GUIGLObjectPopupMenu {
76
FXDECLARE(GNESelectedContainersPopupMenu)
77
78
public:
79
/** @brief Constructor
80
* @param[in] container clicked GNEContainer
81
* @param[in] selectedContainer vector with selected GNEContainer
82
* @param[in] app The main window for instantiation of other windows
83
* @param[in] parent The parent view for changing it
84
*/
85
GNESelectedContainersPopupMenu(GNEContainer* container, const std::vector<GNEContainer*>& selectedContainer, GUIMainWindow& app, GUISUMOAbstractView& parent);
86
87
/// @brief Destructor
88
~GNESelectedContainersPopupMenu();
89
90
/// @brief Called to transform the current container to another container type
91
long onCmdTransform(FXObject* obj, FXSelector, void*);
92
93
protected:
94
FOX_CONSTRUCTOR(GNESelectedContainersPopupMenu)
95
96
private:
97
/// @brief tag of clicked container
98
SumoXMLTag myContainerTag;
99
100
/// @brief current selected containers
101
std::vector<GNEContainer*> mySelectedContainers;
102
103
/// @brief menu command for transform to container
104
FXMenuCommand* myTransformToContainer;
105
106
/// @brief menu command for transform to containerFlow
107
FXMenuCommand* myTransformToContainerFlow;
108
};
109
110
/// @brief default constructor
111
GNEContainer(SumoXMLTag tag, GNENet* net);
112
113
/// @brief constructor for containers
114
GNEContainer(SumoXMLTag tag, GNENet* net, FileBucket* fileBucket, GNEDemandElement* pType,
115
const SUMOVehicleParameter& containerparameters);
116
117
/// @brief destructor
118
~GNEContainer();
119
120
/// @brief methods to retrieve the elements linked to this container
121
/// @{
122
123
/// @brief get GNEMoveElement associated with this container
124
GNEMoveElement* getMoveElement() const override;
125
126
/// @brief get parameters associated with this container
127
Parameterised* getParameters() override;
128
129
/// @brief get parameters associated with this container (constant)
130
const Parameterised* getParameters() const override;
131
132
/// @}
133
134
/**@brief write demand element element into a xml file
135
* @param[in] device device in which write parameters of demand element element
136
*/
137
void writeDemandElement(OutputDevice& device) const override;
138
139
/// @brief check if current demand element is valid to be written into XML (by default true, can be reimplemented in children)
140
Problem isDemandElementValid() const override;
141
142
/// @brief return a string with the current demand element problem (by default empty, can be reimplemented in children)
143
std::string getDemandElementProblem() const override;
144
145
/// @brief fix demand element problem (by default throw an exception, has to be reimplemented in children)
146
void fixDemandElementProblem() override;
147
148
/// @name members and functions relative to elements common to all demand elements
149
/// @{
150
/// @brief obtain VClass related with this demand element
151
SUMOVehicleClass getVClass() const override;
152
153
/// @brief get color
154
const RGBColor& getColor() const override;
155
156
/// @}
157
158
/// @name Functions related with geometry of element
159
/// @{
160
/// @brief update pre-computed geometry information
161
void updateGeometry() override;
162
163
/// @brief Returns position of demand element in view
164
Position getPositionInView() const override;
165
/// @}
166
167
/// @name inherited from GUIGlObject
168
/// @{
169
/**@brief Returns an own popup-menu
170
*
171
* @param[in] app The application needed to build the popup-menu
172
* @param[in] parent The parent window needed to build the popup-menu
173
* @return The built popup-menu
174
* @see GUIGlObject::getPopUpMenu
175
*/
176
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
177
178
/**@brief Returns the name of the parent object
179
* @return This object's parent id
180
*/
181
std::string getParentName() const override;
182
183
/// @brief return exaggeration associated with this GLObject
184
double getExaggeration(const GUIVisualizationSettings& s) const override;
185
186
/**@brief Returns the boundary to which the view shall be centered in order to show the object
187
* @return The boundary the object is within
188
*/
189
Boundary getCenteringBoundary() const override;
190
191
/// @brief split geometry
192
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) override;
193
194
/**@brief Draws the object
195
* @param[in] s The settings for the current view (may influence drawing)
196
* @see GUIGlObject::drawGL
197
*/
198
void drawGL(const GUIVisualizationSettings& s) const override;
199
200
/// @}
201
202
/// @name inherited from GNEPathElement
203
/// @{
204
205
/// @brief compute pathElement
206
void computePathElement() override;
207
208
/**@brief Draws partial object over lane
209
* @param[in] s The settings for the current view (may influence drawing)
210
* @param[in] segment lane segment
211
* @param[in] offsetFront front offset
212
*/
213
void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;
214
215
/**@brief Draws partial object over junction
216
* @param[in] s The settings for the current view (may influence drawing)
217
* @param[in] segment junction segment
218
* @param[in] offsetFront front offset
219
*/
220
void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;
221
222
/// @brief get first path lane
223
GNELane* getFirstPathLane() const override;
224
225
/// @brief get last path lane
226
GNELane* getLastPathLane() const override;
227
/// @}
228
229
/// @brief inherited from GNEAttributeCarrier
230
/// @{
231
/* @brief method for getting the Attribute of an XML key
232
* @param[in] key The attribute key
233
* @return string with the value associated to key
234
*/
235
std::string getAttribute(SumoXMLAttr key) const override;
236
237
/* @brief method for getting the Attribute of an XML key in double format
238
* @param[in] key The attribute key
239
* @return double with the value associated to key
240
*/
241
double getAttributeDouble(SumoXMLAttr key) const override;
242
243
/* @brief method for getting the Attribute of an XML key in position format
244
* @param[in] key The attribute key
245
* @return position with the value associated to key
246
*/
247
Position getAttributePosition(SumoXMLAttr key) const override;
248
249
/* @brief method for setting the attribute and letting the object perform demand element changes
250
* @param[in] key The attribute key
251
* @param[in] value The new value
252
* @param[in] undoList The undoList on which to register changes
253
* @param[in] net optionally the GNENet to inform about gui updates
254
*/
255
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
256
257
/* @brief method for setting the attribute and letting the object perform demand element changes
258
* @param[in] key The attribute key
259
* @param[in] value The new value
260
* @param[in] undoList The undoList on which to register changes
261
*/
262
bool isValid(SumoXMLAttr key, const std::string& value) override;
263
264
/* @brief method for enable attribute
265
* @param[in] key The attribute key
266
* @param[in] undoList The undoList on which to register changes
267
* @note certain attributes can be only enabled, and can produce the disabling of other attributes
268
*/
269
void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList) override;
270
271
/* @brief method for disable attribute
272
* @param[in] key The attribute key
273
* @param[in] undoList The undoList on which to register changes
274
* @note certain attributes can be only enabled, and can produce the disabling of other attributes
275
*/
276
void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList) override;
277
278
/* @brief method for check if the value for certain attribute is set
279
* @param[in] key The attribute key
280
*/
281
bool isAttributeEnabled(SumoXMLAttr key) const override;
282
283
/// @brief get PopPup ID (Used in AC Hierarchy)
284
std::string getPopUpID() const override;
285
286
/// @brief get Hierarchy Name (Used in AC Hierarchy)
287
std::string getHierarchyName() const override;
288
/// @}
289
290
protected:
291
/// @brief move element plan parent
292
GNEMoveElementPlanParent* myMoveElementPlanParent = nullptr;
293
294
/// @brief variable used for contours
295
GNEContour myContainerContour;
296
297
/// @brief get drawing color
298
RGBColor getDrawingColor(const GUIVisualizationSettings& s) const;
299
300
/// @brief draw container as poly
301
void drawAction_drawAsPoly() const;
302
303
/// @brief draw container as image
304
void drawAction_drawAsImage(const GUIVisualizationSettings& s) const;
305
306
private:
307
// @brief struct used for calculating container plan geometry segments
308
struct containerPlanSegment {
309
/// @brief parameter constructor
310
containerPlanSegment(GNEDemandElement* _containerPlan);
311
312
/// @brief container plan
313
const GNEDemandElement* containerPlan;
314
315
/// @brief edge
316
GNEEdge* edge;
317
318
/// @brief busStops placed in this segment
319
std::vector<GNEAdditional*> busStops;
320
321
/// @brief stops placed in this segment
322
std::vector<GNEDemandElement*> stops;
323
324
/// @brief arrival position
325
double arrivalPos;
326
327
private:
328
/// @brief constructor
329
containerPlanSegment();
330
};
331
332
/// @brief method for setting the attribute and nothing else
333
void setAttribute(SumoXMLAttr key, const std::string& value) override;
334
335
/// @brief method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
336
void toggleAttribute(SumoXMLAttr key, const bool value) override;
337
338
/// @brief Invalidated copy constructor.
339
GNEContainer(const GNEContainer&) = delete;
340
341
/// @brief Invalidated assignment operator
342
GNEContainer& operator=(const GNEContainer&) = delete;
343
};
344
345