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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // A abstract class for demand elements
15 /****************************************************************************/
16 #ifndef GNEDemandElement_h
17 #define GNEDemandElement_h
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
27 #include <netedit/GNEGeometry.h>
32 #include <netbuild/NBVehicle.h>
33 #include <netbuild/NBEdge.h>
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 
39 class GNEViewNet;
40 class GNEAdditional;
41 class GNEDemandElement;
42 class GNENetElement;
43 class GNEEdge;
44 class GNELane;
45 class GNEJunction;
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
50 
56 
57 public:
62 
65 
68 
71  };
72 
75 
76  public:
78  RouteCalculator(GNENet* net);
79 
82 
84  void updateDijkstraRouter();
85 
87  std::vector<GNEEdge*> calculateDijkstraRoute(SUMOVehicleClass vClass, const std::vector<GNEEdge*>& partialEdges) const;
88 
90  std::vector<GNEEdge*> calculateDijkstraRoute(GNENet* net, SUMOVehicleClass vClass, const std::vector<std::string>& partialEdgesStr) const;
91 
93  bool areEdgesConsecutives(SUMOVehicleClass vClass, GNEEdge* from, GNEEdge* to) const;
94 
95  private:
98 
101  };
102 
119  GNEDemandElement(const std::string& id, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag,
120  const std::vector<GNEEdge*>& parentEdges,
121  const std::vector<GNELane*>& parentLanes,
122  const std::vector<GNEShape*>& parentShapes,
123  const std::vector<GNEAdditional*>& parentAdditionals,
124  const std::vector<GNEDemandElement*>& parentDemandElements,
125  const std::vector<GNEEdge*>& childEdges,
126  const std::vector<GNELane*>& childLanes,
127  const std::vector<GNEShape*>& childShapes,
128  const std::vector<GNEAdditional*>& childAdditionals,
129  const std::vector<GNEDemandElement*>& childDemandElements);
130 
147  GNEDemandElement(GNEDemandElement* demandElementParent, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag,
148  const std::vector<GNEEdge*>& parentEdges,
149  const std::vector<GNELane*>& parentLanes,
150  const std::vector<GNEShape*>& parentShapes,
151  const std::vector<GNEAdditional*>& parentAdditionals,
152  const std::vector<GNEDemandElement*>& parentDemandElements,
153  const std::vector<GNEEdge*>& childEdges,
154  const std::vector<GNELane*>& childLanes,
155  const std::vector<GNEShape*>& childShapes,
156  const std::vector<GNEAdditional*>& childAdditionals,
157  const std::vector<GNEDemandElement*>& childDemandElements);
158 
161 
164 
167 
169  std::string generateChildID(SumoXMLTag childTag);
170 
174  virtual GNEEdge* getFromEdge() const = 0;
175 
177  virtual GNEEdge* getToEdge() const = 0;
178 
180  virtual SUMOVehicleClass getVClass() const = 0;
181 
183  virtual const RGBColor& getColor() const = 0;
185 
188 
191  virtual void writeDemandElement(OutputDevice& device) const = 0;
192 
194  virtual bool isDemandElementValid() const;
195 
197  virtual std::string getDemandElementProblem() const;
198 
200  virtual void fixDemandElementProblem();
202 
207  virtual void openDemandElementDialog();
208 
213  virtual std::string getBegin() const;
214 
218  virtual void startGeometryMoving() = 0;
219 
221  virtual void endGeometryMoving() = 0;
222 
226  virtual void moveGeometry(const Position& offset) = 0;
227 
231  virtual void commitGeometryMoving(GNEUndoList* undoList) = 0;
232 
234  virtual void updateGeometry() = 0;
235 
237  virtual void updatePartialGeometry(const GNEEdge* edge) = 0;
238 
240  virtual void computePath() = 0;
241 
243  virtual void invalidatePath() = 0;
244 
246  virtual Position getPositionInView() const = 0;
247 
249  virtual void splitEdgeGeometry(const double splitPosition, const GNENetElement* originalElement, const GNENetElement* newElement, GNEUndoList* undoList) = 0;
251 
253  GNEViewNet* getViewNet() const;
254 
257 
259  static void createRouteCalculatorInstance(GNENet* net);
260 
262  static void deleteRouteCalculatorInstance();
263 
266 
268 
271 
280 
289 
293  virtual Boundary getCenteringBoundary() const = 0;
294 
299  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
301 
305  virtual void selectAttributeCarrier(bool changeFlag = true) = 0;
306 
308  virtual void unselectAttributeCarrier(bool changeFlag = true) = 0;
309 
311  bool isAttributeCarrierSelected() const;
312 
314  bool drawUsingSelectColor() const;
315 
316  /* @brief method for getting the Attribute of an XML key
317  * @param[in] key The attribute key
318  * @return string with the value associated to key
319  */
320  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
321 
322  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
323  * @param[in] key The attribute key
324  * @return double with the value associated to key
325  */
326  virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
327 
333  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
334 
340  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
341 
342  /* @brief method for enable attribute
343  * @param[in] key The attribute key
344  * @param[in] undoList The undoList on which to register changes
345  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
346  */
347  virtual void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList) = 0;
348 
349  /* @brief method for disable attribute
350  * @param[in] key The attribute key
351  * @param[in] undoList The undoList on which to register changes
352  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
353  */
354  virtual void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList) = 0;
355 
356  /* @brief method for check if the value for certain attribute is set
357  * @param[in] key The attribute key
358  */
359  virtual bool isAttributeEnabled(SumoXMLAttr key) const = 0;
360 
362  virtual std::string getPopUpID() const = 0;
363 
365  virtual std::string getHierarchyName() const = 0;
367 
372  static bool isRouteValid(const std::vector<GNEEdge*>& edges, bool report);
373 
374 protected:
377 
380 
383 
386 
388  const std::string& getDemandElementID() const;
389 
391  bool isValidDemandElementID(const std::string& newID) const;
392 
397  void changeDemandElementID(const std::string& newID);
398 
400 
402  void calculatePersonPlanLaneStartEndPos(double& startPos, double& endPos) const;
403 
405  void calculatePersonPlanPositionStartEndPos(Position& startPos, Position& endPos) const;
406 
409 
412 
413 private:
417  virtual bool checkChildDemandElementRestriction() const;
418 
420  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
421 
424 
426  GNEDemandElement(const GNEDemandElement&) = delete;
427 
429  GNEDemandElement& operator=(const GNEDemandElement&) = delete;
430 };
431 
432 
433 #endif
434 
435 /****************************************************************************/
436 
GNEDemandElement::myViewNet
GNEViewNet * myViewNet
The GNEViewNet this demand element element belongs.
Definition: GNEDemandElement.h:376
GNEDemandElement::isAttributeEnabled
virtual bool isAttributeEnabled(SumoXMLAttr key) const =0
GNEDemandElement::RouteCalculator::updateDijkstraRouter
void updateDijkstraRouter()
update DijkstraRoute (called when SuperMode Demand is selected)
Definition: GNEDemandElement.cpp:64
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
GNEDemandElement::getLastAllowedVehicleLane
GNELane * getLastAllowedVehicleLane() const
get first allowed vehicle lane
Definition: GNEDemandElement.cpp:512
GUIGlObject.h
GNEDemandElement::getDemandElementGeometry
const GNEGeometry::Geometry & getDemandElementGeometry() const
get demand element geometry
Definition: GNEDemandElement.cpp:211
GNEDemandElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEDemandElement.h:55
GNEDemandElement::createRouteCalculatorInstance
static void createRouteCalculatorInstance(GNENet *net)
create instance of RouteCalculator
Definition: GNEDemandElement.cpp:259
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:62
GNEDemandElement::getFromEdge
virtual GNEEdge * getFromEdge() const =0
GNEDemandElement::invalidatePath
virtual void invalidatePath()=0
invalidate path
GNEDemandElement::getVClass
virtual SUMOVehicleClass getVClass() const =0
obtain VClass related with this demand element
GNEDemandElement::getDemandElementProblem
virtual std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEDemandElement.cpp:229
GNEDemandElement::isValidDemandElementID
bool isValidDemandElementID(const std::string &newID) const
check if a new demand element ID is valid
Definition: GNEDemandElement.cpp:375
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GNEDemandElement::getRouteCalculatorInstance
static RouteCalculator * getRouteCalculatorInstance()
obtain instance of RouteCalculator
Definition: GNEDemandElement.cpp:280
GNEDemandElement::DemandElementMove::firstOriginalLanePosition
std::string firstOriginalLanePosition
value for saving first original position over lane before moving
Definition: GNEDemandElement.h:67
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
GNEDemandElement::selectAttributeCarrier
virtual void selectAttributeCarrier(bool changeFlag=true)=0
GNEDemandElement::getDemandElementSegmentGeometry
const GNEGeometry::SegmentGeometry & getDemandElementSegmentGeometry() const
get demand element segment geometry
Definition: GNEDemandElement.cpp:217
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
GNEHierarchicalParentElements.h
GNEHierarchicalChildElements.h
GNEDemandElement::DemandElementMove
struct for pack all variables related with Demand Element moving
Definition: GNEDemandElement.h:59
GNEDemandElement::getFirstAllowedVehicleLane
GNELane * getFirstAllowedVehicleLane() const
get first allowed vehicle lane
Definition: GNEDemandElement.cpp:476
GNEDemandElement::writeDemandElement
virtual void writeDemandElement(OutputDevice &device) const =0
writte demand element element into a xml file
GNEViewNet
Definition: GNEViewNet.h:42
GNEDemandElement::GNEDemandElement
GNEDemandElement(const std::string &id, GNEViewNet *viewNet, GUIGlObjectType type, SumoXMLTag tag, const std::vector< GNEEdge * > &parentEdges, const std::vector< GNELane * > &parentLanes, const std::vector< GNEShape * > &parentShapes, const std::vector< GNEAdditional * > &parentAdditionals, const std::vector< GNEDemandElement * > &parentDemandElements, const std::vector< GNEEdge * > &childEdges, const std::vector< GNELane * > &childLanes, const std::vector< GNEShape * > &childShapes, const std::vector< GNEAdditional * > &childAdditionals, const std::vector< GNEDemandElement * > &childDemandElements)
Constructor.
Definition: GNEDemandElement.cpp:159
GNEDemandElement::getViewNet
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which demand element element is located.
Definition: GNEDemandElement.cpp:253
GNEDemandElement::DemandElementMove::originalViewPosition
Position originalViewPosition
value for saving first original position over lane before moving
Definition: GNEDemandElement.h:64
GNEDemandElement::isValid
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
GNEDemandElement::getCenteringBoundary
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
GNEDemandElement::startGeometryMoving
virtual void startGeometryMoving()=0
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
GNEDemandElement::updatePartialGeometry
virtual void updatePartialGeometry(const GNEEdge *edge)=0
partial update pre-computed geometry information
GNEHierarchicalChildElements
An special type of Attribute carrier that owns hierarchical elements.
Definition: GNEHierarchicalChildElements.h:45
GNEDemandElement::getPopUpMenu
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEDemandElement.cpp:290
GNEDemandElement::myDemandElementSegmentGeometry
GNEGeometry::SegmentGeometry myDemandElementSegmentGeometry
demand element segment geometry
Definition: GNEDemandElement.h:382
GUIGlObjectType
GUIGlObjectType
Definition: GUIGlObjectTypes.h:39
GNEDemandElement::fixDemandElementProblem
virtual void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNEDemandElement.cpp:235
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:51
GNEDemandElement::DemandElementMove::secondOriginalPosition
std::string secondOriginalPosition
value for saving second original position over lane before moving
Definition: GNEDemandElement.h:70
GNEDemandElement::changeDemandElementID
void changeDemandElementID(const std::string &newID)
change ID of demand element
Definition: GNEDemandElement.cpp:385
GNEDemandElement::getPositionInView
virtual Position getPositionInView() const =0
Returns position of demand element in view.
GNEDemandElement::enableAttribute
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)=0
RGBColor
Definition: RGBColor.h:39
GNEDemandElement::myRouteCalculatorInstance
static RouteCalculator * myRouteCalculatorInstance
RouteCalculator instance.
Definition: GNEDemandElement.h:423
GNEGeometry::SegmentGeometry
struct for pack all variables related with geometry of elemements divided in segments
Definition: GNEGeometry.h:116
GNEDemandElement::updateGeometry
virtual void updateGeometry()=0
update pre-computed geometry information
GNEDemandElement::RouteCalculator::myDijkstraRouter
SUMOAbstractRouter< NBRouterEdge, NBVehicle > * myDijkstraRouter
SUMO Abstract DijkstraRouter.
Definition: GNEDemandElement.h:100
GNEDemandElement::RouteCalculator::myNet
GNENet * myNet
pointer to net
Definition: GNEDemandElement.h:97
GNEDemandElement::getAttribute
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNEDemandElement::disableAttribute
virtual void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)=0
GNEDemandElement::getAttributeDouble
virtual double getAttributeDouble(SumoXMLAttr key) const =0
Parameterised.h
GNEDemandElement::getColor
virtual const RGBColor & getColor() const =0
get color
GNEDemandElement::drawGL
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GNEDemandElement::generateChildID
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEDemandElement.cpp:198
GNEDemandElement::calculatePersonPlanPositionStartEndPos
void calculatePersonPlanPositionStartEndPos(Position &startPos, Position &endPos) const
calculate personPlan start and end positions
Definition: GNEDemandElement.cpp:440
GNEDemandElement::getPopUpID
virtual std::string getPopUpID() const =0
get PopPup ID (Used in AC Hierarchy)
GNEDemandElement::moveGeometry
virtual void moveGeometry(const Position &offset)=0
change the position of the element geometry without saving in undoList
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GNEDemandElement::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNEDemandElement.cpp:552
GNEGeometry::Geometry
struct for pack all variables related with geometry of stop
Definition: GNEGeometry.h:56
GNENetElement
Definition: GNENetElement.h:43
GNEDemandElement::openDemandElementDialog
virtual void openDemandElementDialog()
open DemandElement Dialog
Definition: GNEDemandElement.cpp:241
GUIGlObject
Definition: GUIGlObject.h:65
GNEDemandElement::checkChildDemandElementRestriction
virtual bool checkChildDemandElementRestriction() const
check restriction with the number of children
Definition: GNEDemandElement.cpp:568
GNEDemandElement::RouteCalculator::~RouteCalculator
~RouteCalculator()
destructor
Definition: GNEDemandElement.cpp:58
SUMOAbstractRouter< NBRouterEdge, NBVehicle >
GNEDemandElement::setAttribute
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
GNEDemandElement::RouteCalculator
class used to calculate routes in nets
Definition: GNEDemandElement.h:74
GNEDemandElement::calculatePersonPlanLaneStartEndPos
void calculatePersonPlanLaneStartEndPos(double &startPos, double &endPos) const
calculate personPlan start and end positions over lanes
Definition: GNEDemandElement.cpp:400
GNEGeometry.h
GNEDemandElement::RouteCalculator::areEdgesConsecutives
bool areEdgesConsecutives(SUMOVehicleClass vClass, GNEEdge *from, GNEEdge *to) const
check if exist a route between the two given consecutives edges
Definition: GNEDemandElement.cpp:133
GUIMainWindow
Definition: GUIMainWindow.h:46
GNEDemandElement::RouteCalculator::RouteCalculator
RouteCalculator(GNENet *net)
constructor
Definition: GNEDemandElement.cpp:50
GNEDemandElement::splitEdgeGeometry
virtual void splitEdgeGeometry(const double splitPosition, const GNENetElement *originalElement, const GNENetElement *newElement, GNEUndoList *undoList)=0
split geometry
GNEDemandElement::unselectAttributeCarrier
virtual void unselectAttributeCarrier(bool changeFlag=true)=0
unselect attribute carrier using GUIGlobalSelection
GNEDemandElement::getDemandElementID
const std::string & getDemandElementID() const
returns DemandElement ID
Definition: GNEDemandElement.cpp:369
GNEDemandElement::commitGeometryMoving
virtual void commitGeometryMoving(GNEUndoList *undoList)=0
commit geometry changes in the attributes of an element after use of moveGeometry(....
GNEHierarchicalParentElements
An special type of Attribute carrier that owns hierarchical elements.
Definition: GNEHierarchicalParentElements.h:49
GNEDemandElement::isRouteValid
static bool isRouteValid(const std::vector< GNEEdge * > &edges, bool report)
check if a route is valid
Definition: GNEDemandElement.cpp:334
GNEDemandElement::myDemandElementGeometry
GNEGeometry::Geometry myDemandElementGeometry
demand element geometry
Definition: GNEDemandElement.h:379
GNEDemandElement::deleteRouteCalculatorInstance
static void deleteRouteCalculatorInstance()
delete instance of RouteCalculator
Definition: GNEDemandElement.cpp:269
config.h
GNEDemandElement::RouteCalculator::calculateDijkstraRoute
std::vector< GNEEdge * > calculateDijkstraRoute(SUMOVehicleClass vClass, const std::vector< GNEEdge * > &partialEdges) const
calculate Dijkstra route between a list of partial edges
Definition: GNEDemandElement.cpp:76
GNEUndoList
Definition: GNEUndoList.h:48
GNEDemandElement::getBegin
virtual std::string getBegin() const
get begin time of demand element
Definition: GNEDemandElement.cpp:247
NBVehicle.h
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GNEDemandElement::endGeometryMoving
virtual void endGeometryMoving()=0
end geometry movement
GNEJunction
Definition: GNEJunction.h:47
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
SUMOAbstractRouter.h
GNEDemandElement::DemandElementMove::movingGeometryBoundary
Boundary movingGeometryBoundary
boundary used during moving of elements (to avoid insertion in RTREE)
Definition: GNEDemandElement.h:61
GNEDemandElement::isDemandElementValid
virtual bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNEDemandElement.cpp:223
GNEDemandElement::~GNEDemandElement
~GNEDemandElement()
Destructor.
Definition: GNEDemandElement.cpp:207
GNEDemandElement::getHierarchyName
virtual std::string getHierarchyName() const =0
get Hierarchy Name (Used in AC Hierarchy)
GNEDemandElement::operator=
GNEDemandElement & operator=(const GNEDemandElement &)=delete
Invalidated assignment operator.
PositionVector.h
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
GNEDemandElement::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNEDemandElement.cpp:315
GNEDemandElement::computePath
virtual void computePath()=0
compute path
GNEAttributeCarrier
Definition: GNEAttributeCarrier.h:54
GNEDemandElement::drawUsingSelectColor
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
Definition: GNEDemandElement.cpp:558
NBEdge.h
GNEDemandElement::getToEdge
virtual GNEEdge * getToEdge() const =0
obtain to edge of this demand element