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-2016 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 GNEAdditionalSet;
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
55 class GNEEdge : public GNENetElement {
56 
58  friend class GNEChange_Lane;
59  friend class GNEChange_Connection;
60 
61 public:
63  typedef std::vector<GNELane*> LaneVector;
64 
66  typedef std::vector<GNEConnection*> ConnectionVector;
67 
69  typedef std::vector<GNEAdditional*> AdditionalVector;
70 
72  typedef std::vector<GNEAdditionalSet*> AdditionalSetVector;
73 
79  GNEEdge(NBEdge& nbe, GNENet* net, bool wasSplit = false, bool loaded = false);
80 
82  ~GNEEdge();
83 
86  void updateGeometry();
87 
89  Boundary getBoundary() const;
90 
93 
101 
110 
117 
122  void drawGL(const GUIVisualizationSettings& s) const;
124 
126  void updateJunctionPosition(GNEJunction* junction, const Position& origPos);
127 
129  NBEdge* getNBEdge();
130 
133 
136 
145  Position moveGeometry(const Position& oldPos, const Position& newPos, bool relative = false);
146 
148  static bool changeGeometry(PositionVector& geom, const std::string& id, const Position& oldPos, const Position& newPos, bool relative = false, bool moveEndPoints = false);
149 
153  void moveGeometry(const Position& delta);
154 
158  bool deleteGeometry(const Position& pos, GNEUndoList* undoList);
159 
161  void setEndpoint(Position pos, GNEUndoList* undoList);
162 
164  void resetEndpoint(const Position& pos, GNEUndoList* undoList);
165 
168  /* @brief method for getting the Attribute of an XML key
169  * @param[in] key The attribute key
170  * @return string with the value associated to key
171  */
172  std::string getAttribute(SumoXMLAttr key) const;
173 
174  /* @brief method for setting the attribute and letting the object perform additional changes
175  * @param[in] key The attribute key
176  * @param[in] value The new value
177  * @param[in] undoList The undoList on which to register changes
178  */
179  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
180 
181  /* @brief method for setting the attribute and letting the object perform additional changes
182  * @param[in] key The attribute key
183  * @param[in] value The new value
184  * @param[in] undoList The undoList on which to register changes
185  */
186  bool isValid(SumoXMLAttr key, const std::string& value);
188 
190  void setResponsible(bool newVal);
191 
196  void setGeometry(PositionVector geom, bool inner);
197 
199  void remakeGNEConnections();
200 
203 
205  void copyTemplate(GNEEdge* tpl, GNEUndoList* undolist);
206 
208  std::set<GUIGlID> getLaneGlIDs();
209 
211  const std::vector<GNELane*>& getLanes();
212 
214  const std::vector<GNEConnection*>& getGNEConnections();
215 
218  GNEConnection* retrieveConnection(int fromLane, NBEdge* to, int toLane);
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  bool addAdditionalSet(GNEAdditionalSet* additionalSet);
241 
243  bool removeAdditionalGeometrySet(GNEAdditionalSet* additionalSet);
244 
246  const std::vector<GNEAdditionalSet*>& getAdditionalSets();
247 
249  bool hasRestrictedLane(SUMOVehicleClass vclass) const;
250 
251  // the radius in which to register clicks for geometry nodes
252  static const SUMOReal SNAP_RADIUS;
253 
255  void clearGNEConnections();
256 protected:
259 
262 
264  LaneVector myLanes;
265 
267  ConnectionVector myGNEConnections;
268 
271 
274 
276  std::string myConnectionStatus;
277 
279  AdditionalVector myAdditionals;
280 
282  AdditionalSetVector myAdditionalSets;
283 
284 private:
286  void setAttribute(SumoXMLAttr key, const std::string& value);
287 
289  GNEEdge(const GNEEdge& s);
290 
292  GNEEdge& operator=(const GNEEdge& s);
293 
300  void setNumLanes(int numLanes, GNEUndoList* undoList);
301 
303  void addLane(GNELane* lane, const NBEdge::Lane& laneAttrs);
304 
306  void removeLane(GNELane* lane);
307 
310 
313 
314 };
315 
316 
317 #endif
318 
319 /****************************************************************************/
320 
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:801
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
Definition: GNEEdge.cpp:453
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return list of additionals associated with this edge
Definition: GNEEdge.cpp:955
void remakeGNEConnections()
remake connections
Definition: GNEEdge.cpp:420
void addConnection(NBEdge::Connection nbCon, GNEConnection *con)
adds a connection
Definition: GNEEdge.cpp:872
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:157
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:781
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:270
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:276
PositionVector myOrigShape
restore point for undo
Definition: GNEEdge.h:261
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:917
std::set< GUIGlID > getLaneGlIDs()
returns GLIDs of all lanes
Definition: GNEEdge.cpp:475
Stores the information about how to visualize structures.
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:63
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
Definition: GNEEdge.cpp:995
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:87
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:55
void clearGNEConnections()
clear current connections
Definition: GNEEdge.cpp:438
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
const std::vector< GNEConnection * > & getGNEConnections()
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:491
An Element wich group additionalSet elements.
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:273
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:89
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
bool removeAdditionalGeometrySet(GNEAdditionalSet *additionalSet)
remove GNEAdditionalSet from this edge
Definition: GNEEdge.cpp:975
const std::vector< GNEAdditionalSet * > & getAdditionalSets()
return list of additionalSets associated with this edge
Definition: GNEEdge.cpp:989
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:503
void addAdditionalChild(GNEAdditional *additional)
add additional child to this edge
Definition: GNEEdge.cpp:926
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
AdditionalVector myAdditionals
list with the additonals vinculated with this edge
Definition: GNEEdge.h:279
std::vector< GNEAdditionalSet * > AdditionalSetVector
Definition of the additionalSets vector.
Definition: GNEEdge.h:72
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:839
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:71
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:55
ConnectionVector myGNEConnections
vector with the connections of this edge
Definition: GNEEdge.h:267
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:699
GNEJunction * getGNEJunctionDest() const
returns the destination-junction
Definition: GNEEdge.cpp:165
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:485
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:63
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:111
The popup menu of a globject.
std::vector< GNEAdditional * > AdditionalVector
Definition of the additionals vector.
Definition: GNEEdge.h:69
static const SUMOReal SNAP_RADIUS
Definition: GNEEdge.h:252
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:643
LaneVector myLanes
vectgor with the lanes of this edge
Definition: GNEEdge.h:264
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:886
#define SUMOReal
Definition: config.h:213
bool addAdditionalSet(GNEAdditionalSet *additionalSet)
add GNEAdditionalSet to this edge
Definition: GNEEdge.cpp:961
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:938
GNEConnection * retrieveConnection(int fromLane, NBEdge *to, int toLane)
get connection
Definition: GNEEdge.cpp:903
AdditionalSetVector myAdditionalSets
list with the additonalSets vinculated with this edge
Definition: GNEEdge.h:282
NBEdge & myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:258
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:261
std::vector< GNEConnection * > ConnectionVector
Definition of the connection&#39;s vector.
Definition: GNEEdge.h:66
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:569
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:497
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