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 
25 #include <netedit/GNEMoveElement.h>
26 #include <netedit/GNEPathManager.h>
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 
35 class GNENet;
36 class GNEAdditional;
37 class GNEDemandElement;
38 class GNENetworkElement;
39 class GNEGenericData;
40 class GNEEdge;
41 class GNELane;
42 class GNEJunction;
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
47 
53 
54 public:
56  friend class GNERouteHandler;
57 
59  enum class Problem {
60  OK, // There is no problem
61  INVALID_ELEMENT, // Element is invalid (for example, a route without edges)
62  INVALID_PATH, // Path (route, trip... ) is not valid (i.e is empty)
63  DISCONNECTED_PLAN, // Plan element (person, containers) is not connected with the previous or next plan
64  INVALID_STOPPOSITION, // StopPosition is invalid (only used in stops over edges or lanes
65  STOP_DOWNSTREAM, // Stops don't follow their route parent
66  };
67 
83  GNEDemandElement(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, 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<GNEShape*>& shapeParents,
89  const std::vector<GNETAZElement*>& TAZElementParents,
90  const std::vector<GNEDemandElement*>& demandElementParents,
91  const std::vector<GNEGenericData*>& genericDataParents);
92 
108  GNEDemandElement(GNEDemandElement* demandElementParent, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, const int pathOptions,
109  const std::vector<GNEJunction*>& junctionParents,
110  const std::vector<GNEEdge*>& edgeParents,
111  const std::vector<GNELane*>& laneParents,
112  const std::vector<GNEAdditional*>& additionalParents,
113  const std::vector<GNEShape*>& shapeParents,
114  const std::vector<GNETAZElement*>& TAZElementParents,
115  const std::vector<GNEDemandElement*>& demandElementParents,
116  const std::vector<GNEGenericData*>& genericDataParents);
117 
119  virtual ~GNEDemandElement();
120 
125 
127  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
128 
130  const std::string& getID() const;
131 
134 
137 
140 
142  GNEDemandElement* getNextChildDemandElement(const GNEDemandElement* demandElement) const;
143 
145  std::vector<GNEEdge*> getViaEdges() const;
146 
148  void updateDemandElementGeometry(const GNELane* lane, const double posOverLane);
149 
151  void updateDemandElementStackLabel(const int stack);
152 
154  void updateDemandElementSpreadGeometry(const GNELane* lane, const double posOverLane);
155 
159  virtual SUMOVehicleClass getVClass() const = 0;
160 
162  virtual const RGBColor& getColor() const = 0;
164 
167 
170  virtual void writeDemandElement(OutputDevice& device) const = 0;
171 
173  virtual Problem isDemandElementValid() const = 0;
174 
176  virtual std::string getDemandElementProblem() const = 0;
177 
179  virtual void fixDemandElementProblem() = 0;
181 
186  virtual void openDemandElementDialog();
187 
192  virtual std::string getBegin() const;
193 
197  virtual void updateGeometry() = 0;
198 
200  virtual Position getPositionInView() const = 0;
201 
203  virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
205 
208 
217 
226 
228  virtual double getExaggeration(const GUIVisualizationSettings& s) const = 0;
229 
233  virtual Boundary getCenteringBoundary() const = 0;
234 
239  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
240 
242 
246  virtual void computePathElement() = 0;
247 
254  virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const = 0;
255 
263  virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const = 0;
264 
266  virtual GNELane* getFirstPathLane() const = 0;
267 
269  virtual GNELane* getLastPathLane() const = 0;
270 
272  double getPathElementDepartValue() const;
273 
276 
278  double getPathElementArrivalValue() const;
279 
282 
284 
287  /* @brief method for getting the Attribute of an XML key
288  * @param[in] key The attribute key
289  * @return string with the value associated to key
290  */
291  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
292 
293  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
294  * @param[in] key The attribute key
295  * @return double with the value associated to key
296  */
297  virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
298 
299  /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
300  * @param[in] key The attribute key
301  * @return double with the value associated to key
302  */
303  virtual Position getAttributePosition(SumoXMLAttr key) const = 0;
304 
310  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
311 
317  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
318 
319  /* @brief method for enable attribute
320  * @param[in] key The attribute key
321  * @param[in] undoList The undoList on which to register changes
322  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
323  */
324  virtual void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList) = 0;
325 
326  /* @brief method for disable attribute
327  * @param[in] key The attribute key
328  * @param[in] undoList The undoList on which to register changes
329  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
330  */
331  virtual void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList) = 0;
332 
333  /* @brief method for check if the value for certain attribute is set
334  * @param[in] key The attribute key
335  */
336  virtual bool isAttributeEnabled(SumoXMLAttr key) const = 0;
337 
338  /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
339  * @param[in] key The attribute key
340  */
341  bool isAttributeComputed(SumoXMLAttr key) const;
342 
344  virtual const std::map<std::string, std::string>& getACParametersMap() const = 0;
345 
347  virtual std::string getPopUpID() const = 0;
348 
350  virtual std::string getHierarchyName() const = 0;
352 
354  const Position getBeginPosition(const double pedestrianDepartPos) const;
355 
357  std::vector<GNEDemandElement*> getInvalidStops() const;
358 
359 protected:
362 
365 
368 
370  bool isValidDemandElementID(const std::string& newID) const;
371 
375  bool drawPersonPlan() const;
376 
378  bool drawContainerPlan() const;
379 
381  void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront,
382  const double personPlanWidth, const RGBColor& personPlanColor) const;
383 
385  void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment,
386  const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const;
387 
389  Problem isPersonPlanValid() const;
390 
392  std::string getPersonPlanProblem() const;
393 
396 
398 
401 
403  void replaceDemandParentEdges(const std::string& value);
404 
406  void replaceDemandParentLanes(const std::string& value);
407 
409  void replaceFirstParentJunction(const std::string& value);
410 
412  void replaceLastParentJunction(const std::string& value);
413 
415  void replaceFirstParentEdge(const std::string& value);
416 
418  void replaceMiddleParentEdges(const std::string& value, const bool updateChildReferences);
419 
421  void replaceLastParentEdge(const std::string& value);
422 
424  void replaceAdditionalParent(SumoXMLTag tag, const std::string& value);
425 
427  void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
428 
430  void setVTypeDistributionParent(const std::string& value);
431 
433 
435  struct SortedStops {
437  SortedStops(GNEEdge* edge_);
438 
440  void addStop(const GNEDemandElement* stop);
441 
443  const GNEEdge* edge;
444 
446  std::vector<std::pair<double, const GNEDemandElement*> > myStops;
447  };
448 
450  std::vector<const GNEDemandElement*> getSortedStops(const std::vector<GNEEdge*>& edges) const;
451 
452 private:
456  virtual bool checkChildDemandElementRestriction() const;
457 
459  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
460 
462  virtual void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters) = 0;
463 
465  virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
466 
468  virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
469 
472 
475 };
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 belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
An Element which don't belongs to GNENet but has influency in the simulation.
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 const std::map< std::string, std::string > & 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 void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)=0
split geometry
GNEDemandElement & operator=(const GNEDemandElement &)=delete
Invalidated assignment operator.
virtual bool isAttributeEnabled(SumoXMLAttr key) const =0
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
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
writte 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...
bool drawContainerPlan() const
check if container plan can be drawn
virtual void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters)=0
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
virtual double getExaggeration(const GUIVisualizationSettings &s) const =0
return exaggeration asociated with this GLObject
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
void setVTypeDistributionParent(const std::string &value)
set VTypeDistribution parent
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
int myStackedLabelNumber
stacked label number
virtual void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)=0
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
double getPathElementDepartValue() const
get path element depart lane pos
void replaceMiddleParentEdges(const std::string &value, const bool updateChildReferences)
replace middle (via) parent edges
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
bool drawPersonPlan() const
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
const std::string & getID() const
get ID
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)=0
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)
bool isAttributeComputed(SumoXMLAttr key) const
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
An Element which don't belongs to GNENet but has influency 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
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
struct for writting sorted stops
void addStop(const GNEDemandElement *stop)
add (and sort) stop
SortedStops(GNEEdge *edge_)
constructor
const GNEEdge * edge
route's edge
std::vector< std::pair< double, const GNEDemandElement * > > myStops
stops sorted by end position