Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A road/street connecting two junctions (netedit-version, adapted from GUIEdge)
16 // Basically a container for an NBEdge with drawing and editing capabilities
17 /****************************************************************************/
18 #ifndef GNEEdge_h
19 #define GNEEdge_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 
26 #include "GNENetElement.h"
27 #include <netbuild/NBEdge.h>
28 
29 // ===========================================================================
30 // class declarations
31 // ===========================================================================
32 class GNENet;
33 class GNEJunction;
34 class GNELane;
35 class GNEConnection;
36 class GNERouteProbe;
37 class GNEVaporizer;
38 class GNERerouter;
39 class GNECrossing;
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
50 class GNEEdge : public GNENetElement {
51 
53  friend class GNEChange_Lane;
54  friend class GNEChange_Connection;
55 
56 public:
58  typedef std::vector<GNELane*> LaneVector;
59 
61  typedef std::vector<GNEConnection*> ConnectionVector;
62 
68  GNEEdge(NBEdge& nbe, GNENet* net, bool wasSplit = false, bool loaded = false);
69 
71  ~GNEEdge();
72 
74  std::string generateChildID(SumoXMLTag childTag);
75 
79  void updateGeometry();
80 
84 
88  bool clickedOverShapeStart(const Position& pos);
89 
91  bool clickedOverShapeEnd(const Position& pos);
92 
94  void moveShapeStart(const Position& oldPos, const Position& offset);
95 
97  void moveShapeEnd(const Position& oldPos, const Position& offset);
98 
100  void commitShapeStartChange(const Position& oldPos, GNEUndoList* undoList);
101 
103  void commitShapeEndChange(const Position& oldPos, GNEUndoList* undoList);
105 
109  void startGeometryMoving();
110 
112  void endGeometryMoving();
114 
121  int getVertexIndex(Position pos, bool createIfNoExist, bool snapToGrid);
122 
129  int getVertexIndex(const double offset, bool createIfNoExist, bool snapToGrid);
130 
136  int moveVertexShape(const int index, const Position& oldPos, const Position& offset);
137 
142  void moveEntireShape(const PositionVector& oldShape, const Position& offset);
143 
148  void commitShapeChange(const PositionVector& oldShape, GNEUndoList* undoList);
149 
151  void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
152 
154  void updateJunctionPosition(GNEJunction* junction, const Position& origPos);
155 
158 
166 
173 
175  const std::string getOptionalName() const;
176 
181  void drawGL(const GUIVisualizationSettings& s) const;
183 
185  NBEdge* getNBEdge() const;
186 
189 
192 
194  GNEEdge* getOppositeEdge() const;
195 
197  void editEndpoint(Position pos, GNEUndoList* undoList);
198 
200  void resetEndpoint(const Position& pos, GNEUndoList* undoList);
201 
204  /* @brief method for getting the Attribute of an XML key
205  * @param[in] key The attribute key
206  * @return string with the value associated to key
207  */
208  std::string getAttribute(SumoXMLAttr key) const;
209  std::string getAttributeForSelection(SumoXMLAttr key) const;
210 
211  /* @brief method for setting the attribute and letting the object perform additional changes
212  * @param[in] key The attribute key
213  * @param[in] value The new value
214  * @param[in] undoList The undoList on which to register changes
215  */
216  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
217 
218  /* @brief method for setting the attribute and letting the object perform additional changes
219  * @param[in] key The attribute key
220  * @param[in] value The new value
221  * @param[in] undoList The undoList on which to register changes
222  */
223  bool isValid(SumoXMLAttr key, const std::string& value);
225 
228 
230  std::string getGenericParametersStr() const;
231 
233  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
234 
236  void setGenericParametersStr(const std::string& value);
237 
239 
241  void setResponsible(bool newVal);
242 
247  void setGeometry(PositionVector geom, bool inner);
248 
250  void remakeGNEConnections();
251 
253  void copyTemplate(GNEEdge* tpl, GNEUndoList* undolist);
254 
256  std::set<GUIGlID> getLaneGlIDs() const;
257 
259  const std::vector<GNELane*>& getLanes() const;
260 
262  const std::vector<GNEConnection*>& getGNEConnections() const;
263 
265  GNEConnection* retrieveGNEConnection(int fromLane, NBEdge* to, int toLane, bool createIfNoExist = true);
266 
268  bool wasSplit();
269 
270  /* @brief compute a splitting position which keeps the resulting edges
271  * straight unless the user clicked near a geometry point */
272  Position getSplitPos(const Position& clickPos);
273 
275  void setMicrosimID(const std::string& newID);
276 
278  bool hasRestrictedLane(SUMOVehicleClass vclass) const;
279 
280  // the radius in which to register clicks for geometry nodes
281  static const double SNAP_RADIUS;
282 
284  static GNEEdge& getDummyEdge();
285 
287  void clearGNEConnections();
288 
290  int getRouteProbeRelativePosition(GNERouteProbe* routeProbe) const;
291 
293  std::vector<GNECrossing*> getGNECrossings();
294 
296  void smooth(GNEUndoList* undoList);
297 
299  void straightenElevation(GNEUndoList* undoList);
300 
302  void smoothElevation(GNEUndoList* undoList);
303 
305  PositionVector smoothShape(const PositionVector& shape, bool forElevation);
306 
308  GNELane* getLaneByVClass(const SUMOVehicleClass vClass) const;
309 
313  GNELane* getLaneByVClass(const SUMOVehicleClass vClass, bool& found) const;
314 
316  void drawPartialRoute(const GUIVisualizationSettings& s, const GNEDemandElement* route, const GNEJunction* junction) const;
317 
319  void drawPartialTripFromTo(const GUIVisualizationSettings& s, const GNEDemandElement* tripOrFromTo, const GNEJunction* junction) const;
320 
322  void drawPartialPersonPlan(const GUIVisualizationSettings& s, const GNEDemandElement* personPlan, const GNEJunction* junction) const;
323 
324 protected:
327 
330 
333 
336 
339 
342 
345 
348 
350  std::string myConnectionStatus;
351 
352 private:
354  void setAttribute(SumoXMLAttr key, const std::string& value);
355 
362  void setNumLanes(int numLanes, GNEUndoList* undoList);
363 
365  void addLane(GNELane* lane, const NBEdge::Lane& laneAttrs, bool recomputeConnections);
366 
368  void removeLane(GNELane* lane, bool recomputeConnections);
369 
371  void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation = false);
372 
375 
377  void removeEdgeFromCrossings(GNEJunction* junction, GNEUndoList* undoList);
378 
380  void setShapeStartPos(const Position& pos);
381 
383  void setShapeEndPos(const Position& pos);
384 
386  void drawGeometryPoints(const GUIVisualizationSettings& s) const;
387 
389  void drawEdgeName(const GUIVisualizationSettings& s) const;
390 
392  void drawRerouterSymbol(const GUIVisualizationSettings& s, GNEAdditional* rerouter) const;
393 
395  GNEEdge(const GNEEdge& s) = delete;
396 
398  GNEEdge& operator=(const GNEEdge& s) = delete;
399 
401  GNEEdge();
402 };
403 
404 
405 #endif
406 
407 /****************************************************************************/
408 
GNEEdge::getSplitPos
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:631
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:134
GNEEdge::myAmResponsible
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:344
GNEEdge::smoothElevation
void smoothElevation(GNEUndoList *undoList)
smooth elevation with regard to adjoining edges
Definition: GNEEdge.cpp:1989
GNEDemandElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEDemandElement.h:54
GNEEdge::addLane
void addLane(GNELane *lane, const NBEdge::Lane &laneAttrs, bool recomputeConnections)
increase number of lanes by one use the given attributes and restore the GNELane
Definition: GNEEdge.cpp:1652
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
GNEEdge::myConnectionStatus
std::string myConnectionStatus
modification status of the connections
Definition: GNEEdge.h:350
GNEEdge::copyTemplate
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
Definition: GNEEdge.cpp:808
GNEEdge::myGNEJunctionSource
GNEJunction * myGNEJunctionSource
pointer to GNEJunction source
Definition: GNEEdge.h:332
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
GNEEdge::straightenElevation
void straightenElevation(GNEUndoList *undoList)
interpolate z values linear between junctions
Definition: GNEEdge.cpp:1894
GNEEdge::SNAP_RADIUS
static const double SNAP_RADIUS
Definition: GNEEdge.h:281
GNEEdge::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEEdge.cpp:517
GNEEdge::drawPartialPersonPlan
void drawPartialPersonPlan(const GUIVisualizationSettings &s, const GNEDemandElement *personPlan, const GNEJunction *junction) const
draw partial person plan
Definition: GNEEdge.cpp:1339
GNEEdge::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:460
GNEEdge::moveShapeStart
void moveShapeStart(const Position &oldPos, const Position &offset)
move position of shape start without commiting change
Definition: GNEEdge.cpp:190
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:78
GNEEdge::LaneVector
std::vector< GNELane * > LaneVector
Definition of the lane's vector.
Definition: GNEEdge.h:58
GNEEdge::myGNEJunctionDestiny
GNEJunction * myGNEJunctionDestiny
pointer to GNEJunction destiny
Definition: GNEEdge.h:335
GNEEdge::drawPartialTripFromTo
void drawPartialTripFromTo(const GUIVisualizationSettings &s, const GNEDemandElement *tripOrFromTo, const GNEJunction *junction) const
draw partial trip and Flow
Definition: GNEEdge.cpp:1296
GNEEdge::setMicrosimID
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:1863
GNEEdge::endGeometryMoving
void endGeometryMoving()
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
Definition: GNEEdge.cpp:279
GNEEdge::GNEEdge
GNEEdge()
constructor for dummy edge
Definition: GNEEdge.cpp:84
GNEEdge::setShapeEndPos
void setShapeEndPos(const Position &pos)
change Shape EndPos
Definition: GNEEdge.cpp:2030
GNEEdge::drawEdgeName
void drawEdgeName(const GUIVisualizationSettings &s) const
draw edge name
Definition: GNEEdge.cpp:2134
GNEEdge::clearGNEConnections
void clearGNEConnections()
clear current connections
Definition: GNEEdge.cpp:752
GNEEdge::getGNEConnections
const std::vector< GNEConnection * > & getGNEConnections() const
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:846
GNEEdge::removeLane
void removeLane(GNELane *lane, bool recomputeConnections)
@briefdecrease the number of lanes by one. argument is only used to increase robustness (assertions)
Definition: GNEEdge.cpp:1705
GNEEdge::~GNEEdge
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:89
GNEEdge::hasRestrictedLane
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
Definition: GNEEdge.cpp:1872
GNEEdge::drawPartialRoute
void drawPartialRoute(const GUIVisualizationSettings &s, const GNEDemandElement *route, const GNEJunction *junction) const
draw partial route
Definition: GNEEdge.cpp:1223
GNEEdge::smooth
void smooth(GNEUndoList *undoList)
make geometry smooth
Definition: GNEEdge.cpp:1977
GNEEdge::editEndpoint
void editEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end, or remove current existent endpoint
Definition: GNEEdge.cpp:645
GNERerouter
Definition: GNERerouter.h:40
PositionVector
A list of positions.
Definition: PositionVector.h:46
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:48
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:42
GNEEdge::moveShapeEnd
void moveShapeEnd(const Position &oldPos, const Position &offset)
move position of shape end without commiting change
Definition: GNEEdge.cpp:206
NBEdge
The representation of a single edge during network building.
Definition: NBEdge.h:86
GNEEdge::removeEdgeFromCrossings
void removeEdgeFromCrossings(GNEJunction *junction, GNEUndoList *undoList)
remove crossing of junction
Definition: GNEEdge.cpp:1883
GNERouteProbe
Representation of a RouteProbe in netedit.
Definition: GNERouteProbe.h:35
GNEEdge::getVertexIndex
int getVertexIndex(Position pos, bool createIfNoExist, bool snapToGrid)
return index of a vertex of shape, or of a new vertex if position is over an shape's edge
Definition: GNEEdge.cpp:313
GNEEdge::commitShapeStartChange
void commitShapeStartChange(const Position &oldPos, GNEUndoList *undoList)
commit position changing in shape start
Definition: GNEEdge.cpp:222
GNEEdge::smoothShape
PositionVector smoothShape(const PositionVector &shape, bool forElevation)
return smoothed shape
Definition: GNEEdge.cpp:1904
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
GNEEdge::myWasSplit
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:347
GNEEdge::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:858
GNEEdge::deleteGeometryPoint
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEEdge.cpp:428
GNECrossing
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:45
GNEEdge::clickedOverShapeStart
bool clickedOverShapeStart(const Position &pos)
Definition: GNEEdge.cpp:170
GNEEdge::commitShapeEndChange
void commitShapeEndChange(const Position &oldPos, GNEUndoList *undoList)
commit position changing in shape end
Definition: GNEEdge.cpp:237
GNEEdge::getGenericParametersStr
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNEEdge.cpp:1132
GNEEdge::getNBEdge
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:625
GNENetElement.h
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GNEEdge::getPositionInView
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNEEdge.cpp:163
GNEEdge::getDummyEdge
static GNEEdge & getDummyEdge()
Dummy edge to use when a reference must be supplied in the no-arguments constructor (FOX technicality...
Definition: GNEEdge.cpp:52
GNEChange_Lane
Definition: GNEChange_Lane.h:47
GNEEdge::drawRerouterSymbol
void drawRerouterSymbol(const GUIVisualizationSettings &s, GNEAdditional *rerouter) const
draw Rerouter symbols
Definition: GNEEdge.cpp:2173
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GNEEdge::generateChildID
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEEdge.cpp:115
GNEEdge::clickedOverShapeEnd
bool clickedOverShapeEnd(const Position &pos)
return true if user clicked over ShapeEnd
Definition: GNEEdge.cpp:180
GNEEdge::getOppositeEdge
GNEEdge * getOppositeEdge() const
get opposite edge
Definition: GNEEdge.cpp:511
GNENetElement
Definition: GNENetElement.h:42
GNEChange_Connection
Definition: GNEChange_Connection.h:45
GNEEdge::getGenericParameters
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNEEdge.cpp:1147
GNEEdge::getGNEJunctionDestiny
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:505
GNEEdge::retrieveGNEConnection
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:1831
GNEEdge::setGeometry
void setGeometry(PositionVector geom, bool inner)
update edge geometry and inform the lanes
Definition: GNEEdge.cpp:703
GNEEdge::getLanes
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:840
GNEEdge::getRouteProbeRelativePosition
int getRouteProbeRelativePosition(GNERouteProbe *routeProbe) const
obtain relative positions of RouteProbes
Definition: GNEEdge.cpp:773
GNEEdge::startGeometryMoving
void startGeometryMoving()
Definition: GNEEdge.cpp:252
GNEEdge::myGNEConnections
ConnectionVector myGNEConnections
vector with the connections of this edge
Definition: GNEEdge.h:341
GNEEdge::setResponsible
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:1183
GNEEdge::addConnection
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1755
GNEEdge::drawGeometryPoints
void drawGeometryPoints(const GUIVisualizationSettings &s) const
draw geometry points
Definition: GNEEdge.cpp:2041
GNEEdge::getGNEJunctionSource
GNEJunction * getGNEJunctionSource() const
returns the source-junction
Definition: GNEEdge.cpp:499
GNEEdge::getLaneGlIDs
std::set< GUIGlID > getLaneGlIDs() const
returns GLIDs of all lanes
Definition: GNEEdge.cpp:830
GNEEdge::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEEdge.cpp:484
GNEEdge::getGNECrossings
std::vector< GNECrossing * > getGNECrossings()
get GNECrossings vinculated with this Edge
Definition: GNEEdge.cpp:791
GUIMainWindow
Definition: GUIMainWindow.h:47
GNEEdge::moveEntireShape
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEEdge.cpp:384
GNEEdge::updateJunctionPosition
void updateJunctionPosition(GNEJunction *junction, const Position &origPos)
update edge geometry after junction move
Definition: GNEEdge.cpp:446
GNEEdge::operator=
GNEEdge & operator=(const GNEEdge &s)=delete
invalidated assignment operator
NBEdge::Lane
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:137
GNEEdge::moveVertexShape
int moveVertexShape(const int index, const Position &oldPos, const Position &offset)
change position of a vertex of shape without commiting change
Definition: GNEEdge.cpp:359
GNEVaporizer
Representation of a vaporizer in netedit.
Definition: GNEVaporizer.h:35
GNEEdge::myMovingShape
PositionVector myMovingShape
variable used to save shape bevore moving (used to avoid inconsistences in GL Tree)
Definition: GNEEdge.h:329
GNEEdge::setGenericParametersStr
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNEEdge.cpp:1158
GNEEdge::removeConnection
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1791
GNEConnection
Definition: GNEConnection.h:38
GNEEdge::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNEEdge.cpp:122
GNEEdge::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:1041
GNEEdge::commitShapeChange
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(....
Definition: GNEEdge.cpp:397
GNEUndoList
Definition: GNEUndoList.h:49
GNEEdge::myLanes
LaneVector myLanes
vectgor with the lanes of this edge
Definition: GNEEdge.h:338
GNEEdge::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:940
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
GNEEdge::resetEndpoint
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:689
GNEEdge::getLaneByVClass
GNELane * getLaneByVClass(const SUMOVehicleClass vClass) const
return the first lane that allow a vehicle of type vClass (or the first lane, if none was found)
Definition: GNEEdge.cpp:1189
GNEJunction
Definition: GNEJunction.h:48
NBEdge::Connection
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:184
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:373
GNEEdge::getOptionalName
const std::string getOptionalName() const
Returns the street name.
Definition: GNEEdge.cpp:479
GNEEdge::myNBEdge
NBEdge & myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:326
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
GNEEdge::ConnectionVector
std::vector< GNEConnection * > ConnectionVector
Definition of the connection's vector.
Definition: GNEEdge.h:61
GNEEdge::remakeGNEConnections
void remakeGNEConnections()
remake connections
Definition: GNEEdge.cpp:713
GNEEdge::setShapeStartPos
void setShapeStartPos(const Position &pos)
change Shape StartPos
Definition: GNEEdge.cpp:2019
NBEdge.h
GNEEdge::getAttributeForSelection
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNEEdge.cpp:931
GNEEdge::wasSplit
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:852
GNEEdge::setNumLanes
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:1632