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 /****************************************************************************/
15 // A abstract class for demand elements
16 /****************************************************************************/
17 #ifndef GNEDemandElement_h
18 #define GNEDemandElement_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
32 #include <netbuild/NBVehicle.h>
33 #include <netbuild/NBEdge.h>
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 
39 class GNEViewNet;
40 class GNEEdge;
41 class GNELane;
42 class GNEAdditional;
43 class GNEDemandElement;
44 class GNEJunction;
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
49 
55 
56 public:
59 
62 
64  void clearGeometry();
65 
68 
71 
73  std::vector<double> shapeRotations;
74 
76  std::vector<double> shapeLengths;
77  };
78 
81 
83  struct Segment {
85  Segment(const GNEDemandElement* _element, const GNEEdge* _edge, const Position _pos, const bool _visible, const bool _valid);
86 
88  Segment(const GNEDemandElement* _element, const GNEEdge* _edge, const Position _pos, double _length, double _rotation, const bool _visible, const bool _valid);
89 
91  Segment(const GNEDemandElement* _element, const GNEJunction* _junction, const Position _pos, const bool _visible, const bool _valid);
92 
95 
97  const GNEEdge* edge;
98 
101 
103  const Position pos;
104 
106  const bool visible;
107 
109  const bool valid;
110 
112  double length;
113 
115  double rotation;
116 
117  private:
119  Segment& operator=(const Segment& other) = delete;
120  };
121 
124 
126  void insertEdgeSegment(const GNEDemandElement* element, const GNEEdge* edge, const Position pos, const bool visible, const bool valid);
127 
129  void insertEdgeLengthRotSegment(const GNEDemandElement* element, const GNEEdge* edge, const Position pos, double length, double rotation, const bool visible, const bool valid);
130 
132  void insertJunctionSegment(const GNEDemandElement* element, const GNEJunction* junction, const Position pos, const bool visible, const bool valid);
133 
135  void clearDemandElementSegmentGeometry();
136 
138  void calculatePartialShapeRotationsAndLengths();
139 
141  std::vector<Segment>::const_iterator begin() const;
142 
144  std::vector<Segment>::const_iterator end() const;
145 
148 
149  private:
151  std::vector<Segment> myShapeSegments;
152  };
153 
158 
161 
164 
167  };
168 
171 
172  public:
174  RouteCalculator(GNENet* net);
175 
177  ~RouteCalculator();
178 
180  void updateDijkstraRouter();
181 
183  std::vector<GNEEdge*> calculateDijkstraRoute(SUMOVehicleClass vClass, const std::vector<GNEEdge*>& partialEdges) const;
184 
186  std::vector<GNEEdge*> calculateDijkstraRoute(GNENet* net, SUMOVehicleClass vClass, const std::vector<std::string>& partialEdgesStr) const;
187 
189  bool areEdgesConsecutives(SUMOVehicleClass vClass, GNEEdge* from, GNEEdge* to) const;
190 
191  private:
194 
197  };
198 
215  GNEDemandElement(const std::string& id, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag,
216  const std::vector<GNEEdge*>& edgeParents,
217  const std::vector<GNELane*>& laneParents,
218  const std::vector<GNEShape*>& shapeParents,
219  const std::vector<GNEAdditional*>& additionalParents,
220  const std::vector<GNEDemandElement*>& demandElementParents,
221  const std::vector<GNEEdge*>& edgeChildren,
222  const std::vector<GNELane*>& laneChildren,
223  const std::vector<GNEShape*>& shapeChildren,
224  const std::vector<GNEAdditional*>& additionalChildren,
225  const std::vector<GNEDemandElement*>& demandElementChildren);
226 
243  GNEDemandElement(GNEDemandElement* demandElementParent, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag,
244  const std::vector<GNEEdge*>& edgeParents,
245  const std::vector<GNELane*>& laneParents,
246  const std::vector<GNEShape*>& shapeParents,
247  const std::vector<GNEAdditional*>& additionalParents,
248  const std::vector<GNEDemandElement*>& demandElementParents,
249  const std::vector<GNEEdge*>& edgeChildren,
250  const std::vector<GNELane*>& laneChildren,
251  const std::vector<GNEShape*>& shapeChildren,
252  const std::vector<GNEAdditional*>& additionalChildren,
253  const std::vector<GNEDemandElement*>& demandElementChildren);
254 
257 
260 
263 
266 
268  std::string generateChildID(SumoXMLTag childTag);
269 
273  virtual GNEEdge* getFromEdge() const = 0;
274 
276  virtual GNEEdge* getToEdge() const = 0;
277 
279  virtual SUMOVehicleClass getVClass() const = 0;
280 
282  virtual const RGBColor& getColor() const = 0;
283 
285  virtual void compute() = 0;
286 
288 
291 
294  virtual void writeDemandElement(OutputDevice& device) const = 0;
295 
297  virtual bool isDemandElementValid() const;
298 
300  virtual std::string getDemandElementProblem() const;
301 
303  virtual void fixDemandElementProblem();
305 
310  virtual void openDemandElementDialog();
311 
316  virtual std::string getBegin() const;
317 
321  virtual void startGeometryMoving() = 0;
322 
324  virtual void endGeometryMoving() = 0;
325 
329  virtual void moveGeometry(const Position& offset) = 0;
330 
334  virtual void commitGeometryMoving(GNEUndoList* undoList) = 0;
335 
337  virtual void updateGeometry() = 0;
338 
340  virtual Position getPositionInView() const = 0;
342 
344  GNEViewNet* getViewNet() const;
345 
348 
350  static void createRouteCalculatorInstance(GNENet* net);
351 
353  static void deleteRouteCalculatorInstance();
354 
357 
359 
362 
371 
380 
384  virtual Boundary getCenteringBoundary() const = 0;
385 
390  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
392 
396  virtual void selectAttributeCarrier(bool changeFlag = true) = 0;
397 
399  virtual void unselectAttributeCarrier(bool changeFlag = true) = 0;
400 
402  bool isAttributeCarrierSelected() const;
403 
405  bool drawUsingSelectColor() const;
406 
407  /* @brief method for getting the Attribute of an XML key
408  * @param[in] key The attribute key
409  * @return string with the value associated to key
410  */
411  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
412 
413  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
414  * @param[in] key The attribute key
415  * @return double with the value associated to key
416  */
417  virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
418 
424  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
425 
431  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
432 
433  /* @brief method for enabling attribute
434  * @param[in] key The attribute key
435  * @param[in] undoList The undoList on which to register changes
436  * @note only certain attributes can be enabled, and can produce the disabling of other attributes
437  */
438  virtual void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList) = 0;
439 
441  virtual std::string getPopUpID() const = 0;
442 
444  virtual std::string getHierarchyName() const = 0;
446 
449 
451  virtual std::string getGenericParametersStr() const = 0;
452 
454  virtual std::vector<std::pair<std::string, std::string> > getGenericParameters() const = 0;
455 
457  virtual void setGenericParametersStr(const std::string& value) = 0;
458 
460 
465  static bool isRouteValid(const std::vector<GNEEdge*>& edges, bool report);
466 
467 protected:
470 
473 
476 
479 
481  const std::string& getDemandElementID() const;
482 
484  bool isValidDemandElementID(const std::string& newID) const;
485 
490  void changeDemandElementID(const std::string& newID);
491 
493 
494 private:
498  virtual bool checkDemandElementChildRestriction() const;
499 
501  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
502 
505 
507  GNEDemandElement(const GNEDemandElement&) = delete;
508 
510  GNEDemandElement& operator=(const GNEDemandElement&) = delete;
511 };
512 
513 
514 #endif
515 
516 /****************************************************************************/
517 
struct for pack all variables related with geometry of elemements divided in segments ...
void calculateShapeRotationsAndLengths()
calculate shape rotations and lengths
static bool isRouteValid(const std::vector< GNEEdge *> &edges, bool report)
check if a route is valid
DemandElementGeometry myDemandElementGeometry
demand element geometry
An special type of Attribute carrier that owns hierarchical elements.
SumoXMLTag
Numbers representing SUMO-XML - element names.
virtual void selectAttributeCarrier(bool changeFlag=true)=0
GNEDemandElement(const std::string &id, GNEViewNet *viewNet, GUIGlObjectType type, SumoXMLTag tag, const std::vector< GNEEdge *> &edgeParents, const std::vector< GNELane *> &laneParents, const std::vector< GNEShape *> &shapeParents, const std::vector< GNEAdditional *> &additionalParents, const std::vector< GNEDemandElement *> &demandElementParents, const std::vector< GNEEdge *> &edgeChildren, const std::vector< GNELane *> &laneChildren, const std::vector< GNEShape *> &shapeChildren, const std::vector< GNEAdditional *> &additionalChildren, const std::vector< GNEDemandElement *> &demandElementChildren)
Constructor.
Boundary movingGeometryBoundary
boundary used during moving of elements (to avoid insertion in RTREE)
GUIGlObjectType
virtual void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children) ...
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
virtual std::string getHierarchyName() const =0
get Hierarchy Name (Used in AC Hierarchy)
virtual std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
std::string firstOriginalLanePosition
value for saving first original position over lane before moving
virtual Position getPositionInView() const =0
Returns position of demand element in view.
Stores the information about how to visualize structures.
struct for pack all variables related with Demand Element moving
bool geometryDeprecated
mark geometry as deprecated (used to avoid multiple updates)
GNEDemandElement & operator=(const GNEDemandElement &)=delete
Invalidated assignment operator.
virtual void updateGeometry()=0
update pre-computed geometry information
std::string secondOriginalPosition
value for saving second original position over lane before moving
Position originalViewPosition
value for saving first original position over lane before moving
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
class used to calculate routes in nets
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:78
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
virtual void writeDemandElement(OutputDevice &device) const =0
writte demand element element into a xml file
virtual double getAttributeDouble(SumoXMLAttr key) const =0
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
void changeDemandElementID(const std::string &newID)
change ID of demand element
PositionVector shape
The shape of the additional element.
virtual void moveGeometry(const Position &offset)=0
change the position of the element geometry without saving in undoList
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
static RouteCalculator * getRouteCalculatorInstance()
obtain instance of RouteCalculator
virtual std::string getPopUpID() const =0
get PopPup ID (Used in AC Hierarchy)
virtual void compute()=0
compute demand element (used by flows, trips, personPlans<from-to>,...)
const DemandElementGeometry & getDemandElementGeometry() const
get demand element geometry
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
An special type of Attribute carrier that owns hierarchical elements.
virtual void setGenericParametersStr(const std::string &value)=0
set generic parameters in string format
virtual SUMOVehicleClass getVClass() const =0
obtain VClass related with this demand element
static void createRouteCalculatorInstance(GNENet *net)
create instance of RouteCalculator
virtual std::string getGenericParametersStr() const =0
return generic parameters in string format
virtual void endGeometryMoving()=0
end geometry movement
~GNEDemandElement()
Destructor.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
DemandElementSegmentGeometry myDemandElementSegmentGeometry
demand element segment geometry
std::vector< double > shapeLengths
The lengths of the single shape parts.
A list of positions.
virtual void startGeometryMoving()=0
void markSegmentGeometryDeprecated()
mark demand element segment geometry as deprecated
bool isValidDemandElementID(const std::string &newID) const
check if a new demand element ID is valid
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
virtual const RGBColor & getColor() const =0
get color
virtual void unselectAttributeCarrier(bool changeFlag=true)=0
unselect attribute carrier using GUIGlobalSelection
const std::string & getDemandElementID() const
returns DemandElement ID
virtual std::vector< std::pair< std::string, std::string > > getGenericParameters() const =0
return generic parameters as vector of pairs format
static RouteCalculator * myRouteCalculatorInstance
RouteCalculator instance.
virtual bool checkDemandElementChildRestriction() const
check restriction with the number of children
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)=0
struct used for represent segments of demand element geometry
virtual void openDemandElementDialog()
open DemandElement Dialog
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const DemandElementSegmentGeometry & getDemandElementSegmentGeometry() const
get demand element segment geometry
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
virtual GNEEdge * getToEdge() const =0
obtain to edge of this demand element
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
virtual GNEEdge * getFromEdge() const =0
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 ...
The popup menu of a globject.
virtual void commitGeometryMoving(GNEUndoList *undoList)=0
commit geometry changes in the attributes of an element after use of moveGeometry(...)
GNEViewNet * myViewNet
The GNEViewNet this demand element element belongs.
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which demand element element is located.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
virtual std::string getBegin() const
get begin time of demand element
struct for pack all variables related with geometry of stop
static void deleteRouteCalculatorInstance()
delete instance of RouteCalculator
std::vector< double > shapeRotations
The rotations of the single shape parts.
SUMOAbstractRouter< NBRouterEdge, NBVehicle > * myDijkstraRouter
SUMO Abstract DijkstraRouter.
A window containing a gl-object&#39;s parameter.
virtual std::string getAttribute(SumoXMLAttr key) const =0
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
virtual bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
std::vector< Segment > myShapeSegments
vector of segments that constitutes the shape