SUMO - Simulation of Urban MObility
GNEEdge.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // A road/street connecting two junctions (netedit-version, adapted from GUIEdge)
8 // Basically a container for an NBEdge with drawing and editing capabilities
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef GNEEdge_h
22 #define GNEEdge_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include "GNENetElement.h"
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class GNENet;
40 class GNEJunction;
41 class GNELane;
42 class GNEConnection;
43 class GNEAdditional;
44 class GNERouteProbe;
45 class GNEVaporizer;
46 class GNERerouter;
47 class GNECrossing;
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
58 class GNEEdge : public GNENetElement {
59 
61  friend class GNEChange_Lane;
62  friend class GNEChange_Connection;
63 
64 public:
66  typedef std::vector<GNELane*> LaneVector;
67 
69  typedef std::vector<GNEConnection*> ConnectionVector;
70 
72  typedef std::vector<GNEAdditional*> AdditionalVector;
73 
79  GNEEdge(NBEdge& nbe, GNENet* net, bool wasSplit = false, bool loaded = false);
80 
82  ~GNEEdge();
83 
86  void updateGeometry();
87 
89  void commitGeometryMoving(const PositionVector& oldShape, double minDistToEnd, GNEUndoList* undoList);
90 
92  Boundary getBoundary() const;
93 
96 
104 
113 
120 
125  void drawGL(const GUIVisualizationSettings& s) const;
127 
129  void updateJunctionPosition(GNEJunction* junction, const Position& origPos);
130 
132  NBEdge* getNBEdge();
133 
136 
139 
148  Position moveGeometry(const Position& oldPos, const Position& newPos, bool relative = false);
149 
151  static bool changeGeometry(PositionVector& geom, const std::string& id, const Position& oldPos, const Position& newPos, bool relative = false, bool moveEndPoints = false);
152 
156  void moveGeometry(const Position& delta);
157 
161  bool deleteGeometry(const Position& pos, GNEUndoList* undoList);
162 
164  void setEndpoint(Position pos, GNEUndoList* undoList);
165 
167  void resetEndpoint(const Position& pos, GNEUndoList* undoList);
168 
171  /* @brief method for getting the Attribute of an XML key
172  * @param[in] key The attribute key
173  * @return string with the value associated to key
174  */
175  std::string getAttribute(SumoXMLAttr key) const;
176  std::string getAttributeForSelection(SumoXMLAttr key) const;
177 
178  /* @brief method for setting the attribute and letting the object perform additional changes
179  * @param[in] key The attribute key
180  * @param[in] value The new value
181  * @param[in] undoList The undoList on which to register changes
182  */
183  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
184 
185  /* @brief method for setting the attribute and letting the object perform additional changes
186  * @param[in] key The attribute key
187  * @param[in] value The new value
188  * @param[in] undoList The undoList on which to register changes
189  */
190  bool isValid(SumoXMLAttr key, const std::string& value);
192 
194  void setResponsible(bool newVal);
195 
200  void setGeometry(PositionVector geom, bool inner);
201 
203  void remakeGNEConnections();
204 
206  void copyTemplate(GNEEdge* tpl, GNEUndoList* undolist);
207 
209  std::set<GUIGlID> getLaneGlIDs();
210 
212  const std::vector<GNELane*>& getLanes();
213 
215  const std::vector<GNEConnection*>& getGNEConnections();
216 
218  GNEConnection* retrieveGNEConnection(int fromLane, NBEdge* to, int toLane, bool createIfNoExist = true);
219 
221  bool wasSplit();
222 
223  /* @brief compute a splitting position which keeps the resulting edges
224  * straight unless the user clicked near a geometry point */
225  Position getSplitPos(const Position& clickPos);
226 
228  void setMicrosimID(const std::string& newID);
229 
231  void addAdditionalChild(GNEAdditional* additional);
232 
234  void removeAdditionalChild(GNEAdditional* additional);
235 
237  const std::vector<GNEAdditional*>& getAdditionalChilds() const;
238 
240  void addGNERerouter(GNERerouter* rerouter);
241 
243  void removeGNERerouter(GNERerouter* rerouter);
244 
246  const std::vector<GNERerouter*>& getGNERerouters() const;
247 
249  int getNumberOfGNERerouters() const;
250 
252  bool hasRestrictedLane(SUMOVehicleClass vclass) const;
253 
254  // the radius in which to register clicks for geometry nodes
255  static const double SNAP_RADIUS;
256 
258  void clearGNEConnections();
259 
261  int getRouteProbeRelativePosition(GNERouteProbe* routeProbe) const;
262 
264  int getVaporizerRelativePosition(GNEVaporizer* vaporizer) const;
265 
267  std::vector<GNECrossing*> getGNECrossings();
268 
269 protected:
272 
275 
278 
281 
283  LaneVector myLanes;
284 
286  ConnectionVector myGNEConnections;
287 
290 
293 
295  std::string myConnectionStatus;
296 
298  AdditionalVector myAdditionals;
299 
301  std::vector<GNERerouter*> myReroutes;
302 
303 private:
305  void setAttribute(SumoXMLAttr key, const std::string& value);
306 
308  GNEEdge(const GNEEdge& s);
309 
311  GNEEdge& operator=(const GNEEdge& s);
312 
319  void setNumLanes(int numLanes, GNEUndoList* undoList);
320 
322  void addLane(GNELane* lane, const NBEdge::Lane& laneAttrs);
323 
325  void removeLane(GNELane* lane);
326 
328  void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation = false);
329 
332 
334  void removeEdgeFromCrossings(GNEJunction* junction, GNEUndoList* undoList);
335 };
336 
337 
338 #endif
339 
340 /****************************************************************************/
341 
void addLane(GNELane *lane, const NBEdge::Lane &laneAttrs)
increase number of lanes by one use the given attributes and restore the GNELane
Definition: GNEEdge.cpp:1017
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
Definition: GNEEdge.cpp:567
GNEJunction * myGNEJunctionSource
pointer to GNEJunction source
Definition: GNEEdge.h:274
void remakeGNEConnections()
remake connections
Definition: GNEEdge.cpp:458
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:165
void setNumLanes(int numLanes, GNEUndoList *undoList)
changes the number of lanes. When reducing the number of lanes, higher-numbered lanes are removed fir...
Definition: GNEEdge.cpp:997
GNEJunction * getGNEJunctionSource() const
returns the source-junction
Definition: GNEEdge.cpp:194
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:289
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
std::string myConnectionStatus
modification status of the connections
Definition: GNEEdge.h:295
GNEJunction * myGNEJunctionDestiny
pointer to GNEJunction destiny
Definition: GNEEdge.h:277
PositionVector myOrigShape
restore point for undo
Definition: GNEEdge.h:280
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:1176
std::set< GUIGlID > getLaneGlIDs()
returns GLIDs of all lanes
Definition: GNEEdge.cpp:589
Stores the information about how to visualize structures.
static const double SNAP_RADIUS
Definition: GNEEdge.h:255
The representation of a single edge during network building.
Definition: NBEdge.h:71
Position moveGeometry(const Position &oldPos, const Position &newPos, bool relative=false)
change the edge geometry It is up to the Edge to decide whether an new geometry node should be genera...
Definition: GNEEdge.cpp:326
std::vector< GNELane * > LaneVector
Definition of the lane&#39;s vector.
Definition: GNEEdge.h:66
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
Definition: GNEEdge.cpp:1251
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in allGNEAttributeCarrier.
Definition: GNEEdge.cpp:617
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:92
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:54
void clearGNEConnections()
clear current connections
Definition: GNEEdge.cpp:495
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void removeEdgeFromCrossings(GNEJunction *junction, GNEUndoList *undoList)
remove crossing of junction
Definition: GNEEdge.cpp:1262
const std::vector< GNEConnection * > & getGNEConnections()
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:605
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return list of additionals associated with this edge
Definition: GNEEdge.cpp:1212
int getRouteProbeRelativePosition(GNERouteProbe *routeProbe) const
obtain relative positions of RouteProbes
Definition: GNEEdge.cpp:514
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:292
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:94
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNEEdge.cpp:284
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEEdge.cpp:205
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:122
const std::vector< GNERerouter * > & getGNERerouters() const
get rerouters vinculated with this edge
Definition: GNEEdge.cpp:1239
void addAdditionalChild(GNEAdditional *additional)
add additional child to this edge
Definition: GNEEdge.cpp:1185
void addGNERerouter(GNERerouter *rerouter)
add a reference to a rerouter that has this edge as parameter
Definition: GNEEdge.cpp:1218
int getNumberOfGNERerouters() const
get number of rerouters that has this edge as parameters
Definition: GNEEdge.cpp:1245
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:52
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
std::vector< GNERerouter * > myReroutes
list of reroutes that has this edge as parameter
Definition: GNEEdge.h:301
void removeGNERerouter(GNERerouter *rerouter)
remove a reference to a rerouter that has this edge as parameter
Definition: GNEEdge.cpp:1228
AdditionalVector myAdditionals
list with the additionals vinculated with this edge
Definition: GNEEdge.h:298
Boundary getBoundary() const
Returns the street&#39;s geometry.
Definition: GNEEdge.cpp:163
int getVaporizerRelativePosition(GNEVaporizer *vaporizer) const
obtain relative positions of Vaporizer
Definition: GNEEdge.cpp:532
GNEConnection * retrieveGNEConnection(int fromLane, NBEdge *to, int toLane, bool createIfNoExist=true)
get GNEConnection if exist, and if not create it if create is enabled
Definition: GNEEdge.cpp:1152
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:174
void removeLane(GNELane *lane)
the number of lanes by one. argument is only used to increase robustness (assertions) ...
Definition: GNEEdge.cpp:1062
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEEdge.cpp:182
std::vector< GNECrossing * > getGNECrossings()
get GNECrossings vinculated with this Edge
Definition: GNEEdge.cpp:550
void setGeometry(PositionVector geom, bool inner)
update edge geometry and inform the lanes
Definition: GNEEdge.cpp:448
GNEEdge(NBEdge &nbe, GNENet *net, bool wasSplit=false, bool loaded=false)
Constructor.
Definition: GNEEdge.cpp:70
void commitGeometryMoving(const PositionVector &oldShape, double minDistToEnd, GNEUndoList *undoList)
registers completed movement with the undoList
Definition: GNEEdge.cpp:136
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:58
ConnectionVector myGNEConnections
vector with the connections of this edge
Definition: GNEEdge.h:286
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:885
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1106
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:599
bool deleteGeometry(const Position &pos, GNEUndoList *undoList)
deletes the closest geometry node within SNAP_RADIUS.
Definition: GNEEdge.cpp:394
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:62
void updateJunctionPosition(GNEJunction *junction, const Position &origPos)
update edge geometry after junction move
Definition: GNEEdge.cpp:293
void updateGeometry()
update pre-computed geometry information
Definition: GNEEdge.cpp:124
The popup menu of a globject.
std::vector< GNEAdditional * > AdditionalVector
Definition of the additionals vector.
Definition: GNEEdge.h:72
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:790
LaneVector myLanes
vectgor with the lanes of this edge
Definition: GNEEdge.h:283
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1127
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
Definition: GNEEdge.cpp:411
void removeAdditionalChild(GNEAdditional *additional)
remove additional child from this edge
Definition: GNEEdge.cpp:1198
NBEdge & myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:271
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:306
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNEEdge.cpp:684
std::vector< GNEConnection * > ConnectionVector
Definition of the connection&#39;s vector.
Definition: GNEEdge.h:69
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:693
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:434
A window containing a gl-object&#39;s parameter.
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:611
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:312
static bool changeGeometry(PositionVector &geom, const std::string &id, const Position &oldPos, const Position &newPos, bool relative=false, bool moveEndPoints=false)
Definition: GNEEdge.cpp:339
GNEEdge & operator=(const GNEEdge &s)
invalidated assignment operator
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:200