Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
87
89 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
90
93
95 const GUIGlObject* getGUIGlObject() const;
96
99
102
105
107 void updateDemandElementGeometry(const GNELane* lane, const double posOverLane);
108
110 void updateDemandElementStackLabel(const int stack);
111
113 void updateDemandElementSpreadGeometry(const GNELane* lane, const double posOverLane);
114
117
119 virtual SUMOVehicleClass getVClass() const = 0;
120
122 virtual const RGBColor& getColor() const = 0;
123
125
128
131 virtual void writeDemandElement(OutputDevice& device) const = 0;
132
134 virtual Problem isDemandElementValid() const = 0;
135
137 virtual std::string getDemandElementProblem() const = 0;
138
140 virtual void fixDemandElementProblem() = 0;
142
147 virtual void openDemandElementDialog();
148
151
153 virtual void updateGeometry() = 0;
154
156 virtual Position getPositionInView() const = 0;
157
159 virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
160
163
165
168
170 bool checkDrawFromContour() const;
171
173 bool checkDrawToContour() const;
174
176 bool checkDrawRelatedContour() const;
177
179 bool checkDrawOverContour() const;
180
182 bool checkDrawDeleteContour() const;
183
185 bool checkDrawDeleteContourSmall() const;
186
188 bool checkDrawSelectContour() const;
189
191 bool checkDrawMoveContour() const;
192
194
197
206
215
220 virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
221
223 bool isGLObjectLocked() const;
224
226 void markAsFrontElement();
227
229 void deleteGLObject();
230
232 void selectGLObject();
233
235 void updateGLObject();
236
238
242 virtual void computePathElement() = 0;
243
245 bool isPathElementSelected() const;
246
252 virtual void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const = 0;
253
259 virtual void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const = 0;
260
262 virtual GNELane* getFirstPathLane() const = 0;
263
265 virtual GNELane* getLastPathLane() const = 0;
266
268
271 /* @brief method for getting the Attribute of an XML key
272 * @param[in] key The attribute key
273 * @return string with the value associated to key
274 */
275 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
276
277 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
278 * @param[in] key The attribute key
279 * @return double with the value associated to key
280 */
281 virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
282
283 /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
284 * @param[in] key The attribute key
285 * @return double with the value associated to key
286 */
288
294 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
295
301 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
302
304 virtual const Parameterised::Map& getACParametersMap() const = 0;
305
307 virtual std::string getPopUpID() const = 0;
308
310 virtual std::string getHierarchyName() const = 0;
311
313
315 std::vector<GNEDemandElement*> getInvalidStops() const;
316
317protected:
320
323
326
328 bool isValidDemandElementID(const std::string& value) const;
329
331 bool isValidDemandElementID(const std::vector<SumoXMLTag>& tags, const std::string& value) const;
332
334 void setDemandElementID(const std::string& newID);
335
338
341
343 void drawJunctionLine(const GNEDemandElement* element) const;
344
346 void drawStackLabel(const int number, const std::string& element, const Position& position, const double rotation,
347 const double width, const double length, const double exaggeration) const;
348
351
353 void replaceParentEdges(const std::string& value);
354
356 void replaceFirstParentLane(const std::string& value);
357
359 void replaceFirstParentJunction(const std::string& value);
360
362 void replaceLastParentJunction(const std::string& value);
363
365 void replaceFirstParentEdge(const std::string& value);
366
368 void replaceLastParentEdge(const std::string& value);
369
371 void replaceFirstParentAdditional(SumoXMLTag tag, const std::string& value);
372
374 void replaceLastParentAdditional(SumoXMLTag tag, const std::string& value);
375
377 void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
378
380
383
386 edge(edge_),
387 stops({stop}) {}
388
390 const GNEEdge* edge = nullptr;
391
393 std::vector<GNEDemandElement*> stops;
394
396 int stopIndex = -1;
397
398 private:
401 };
402
404 std::vector<EdgeStopIndex> getEdgeStopIndex() const;
405
407 RGBColor getColorByScheme(const GUIColorer& c, const SUMOVehicleParameter* parameters) const;
408
411
414
415private:
419 virtual bool checkChildDemandElementRestriction() const;
420
422 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
423
425 virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
426
428 virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
429
432
435};
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
virtual void updateGeometry()=0
update pre-computed geometry information
GNEDemandElement(const GNEDemandElement &)=delete
Invalidated copy constructor.
virtual void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)=0
commit move shape
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
virtual void setAttribute(SumoXMLAttr key, const std::string &value)=0
method for setting the attribute and nothing else (used in GNEChange_Attribute)
virtual GNELane * getLastPathLane() const =0
get last path lane
bool checkDrawOverContour() const
check if draw over contour (orange)
GNEDemandElement & operator=(const GNEDemandElement &)=delete
Invalidated assignment operator.
virtual GNELane * getFirstPathLane() const =0
get first path lane
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
virtual void setMoveShape(const GNEMoveResult &moveResult)=0
set move shape
virtual void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const =0
Draws partial object over lane.
virtual const Parameterised::Map & getACParametersMap() const =0
get parameters map
virtual double getAttributeDouble(SumoXMLAttr key) const =0
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
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 GNEMoveOperation * getMoveOperation()=0
get move operation
virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)=0
split geometry
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
virtual std::string getAttribute(SumoXMLAttr key) const =0
virtual const RGBColor & getColor() const =0
get color
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
bool isPathElementSelected() const
check if path element is selected
bool checkDrawToContour() const
check if draw from contour (magenta)
virtual void computePathElement()=0
implement in children+
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 drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const =0
Draws partial object over junction.
virtual void writeDemandElement(OutputDevice &device) const =0
write demand element element into a xml file
virtual std::string getPopUpID() const =0
get PopPup ID (Used in AC Hierarchy)
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 selectGLObject()
select element
bool checkDrawMoveContour() const
check if draw move contour (red)
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
void setDemandElementID(const std::string &newID)
set demand element id
bool checkDrawDeleteContourSmall() const
check if draw delete contour small (pink/white)
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
void buildMenuAddReverse(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
std::vector< EdgeStopIndex > getEdgeStopIndex() const
get edgeStopIndex
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
void updateGLObject()
update GLObject (geometry, ID, etc.)
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
bool checkDrawSelectContour() const
check if draw select contour (blue)
void replaceParentEdges(const std::string &value)
all edges
GNEHierarchicalElement * getHierarchicalElement()
get GNEHierarchicalElement associated with this AttributeCarrier
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void updateDemandElementSpreadGeometry(const GNELane *lane, const double posOverLane)
update element spread geometry
virtual std::string getHierarchyName() const =0
get Hierarchy Name (Used in AC Hierarchy)
virtual Position getPositionInView() const =0
Returns position of demand element in view.
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform demand element changes
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 GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
virtual bool checkChildDemandElementRestriction() const
check restriction with the number of children
Problem
enum class for demandElement problems
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position (Currently unused in shapes)
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 isGLObjectLocked() const
check if element is locked
void markAsFrontElement()
mark element as front element
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
void replaceLastParentAdditional(SumoXMLTag tag, const std::string &value)
replace the last parent additional
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
virtual ~GNEDemandElement()
Destructor.
virtual void openDemandElementDialog()
open DemandElement Dialog
void deleteGLObject()
delete element
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
bool checkDrawFromContour() const
check if draw from contour (green)
virtual Position getAttributePosition(SumoXMLAttr key) const =0
virtual void fixDemandElementProblem()=0
fix demand element problem (by default throw an exception, has to be reimplemented in children)
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
move element
move operation
move result
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.
Stores the information about how to visualize structures.
Static storage of an output device and its base (abstract) implementation.
std::map< std::string, std::string > Map
parameters map
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
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