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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A road/street connecting two junctions (netedit-version, adapted from GUIEdge)
19 // Basically a container for an NBEdge with drawing and editing capabilities
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
24 #include <netbuild/NBEdge.h>
28 
29 #include "GNENetworkElement.h"
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class GNENet;
36 class GNEJunction;
37 class GNELane;
38 class GNEConnection;
39 class GNERouteProbe;
40 class GNECrossing;
41 class GNEEdgeType;
42 class GNEEdgeTemplate;
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
54 
56  friend class GNEChange_Lane;
57  friend class GNEChange_Connection;
58 
59 public:
61  typedef std::vector<GNELane*> LaneVector;
62 
64  typedef std::vector<GNEConnection*> ConnectionVector;
65 
71  GNEEdge(GNENet* net, NBEdge* nbe, bool wasSplit = false, bool loaded = false);
72 
74  ~GNEEdge();
75 
77  inline GNEJunction* getFromJunction() const {
78  return getParentJunctions().front();
79  }
80 
82  inline GNEJunction* getToJunction() const {
83  return getParentJunctions().back();
84  }
85 
89  void updateGeometry();
90 
94 
99 
101  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
103 
107  bool hasCustomEndPoints() const;
108 
110  bool clickedOverShapeStart(const Position& pos) const;
111 
113  bool clickedOverShapeEnd(const Position& pos) const;
114 
116  bool clickedOverGeometryPoint(const Position& pos) const;
118 
120  void updateJunctionPosition(GNEJunction* junction, const Position& origPos);
121 
124 
132 
134  double getExaggeration(const GUIVisualizationSettings& s) const;
135 
137  void updateCenteringBoundary(const bool updateGrid);
138 
140  const std::string getOptionalName() const;
141 
146  void drawGL(const GUIVisualizationSettings& s) const;
148 
150  NBEdge* getNBEdge() const;
151 
153  GNEEdge* getOppositeEdge() const;
154 
156  void editEndpoint(Position pos, GNEUndoList* undoList);
157 
159  void resetEndpoint(const Position& pos, GNEUndoList* undoList);
160 
162  void resetBothEndpoint(GNEUndoList* undoList);
163 
166  /* @brief method for getting the Attribute of an XML key
167  * @param[in] key The attribute key
168  * @return string with the value associated to key
169  */
170  std::string getAttribute(SumoXMLAttr key) const;
171  std::string getAttributeForSelection(SumoXMLAttr key) const;
172 
173  /* @brief method for setting the attribute and letting the object perform additional changes
174  * @param[in] key The attribute key
175  * @param[in] value The new value
176  * @param[in] undoList The undoList on which to register changes
177  */
178  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
179 
180  /* @brief method for setting the attribute and letting the object perform additional changes
181  * @param[in] key The attribute key
182  * @param[in] value The new value
183  * @param[in] undoList The undoList on which to register changes
184  */
185  bool isValid(SumoXMLAttr key, const std::string& value);
186 
187  /* @brief method for check if the value for certain attribute is set
188  * @param[in] key The attribute key
189  */
190  bool isAttributeEnabled(SumoXMLAttr key) const;
191 
192  /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
193  * @param[in] key The attribute key
194  */
195  bool isAttributeComputed(SumoXMLAttr key) const;
196 
198 
200  const std::map<std::string, std::string>& getACParametersMap() const;
201 
203  void setResponsible(bool newVal);
204 
209  void setGeometry(PositionVector geom, bool inner);
210 
212  const Position getFrontUpShapePosition() const;
213 
215  const Position getFrontDownShapePosition() const;
216 
218  const Position getBackUpShapePosition() const;
219 
221  const Position getBackDownShapePosition() const;
222 
224  void remakeGNEConnections();
225 
227  void copyTemplate(const GNEEdgeTemplate* edgeTemplate, GNEUndoList* undoList);
228 
230  void copyEdgeType(const GNEEdgeType* edgeType, GNEUndoList* undoList);
231 
233  std::set<GUIGlID> getLaneGlIDs() const;
234 
236  const std::vector<GNELane*>& getLanes() const;
237 
239  const std::vector<GNEConnection*>& getGNEConnections() const;
240 
242  GNEConnection* retrieveGNEConnection(int fromLane, NBEdge* to, int toLane, bool createIfNoExist = true);
243 
245  bool wasSplit();
246 
247  /* @brief compute a splitting position which keeps the resulting edges
248  * straight unless the user clicked near a geometry point */
249  Position getSplitPos(const Position& clickPos);
250 
252  void setMicrosimID(const std::string& newID);
253 
255  bool hasRestrictedLane(SUMOVehicleClass vclass) const;
256 
257  // @brief the radius in which to register clicks for geometry nodes
258  static const double SNAP_RADIUS;
259 
260  // @brief the radius in which to register clicks for geometry nodes (Squared)
261  static const double SNAP_RADIUS_SQUARED;
262 
264  void clearGNEConnections();
265 
267  int getRouteProbeRelativePosition(GNERouteProbe* routeProbe) const;
268 
270  std::vector<GNECrossing*> getGNECrossings();
271 
273  void smooth(GNEUndoList* undoList);
274 
276  void straightenElevation(GNEUndoList* undoList);
277 
279  void smoothElevation(GNEUndoList* undoList);
280 
282  PositionVector smoothShape(const PositionVector& shape, bool forElevation);
283 
285  GNELane* getLaneByAllowedVClass(const SUMOVehicleClass vClass) const;
286 
289 
290  // @brief update vehicle spread geometries
292 
293  // @brief update vehicle geometries
295 
297  void drawEdgeGeometryPoints(const GUIVisualizationSettings& s, const GNELane* lane) const;
298 
301  const bool drawFrontExtreme, const bool drawBackExtreme);
302 
304  bool isConvexAngle() const;
305 
306 protected:
309 
312 
315 
318 
321 
324 
326  std::string myConnectionStatus;
327 
328 private:
330  class StackPosition : public std::pair<double, double> {
331 
332  public:
334  StackPosition(const double departPos, const double length);
335 
337  double beginPosition() const;
338 
340  double endPosition() const;
341  };
342 
344  class StackDemandElements : public std::pair<StackPosition, std::vector<GNEDemandElement*> > {
345 
346  public:
348  StackDemandElements(const StackPosition stackedPosition, GNEDemandElement* demandElement);
349 
351  void addDemandElements(GNEDemandElement* demandElement);
352 
354  const StackPosition& getStackPosition() const;
355 
357  const std::vector<GNEDemandElement*>& getDemandElements() const;
358  };
359 
362 
364  void setAttribute(SumoXMLAttr key, const std::string& value);
365 
367  void setMoveShape(const GNEMoveResult& moveResult);
368 
370  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
371 
378  void setNumLanes(int numLanes, GNEUndoList* undoList);
379 
381  void updateFirstParentJunction(const std::string& value);
382 
384  void updateSecondParentJunction(const std::string& value);
385 
387  void addLane(GNELane* lane, const NBEdge::Lane& laneAttrs, bool recomputeConnections);
388 
390  void removeLane(GNELane* lane, bool recomputeConnections);
391 
393  void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation = false);
394 
397 
399  void removeEdgeFromCrossings(GNEJunction* junction, GNEUndoList* undoList);
400 
402  void setShapeStartPos(const Position& pos);
403 
405  void setShapeEndPos(const Position& pos);
406 
408  const std::map<const GNELane*, std::vector<GNEDemandElement*> > getVehiclesOverEdgeMap() const;
409 
411  void drawEdgeName(const GUIVisualizationSettings& s) const;
412 
414  void drawLaneStopOffset(const GUIVisualizationSettings& s) const;
415 
417  bool areStackPositionOverlapped(const GNEEdge::StackPosition& vehicleA, const GNEEdge::StackPosition& vehicleB) const;
418 
420  GNEMoveOperation* processMoveFromJunctionSelected(const PositionVector originalShape, const Position mousePosition, const double snapRadius);
421 
423  GNEMoveOperation* processMoveToJunctionSelected(const PositionVector originalShape, const Position mousePosition, const double snapRadius);
424 
427 
429  GNEMoveOperation* processNoneJunctionSelected(const double snapRadius);
430 
432  GNEEdge(const GNEEdge& s) = delete;
433 
435  GNEEdge& operator=(const GNEEdge& s) = delete;
436 };
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:42
An Element which don't belongs to GNENet but has influency in the simulation.
Stack demand elements.
Definition: GNEEdge.h:344
const StackPosition & getStackPosition() const
get stack position
Definition: GNEEdge.cpp:1479
const std::vector< GNEDemandElement * > & getDemandElements() const
get demand elements
Definition: GNEEdge.cpp:1485
void addDemandElements(GNEDemandElement *demandElement)
add demand elment to current StackDemandElements
Definition: GNEEdge.cpp:1473
StackDemandElements(const StackPosition stackedPosition, GNEDemandElement *demandElement)
constructor
Definition: GNEEdge.cpp:1465
Stack position (used to stack demand elements over edges)
Definition: GNEEdge.h:330
double beginPosition() const
get begin position
Definition: GNEEdge.cpp:1454
StackPosition(const double departPos, const double length)
constructor
Definition: GNEEdge.cpp:1448
double endPosition() const
get end position
Definition: GNEEdge.cpp:1460
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
const Position getFrontDownShapePosition() const
get front down shape position
Definition: GNEEdge.cpp:570
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNEEdge.cpp:329
void drawEdgeName(const GUIVisualizationSettings &s) const
draw edge name
Definition: GNEEdge.cpp:2166
bool isConvexAngle() const
check if edge makes a convex angle [0 - 180) degrees
Definition: GNEEdge.cpp:1431
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:1706
void remakeGNEConnections()
remake connections
Definition: GNEEdge.cpp:593
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNEEdge.cpp:1679
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNEEdge.cpp:1657
GNEEdge * getOppositeEdge() const
get opposite edge
Definition: GNEEdge.cpp:384
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:89
void smooth(GNEUndoList *undoList)
make geometry smooth
Definition: GNEEdge.cpp:2060
void updateGeometry()
update pre-computed geometry information
Definition: GNEEdge.cpp:123
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEEdge.cpp:173
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNEEdge.cpp:884
GNEJunction * getFromJunction() const
get from Junction (only used to increase readability)
Definition: GNEEdge.h:77
void setResponsible(bool newVal)
set responsibility for deleting internal structures
Definition: GNEEdge.cpp:1138
void copyEdgeType(const GNEEdgeType *edgeType, GNEUndoList *undoList)
copy edge attributes from edgeType
Definition: GNEEdge.cpp:732
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:435
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEEdge.cpp:369
const std::map< const GNELane *, std::vector< GNEDemandElement * > > getVehiclesOverEdgeMap() const
get vehicles a that start over this edge
Definition: GNEEdge.cpp:2124
std::set< GUIGlID > getLaneGlIDs() const
returns GLIDs of all lanes
Definition: GNEEdge.cpp:772
static void drawDottedContourEdge(const GUIDottedGeometry::DottedContourType type, const GUIVisualizationSettings &s, const GNEEdge *edge, const bool drawFrontExtreme, const bool drawBackExtreme)
draw dotted contour for the given dottedGeometries
Definition: GNEEdge.cpp:1379
const Position getFrontUpShapePosition() const
get front up shape position
Definition: GNEEdge.cpp:562
std::vector< GNEConnection * > ConnectionVector
Definition of the connection's vector.
Definition: GNEEdge.h:64
void setGeometry(PositionVector geom, bool inner)
update edge geometry and inform the lanes
Definition: GNEEdge.cpp:527
void smoothElevation(GNEUndoList *undoList)
smooth elevation with regard to adjoining edges
Definition: GNEEdge.cpp:2072
void drawLaneStopOffset(const GUIVisualizationSettings &s) const
draw edgeStopOffset
Definition: GNEEdge.cpp:2232
bool clickedOverGeometryPoint(const Position &pos) const
return true if user clicked over a Geometry Point
Definition: GNEEdge.cpp:290
bool clickedOverShapeEnd(const Position &pos) const
return true if user clicked over ShapeEnd
Definition: GNEEdge.cpp:280
void updateVehicleStackLabels()
Definition: GNEEdge.cpp:1205
GNEEdge & operator=(const GNEEdge &s)=delete
invalidated assignment operator
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition: GNEEdge.h:82
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:1001
GNEMoveOperation * processMoveBothJunctionSelected()
process moving edge when both junctions are selected
Definition: GNEEdge.cpp:2356
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition: GNEEdge.cpp:199
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:782
LaneVector myLanes
vector with the lanes of this edge
Definition: GNEEdge.h:311
static const double SNAP_RADIUS
Definition: GNEEdge.h:258
GNELane * getLaneByAllowedVClass(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:1144
bool hasCustomEndPoints() const
Definition: GNEEdge.cpp:258
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1890
bool isAttributeComputed(SumoXMLAttr key) const
Definition: GNEEdge.cpp:1115
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:323
void removeLane(GNELane *lane, bool recomputeConnections)
@briefdecrease the number of lanes by one. argument is only used to increase robustness (assertions)
Definition: GNEEdge.cpp:1813
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GNEEdge.cpp:323
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
Definition: GNEEdge.cpp:1955
static const double SNAP_RADIUS_SQUARED
Definition: GNEEdge.h:261
void updateSecondParentJunction(const std::string &value)
update last parent junction
Definition: GNEEdge.cpp:1752
Position myPositionBeforeMoving
position used for move Lanes
Definition: GNEEdge.h:317
std::vector< GNELane * > LaneVector
Definition of the lane's vector.
Definition: GNEEdge.h:61
PositionVector smoothShape(const PositionVector &shape, bool forElevation)
return smoothed shape
Definition: GNEEdge.cpp:1987
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:794
NBEdge * myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:308
void copyTemplate(const GNEEdgeTemplate *edgeTemplate, GNEUndoList *undoList)
copy edge attributes from edgetemplate
Definition: GNEEdge.cpp:701
void removeEdgeFromCrossings(GNEJunction *junction, GNEUndoList *undoList)
remove crossing of junction
Definition: GNEEdge.cpp:1966
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNEEdge.cpp:167
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:1761
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:1923
ConnectionVector myGNEConnections
vector with the connections of this edge
Definition: GNEEdge.h:314
void editEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end, or remove current existent endpoint
Definition: GNEEdge.cpp:455
void resetBothEndpoint(GNEUndoList *undoList)
restores both endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:517
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:441
const std::vector< GNEConnection * > & getGNEConnections() const
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:788
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:800
int getRouteProbeRelativePosition(GNERouteProbe *routeProbe) const
obtain relative positions of RouteProbes
Definition: GNEEdge.cpp:666
std::string myConnectionStatus
modification status of the connections
Definition: GNEEdge.h:326
const std::string getOptionalName() const
Returns the street name.
Definition: GNEEdge.cpp:363
void clearGNEConnections()
clear current connections
Definition: GNEEdge.cpp:639
bool myUpdateGeometry
@brif flag to enable/disable update geometry of lanes (used mainly by setNumLanes)
Definition: GNEEdge.h:361
const Position getBackDownShapePosition() const
get back down shape position
Definition: GNEEdge.cpp:586
GNEEdge(const GNEEdge &s)=delete
invalidated copy constructor
bool areStackPositionOverlapped(const GNEEdge::StackPosition &vehicleA, const GNEEdge::StackPosition &vehicleB) const
check if given stacked positions are overlapped
Definition: GNEEdge.cpp:2252
void updateFirstParentJunction(const std::string &value)
update front parent junction
Definition: GNEEdge.cpp:1743
void straightenElevation(GNEUndoList *undoList)
interpolate z values linear between junctions
Definition: GNEEdge.cpp:1977
bool clickedOverShapeStart(const Position &pos) const
return true if user clicked over ShapeStart
Definition: GNEEdge.cpp:270
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNEEdge.cpp:1132
void setShapeStartPos(const Position &pos)
change Shape StartPos
Definition: GNEEdge.cpp:2102
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:894
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:1946
const Position getBackUpShapePosition() const
get back up shape position
Definition: GNEEdge.cpp:578
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:503
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEEdge.cpp:1104
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEEdge.cpp:390
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1866
GNEMoveOperation * processMoveFromJunctionSelected(const PositionVector originalShape, const Position mousePosition, const double snapRadius)
process moving edge when only from junction is selected
Definition: GNEEdge.cpp:2268
void drawEdgeGeometryPoints(const GUIVisualizationSettings &s, const GNELane *lane) const
draw edge geometry points (note: This function is called by GNELane::drawGL(...)
Definition: GNEEdge.cpp:1263
GNEMoveOperation * processNoneJunctionSelected(const double snapRadius)
process moving edge when none junction are selected
Definition: GNEEdge.cpp:2368
std::vector< GNECrossing * > getGNECrossings()
get GNECrossings vinculated with this Edge
Definition: GNEEdge.cpp:684
GNELane * getLaneByDisallowedVClass(const SUMOVehicleClass vClass) const
return the first lane that disallow a vehicle of type vClass (or the first lane, if none was found)
Definition: GNEEdge.cpp:1159
void updateVehicleSpreadGeometries()
Definition: GNEEdge.cpp:1174
GNEMoveOperation * processMoveToJunctionSelected(const PositionVector originalShape, const Position mousePosition, const double snapRadius)
process moving edge when only to junction is selected
Definition: GNEEdge.cpp:2312
void updateJunctionPosition(GNEJunction *junction, const Position &origPos)
update edge geometry after junction move
Definition: GNEEdge.cpp:309
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:320
GNEEdge(GNENet *net, NBEdge *nbe, bool wasSplit=false, bool loaded=false)
Constructor.
Definition: GNEEdge.cpp:61
void setShapeEndPos(const Position &pos)
change Shape EndPos
Definition: GNEEdge.cpp:2113
const std::vector< GNEJunction * > & getParentJunctions() const
get parent junctions
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
Representation of a RouteProbe in netedit.
Definition: GNERouteProbe.h:32
The popup menu of a globject.
Stores the information about how to visualize structures.
The representation of a single edge during network building.
Definition: NBEdge.h:91
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:197
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:142