SUMO - Simulation of Urban MObility
GNEEdge.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // A road/street connecting two junctions (netedit-version, adapted from GUIEdge)
18 // Basically a container for an NBEdge with drawing and editing capabilities
19 /****************************************************************************/
20 #ifndef GNEEdge_h
21 #define GNEEdge_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "GNENetElement.h"
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class GNENet;
39 class GNEJunction;
40 class GNELane;
41 class GNEConnection;
42 class GNERouteProbe;
43 class GNEVaporizer;
44 class GNERerouter;
45 class GNECrossing;
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
56 class GNEEdge : public GNENetElement {
57 
59  friend class GNEChange_Lane;
60  friend class GNEChange_Connection;
61 
62 public:
64  typedef std::vector<GNELane*> LaneVector;
65 
67  typedef std::vector<GNEConnection*> ConnectionVector;
68 
74  GNEEdge(NBEdge& nbe, GNENet* net, bool wasSplit = false, bool loaded = false);
75 
77  ~GNEEdge();
78 
82  void updateGeometry();
83 
89  int getVertexIndex(const Position& pos, bool createIfNoExist = true);
90 
96  int getVertexIndex(const double offset, bool createIfNoExist = true);
97 
103  int moveVertexShape(const int index, const Position& oldPos, const Position& offset);
104 
109  void moveEntireShape(const PositionVector& oldShape, const Position& offset);
110 
115  void commitShapeChange(const PositionVector& oldShape, GNEUndoList* undoList);
116 
118  void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
119 
121  void updateJunctionPosition(GNEJunction* junction, const Position& origPos);
122 
124  Boundary getBoundary() const;
125 
127  bool isInverted() const;
128 
131 
139 
146 
151  void drawGL(const GUIVisualizationSettings& s) const;
153 
155  NBEdge* getNBEdge();
156 
159 
162 
164  GNEEdge* getOppositeEdge() const;
165 
167  void setEndpoint(Position pos, GNEUndoList* undoList);
168 
170  void resetEndpoint(const Position& pos, GNEUndoList* undoList);
171 
174  /* @brief method for getting the Attribute of an XML key
175  * @param[in] key The attribute key
176  * @return string with the value associated to key
177  */
178  std::string getAttribute(SumoXMLAttr key) const;
179  std::string getAttributeForSelection(SumoXMLAttr key) const;
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  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
187 
188  /* @brief method for setting the attribute and letting the object perform additional changes
189  * @param[in] key The attribute key
190  * @param[in] value The new value
191  * @param[in] undoList The undoList on which to register changes
192  */
193  bool isValid(SumoXMLAttr key, const std::string& value);
195 
197  void setResponsible(bool newVal);
198 
203  void setGeometry(PositionVector geom, bool inner);
204 
206  void remakeGNEConnections();
207 
209  void copyTemplate(GNEEdge* tpl, GNEUndoList* undolist);
210 
212  std::set<GUIGlID> getLaneGlIDs();
213 
215  const std::vector<GNELane*>& getLanes();
216 
218  const std::vector<GNEConnection*>& getGNEConnections();
219 
221  GNEConnection* retrieveGNEConnection(int fromLane, NBEdge* to, int toLane, bool createIfNoExist = true);
222 
224  bool wasSplit();
225 
226  /* @brief compute a splitting position which keeps the resulting edges
227  * straight unless the user clicked near a geometry point */
228  Position getSplitPos(const Position& clickPos);
229 
231  void setMicrosimID(const std::string& newID);
232 
234  bool hasRestrictedLane(SUMOVehicleClass vclass) const;
235 
236  // the radius in which to register clicks for geometry nodes
237  static const double SNAP_RADIUS;
238 
240  void clearGNEConnections();
241 
243  int getRouteProbeRelativePosition(GNERouteProbe* routeProbe) const;
244 
246  int getVaporizerRelativePosition(GNEVaporizer* vaporizer) const;
247 
249  std::vector<GNECrossing*> getGNECrossings();
250 
252  void removeEdgeOfAdditionalParents(GNEUndoList* undoList, bool allowEmpty);
253 
255  void smooth(GNEUndoList* undoList);
256 
258  void straightenElevation(GNEUndoList* undoList);
259 
261  void smoothElevation(GNEUndoList* undoList);
262 
264  PositionVector smoothShape(const PositionVector& shape, bool forElevation);
265 
266 protected:
269 
272 
275 
278 
280  LaneVector myLanes;
281 
283  ConnectionVector myGNEConnections;
284 
287 
290 
292  std::string myConnectionStatus;
293 
294 private:
296  void setAttribute(SumoXMLAttr key, const std::string& value);
297 
304  void setNumLanes(int numLanes, GNEUndoList* undoList);
305 
307  void addLane(GNELane* lane, const NBEdge::Lane& laneAttrs);
308 
310  void removeLane(GNELane* lane);
311 
313  void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation = false);
314 
317 
319  void removeEdgeFromCrossings(GNEJunction* junction, GNEUndoList* undoList);
320 
322  GNEEdge(const GNEEdge& s) = delete;
323 
325  GNEEdge& operator=(const GNEEdge& s) = delete;
326 };
327 
328 
329 #endif
330 
331 /****************************************************************************/
332 
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:1071
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
Definition: GNEEdge.cpp:621
GNEJunction * myGNEJunctionSource
pointer to GNEJunction source
Definition: GNEEdge.h:271
void remakeGNEConnections()
remake connections
Definition: GNEEdge.cpp:482
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:161
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:1051
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:286
void smoothElevation(GNEUndoList *undoList)
smooth elevation with regard to adjoining edges
Definition: GNEEdge.cpp:1353
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEEdge.cpp:335
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:294
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:292
GNEJunction * myGNEJunctionDestiny
pointer to GNEJunction destiny
Definition: GNEEdge.h:274
PositionVector myOrigShape
restore point for undo
Definition: GNEEdge.h:277
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:1227
void straightenElevation(GNEUndoList *undoList)
interpolate z values linear between junctions
Definition: GNEEdge.cpp:1258
std::set< GUIGlID > getLaneGlIDs()
returns GLIDs of all lanes
Definition: GNEEdge.cpp:643
Stores the information about how to visualize structures.
static const double SNAP_RADIUS
Definition: GNEEdge.h:237
The representation of a single edge during network building.
Definition: NBEdge.h:70
std::vector< GNELane * > LaneVector
Definition of the lane&#39;s vector.
Definition: GNEEdge.h:64
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
Definition: GNEEdge.cpp:1236
Representation of a RouteProbe in netedit.
Definition: GNERouteProbe.h:42
void smooth(GNEUndoList *undoList)
make geometry smooth
Definition: GNEEdge.cpp:1341
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:91
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:53
void clearGNEConnections()
clear current connections
Definition: GNEEdge.cpp:519
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void removeEdgeFromCrossings(GNEJunction *junction, GNEUndoList *undoList)
remove crossing of junction
Definition: GNEEdge.cpp:1247
const std::vector< GNEConnection * > & getGNEConnections()
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:659
PositionVector smoothShape(const PositionVector &shape, bool forElevation)
return smoothed shape
Definition: GNEEdge.cpp:1268
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:289
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:94
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEEdge.cpp:245
int getVertexIndex(const Position &pos, bool createIfNoExist=true)
return index of a vertex of shape, or of a new vertex if position is over an shape&#39;s edge ...
Definition: GNEEdge.cpp:143
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:121
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in all GNEAttributeCarriers.
Definition: GNEEdge.cpp:671
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:51
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A list of positions.
GNEEdge * getOppositeEdge() const
get opposite edge
Definition: GNEEdge.cpp:329
Representation of a vaporizer in netedit.
Definition: GNEVaporizer.h:42
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:323
GNEConnection * retrieveGNEConnection(int fromLane, NBEdge *to, int toLane, bool createIfNoExist=true)
get GNEConnection if exist, and if not create it if create is enabled
Definition: GNEEdge.cpp:1205
int getVaporizerRelativePosition(GNEVaporizer *vaporizer) const
obtain relative positions of Vaporizer
Definition: GNEEdge.cpp:556
GNEJunction * getGNEJunctionSource() const
returns the source-junction
Definition: GNEEdge.cpp:317
void removeLane(GNELane *lane)
the number of lanes by one. argument is only used to increase robustness (assertions) ...
Definition: GNEEdge.cpp:1115
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEEdge.cpp:302
std::vector< GNECrossing * > getGNECrossings()
get GNECrossings vinculated with this Edge
Definition: GNEEdge.cpp:574
void setGeometry(PositionVector geom, bool inner)
update edge geometry and inform the lanes
Definition: GNEEdge.cpp:471
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:56
int getRouteProbeRelativePosition(GNERouteProbe *routeProbe) const
obtain relative positions of RouteProbes
Definition: GNEEdge.cpp:538
ConnectionVector myGNEConnections
vector with the connections of this edge
Definition: GNEEdge.h:283
int moveVertexShape(const int index, const Position &oldPos, const Position &offset)
change position of a vertex of shape without commiting change
Definition: GNEEdge.cpp:180
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:939
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1159
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:653
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEEdge.cpp:203
void updateJunctionPosition(GNEJunction *junction, const Position &origPos)
update edge geometry after junction move
Definition: GNEEdge.cpp:263
GNEEdge & operator=(const GNEEdge &s)=delete
invalidated assignment operator
void updateGeometry()
update pre-computed geometry information
Definition: GNEEdge.cpp:124
The popup menu of a globject.
bool isInverted() const
return true if edge is inverted (Angle between origin and destiny junction is -PI/2 <= angle < PI/2 ...
Definition: GNEEdge.cpp:287
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:844
void removeEdgeOfAdditionalParents(GNEUndoList *undoList, bool allowEmpty)
remove Edge of Additional Parent
Definition: GNEEdge.cpp:591
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(...)
Definition: GNEEdge.cpp:218
LaneVector myLanes
vectgor with the lanes of this edge
Definition: GNEEdge.h:280
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1180
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
Definition: GNEEdge.cpp:432
NBEdge & myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:268
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:412
std::vector< GNEConnection * > ConnectionVector
Definition of the connection&#39;s vector.
Definition: GNEEdge.h:67
Boundary getBoundary() const
Returns the street&#39;s geometry.
Definition: GNEEdge.cpp:277
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:747
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:457
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNEEdge.cpp:738
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:665
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:418