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 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
54 class GNEEdge : public GNENetElement {
55 
57  friend class GNEChange_Lane;
58  friend class GNEChange_Connection;
59 
60 public:
62  typedef std::vector<GNELane*> LaneVector;
63 
65  typedef std::vector<GNEConnection*> ConnectionVector;
66 
68  typedef std::vector<GNEAdditional*> AdditionalVector;
69 
75  GNEEdge(NBEdge& nbe, GNENet* net, bool wasSplit = false, bool loaded = false);
76 
78  ~GNEEdge();
79 
82  void updateGeometry();
83 
85  Boundary getBoundary() const;
86 
89 
97 
106 
113 
118  void drawGL(const GUIVisualizationSettings& s) const;
120 
122  void updateJunctionPosition(GNEJunction* junction, const Position& origPos);
123 
125  NBEdge* getNBEdge();
126 
129 
132 
141  Position moveGeometry(const Position& oldPos, const Position& newPos, bool relative = false);
142 
144  static bool changeGeometry(PositionVector& geom, const std::string& id, const Position& oldPos, const Position& newPos, bool relative = false, bool moveEndPoints = false);
145 
149  void moveGeometry(const Position& delta);
150 
154  bool deleteGeometry(const Position& pos, GNEUndoList* undoList);
155 
157  void setEndpoint(Position pos, GNEUndoList* undoList);
158 
160  void resetEndpoint(const Position& pos, GNEUndoList* undoList);
161 
164  /* @brief method for getting the Attribute of an XML key
165  * @param[in] key The attribute key
166  * @return string with the value associated to key
167  */
168  std::string getAttribute(SumoXMLAttr key) const;
169 
170  /* @brief method for setting the attribute and letting the object perform additional changes
171  * @param[in] key The attribute key
172  * @param[in] value The new value
173  * @param[in] undoList The undoList on which to register changes
174  */
175  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
176 
177  /* @brief method for setting the attribute and letting the object perform additional changes
178  * @param[in] key The attribute key
179  * @param[in] value The new value
180  * @param[in] undoList The undoList on which to register changes
181  */
182  bool isValid(SumoXMLAttr key, const std::string& value);
184 
186  void setResponsible(bool newVal);
187 
192  void setGeometry(PositionVector geom, bool inner);
193 
195  void remakeGNEConnections();
196 
199 
201  void copyTemplate(GNEEdge* tpl, GNEUndoList* undolist);
202 
204  std::set<GUIGlID> getLaneGlIDs();
205 
207  const std::vector<GNELane*>& getLanes();
208 
210  const std::vector<GNEConnection*>& getGNEConnections();
211 
214  GNEConnection* retrieveConnection(int fromLane, NBEdge* to, int toLane);
215 
217  bool wasSplit();
218 
219  /* @brief compute a splitting position which keeps the resulting edges
220  * straight unless the user clicked near a geometry point */
221  Position getSplitPos(const Position& clickPos);
222 
224  void setMicrosimID(const std::string& newID);
225 
227  void addAdditionalChild(GNEAdditional* additional);
228 
230  void removeAdditionalChild(GNEAdditional* additional);
231 
233  const std::vector<GNEAdditional*>& getAdditionalChilds() const;
234 
236  bool hasRestrictedLane(SUMOVehicleClass vclass) const;
237 
238  // the radius in which to register clicks for geometry nodes
239  static const SUMOReal SNAP_RADIUS;
240 
242  void clearGNEConnections();
243 protected:
246 
249 
252 
255 
257  LaneVector myLanes;
258 
260  ConnectionVector myGNEConnections;
261 
264 
267 
269  std::string myConnectionStatus;
270 
272  AdditionalVector myAdditionals;
273 
274 private:
276  void setAttribute(SumoXMLAttr key, const std::string& value);
277 
279  GNEEdge(const GNEEdge& s);
280 
282  GNEEdge& operator=(const GNEEdge& s);
283 
290  void setNumLanes(int numLanes, GNEUndoList* undoList);
291 
293  void addLane(GNELane* lane, const NBEdge::Lane& laneAttrs);
294 
296  void removeLane(GNELane* lane);
297 
300 
303 
304 };
305 
306 
307 #endif
308 
309 /****************************************************************************/
310 
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:820
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
Definition: GNEEdge.cpp:447
GNEJunction * myGNEJunctionSource
pointer to GNEJunction source
Definition: GNEEdge.h:248
void remakeGNEConnections()
remake connections
Definition: GNEEdge.cpp:414
void addConnection(NBEdge::Connection nbCon, GNEConnection *con)
adds a connection
Definition: GNEEdge.cpp:891
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:800
GNEJunction * getGNEJunctionSource() const
returns the source-junction
Definition: GNEEdge.cpp:156
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:263
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:269
GNEJunction * myGNEJunctionDestiny
pointer to GNEJunction destiny
Definition: GNEEdge.h:251
PositionVector myOrigShape
restore point for undo
Definition: GNEEdge.h:254
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:936
std::set< GUIGlID > getLaneGlIDs()
returns GLIDs of all lanes
Definition: GNEEdge.cpp:469
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:278
std::vector< GNELane * > LaneVector
Definition of the lane&#39;s vector.
Definition: GNEEdge.h:62
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
Definition: GNEEdge.cpp:974
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:497
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:54
void clearGNEConnections()
clear current connections
Definition: GNEEdge.cpp:432
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
const std::vector< GNEConnection * > & getGNEConnections()
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:485
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return list of additionals associated with this edge
Definition: GNEEdge.cpp:968
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:266
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:90
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:236
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEEdge.cpp:167
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:124
void addAdditionalChild(GNEAdditional *additional)
add additional child to this edge
Definition: GNEEdge.cpp:945
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:272
Boundary getBoundary() const
Returns the street&#39;s geometry.
Definition: GNEEdge.cpp:125
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:136
void removeLane(GNELane *lane)
the number of lanes by one. argument is only used to increase robustness (assertions) ...
Definition: GNEEdge.cpp:858
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEEdge.cpp:144
void setGeometry(PositionVector geom, bool inner)
update edge geometry and inform the lanes
Definition: GNEEdge.cpp:398
GNEEdge(NBEdge &nbe, GNENet *net, bool wasSplit=false, bool loaded=false)
Constructor.
Definition: GNEEdge.cpp:70
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:54
ConnectionVector myGNEConnections
vector with the connections of this edge
Definition: GNEEdge.h:260
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:698
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:479
bool deleteGeometry(const Position &pos, GNEUndoList *undoList)
deletes the closest geometry node within SNAP_RADIUS.
Definition: GNEEdge.cpp:344
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:245
void updateGeometry()
update pre-computed geometry information
Definition: GNEEdge.cpp:112
The popup menu of a globject.
std::vector< GNEAdditional * > AdditionalVector
Definition of the additionals vector.
Definition: GNEEdge.h:68
static const SUMOReal SNAP_RADIUS
Definition: GNEEdge.h:239
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:639
LaneVector myLanes
vectgor with the lanes of this edge
Definition: GNEEdge.h:257
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:905
#define SUMOReal
Definition: config.h:208
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
Definition: GNEEdge.cpp:361
void removeAdditionalChild(GNEAdditional *additional)
remove additional child from this edge
Definition: GNEEdge.cpp:956
GNEConnection * retrieveConnection(int fromLane, NBEdge *to, int toLane)
get connection
Definition: GNEEdge.cpp:922
NBEdge & myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:245
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:258
std::vector< GNEConnection * > ConnectionVector
Definition of the connection&#39;s vector.
Definition: GNEEdge.h:65
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:565
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:384
A window containing a gl-object&#39;s parameter.
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:491
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:264
static bool changeGeometry(PositionVector &geom, const std::string &id, const Position &oldPos, const Position &newPos, bool relative=false, bool moveEndPoints=false)
Definition: GNEEdge.cpp:291
GNEEdge & operator=(const GNEEdge &s)
invalidated assignment operator
void remakeIncomingGNEConnections()
remake connections of all incoming edges
Definition: GNEEdge.cpp:407
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:162