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-2020 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/GNEGeometry.h>
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 
34 class GNENet;
35 class GNEAdditional;
36 class GNEDemandElement;
37 class GNENetworkElement;
38 class GNEGenericData;
39 class GNEEdge;
40 class GNELane;
41 class GNEJunction;
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
46 
52 
53 public:
58 
61 
64 
67  };
68 
83  GNEDemandElement(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag,
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 
107  GNEDemandElement(GNEDemandElement* demandElementParent, GNENet* net, GUIGlObjectType type, SumoXMLTag tag,
108  const std::vector<GNEJunction*>& junctionParents,
109  const std::vector<GNEEdge*>& edgeParents,
110  const std::vector<GNELane*>& laneParents,
111  const std::vector<GNEAdditional*>& additionalParents,
112  const std::vector<GNEShape*>& shapeParents,
113  const std::vector<GNETAZElement*>& TAZElementParents,
114  const std::vector<GNEDemandElement*>& demandElementParents,
115  const std::vector<GNEGenericData*>& genericDataParents);
116 
118  virtual ~GNEDemandElement();
119 
121  const std::string& getID() const;
122 
125 
128 
131 
134 
136  GNEDemandElement* getNextChildDemandElement(const GNEDemandElement* demandElement) const;
137 
139  std::vector<GNEEdge*> getViaEdges() const;
140 
142  void updateDemandElementGeometry(const GNELane* lane, const double posOverLane);
143 
145  void updateDemandElementStackLabel(const int stack);
146 
148  void updateDemandElementSpreadGeometry(const GNELane* lane, const double posOverLane);
149 
151  void updatePartialGeometry(const GNELane* lane);
152 
156  virtual SUMOVehicleClass getVClass() const = 0;
157 
159  virtual const RGBColor& getColor() const = 0;
161 
164 
167  virtual void writeDemandElement(OutputDevice& device) const = 0;
168 
170  virtual bool isDemandElementValid() const;
171 
173  virtual std::string getDemandElementProblem() const;
174 
176  virtual void fixDemandElementProblem();
178 
183  virtual void openDemandElementDialog();
184 
189  virtual std::string getBegin() const;
190 
194  virtual void startGeometryMoving() = 0;
195 
197  virtual void endGeometryMoving() = 0;
198 
202  virtual void moveGeometry(const Position& offset) = 0;
203 
207  virtual void commitGeometryMoving(GNEUndoList* undoList) = 0;
208 
210  virtual void updateGeometry() = 0;
211 
213  virtual void computePath() = 0;
214 
216  virtual void invalidatePath() = 0;
217 
219  virtual Position getPositionInView() const = 0;
220 
222  virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
224 
227 
236 
245 
249  virtual Boundary getCenteringBoundary() const = 0;
250 
255  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
256 
262  virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const double offsetFront) const = 0;
263 
270  virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const double offsetFront) const = 0;
272 
275  /* @brief method for getting the Attribute of an XML key
276  * @param[in] key The attribute key
277  * @return string with the value associated to key
278  */
279  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
280 
281  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
282  * @param[in] key The attribute key
283  * @return double with the value associated to key
284  */
285  virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
286 
292  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
293 
299  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
300 
301  /* @brief method for enable attribute
302  * @param[in] key The attribute key
303  * @param[in] undoList The undoList on which to register changes
304  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
305  */
306  virtual void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList) = 0;
307 
308  /* @brief method for disable attribute
309  * @param[in] key The attribute key
310  * @param[in] undoList The undoList on which to register changes
311  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
312  */
313  virtual void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList) = 0;
314 
315  /* @brief method for check if the value for certain attribute is set
316  * @param[in] key The attribute key
317  */
318  virtual bool isAttributeEnabled(SumoXMLAttr key) const = 0;
319 
321  virtual const std::map<std::string, std::string>& getACParametersMap() const = 0;
322 
324  virtual std::string getPopUpID() const = 0;
325 
327  virtual std::string getHierarchyName() const = 0;
329 
332 
335 
336 protected:
339 
342 
345 
348 
350  bool isValidDemandElementID(const std::string& newID) const;
351 
353  const GNEEdge* getFirstPersonPlanEdge() const;
354 
357 
360 
363  const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const;
364 
366  void drawPersonPlanPartialJunction(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane,
367  const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const;
368 
371 
373 
375  void replaceDemandParentEdges(const std::string& value);
376 
378  void replaceDemandParentLanes(const std::string& value);
379 
381  void replaceFirstParentEdge(const std::string& value);
382 
384  void replaceMiddleParentEdges(const std::string& value, const bool updateChildReferences);
385 
387  void replaceLastParentEdge(const std::string& value);
388 
390  void replaceAdditionalParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
391 
393  void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
394 
395 private:
399  virtual bool checkChildDemandElementRestriction() const;
400 
402  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
403 
406 
409 };
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:47
An Element which don't belongs to GNENet but has influency in the simulation.
virtual void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *fromLane, const GNELane *toLane, const double offsetFront) const =0
Draws partial object (junction)
GNEGeometry::SegmentGeometry myDemandElementSegmentGeometry
demand element segment geometry (also called "stacked geometry")
void replaceDemandParentEdges(const std::string &value)
replace demand parent edges
virtual void updateGeometry()=0
update pre-computed geometry information
const GNEGeometry::SegmentGeometry & getDemandElementSegmentGeometry() const
get demand element segment geometry (stacked)
GNEDemandElement(const GNEDemandElement &)=delete
Invalidated copy constructor.
virtual void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const double offsetFront) const =0
Draws partial object (lane)
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)
virtual void commitGeometryMoving(GNEUndoList *undoList)=0
commit geometry changes in the attributes of an element after use of moveGeometry(....
virtual const std::map< std::string, std::string > & getACParametersMap() const =0
get parameters map
virtual double getAttributeDouble(SumoXMLAttr key) const =0
void drawPersonPlanPartialLane(const GUIVisualizationSettings &s, const GNELane *lane, const double offsetFront, const double personPlanWidth, const RGBColor &personPlanColor) const
draw person plan partial lane
GNEDemandElement * getNextChildDemandElement(const GNEDemandElement *demandElement) const
get next child demand element to the given demand element
GNELane * getLastAllowedVehicleLane() const
get first allowed vehicle lane
GNEGeometry::ExtremeGeometry calculatePersonPlanLaneStartEndPos() const
calculate extreme geometry
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
void updatePartialGeometry(const GNELane *lane)
partial update pre-computed geometry information
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 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 bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
virtual void invalidatePath()=0
invalidate path
const GNEGeometry::Geometry & getDemandElementGeometry()
get demand element geometry (stacked)
virtual std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
void drawPersonPlanPartialJunction(const GUIVisualizationSettings &s, const GNELane *fromLane, const GNELane *toLane, const double offsetFront, const double personPlanWidth, const RGBColor &personPlanColor) const
draw person plan partial junction
void replaceDemandParentLanes(const std::string &value)
replace demand parent lanes
GNEGeometry::Geometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
virtual void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
virtual void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)=0
GNEGeometry::Geometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
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
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
virtual bool checkChildDemandElementRestriction() const
check restriction with the number of children
virtual void endGeometryMoving()=0
end geometry movement
GNELane * getFirstAllowedVehicleLane() const
get first allowed vehicle lane
GNEDemandElement * getPreviousChildDemandElement(const GNEDemandElement *demandElement) const
get previous child demand element to the given demand element
void replaceAdditionalParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace additional parent
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
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
virtual void computePath()=0
compute path
virtual void startGeometryMoving()=0
virtual void moveGeometry(const Position &offset)=0
change the position of the element geometry without saving in undoList
const std::string & getID() const
get ID
const GNEEdge * getFirstPersonPlanEdge() const
get first person plan edge
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)=0
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
An Element which don't belongs to GNENet but has influency in the simulation.
class for NETEDIT geometries over lanes
Definition: GNEGeometry.h:76
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
An special type of Attribute carrier that owns hierarchical elements.
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:60
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
struct for pack all variables related with Demand Element moving
Position originalViewPosition
value for saving first original position over lane before moving
std::string secondOriginalPosition
value for saving second original position over lane before moving
std::string firstOriginalLanePosition
value for saving first original position over lane before moving
Boundary movingGeometryBoundary
boundary used during moving of elements (to avoid insertion in RTREE)
struct for variables used in Geometry extremes
Definition: GNEGeometry.h:58
struct for pack all variables related with geometry of elemements divided in segments
Definition: GNEGeometry.h:261