Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEDemandElement.h
Go to the documentation of this file.
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/****************************************************************************/
18// A abstract class for demand elements
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
28
29// ===========================================================================
30// class declarations
31// ===========================================================================
32
34
35// ===========================================================================
36// class definitions
37// ===========================================================================
38
40
41public:
43 friend class GNERouteHandler;
46
48 enum class Problem {
49 OK, // There is no problem
50 INVALID_ELEMENT, // Element is invalid (for example, a route without edges)
51 INVALID_PATH, // Path (route, trip... ) is not valid (i.e is empty)
52 DISCONNECTED_PLAN, // Plan element (person, containers) is not connected with the previous or next plan
53 INVALID_STOPPOSITION, // StopPosition is invalid (only used in stops over edges or lanes
54 STOP_DOWNSTREAM, // Stops don't follow their route parent
55 REPEATEDROUTE_DISCONNECTED, // Repeated route is disconnected
56 NO_PLANS // Person or container doesn't have a plan
57 };
58
66 GNEDemandElement(const std::string& id, GNENet* net, const std::string& filename,
67 SumoXMLTag tag, const GNEPathElement::Options pathOptions);
68
75 GNEDemandElement(GNEDemandElement* demandElementParent, SumoXMLTag tag, const GNEPathElement::Options pathOptions);
76
78 virtual ~GNEDemandElement();
79
82
85
87 GUIGlObject* getGUIGlObject() override;
88
90 const GUIGlObject* getGUIGlObject() const override;
91
93
96
99
102
104 void updateDemandElementGeometry(const GNELane* lane, const double posOverLane);
105
107 void updateDemandElementStackLabel(const int stack);
108
110 void updateDemandElementSpreadGeometry(const GNELane* lane, const double posOverLane);
111
114
116 virtual SUMOVehicleClass getVClass() const = 0;
117
119 virtual const RGBColor& getColor() const = 0;
120
122
125
129 virtual void writeDemandElement(OutputDevice& device) const = 0;
130
132 virtual Problem isDemandElementValid() const = 0;
133
135 virtual std::string getDemandElementProblem() const = 0;
136
138 virtual void fixDemandElementProblem() = 0;
139
141
146 virtual void openDemandElementDialog();
147
150
152 virtual Position getPositionInView() const = 0;
153
155 virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
156
159
161
164
166 bool checkDrawFromContour() const override;
167
169 bool checkDrawToContour() const override;
170
172 bool checkDrawRelatedContour() const override;
173
175 bool checkDrawOverContour() const override;
176
178 bool checkDrawDeleteContour() const override;
179
181 bool checkDrawDeleteContourSmall() const override;
182
184 bool checkDrawSelectContour() const override;
185
187 bool checkDrawMoveContour() const override;
188
190
193
202
211
213 bool isGLObjectLocked() const override;
214
216 void markAsFrontElement() override;
217
219 void deleteGLObject() override;
220
222 void selectGLObject() override;
223
225 void updateGLObject() override;
226
228
231
232 /* @brief method for getting the Attribute of an XML key in position format
233 * @param[in] key The attribute key
234 * @return position with the value associated to key
235 */
236 Position getAttributePosition(SumoXMLAttr key) const override;
237
238 /* @brief method for getting the Attribute of an XML key in positionVector format
239 * @param[in] key The attribute key
240 * @return positionVector with the value associated to key
241 */
243
245
248
250 bool isPathElementSelected() const override;
251
253
255 std::vector<GNEDemandElement*> getInvalidStops() const;
256
257protected:
260
263
266
268 bool isValidDemandElementID(const std::string& value) const;
269
271 bool isValidDemandElementID(const std::vector<SumoXMLTag>& tags, const std::string& value) const;
272
274 void setDemandElementID(const std::string& newID);
275
278
281
283 void drawJunctionLine(const GNEDemandElement* element) const;
284
286 void drawStackLabel(const int number, const std::string& element, const Position& position, const double rotation,
287 const double width, const double length, const double exaggeration) const;
288
291
293 void replaceParentEdges(const std::string& value);
294
296 void replaceFirstParentLane(const std::string& value);
297
299 void replaceFirstParentJunction(const std::string& value);
300
302 void replaceLastParentJunction(const std::string& value);
303
305 void replaceFirstParentEdge(const std::string& value);
306
308 void replaceLastParentEdge(const std::string& value);
309
311 void replaceFirstParentAdditional(SumoXMLTag tag, const std::string& value);
312
314 void replaceLastParentAdditional(SumoXMLTag tag, const std::string& value);
315
317 void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
318
320
323
326 edge(edge_),
327 stops({stop}) {}
328
330 const GNEEdge* edge = nullptr;
331
333 std::vector<GNEDemandElement*> stops;
334
336 int stopIndex = -1;
337
338 private:
341 };
342
344 std::vector<EdgeStopIndex> getEdgeStopIndex() const;
345
347 RGBColor getColorByScheme(const GUIColorer& c, const SUMOVehicleParameter* parameters) const;
348
351
354
355private:
359 virtual bool checkChildDemandElementRestriction() const;
360
363
366};
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
bool checkDrawFromContour() const override
check if draw from contour (green)
bool isGLObjectLocked() const override
check if element is locked
GNEDemandElement(const GNEDemandElement &)=delete
Invalidated copy constructor.
Position getAttributePosition(SumoXMLAttr key) const override
std::vector< GNEDemandElement * > getInvalidStops() const
get invalid stops
virtual SUMOVehicleClass getVClass() const =0
obtain VClass related with this demand element
void updateDemandElementGeometry(const GNELane *lane, const double posOverLane)
update element stacked geometry (stacked)
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
void drawStackLabel(const int number, const std::string &element, const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw stack label
GNEHierarchicalElement * getHierarchicalElement() override
methods to retrieve the elements linked to this GNEDemandElement
GNEDemandElement & operator=(const GNEDemandElement &)=delete
Invalidated assignment operator.
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
void selectGLObject() override
select element
GNEDemandElement * getNextChildDemandElement(const GNEDemandElement *demandElement) const
get next child demand element to the given demand element
void updateDemandElementStackLabel(const int stack)
update stack label
virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)=0
split geometry
bool checkDrawDeleteContour() const override
check if draw delete contour (pink/white)
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
virtual const RGBColor & getColor() const =0
get color
bool isPathElementSelected() const override
check if path element is selected
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
virtual Problem isDemandElementValid() const =0
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
void replaceFirstParentAdditional(SumoXMLTag tag, const std::string &value)
replace the first parent additional
virtual void writeDemandElement(OutputDevice &device) const =0
write demand element element into a xml file
GNEDemandElement * getRouteParent() const
get route parent (always the second parent demand element)
virtual std::string getDemandElementProblem() const =0
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
void setDemandElementID(const std::string &newID)
set demand element id
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
bool checkDrawMoveContour() const override
check if draw move contour (red)
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
void buildMenuAddReverse(GUIGLObjectPopupMenu *ret) const
build menu command route length
void updateGLObject() override
update GLObject (geometry, ID, etc.)
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
std::vector< EdgeStopIndex > getEdgeStopIndex() const
get edgeStopIndex
bool checkDrawSelectContour() const override
check if draw select contour (blue)
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
void deleteGLObject() override
delete element
void replaceParentEdges(const std::string &value)
all edges
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
void updateDemandElementSpreadGeometry(const GNELane *lane, const double posOverLane)
update element spread geometry
virtual Position getPositionInView() const =0
Returns position of demand element in view.
RGBColor getColorByScheme(const GUIColorer &c, const SUMOVehicleParameter *parameters) const
get color by scheme (used by vehicles, persons and containers)
const GUIGeometry & getDemandElementGeometry()
get demand element geometry (stacked)
virtual bool checkChildDemandElementRestriction() const
check restriction with the number of children
GUIGlObject * getGUIGlObject() override
get GUIGlObject associated with this GNEDemandElement
bool checkDrawRelatedContour() const override
check if draw related contour (cyan)
Problem
enum class for demandElement problems
GNEDemandElement * getPreviousChildDemandElement(const GNEDemandElement *demandElement) const
get previous child demand element to the given demand element
void replaceFirstParentLane(const std::string &value)
replace the first parent lane
bool checkDrawDeleteContourSmall() const override
check if draw delete contour small (pink/white)
void replaceLastParentAdditional(SumoXMLTag tag, const std::string &value)
replace the last parent additional
virtual ~GNEDemandElement()
Destructor.
virtual void openDemandElementDialog()
open DemandElement Dialog
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
bool checkDrawToContour() const override
check if draw from contour (magenta)
void markAsFrontElement() override
mark element as front element
bool checkDrawOverContour() const override
check if draw over contour (orange)
virtual void fixDemandElementProblem()=0
fix demand element problem (by default throw an exception, has to be reimplemented in children)
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
The popup menu of a globject.
A window containing a gl-object's parameter.
Static storage of an output device and its base (abstract) implementation.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
Structure representing possible vehicle parameter.
auxiliar struct used for calculate pathStopIndex
int stopIndex
stopIndex (-1 menans out of route)
EdgeStopIndex(GNEEdge *edge_, GNEDemandElement *stop)
constructor
EdgeStopIndex()
default constructor (disabled)
const GNEEdge * edge
edge (obtained from segment)
std::vector< GNEDemandElement * > stops
list of stops placed in the edge