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 GNEAdditional;
43 class GNEAdditionalSet;
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<GNEAdditional*> AdditionalVector;
66 
68  typedef std::vector<GNEAdditionalSet*> AdditionalSetVector;
69 
75  GNEEdge(NBEdge& nbe, GNENet* net, bool wasSplit = false, bool loaded = false);
76 
78  ~GNEEdge();
79 
81  void updateGeometry();
82 
84  Boundary getBoundary() const;
85 
88 
96 
105 
112 
117  void drawGL(const GUIVisualizationSettings& s) const;
119 
121  void updateJunctionPosition(GNEJunction* junction, const Position& origPos);
122 
124  NBEdge* getNBEdge();
125 
127  GNEJunction* getSource() const;
128 
130  GNEJunction* getDest() const;
131 
140  Position moveGeometry(const Position& oldPos, const Position& newPos, bool relative = false);
141 
143  static bool changeGeometry(PositionVector& geom, const std::string& id, const Position& oldPos, const Position& newPos, bool relative = false, bool moveEndPoints = false);
144 
148  void moveGeometry(const Position& delta);
149 
153  bool deleteGeometry(const Position& pos, GNEUndoList* undoList);
154 
156  void setEndpoint(Position pos, GNEUndoList* undoList);
157 
159  void resetEndpoint(const Position& pos, GNEUndoList* undoList);
160 
163  /* @brief method for getting the Attribute of an XML key
164  * @param[in] key The attribute key
165  * @return string with the value associated to key
166  */
167  std::string getAttribute(SumoXMLAttr key) const;
168 
169  /* @brief method for setting the attribute and letting the object perform additional changes
170  * @param[in] key The attribute key
171  * @param[in] value The new value
172  * @param[in] undoList The undoList on which to register changes
173  */
174  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
175 
176  /* @brief method for setting the attribute and letting the object perform additional changes
177  * @param[in] key The attribute key
178  * @param[in] value The new value
179  * @param[in] undoList The undoList on which to register changes
180  */
181  bool isValid(SumoXMLAttr key, const std::string& value);
183 
185  void setResponsible(bool newVal);
186 
191  void setGeometry(PositionVector geom, bool inner);
192 
197  void updateLaneGeometries();
198 
200  void copyTemplate(GNEEdge* tpl, GNEUndoList* undolist);
201 
203  std::set<GUIGlID> getLaneGlIDs();
204 
206  const std::vector<GNELane*>& getLanes();
207 
209  bool wasSplit();
210 
211  /* @brief compute a splitting position which keeps the resulting edges
212  * straight unless the user clicked near a geometry point */
213  Position getSplitPos(const Position& clickPos);
214 
216  void setMicrosimID(const std::string& newID);
217 
219  bool addAdditional(GNEAdditional* additional);
220 
222  bool removeAdditional(GNEAdditional* additional);
223 
225  const std::vector<GNEAdditional*>& getAdditionals() const;
226 
228  bool addAdditionalSet(GNEAdditionalSet* additionalSet);
229 
231  bool removeAdditionalSet(GNEAdditionalSet* additionalSet);
232 
234  const std::vector<GNEAdditionalSet*>& getAdditionalSets();
235 
236  // the radius in which to register clicks for geometry nodes
237  static const SUMOReal SNAP_RADIUS;
238 
239 protected:
242 
245 
247  LaneVector myLanes;
248 
251 
254 
256  std::string myConnectionStatus;
257 
259  AdditionalVector myAdditionals;
260 
262  AdditionalSetVector myAdditionalSets;
263 
264 private:
266  void setAttribute(SumoXMLAttr key, const std::string& value);
267 
269  GNEEdge(const GNEEdge& s);
270 
272  GNEEdge& operator=(const GNEEdge& s);
273 
280  void setNumLanes(int numLanes, GNEUndoList* undoList);
281 
283  void addLane(GNELane* lane, const NBEdge::Lane& laneAttrs);
284 
286  void removeLane(GNELane* lane);
287 
289  void addConnection(int fromLane, const std::string& toEdgeID, int toLane, bool mayPass);
290 
292  void removeConnection(int fromLane, const std::string& toEdgeID, int toLane);
293 };
294 
295 
296 #endif
297 
298 /****************************************************************************/
299 
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:734
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
Definition: GNEEdge.cpp:392
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:714
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:250
void addConnection(int fromLane, const std::string &toEdgeID, int toLane, bool mayPass)
adds a connection
Definition: GNEEdge.cpp:793
std::string myConnectionStatus
modification status of the connections
Definition: GNEEdge.h:256
PositionVector myOrigShape
restore point for undo
Definition: GNEEdge.h:244
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:812
std::set< GUIGlID > getLaneGlIDs()
returns GLIDs of all lanes
Definition: GNEEdge.cpp:414
Stores the information about how to visualize structures.
The representation of a single edge during network building.
Definition: NBEdge.h:70
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:245
std::vector< GNELane * > LaneVector
Definition of the lane&#39;s positions vector.
Definition: GNEEdge.h:62
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:436
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:86
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:54
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
bool addAdditional(GNEAdditional *additional)
add additional to this edge
Definition: GNEEdge.cpp:821
const std::vector< GNEAdditional * > & getAdditionals() const
return list of additionals associated with this edge
Definition: GNEEdge.cpp:849
An Element wich group additionalSet elements.
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:253
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:86
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
bool removeAdditional(GNEAdditional *additional)
remove additional from this edge
Definition: GNEEdge.cpp:835
const std::vector< GNEAdditionalSet * > & getAdditionalSets()
return list of additionalSets associated with this edge
Definition: GNEEdge.cpp:883
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNEEdge.cpp:203
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEEdge.cpp:150
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:122
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
AdditionalVector myAdditionals
vector with the additonals vinculated with this edge
Definition: GNEEdge.h:259
Boundary getBoundary() const
Returns the street&#39;s geometry.
Definition: GNEEdge.cpp:108
std::vector< GNEAdditionalSet * > AdditionalSetVector
Definition of the additionalSets vector.
Definition: GNEEdge.h:68
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:119
void removeLane(GNELane *lane)
the number of lanes by one. argument is only used to increase robustness (assertions) ...
Definition: GNEEdge.cpp:767
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEEdge.cpp:127
void setGeometry(PositionVector geom, bool inner)
update edge geometry and inform the lanes
Definition: GNEEdge.cpp:365
GNEEdge(NBEdge &nbe, GNENet *net, bool wasSplit=false, bool loaded=false)
Constructor.
Definition: GNEEdge.cpp:68
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:54
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:632
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:424
bool deleteGeometry(const Position &pos, GNEUndoList *undoList)
deletes the closest geometry node within SNAP_RADIUS.
Definition: GNEEdge.cpp:311
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:212
void updateGeometry()
update pre-computed geometry information
Definition: GNEEdge.cpp:104
The popup menu of a globject.
std::vector< GNEAdditional * > AdditionalVector
Definition of the additionals vector.
Definition: GNEEdge.h:65
static const SUMOReal SNAP_RADIUS
Definition: GNEEdge.h:237
GNEJunction * getDest() const
returns the destination-junction
Definition: GNEEdge.cpp:145
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:576
void updateLaneGeometries()
update edge geometry and inform the lanes let the lanes recompute their precomputed geometry informat...
Definition: GNEEdge.cpp:375
LaneVector myLanes
List of this edges lanes.
Definition: GNEEdge.h:247
bool removeAdditionalSet(GNEAdditionalSet *additionalSet)
remove GNEAdditionalSet from this edge
Definition: GNEEdge.cpp:869
#define SUMOReal
Definition: config.h:213
bool addAdditionalSet(GNEAdditionalSet *additionalSet)
add GNEAdditionalSet to this edge
Definition: GNEEdge.cpp:855
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
Definition: GNEEdge.cpp:328
void removeConnection(int fromLane, const std::string &toEdgeID, int toLane)
removes a connection
Definition: GNEEdge.cpp:801
AdditionalSetVector myAdditionalSets
vector with the additonalSets vinculated with this edge
Definition: GNEEdge.h:262
NBEdge & myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:241
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:225
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:502
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:351
A window containing a gl-object&#39;s parameter.
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:430
GNEJunction * getSource() const
returns the source-junction
Definition: GNEEdge.cpp:139
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:231
static bool changeGeometry(PositionVector &geom, const std::string &id, const Position &oldPos, const Position &newPos, bool relative=false, bool moveEndPoints=false)
Definition: GNEEdge.cpp:258
GNEEdge & operator=(const GNEEdge &s)
invalidated assignment operator