Eclipse SUMO - Simulation of Urban MObility
GNEDemandElement.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 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 
23 #include <netedit/GNEMoveElement.h>
24 #include <netedit/GNEPathManager.h>
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 
36 class GNENet;
37 class GNEAdditional;
38 class GNEDemandElement;
39 class GNENetworkElement;
40 class GNEGenericData;
41 class GNEEdge;
42 class GNELane;
43 class GNEJunction;
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
48 
54 
55 public:
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 
133  GNEDemandElement* getNextChildDemandElement(const GNEDemandElement* demandElement) const;
134 
136  std::vector<GNEEdge*> getViaEdges() const;
137 
139  void updateDemandElementGeometry(const GNELane* lane, const double posOverLane);
140 
142  void updateDemandElementStackLabel(const int stack);
143 
145  void updateDemandElementSpreadGeometry(const GNELane* lane, const double posOverLane);
146 
150  virtual SUMOVehicleClass getVClass() const = 0;
151 
153  virtual const RGBColor& getColor() const = 0;
155 
158 
161  virtual void writeDemandElement(OutputDevice& device) const = 0;
162 
164  virtual Problem isDemandElementValid() const = 0;
165 
167  virtual std::string getDemandElementProblem() const = 0;
168 
170  virtual void fixDemandElementProblem() = 0;
172 
177  virtual void openDemandElementDialog();
178 
183  virtual std::string getBegin() const;
184 
188  virtual void updateGeometry() = 0;
189 
191  virtual Position getPositionInView() const = 0;
192 
194  virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
196 
199 
208 
217 
219  virtual double getExaggeration(const GUIVisualizationSettings& s) const = 0;
220 
224  virtual Boundary getCenteringBoundary() const = 0;
225 
230  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
231 
233  bool isGLObjectLocked();
234 
236  void markAsFrontElement();
237 
239  void deleteGLObject();
240 
242  void selectGLObject();
243 
245  void updateGLObject();
246 
248 
252  virtual void computePathElement() = 0;
253 
260  virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const = 0;
261 
269  virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const = 0;
270 
272  virtual GNELane* getFirstPathLane() const = 0;
273 
275  virtual GNELane* getLastPathLane() const = 0;
276 
278  double getPathElementDepartValue() const;
279 
282 
284  double getPathElementArrivalValue() const;
285 
288 
290 
293  /* @brief method for getting the Attribute of an XML key
294  * @param[in] key The attribute key
295  * @return string with the value associated to key
296  */
297  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
298 
299  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
300  * @param[in] key The attribute key
301  * @return double with the value associated to key
302  */
303  virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
304 
305  /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
306  * @param[in] key The attribute key
307  * @return double with the value associated to key
308  */
309  virtual Position getAttributePosition(SumoXMLAttr key) const = 0;
310 
316  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
317 
323  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
324 
326  virtual const Parameterised::Map& getACParametersMap() const = 0;
327 
329  virtual std::string getPopUpID() const = 0;
330 
332  virtual std::string getHierarchyName() const = 0;
334 
336  const Position getBeginPosition(const double pedestrianDepartPos) const;
337 
339  std::vector<GNEDemandElement*> getInvalidStops() const;
340 
341 protected:
344 
347 
350 
352  bool isValidDemandElementID(const std::string& newID) const;
353 
357  bool drawPersonPlan() const;
358 
360  bool drawContainerPlan() const;
361 
363  void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront,
364  const double personPlanWidth, const RGBColor& personPlanColor) const;
365 
367  void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment,
368  const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const;
369 
371  Problem isPersonPlanValid() const;
372 
374  std::string getPersonPlanProblem() const;
375 
378 
380 
382  void drawJunctionLine(const GNEDemandElement* element) const;
383 
386 
388  void replaceDemandParentEdges(const std::string& value);
389 
391  void replaceDemandParentLanes(const std::string& value);
392 
394  void replaceFirstParentJunction(const std::string& value);
395 
397  void replaceLastParentJunction(const std::string& value);
398 
400  void replaceFirstParentEdge(const std::string& value);
401 
403  void replaceMiddleParentEdges(const std::string& value, const bool updateChildReferences);
404 
406  void replaceLastParentEdge(const std::string& value);
407 
409  void replaceAdditionalParent(SumoXMLTag tag, const std::string& value);
410 
412  void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
413 
415  void setVTypeDistributionParent(const std::string& value);
416 
418 
420  struct SortedStops {
422  SortedStops(GNEEdge* edge_);
423 
425  void addStop(const GNEDemandElement* stop);
426 
428  const GNEEdge* edge;
429 
431  std::vector<std::pair<std::pair<double, double >, const GNEDemandElement*> > myStops;
432  };
433 
435  std::vector<const GNEDemandElement*> getSortedStops(const std::vector<GNEEdge*>& edges) const;
436 
438  void setFlowParameters(SUMOVehicleParameter* vehicleParameters, const SumoXMLAttr attribute, const bool value);
439 
441  void adjustDefaultFlowAttributes(SUMOVehicleParameter* vehicleParameters);
442 
445 
446 private:
450  virtual bool checkChildDemandElementRestriction() const;
451 
453  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
454 
456  virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
457 
459  virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
460 
463 
466 };
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.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:48
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 GNEMoveOperation * getMoveOperation()=0
get move operation
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
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)
Problem isPersonPlanValid() const
check if person plan is valid
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 GNELane * getLastPathLane() const =0
get last path lane
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 void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)=0
split geometry
GNEDemandElement & operator=(const GNEDemandElement &)=delete
Invalidated assignment operator.
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
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
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...
double getPathElementArrivalValue() const
get path element arrival lane pos
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
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)
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
virtual double getExaggeration(const GUIVisualizationSettings &s) const =0
return exaggeration associated with this GLObject
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
std::string getPersonPlanProblem() const
get person plan problem
virtual const Parameterised::Map & getACParametersMap() const =0
get parameters map
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
void setVTypeDistributionParent(const std::string &value)
set VTypeDistribution parent
void updateGLObject()
update GLObject (geometry, ID, etc.)
std::vector< const GNEDemandElement * > getSortedStops(const std::vector< GNEEdge * > &edges) const
get sorted stops
void replaceDemandParentLanes(const std::string &value)
replace demand parent lanes
virtual GNELane * getFirstPathLane() const =0
get first path lane
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
bool isGLObjectLocked()
check if element is locked
int myStackedLabelNumber
stacked label number
virtual const RGBColor & getColor() const =0
get color
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
void replaceAdditionalParent(SumoXMLTag tag, const std::string &value)
replace additional parent
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 replaceMiddleParentEdges(const std::string &value, const bool updateChildReferences)
replace middle (via) parent edges
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
std::vector< GNEEdge * > getViaEdges() const
get middle (via) parent edges
static const double myPersonPlanArrivalPositionDiameter
person plans arrival position radius
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.
Definition: OutputDevice.h:61
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
Structure representing possible vehicle parameter.
struct for writting sorted stops
void addStop(const GNEDemandElement *stop)
add (and sort) stop
std::vector< std::pair< std::pair< double, double >, const GNEDemandElement * > > myStops
stops sorted by end position
SortedStops(GNEEdge *edge_)
constructor
const GNEEdge * edge
route's edge