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-2015 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 <vector>
35 #include <string>
37 #include <utils/geom/Position.h>
38 #include <utils/geom/Boundary.h>
41 #include <netbuild/NBEdge.h>
42 #include "GNEAttributeCarrier.h"
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class GNENet;
49 class GNEJunction;
50 class GNELane;
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
61 class GNEEdge : public GUIGlObject, public GNEAttributeCarrier {
62 
63  friend class GNEChange_Lane;
64  friend class GNEChange_Connection;
65 
66 public:
68  typedef std::vector<GNELane*> LaneVector;
69 
75  GNEEdge(NBEdge& nbe, GNENet* net, bool wasSplit = false, bool loaded = false) ;
76 
77 
79  ~GNEEdge() ;
80 
82  Boundary getBoundary() const;
83 
84 
86 
87 
96  GUISUMOAbstractView& parent) ;
97 
98 
107  GUISUMOAbstractView& parent) ;
108 
109 
116 
117 
122  void drawGL(const GUIVisualizationSettings& s) const ;
124 
125 
127  void updateJunctionPosition(GNEJunction* junction, const Position& origPos);
128 
129 
133  return &myNBEdge;
134  }
135 
136 
138  GNEJunction* getSource() const;
139 
141  GNEJunction* getDest() const;
142 
151  Position moveGeometry(const Position& oldPos, const Position& newPos, bool relative = false);
152 
154  static bool changeGeometry(PositionVector& geom, const std::string& id, const Position& oldPos, const Position& newPos, bool relative = false, bool moveEndPoints = false);
155 
159  void moveGeometry(const Position& delta);
160 
161 
165  bool deleteGeometry(const Position& pos, GNEUndoList* undoList);
166 
167 
170  void setEndpoint(Position pos, GNEUndoList* undoList);
171 
172 
175  void resetEndpoint(const Position& pos, GNEUndoList* undoList);
176 
177 
178  //@name inherited from GNEAttributeCarrier
180  std::string getAttribute(SumoXMLAttr key) const;
181 
182  /* @brief method for setting the attribute and letting the object perform additional changes
183  * @param[in] key The attribute key
184  * @param[in] value The new value
185  * @param[in] undoList The undoList on which to register changes
186  */
187  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
188 
189  bool isValid(SumoXMLAttr key, const std::string& value);
191 
193  void setResponsible(bool newVal) {
194  myAmResponsible = newVal;
195  }
196 
201  void setGeometry(PositionVector geom, bool inner);
202 
203 
208  void updateLaneGeometries();
209 
210 
212  void copyTemplate(GNEEdge* tpl, GNEUndoList* undolist);
213 
214 
216  std::set<GUIGlID> getLaneGlIDs();
217 
219  const LaneVector& getLanes() {
220  return myLanes;
221  }
222 
224  bool wasSplit() {
225  return myWasSplit;
226  }
227 
228  /* @brief compute a splitting position which keeps the resulting edges
229  * straight unless the user clicked near a geometry point */
230  Position getSplitPos(const Position& clickPos);
231 
233  void setMicrosimID(const std::string& newID);
234 
235  // the radius in which to register clicks for geometry nodes
236  static const SUMOReal SNAP_RADIUS;
237 private:
238 
241 
244 
246  LaneVector myLanes;
247 
248  // the net to inform about updates
250 
253 
256 
258  std::string myConnectionStatus;
259 
260 private:
261  void setAttribute(SumoXMLAttr key, const std::string& value);
262 
264  GNEEdge(const GNEEdge& s);
265 
267  GNEEdge& operator=(const GNEEdge& s);
268 
275  void setNumLanes(unsigned int numLanes, GNEUndoList* undoList);
276 
279  void addLane(GNELane* lane, const NBEdge::Lane& laneAttrs);
280 
281  /* decrease the number of lanes by one. argument is only used to increase
282  * robustness (assertions) */
283  void removeLane(GNELane* lane);
284 
286  void addConnection(unsigned int fromLane, const std::string& toEdgeID, unsigned int toLane, bool mayPass);
287 
289  void removeConnection(unsigned int fromLane, const std::string& toEdgeID, unsigned int toLane);
290 };
291 
292 
293 #endif
294 
295 /****************************************************************************/
296 
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:694
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
Definition: GNEEdge.cpp:369
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:252
std::string myConnectionStatus
modification status of the connections
Definition: GNEEdge.h:258
PositionVector myOrigShape
restore point for undo
Definition: GNEEdge.h:243
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:770
std::set< GUIGlID > getLaneGlIDs()
Definition: GNEEdge.cpp:391
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 without registering undo/redo It is up to the Edge to decide whether an new ...
Definition: GNEEdge.cpp:231
std::vector< GNELane * > LaneVector
Definition of the lane&#39;s positions vector.
Definition: GNEEdge.h:68
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:401
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:56
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:255
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:84
void addConnection(unsigned int fromLane, const std::string &toEdgeID, unsigned int toLane, bool mayPass)
adds a connection
Definition: GNEEdge.cpp:751
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:194
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEEdge.cpp:141
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:122
GNENet * myNet
Definition: GNEEdge.h:249
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
Boundary getBoundary() const
Returns the street&#39;s geometry.
Definition: GNEEdge.cpp:98
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:121
void removeLane(GNELane *lane)
Definition: GNEEdge.cpp:727
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEEdge.cpp:109
void setGeometry(PositionVector geom, bool inner)
update edge geometry and inform the lanes
Definition: GNEEdge.cpp:351
GNEEdge(NBEdge &nbe, GNENet *net, bool wasSplit=false, bool loaded=false)
Constructor.
Definition: GNEEdge.cpp:65
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.h:132
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:61
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.h:193
bool deleteGeometry(const Position &pos, GNEUndoList *undoList)
deletes the closest geometry node within SNAP_RADIUS.
Definition: GNEEdge.cpp:297
void updateJunctionPosition(GNEJunction *junction, const Position &origPos)
update edge geometry after junction move
Definition: GNEEdge.cpp:203
The popup menu of a globject.
static const SUMOReal SNAP_RADIUS
Definition: GNEEdge.h:236
GNEJunction * getDest() const
returns the destination-junction
Definition: GNEEdge.cpp:135
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:541
void updateLaneGeometries()
update edge geometry and inform the lanes let the lanes recompute their precomputed geometry informat...
Definition: GNEEdge.cpp:361
LaneVector myLanes
List of this edges lanes.
Definition: GNEEdge.h:246
#define SUMOReal
Definition: config.h:214
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
Definition: GNEEdge.cpp:314
NBEdge & myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:240
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:467
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:337
A window containing a gl-object&#39;s parameter.
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.h:224
GNEJunction * getSource() const
returns the source-junction
Definition: GNEEdge.cpp:129
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:217
static bool changeGeometry(PositionVector &geom, const std::string &id, const Position &oldPos, const Position &newPos, bool relative=false, bool moveEndPoints=false)
Definition: GNEEdge.cpp:244
const LaneVector & getLanes()
Definition: GNEEdge.h:219
GNEEdge & operator=(const GNEEdge &s)
invalidated assignment operator
void setNumLanes(unsigned int numLanes, GNEUndoList *undoList)
changes the number of lanes. When reducing the number of lanes, higher-numbered lanes are removed fir...
Definition: GNEEdge.cpp:674
void removeConnection(unsigned int fromLane, const std::string &toEdgeID, unsigned int toLane)
removes a connection
Definition: GNEEdge.cpp:759