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 
338  LaneVector myLanes;
339 
341  ConnectionVector myGNEConnections;
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 
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
Definition: GNEEdge.cpp:808
GNEJunction * myGNEJunctionSource
pointer to GNEJunction source
Definition: GNEEdge.h:332
void remakeGNEConnections()
remake connections
Definition: GNEEdge.cpp:713
SumoXMLTag
Numbers representing SUMO-XML - element names.
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:184
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
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:344
void smoothElevation(GNEUndoList *undoList)
smooth elevation with regard to adjoining edges
Definition: GNEEdge.cpp:1989
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEEdge.cpp:517
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
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:460
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:350
GNEJunction * myGNEJunctionDestiny
pointer to GNEJunction destiny
Definition: GNEEdge.h:335
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:1863
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()
constructor for dummy edge
Definition: GNEEdge.cpp:84
void straightenElevation(GNEUndoList *undoList)
interpolate z values linear between junctions
Definition: GNEEdge.cpp:1894
Stores the information about how to visualize structures.
void drawEdgeName(const GUIVisualizationSettings &s) const
draw edge name
Definition: GNEEdge.cpp:2134
static const double SNAP_RADIUS
Definition: GNEEdge.h:281
The representation of a single edge during network building.
Definition: NBEdge.h:86
void drawPartialPersonPlan(const GUIVisualizationSettings &s, const GNEDemandElement *personPlan, const GNEJunction *junction) const
draw partial person plan
Definition: GNEEdge.cpp:1339
void moveShapeStart(const Position &oldPos, const Position &offset)
move position of shape start without commiting change
Definition: GNEEdge.cpp:190
std::vector< GNELane * > LaneVector
Definition of the lane&#39;s vector.
Definition: GNEEdge.h:58
const std::vector< GNEConnection * > & getGNEConnections() const
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:846
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
Definition: GNEEdge.cpp:1872
Representation of a RouteProbe in netedit.
Definition: GNERouteProbe.h:35
void smooth(GNEUndoList *undoList)
make geometry smooth
Definition: GNEEdge.cpp:1977
void drawPartialTripFromTo(const GUIVisualizationSettings &s, const GNEDemandElement *tripOrFromTo, const GNEJunction *junction) const
draw partial trip and Flow
Definition: GNEEdge.cpp:1296
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:78
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
void setShapeEndPos(const Position &pos)
change Shape EndPos
Definition: GNEEdge.cpp:2030
void clearGNEConnections()
clear current connections
Definition: GNEEdge.cpp:752
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void moveShapeEnd(const Position &oldPos, const Position &offset)
move position of shape end without commiting change
Definition: GNEEdge.cpp:206
void removeEdgeFromCrossings(GNEJunction *junction, GNEUndoList *undoList)
remove crossing of junction
Definition: GNEEdge.cpp:1883
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&#39;s edge ...
Definition: GNEEdge.cpp:313
void commitShapeStartChange(const Position &oldPos, GNEUndoList *undoList)
commit position changing in shape start
Definition: GNEEdge.cpp:222
PositionVector smoothShape(const PositionVector &shape, bool forElevation)
return smoothed shape
Definition: GNEEdge.cpp:1904
void removeLane(GNELane *lane, bool recomputeConnections)
the number of lanes by one. argument is only used to increase robustness (assertions) ...
Definition: GNEEdge.cpp:1705
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:347
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:89
void drawPartialRoute(const GUIVisualizationSettings &s, const GNEDemandElement *route, const GNEJunction *junction) const
draw partial route
Definition: GNEEdge.cpp:1223
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
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEEdge.cpp:428
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:625
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:137
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:858
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNEEdge.cpp:163
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:45
bool clickedOverShapeStart(const Position &pos)
Definition: GNEEdge.cpp:170
void commitShapeEndChange(const Position &oldPos, GNEUndoList *undoList)
commit position changing in shape end
Definition: GNEEdge.cpp:237
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNEEdge.cpp:1132
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
A list of positions.
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEEdge.cpp:115
GNEEdge * getOppositeEdge() const
get opposite edge
Definition: GNEEdge.cpp:511
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNEEdge.cpp:1147
Representation of a vaporizer in netedit.
Definition: GNEVaporizer.h:35
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:505
static GNEEdge & getDummyEdge()
Dummy edge to use when a reference must be supplied in the no-arguments constructor (FOX technicality...
Definition: GNEEdge.cpp:52
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
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:840
void drawRerouterSymbol(const GUIVisualizationSettings &s, GNEAdditional *rerouter) const
draw Rerouter symbols
Definition: GNEEdge.cpp:2173
void startGeometryMoving()
Definition: GNEEdge.cpp:252
bool clickedOverShapeEnd(const Position &pos)
return true if user clicked over ShapeEnd
Definition: GNEEdge.cpp:180
GNEJunction * getGNEJunctionSource() const
returns the source-junction
Definition: GNEEdge.cpp:499
std::set< GUIGlID > getLaneGlIDs() const
returns GLIDs of all lanes
Definition: GNEEdge.cpp:830
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEEdge.cpp:484
std::vector< GNECrossing * > getGNECrossings()
get GNECrossings vinculated with this Edge
Definition: GNEEdge.cpp:791
void setGeometry(PositionVector geom, bool inner)
update edge geometry and inform the lanes
Definition: GNEEdge.cpp:703
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
int getRouteProbeRelativePosition(GNERouteProbe *routeProbe) const
obtain relative positions of RouteProbes
Definition: GNEEdge.cpp:773
ConnectionVector myGNEConnections
vector with the connections of this edge
Definition: GNEEdge.h:341
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
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:1183
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1755
void drawGeometryPoints(const GUIVisualizationSettings &s) const
draw geometry points
Definition: GNEEdge.cpp:2041
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNEEdge.cpp:1158
PositionVector myMovingShape
variable used to save shape bevore moving (used to avoid inconsistences in GL Tree) ...
Definition: GNEEdge.h:329
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEEdge.cpp:384
void updateJunctionPosition(GNEJunction *junction, const Position &origPos)
update edge geometry after junction move
Definition: GNEEdge.cpp:446
GNEEdge & operator=(const GNEEdge &s)=delete
invalidated assignment operator
void updateGeometry()
update pre-computed geometry information
Definition: GNEEdge.cpp:122
The popup menu of a globject.
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:1041
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(...)
Definition: GNEEdge.cpp:397
LaneVector myLanes
vectgor with the lanes of this edge
Definition: GNEEdge.h:338
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1791
const std::string getOptionalName() const
Returns the street name.
Definition: GNEEdge.cpp:479
NBEdge & myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:326
std::vector< GNEConnection * > ConnectionVector
Definition of the connection&#39;s vector.
Definition: GNEEdge.h:61
void setShapeStartPos(const Position &pos)
change Shape StartPos
Definition: GNEEdge.cpp:2019
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:940
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:689
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
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNEEdge.cpp:931
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:852
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:631
An Element which don&#39;t belongs to GNENet but has influency in the simulation.