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 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
57 class GNEEdge : public GNENetElement {
58 
60  friend class GNEChange_Lane;
61  friend class GNEChange_Connection;
62 
63 public:
65  typedef std::vector<GNELane*> LaneVector;
66 
68  typedef std::vector<GNEConnection*> ConnectionVector;
69 
71  typedef std::vector<GNEAdditional*> AdditionalVector;
72 
78  GNEEdge(NBEdge& nbe, GNENet* net, bool wasSplit = false, bool loaded = false);
79 
81  ~GNEEdge();
82 
85  void updateGeometry();
86 
88  Boundary getBoundary() const;
89 
92 
100 
109 
116 
121  void drawGL(const GUIVisualizationSettings& s) const;
123 
125  void updateJunctionPosition(GNEJunction* junction, const Position& origPos);
126 
128  NBEdge* getNBEdge();
129 
132 
135 
144  Position moveGeometry(const Position& oldPos, const Position& newPos, bool relative = false);
145 
147  static bool changeGeometry(PositionVector& geom, const std::string& id, const Position& oldPos, const Position& newPos, bool relative = false, bool moveEndPoints = false);
148 
152  void moveGeometry(const Position& delta);
153 
157  bool deleteGeometry(const Position& pos, GNEUndoList* undoList);
158 
160  void setEndpoint(Position pos, GNEUndoList* undoList);
161 
163  void resetEndpoint(const Position& pos, GNEUndoList* undoList);
164 
167  /* @brief method for getting the Attribute of an XML key
168  * @param[in] key The attribute key
169  * @return string with the value associated to key
170  */
171  std::string getAttribute(SumoXMLAttr key) const;
172 
173  /* @brief method for setting the attribute and letting the object perform additional changes
174  * @param[in] key The attribute key
175  * @param[in] value The new value
176  * @param[in] undoList The undoList on which to register changes
177  */
178  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
179 
180  /* @brief method for setting the attribute and letting the object perform additional changes
181  * @param[in] key The attribute key
182  * @param[in] value The new value
183  * @param[in] undoList The undoList on which to register changes
184  */
185  bool isValid(SumoXMLAttr key, const std::string& value);
187 
189  void setResponsible(bool newVal);
190 
195  void setGeometry(PositionVector geom, bool inner);
196 
198  void remakeGNEConnections();
199 
202 
204  void copyTemplate(GNEEdge* tpl, GNEUndoList* undolist);
205 
207  std::set<GUIGlID> getLaneGlIDs();
208 
210  const std::vector<GNELane*>& getLanes();
211 
213  const std::vector<GNEConnection*>& getGNEConnections();
214 
216  GNEConnection* retrieveConnection(int fromLane, NBEdge* to, int toLane);
217 
219  bool wasSplit();
220 
221  /* @brief compute a splitting position which keeps the resulting edges
222  * straight unless the user clicked near a geometry point */
223  Position getSplitPos(const Position& clickPos);
224 
226  void setMicrosimID(const std::string& newID);
227 
229  void addAdditionalChild(GNEAdditional* additional);
230 
232  void removeAdditionalChild(GNEAdditional* additional);
233 
235  const std::vector<GNEAdditional*>& getAdditionalChilds() const;
236 
238  void addGNERerouter(GNERerouter* rerouter);
239 
241  void removeGNERerouter(GNERerouter* rerouter);
242 
244  const std::vector<GNERerouter*>& getGNERerouters() const;
245 
247  int getNumberOfGNERerouters() const;
248 
250  bool hasRestrictedLane(SUMOVehicleClass vclass) const;
251 
252  // the radius in which to register clicks for geometry nodes
253  static const double SNAP_RADIUS;
254 
256  void clearGNEConnections();
257 
259  int getRouteProbeRelativePosition(GNERouteProbe* routeProbe) const;
260 
262  int getVaporizerRelativePosition(GNEVaporizer* vaporizer) const;
263 
264 protected:
267 
270 
273 
276 
278  LaneVector myLanes;
279 
281  ConnectionVector myGNEConnections;
282 
285 
288 
290  std::string myConnectionStatus;
291 
293  AdditionalVector myAdditionals;
294 
296  std::vector<GNERerouter*> myReroutes;
297 
298 private:
300  void setAttribute(SumoXMLAttr key, const std::string& value);
301 
303  GNEEdge(const GNEEdge& s);
304 
306  GNEEdge& operator=(const GNEEdge& s);
307 
314  void setNumLanes(int numLanes, GNEUndoList* undoList);
315 
317  void addLane(GNELane* lane, const NBEdge::Lane& laneAttrs);
318 
320  void removeLane(GNELane* lane);
321 
324 
327 
328 };
329 
330 
331 #endif
332 
333 /****************************************************************************/
334 
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:910
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
Definition: GNEEdge.cpp:511
GNEJunction * myGNEJunctionSource
pointer to GNEJunction source
Definition: GNEEdge.h:269
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return list of additionals associated with this edge
Definition: GNEEdge.cpp:1062
void remakeGNEConnections()
remake connections
Definition: GNEEdge.cpp:417
void addConnection(NBEdge::Connection nbCon, GNEConnection *con)
adds a connection
Definition: GNEEdge.cpp:981
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:164
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:890
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:284
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEEdge.cpp:170
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:139
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:290
GNEJunction * myGNEJunctionDestiny
pointer to GNEJunction destiny
Definition: GNEEdge.h:272
PositionVector myOrigShape
restore point for undo
Definition: GNEEdge.h:275
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:1026
std::set< GUIGlID > getLaneGlIDs()
returns GLIDs of all lanes
Definition: GNEEdge.cpp:533
Stores the information about how to visualize structures.
static const double SNAP_RADIUS
Definition: GNEEdge.h:253
int getNumberOfGNERerouters() const
get number of rerouters that has this edge as parameters
Definition: GNEEdge.cpp:1095
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:281
std::vector< GNELane * > LaneVector
Definition of the lane&#39;s vector.
Definition: GNEEdge.h:65
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
Definition: GNEEdge.cpp:1101
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:88
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:460
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
const std::vector< GNEConnection * > & getGNEConnections()
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:549
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:287
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:93
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:239
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:124
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:561
void addAdditionalChild(GNEAdditional *additional)
add additional child to this edge
Definition: GNEEdge.cpp:1035
void addGNERerouter(GNERerouter *rerouter)
add a reference to a rerouter that has this edge as parameter
Definition: GNEEdge.cpp:1068
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:296
void removeGNERerouter(GNERerouter *rerouter)
remove a reference to a rerouter that has this edge as parameter
Definition: GNEEdge.cpp:1078
AdditionalVector myAdditionals
list with the additionals vinculated with this edge
Definition: GNEEdge.h:293
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:165
const std::vector< GNERerouter * > & getGNERerouters() const
get rerouters vinculated with this edge
Definition: GNEEdge.cpp:1089
int getVaporizerRelativePosition(GNEVaporizer *vaporizer) const
obtain relative positions of Vaporizer
Definition: GNEEdge.cpp:493
GNEJunction * getGNEJunctionSource() const
returns the source-junction
Definition: GNEEdge.cpp:159
void removeLane(GNELane *lane)
the number of lanes by one. argument is only used to increase robustness (assertions) ...
Definition: GNEEdge.cpp:948
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEEdge.cpp:147
void setGeometry(PositionVector geom, bool inner)
update edge geometry and inform the lanes
Definition: GNEEdge.cpp:401
GNEEdge(NBEdge &nbe, GNENet *net, bool wasSplit=false, bool loaded=false)
Constructor.
Definition: GNEEdge.cpp:69
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:57
int getRouteProbeRelativePosition(GNERouteProbe *routeProbe) const
obtain relative positions of RouteProbes
Definition: GNEEdge.cpp:475
ConnectionVector myGNEConnections
vector with the connections of this edge
Definition: GNEEdge.h:281
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:778
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:543
bool deleteGeometry(const Position &pos, GNEUndoList *undoList)
deletes the closest geometry node within SNAP_RADIUS.
Definition: GNEEdge.cpp:347
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:248
void updateGeometry()
update pre-computed geometry information
Definition: GNEEdge.cpp:115
The popup menu of a globject.
std::vector< GNEAdditional * > AdditionalVector
Definition of the additionals vector.
Definition: GNEEdge.h:71
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:709
LaneVector myLanes
vectgor with the lanes of this edge
Definition: GNEEdge.h:278
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:995
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
Definition: GNEEdge.cpp:364
void removeAdditionalChild(GNEAdditional *additional)
remove additional child from this edge
Definition: GNEEdge.cpp:1048
GNEConnection * retrieveConnection(int fromLane, NBEdge *to, int toLane)
get connection
Definition: GNEEdge.cpp:1012
NBEdge & myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:266
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:261
std::vector< GNEConnection * > ConnectionVector
Definition of the connection&#39;s vector.
Definition: GNEEdge.h:68
Boundary getBoundary() const
Returns the street&#39;s geometry.
Definition: GNEEdge.cpp:128
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:635
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:387
A window containing a gl-object&#39;s parameter.
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:555
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:267
static bool changeGeometry(PositionVector &geom, const std::string &id, const Position &oldPos, const Position &newPos, bool relative=false, bool moveEndPoints=false)
Definition: GNEEdge.cpp:294
GNEEdge & operator=(const GNEEdge &s)
invalidated assignment operator
void remakeIncomingGNEConnections()
remake connections of all incoming edges
Definition: GNEEdge.cpp:410