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-2023 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
31
32// ===========================================================================
33// class declarations
34// ===========================================================================
35
36class GNENet;
37class GNEAdditional;
40class GNEGenericData;
41class GNEEdge;
42class GNELane;
43class GNEJunction;
44
45// ===========================================================================
46// class definitions
47// ===========================================================================
48
54
55public:
57 friend class GNERouteHandler;
58
60 enum class Problem {
61 OK, // There is no problem
62 INVALID_ELEMENT, // Element is invalid (for example, a route without edges)
63 INVALID_PATH, // Path (route, trip... ) is not valid (i.e is empty)
64 DISCONNECTED_PLAN, // Plan element (person, containers) is not connected with the previous or next plan
65 INVALID_STOPPOSITION, // StopPosition is invalid (only used in stops over edges or lanes
66 STOP_DOWNSTREAM, // Stops don't follow their route parent
67 NO_PLANS // Person or container doesn't have a plan
68 };
69
83 GNEDemandElement(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, const int pathOptions,
84 const std::vector<GNEJunction*>& junctionParents,
85 const std::vector<GNEEdge*>& edgeParents,
86 const std::vector<GNELane*>& laneParents,
87 const std::vector<GNEAdditional*>& additionalParents,
88 const std::vector<GNEDemandElement*>& demandElementParents,
89 const std::vector<GNEGenericData*>& genericDataParents);
90
104 GNEDemandElement(GNEDemandElement* demandElementParent, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, const int pathOptions,
105 const std::vector<GNEJunction*>& junctionParents,
106 const std::vector<GNEEdge*>& edgeParents,
107 const std::vector<GNELane*>& laneParents,
108 const std::vector<GNEAdditional*>& additionalParents,
109 const std::vector<GNEDemandElement*>& demandElementParents,
110 const std::vector<GNEGenericData*>& genericDataParents);
111
113 virtual ~GNEDemandElement();
114
119
121 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
122
125
128
131
134
136 void updateDemandElementGeometry(const GNELane* lane, const double posOverLane);
137
139 void updateDemandElementStackLabel(const int stack);
140
142 void updateDemandElementSpreadGeometry(const GNELane* lane, const double posOverLane);
143
147 virtual SUMOVehicleClass getVClass() const = 0;
148
150 virtual const RGBColor& getColor() const = 0;
152
155
158 virtual void writeDemandElement(OutputDevice& device) const = 0;
159
161 virtual Problem isDemandElementValid() const = 0;
162
164 virtual std::string getDemandElementProblem() const = 0;
165
167 virtual void fixDemandElementProblem() = 0;
169
174 virtual void openDemandElementDialog();
175
180 virtual std::string getBegin() const;
181
185 virtual void updateGeometry() = 0;
186
188 virtual Position getPositionInView() const = 0;
189
191 virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
193
196
205
214
219 virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
220
222 bool isGLObjectLocked();
223
225 void markAsFrontElement();
226
228 void deleteGLObject();
229
231 void selectGLObject();
232
234 void updateGLObject();
235
237
241 virtual void computePathElement() = 0;
242
244 bool isPathElementSelected() const;
245
252 virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const = 0;
253
261 virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const = 0;
262
264 virtual GNELane* getFirstPathLane() const = 0;
265
267 virtual GNELane* getLastPathLane() const = 0;
268
270 double getPathElementDepartValue() const;
271
274
276 double getPathElementArrivalValue() const;
277
280
282
285 /* @brief method for getting the Attribute of an XML key
286 * @param[in] key The attribute key
287 * @return string with the value associated to key
288 */
289 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
290
291 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
292 * @param[in] key The attribute key
293 * @return double with the value associated to key
294 */
295 virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
296
297 /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
298 * @param[in] key The attribute key
299 * @return double with the value associated to key
300 */
302
308 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
309
315 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
316
318 virtual const Parameterised::Map& getACParametersMap() const = 0;
319
321 virtual std::string getPopUpID() const = 0;
322
324 virtual std::string getHierarchyName() const = 0;
326
328 const Position getBeginPosition(const double pedestrianDepartPos) const;
329
331 std::vector<GNEDemandElement*> getInvalidStops() const;
332
333protected:
336
339
342
344 bool isValidDemandElementID(const std::string& newID) const;
345
348
351
355 bool drawPersonPlan() const;
356
358 bool drawContainerPlan() const;
359
361 void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront,
362 const double personPlanWidth, const RGBColor& personPlanColor) const;
363
365 void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment,
366 const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const;
367
370
372 std::string getPersonPlanProblem() const;
373
376
378
380 void drawJunctionLine(const GNEDemandElement* element) const;
381
383 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;
384
386 void drawFlowLabel(const Position& position, const double rotation, const double width, const double length, const double exaggeration) const;
387
390
392 void replaceDemandParentEdges(const std::string& value);
393
395 void replaceDemandParentLanes(const std::string& value);
396
398 void replaceFirstParentJunction(const std::string& value);
399
401 void replaceLastParentJunction(const std::string& value);
402
404 void replaceFirstParentEdge(const std::string& value);
405
407 void replaceLastParentEdge(const std::string& value);
408
410 void replaceFirstParentAdditional(SumoXMLTag tag, const std::string& value);
411
413 void replaceLastParentAdditional(SumoXMLTag tag, const std::string& value);
414
416 void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
417
419 void setVTypeDistributionParent(const std::string& value);
420
422
424 bool demandElementExist(const std::string &id, const std::vector<SumoXMLTag> tags) const;
425
428
431 edge(edge_),
432 stops({stop}) {}
433
435 const GNEEdge* edge = nullptr;
436
438 std::vector<GNEDemandElement*> stops;
439
441 int stopIndex = -1;
442
443 private:
446 };
447
449 std::vector<EdgeStopIndex> getEdgeStopIndex() const;
450
452 void setFlowParameters(SUMOVehicleParameter* vehicleParameters, const SumoXMLAttr attribute, const bool value);
453
455 void adjustDefaultFlowAttributes(SUMOVehicleParameter* vehicleParameters);
456
459
460private:
464 virtual bool checkChildDemandElementRestriction() const;
465
467 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
468
470 virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
471
473 virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
474
477
480};
GUIGlObjectType
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.
An Element which don't belong to GNENet but has influence in the simulation.
An Element which don't belong to GNENet but has influence in the simulation.
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceDemandParentEdges(const std::string &value)
replace demand parent edges
virtual void updateGeometry()=0
update pre-computed geometry information
virtual void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const =0
Draws partial object (lane)
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
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 std::string getBegin() const
get begin time of demand element
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
GNEDemandElement & operator=(const GNEDemandElement &)=delete
Invalidated assignment operator.
Problem isPersonPlanValid() const
check if person plan is valid
virtual GNELane * getFirstPathLane() const =0
get first path lane
Position getPathElementArrivalPos() const
get path element arrival position
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
virtual void setMoveShape(const GNEMoveResult &moveResult)=0
set move shape
virtual const Parameterised::Map & getACParametersMap() const =0
get parameters map
virtual double getAttributeDouble(SumoXMLAttr key) const =0
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 drawFlowLabel(const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw flow label
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
virtual void computePathElement()=0
compute pathElement
virtual Problem isDemandElementValid() const =0
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
void replaceFirstParentAdditional(SumoXMLTag tag, const std::string &value)
replace the first parent additional
double getPathElementArrivalValue() const
get path element arrival lane pos
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 drawContainerPlan() const
check if container plan can be drawn
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
std::string getPersonPlanProblem() const
get person plan problem
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
std::vector< EdgeStopIndex > getEdgeStopIndex() const
get edgeStopIndex
void setVTypeDistributionParent(const std::string &value)
set VTypeDistribution parent
void updateGLObject()
update GLObject (geometry, ID, etc.)
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
void replaceDemandParentLanes(const std::string &value)
replace demand parent lanes
bool demandElementExist(const std::string &id, const std::vector< SumoXMLTag > tags) const
check if the given demand element exist
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
bool isGLObjectLocked()
check if element is locked
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
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
const Position getBeginPosition(const double pedestrianDepartPos) const
get personPlan start position
Problem
enum class for demandElement problems
virtual void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *fromLane, const GNELane *toLane, const GNEPathManager::Segment *segment, const double offsetFront) const =0
Draws partial object (junction)
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
Position getPathElementDepartPos() const
get path element depart position
void adjustDefaultFlowAttributes(SUMOVehicleParameter *vehicleParameters)
adjust flow default attributes (called in vehicle/person/flow constructors)
double getPathElementDepartValue() const
get path element depart lane pos
void markAsFrontElement()
mark element as front element
void setFlowParameters(SUMOVehicleParameter *vehicleParameters, const SumoXMLAttr attribute, const bool value)
set flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront, const double personPlanWidth, const RGBColor &personPlanColor) const
draw person plan partial lane
bool isValidDemandElementID(const std::string &newID) const
check if a new demand element ID is valid
static const double myPersonPlanArrivalPositionDiameter
person plans arrival position radius
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
bool drawPersonPlan() const
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
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
An Element which don't belong to GNENet but has influence in the simulation.
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
class used for path elements
Builds trigger objects for GNENet (busStops, chargingStations, detectors, etc..)
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