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-2020 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 "GNENetworkElement.h"
23 
24 #include <netbuild/NBEdge.h>
27 
28 
29 // ===========================================================================
30 // class declarations
31 // ===========================================================================
32 class GNENet;
33 class GNEJunction;
34 class GNELane;
35 class GNEConnection;
36 class GNERouteProbe;
37 class GNECrossing;
38 class GNEEdgeType;
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
50 
52  friend class GNEChange_Lane;
53  friend class GNEChange_Connection;
54 
55 public:
57  typedef std::vector<GNELane*> LaneVector;
58 
60  typedef std::vector<GNEConnection*> ConnectionVector;
61 
67  GNEEdge(GNENet* net, NBEdge* nbe, bool wasSplit = false, bool loaded = false);
68 
70  ~GNEEdge();
71 
75  void updateGeometry();
76 
80 
84  GNEMoveOperation* getMoveOperation(const double shapeOffset);
85 
87  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
89 
93  bool clickedOverShapeStart(const Position& pos);
94 
96  bool clickedOverShapeEnd(const Position& pos);
98 
100  void updateJunctionPosition(GNEJunction* junction, const Position& origPos);
101 
104 
112 
114  void updateCenteringBoundary(const bool updateGrid);
115 
117  const std::string getOptionalName() const;
118 
123  void drawGL(const GUIVisualizationSettings& s) const;
125 
127  NBEdge* getNBEdge() const;
128 
130  GNEEdge* getOppositeEdge() const;
131 
133  void editEndpoint(Position pos, GNEUndoList* undoList);
134 
136  void resetEndpoint(const Position& pos, GNEUndoList* undoList);
137 
139  void resetBothEndpoint(GNEUndoList* undoList);
140 
143  /* @brief method for getting the Attribute of an XML key
144  * @param[in] key The attribute key
145  * @return string with the value associated to key
146  */
147  std::string getAttribute(SumoXMLAttr key) const;
148  std::string getAttributeForSelection(SumoXMLAttr key) const;
149 
150  /* @brief method for setting the attribute and letting the object perform additional changes
151  * @param[in] key The attribute key
152  * @param[in] value The new value
153  * @param[in] undoList The undoList on which to register changes
154  */
155  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
156 
157  /* @brief method for setting the attribute and letting the object perform additional changes
158  * @param[in] key The attribute key
159  * @param[in] value The new value
160  * @param[in] undoList The undoList on which to register changes
161  */
162  bool isValid(SumoXMLAttr key, const std::string& value);
163 
164  /* @brief method for check if the value for certain attribute is set
165  * @param[in] key The attribute key
166  */
167  bool isAttributeEnabled(SumoXMLAttr key) const;
169 
171  const std::map<std::string, std::string>& getACParametersMap() const;
172 
174  void setResponsible(bool newVal);
175 
180  void setGeometry(PositionVector geom, bool inner);
181 
183  const Position getFrontUpShapePosition() const;
184 
186  const Position getFrontDownShapePosition() const;
187 
189  const Position getBackUpShapePosition() const;
190 
192  const Position getBackDownShapePosition() const;
193 
195  void remakeGNEConnections();
196 
198  void copyTemplate(const GNEInspectorFrame::TemplateEditor::EdgeTemplate& edgeTemplate, GNEUndoList* undoList);
199 
201  void copyEdgeType(const GNEEdgeType *edgeType, GNEUndoList* undoList);
202 
204  std::set<GUIGlID> getLaneGlIDs() const;
205 
207  const std::vector<GNELane*>& getLanes() const;
208 
210  const std::vector<GNEConnection*>& getGNEConnections() const;
211 
213  GNEConnection* retrieveGNEConnection(int fromLane, NBEdge* to, int toLane, bool createIfNoExist = true);
214 
216  bool wasSplit();
217 
218  /* @brief compute a splitting position which keeps the resulting edges
219  * straight unless the user clicked near a geometry point */
220  Position getSplitPos(const Position& clickPos);
221 
223  void setMicrosimID(const std::string& newID);
224 
226  bool hasRestrictedLane(SUMOVehicleClass vclass) const;
227 
228  // the radius in which to register clicks for geometry nodes
229  static const double SNAP_RADIUS;
230 
232  void clearGNEConnections();
233 
235  int getRouteProbeRelativePosition(GNERouteProbe* routeProbe) const;
236 
238  std::vector<GNECrossing*> getGNECrossings();
239 
241  void smooth(GNEUndoList* undoList);
242 
244  void straightenElevation(GNEUndoList* undoList);
245 
247  void smoothElevation(GNEUndoList* undoList);
248 
250  PositionVector smoothShape(const PositionVector& shape, bool forElevation);
251 
253  GNELane* getLaneByAllowedVClass(const SUMOVehicleClass vClass) const;
254 
257 
258  // @brief update vehicle spread geometries
260 
261  // @brief update vehicle geometries
263 
265  void drawEdgeGeometryPoints(const GUIVisualizationSettings& s, const GNELane* lane) const;
266 
267 protected:
270 
273 
276 
279 
282 
285 
287  std::string myConnectionStatus;
288 
289 private:
291  class StackPosition : public std::tuple<double, double> {
292 
293  public:
295  StackPosition(const double departPos, const double length);
296 
298  double beginPosition() const;
299 
301  double endPosition() const;
302  };
303 
305  class StackDemandElements : public std::tuple<StackPosition, std::vector<GNEDemandElement*> > {
306 
307  public:
309  StackDemandElements(const StackPosition stackedPosition, GNEDemandElement* demandElement);
310 
312  void addDemandElements(GNEDemandElement* demandElement);
313 
315  const StackPosition& getStackPosition() const;
316 
318  const std::vector<GNEDemandElement*>& getDemandElements() const;
319  };
320 
323 
325  void setAttribute(SumoXMLAttr key, const std::string& value);
326 
328  void setMoveShape(const GNEMoveResult& moveResult);
329 
331  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
332 
339  void setNumLanes(int numLanes, GNEUndoList* undoList);
340 
342  void updateFirstParentJunction(const std::string& value);
343 
345  void updateSecondParentJunction(const std::string& value);
346 
348  void addLane(GNELane* lane, const NBEdge::Lane& laneAttrs, bool recomputeConnections);
349 
351  void removeLane(GNELane* lane, bool recomputeConnections);
352 
354  void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation = false);
355 
358 
360  void removeEdgeFromCrossings(GNEJunction* junction, GNEUndoList* undoList);
361 
363  void setShapeStartPos(const Position& pos);
364 
366  void setShapeEndPos(const Position& pos);
367 
369  const std::map<const GNELane*, std::vector<GNEDemandElement*> > getVehiclesOverEdgeMap() const;
370 
372  void drawEdgeName(const GUIVisualizationSettings& s) const;
373 
375  bool areStackPositionOverlapped(const GNEEdge::StackPosition& vehicleA, const GNEEdge::StackPosition& vehicleB) const;
376 
378  GNEEdge(const GNEEdge& s) = delete;
379 
381  GNEEdge& operator=(const GNEEdge& s) = delete;
382 };
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:41
An Element which don't belongs to GNENet but has influency in the simulation.
Stack demand elements.
Definition: GNEEdge.h:305
const StackPosition & getStackPosition() const
get stack position
Definition: GNEEdge.cpp:1294
const std::vector< GNEDemandElement * > & getDemandElements() const
get demand elements
Definition: GNEEdge.cpp:1300
void addDemandElements(GNEDemandElement *demandElement)
add demand elment to current StackDemandElements
Definition: GNEEdge.cpp:1288
StackDemandElements(const StackPosition stackedPosition, GNEDemandElement *demandElement)
constructor
Definition: GNEEdge.cpp:1280
Stack position (used to stack demand elements over edges)
Definition: GNEEdge.h:291
double beginPosition() const
get begin position
Definition: GNEEdge.cpp:1269
StackPosition(const double departPos, const double length)
constructor
Definition: GNEEdge.cpp:1263
double endPosition() const
get end position
Definition: GNEEdge.cpp:1275
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
const Position getFrontDownShapePosition() const
get front down shape position
Definition: GNEEdge.cpp:532
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNEEdge.cpp:304
void drawEdgeName(const GUIVisualizationSettings &s) const
draw edge name
Definition: GNEEdge.cpp:1923
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:1480
void remakeGNEConnections()
remake connections
Definition: GNEEdge.cpp:555
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNEEdge.cpp:1453
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNEEdge.cpp:1431
GNEEdge * getOppositeEdge() const
get opposite edge
Definition: GNEEdge.cpp:350
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:82
void smooth(GNEUndoList *undoList)
make geometry smooth
Definition: GNEEdge.cpp:1817
void updateGeometry()
update pre-computed geometry information
Definition: GNEEdge.cpp:108
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNEEdge.cpp:815
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:1030
void copyEdgeType(const GNEEdgeType *edgeType, GNEUndoList *undoList)
copy edge attributes from edgeType
Definition: GNEEdge.cpp:679
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:399
GNEMoveOperation * getMoveOperation(const double shapeOffset)
get move operation for the given shapeOffset
Definition: GNEEdge.cpp:148
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEEdge.cpp:335
const std::map< const GNELane *, std::vector< GNEDemandElement * > > getVehiclesOverEdgeMap() const
get vehicles a that start over this edge
Definition: GNEEdge.cpp:1881
std::set< GUIGlID > getLaneGlIDs() const
returns GLIDs of all lanes
Definition: GNEEdge.cpp:713
const Position getFrontUpShapePosition() const
get front up shape position
Definition: GNEEdge.cpp:524
std::vector< GNEConnection * > ConnectionVector
Definition of the connection's vector.
Definition: GNEEdge.h:60
void setGeometry(PositionVector geom, bool inner)
update edge geometry and inform the lanes
Definition: GNEEdge.cpp:489
void smoothElevation(GNEUndoList *undoList)
smooth elevation with regard to adjoining edges
Definition: GNEEdge.cpp:1829
bool clickedOverShapeEnd(const Position &pos)
return true if user clicked over ShapeEnd
Definition: GNEEdge.cpp:280
void updateVehicleStackLabels()
Definition: GNEEdge.cpp:1097
GNEEdge & operator=(const GNEEdge &s)=delete
invalidated assignment operator
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:922
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition: GNEEdge.cpp:211
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:723
LaneVector myLanes
vector with the lanes of this edge
Definition: GNEEdge.h:272
static const double SNAP_RADIUS
Definition: GNEEdge.h:229
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:1036
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1653
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:284
void removeLane(GNELane *lane, bool recomputeConnections)
@briefdecrease the number of lanes by one. argument is only used to increase robustness (assertions)
Definition: GNEEdge.cpp:1578
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
Definition: GNEEdge.cpp:1712
void updateSecondParentJunction(const std::string &value)
update last parent junction
Definition: GNEEdge.cpp:1518
Position myPositionBeforeMoving
position used for move Lanes
Definition: GNEEdge.h:278
std::vector< GNELane * > LaneVector
Definition of the lane's vector.
Definition: GNEEdge.h:57
PositionVector smoothShape(const PositionVector &shape, bool forElevation)
return smoothed shape
Definition: GNEEdge.cpp:1744
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:735
NBEdge * myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:269
void removeEdgeFromCrossings(GNEJunction *junction, GNEUndoList *undoList)
remove crossing of junction
Definition: GNEEdge.cpp:1723
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNEEdge.cpp:141
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:1527
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:1681
ConnectionVector myGNEConnections
vector with the connections of this edge
Definition: GNEEdge.h:275
void editEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end, or remove current existent endpoint
Definition: GNEEdge.cpp:419
void resetBothEndpoint(GNEUndoList *undoList)
restores both endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:479
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:405
const std::vector< GNEConnection * > & getGNEConnections() const
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:729
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:741
void copyTemplate(const GNEInspectorFrame::TemplateEditor::EdgeTemplate &edgeTemplate, GNEUndoList *undoList)
copy edge attributes from edgetemplate
Definition: GNEEdge.cpp:652
int getRouteProbeRelativePosition(GNERouteProbe *routeProbe) const
obtain relative positions of RouteProbes
Definition: GNEEdge.cpp:617
std::string myConnectionStatus
modification status of the connections
Definition: GNEEdge.h:287
const std::string getOptionalName() const
Returns the street name.
Definition: GNEEdge.cpp:329
void clearGNEConnections()
clear current connections
Definition: GNEEdge.cpp:596
bool myUpdateGeometry
@brif flag to enable/disable update geometry of lanes (used mainly by setNumLanes)
Definition: GNEEdge.h:322
const Position getBackDownShapePosition() const
get back down shape position
Definition: GNEEdge.cpp:548
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:1989
void updateFirstParentJunction(const std::string &value)
update front parent junction
Definition: GNEEdge.cpp:1509
void straightenElevation(GNEUndoList *undoList)
interpolate z values linear between junctions
Definition: GNEEdge.cpp:1734
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNEEdge.cpp:1024
void setShapeStartPos(const Position &pos)
change Shape StartPos
Definition: GNEEdge.cpp:1859
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:825
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:1703
const Position getBackUpShapePosition() const
get back up shape position
Definition: GNEEdge.cpp:540
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:465
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEEdge.cpp:1013
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEEdge.cpp:356
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1629
void drawEdgeGeometryPoints(const GUIVisualizationSettings &s, const GNELane *lane) const
draw edge geometry points (note: This function is called by GNELane::drawGL(...)
Definition: GNEEdge.cpp:1155
bool clickedOverShapeStart(const Position &pos)
Definition: GNEEdge.cpp:270
std::vector< GNECrossing * > getGNECrossings()
get GNECrossings vinculated with this Edge
Definition: GNEEdge.cpp:635
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:1051
void updateVehicleSpreadGeometries()
Definition: GNEEdge.cpp:1066
void updateJunctionPosition(GNEJunction *junction, const Position &origPos)
update edge geometry after junction move
Definition: GNEEdge.cpp:290
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:281
GNEEdge(GNENet *net, NBEdge *nbe, bool wasSplit=false, bool loaded=false)
Constructor.
Definition: GNEEdge.cpp:55
void setShapeEndPos(const Position &pos)
change Shape EndPos
Definition: GNEEdge.cpp:1870
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
Representation of a RouteProbe in netedit.
Definition: GNERouteProbe.h:31
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:36
A list of positions.
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:188
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:142