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-2018 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 
76  void updateGeometry(bool updateGrid);
77 
81  bool clickedOverShapeStart(const Position& pos);
82 
84  bool clickedOverShapeEnd(const Position& pos);
85 
87  void moveShapeStart(const Position& oldPos, const Position& offset);
88 
90  void moveShapeEnd(const Position& oldPos, const Position& offset);
91 
93  void commitShapeStartChange(const Position& oldPos, GNEUndoList* undoList);
94 
96  void commitShapeEndChange(const Position& oldPos, GNEUndoList* undoList);
98 
102  void startGeometryMoving();
103 
105  void endGeometryMoving();
107 
114  int getVertexIndex(Position pos, bool createIfNoExist, bool snapToGrid);
115 
122  int getVertexIndex(const double offset, bool createIfNoExist, bool snapToGrid);
123 
129  int moveVertexShape(const int index, const Position& oldPos, const Position& offset);
130 
135  void moveEntireShape(const PositionVector& oldShape, const Position& offset);
136 
141  void commitShapeChange(const PositionVector& oldShape, GNEUndoList* undoList);
142 
144  void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
145 
147  void updateJunctionPosition(GNEJunction* junction, const Position& origPos, bool updateGrid);
148 
150  Boundary getBoundary() const;
151 
154 
162 
169 
174  void drawGL(const GUIVisualizationSettings& s) const;
176 
178  NBEdge* getNBEdge();
179 
182 
185 
187  GNEEdge* getOppositeEdge() const;
188 
190  void editEndpoint(Position pos, GNEUndoList* undoList);
191 
193  void resetEndpoint(const Position& pos, GNEUndoList* undoList);
194 
197  /* @brief method for getting the Attribute of an XML key
198  * @param[in] key The attribute key
199  * @return string with the value associated to key
200  */
201  std::string getAttribute(SumoXMLAttr key) const;
202  std::string getAttributeForSelection(SumoXMLAttr key) const;
203 
204  /* @brief method for setting the attribute and letting the object perform additional changes
205  * @param[in] key The attribute key
206  * @param[in] value The new value
207  * @param[in] undoList The undoList on which to register changes
208  */
209  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
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  bool isValid(SumoXMLAttr key, const std::string& value);
218 
221 
223  std::string getGenericParametersStr() const;
224 
226  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
227 
229  void setGenericParametersStr(const std::string& value);
230 
232 
234  void setResponsible(bool newVal);
235 
240  void setGeometry(PositionVector geom, bool inner, bool updateGrid);
241 
243  void remakeGNEConnections();
244 
246  void copyTemplate(GNEEdge* tpl, GNEUndoList* undolist);
247 
249  std::set<GUIGlID> getLaneGlIDs();
250 
252  const std::vector<GNELane*>& getLanes();
253 
255  const std::vector<GNEConnection*>& getGNEConnections();
256 
258  GNEConnection* retrieveGNEConnection(int fromLane, NBEdge* to, int toLane, bool createIfNoExist = true);
259 
261  bool wasSplit();
262 
263  /* @brief compute a splitting position which keeps the resulting edges
264  * straight unless the user clicked near a geometry point */
265  Position getSplitPos(const Position& clickPos);
266 
268  void setMicrosimID(const std::string& newID);
269 
271  bool hasRestrictedLane(SUMOVehicleClass vclass) const;
272 
273  // the radius in which to register clicks for geometry nodes
274  static const double SNAP_RADIUS;
275 
278 
280  void clearGNEConnections();
281 
283  int getRouteProbeRelativePosition(GNERouteProbe* routeProbe) const;
284 
286  std::vector<GNECrossing*> getGNECrossings();
287 
290 
292  void smooth(GNEUndoList* undoList);
293 
295  void straightenElevation(GNEUndoList* undoList);
296 
298  void smoothElevation(GNEUndoList* undoList);
299 
301  PositionVector smoothShape(const PositionVector& shape, bool forElevation);
302 
303 protected:
306 
309 
312 
315 
317  LaneVector myLanes;
318 
320  ConnectionVector myGNEConnections;
321 
324 
327 
329  std::string myConnectionStatus;
330 
331 private:
333  void setAttribute(SumoXMLAttr key, const std::string& value);
334 
336  void mouseOverObject(const GUIVisualizationSettings& s) const;
337 
344  void setNumLanes(int numLanes, GNEUndoList* undoList);
345 
347  void addLane(GNELane* lane, const NBEdge::Lane& laneAttrs, bool recomputeConnections);
348 
350  void removeLane(GNELane* lane, bool recomputeConnections);
351 
353  void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation = false);
354 
357 
359  void removeEdgeFromCrossings(GNEJunction* junction, GNEUndoList* undoList);
360 
362  void setShapeStartPos(const Position& pos, bool updateGrid);
363 
365  void setShapeEndPos(const Position& pos, bool updateGrid);
366 
368  GNEEdge(const GNEEdge& s) = delete;
369 
371  GNEEdge& operator=(const GNEEdge& s) = delete;
372 
374  GNEEdge();
375 };
376 
377 
378 #endif
379 
380 /****************************************************************************/
381 
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
Definition: GNEEdge.cpp:841
GNEJunction * myGNEJunctionSource
pointer to GNEJunction source
Definition: GNEEdge.h:311
void remakeGNEConnections()
remake connections
Definition: GNEEdge.cpp:709
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:160
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:1340
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:323
void smoothElevation(GNEUndoList *undoList)
smooth elevation with regard to adjoining edges
Definition: GNEEdge.cpp:1701
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEEdge.cpp:476
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:1360
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:430
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:329
GNEJunction * myGNEJunctionDestiny
pointer to GNEJunction destiny
Definition: GNEEdge.h:314
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:1575
void endGeometryMoving()
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
Definition: GNEEdge.cpp:243
GNEEdge()
constructor for dummy edge
Definition: GNEEdge.cpp:82
void straightenElevation(GNEUndoList *undoList)
interpolate z values linear between junctions
Definition: GNEEdge.cpp:1606
std::set< GUIGlID > getLaneGlIDs()
returns GLIDs of all lanes
Definition: GNEEdge.cpp:863
Stores the information about how to visualize structures.
static const double SNAP_RADIUS
Definition: GNEEdge.h:274
The representation of a single edge during network building.
Definition: NBEdge.h:65
void moveShapeStart(const Position &oldPos, const Position &offset)
move position of shape start without commiting change
Definition: GNEEdge.cpp:166
std::vector< GNELane * > LaneVector
Definition of the lane&#39;s vector.
Definition: GNEEdge.h:58
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
Definition: GNEEdge.cpp:1584
Representation of a RouteProbe in netedit.
Definition: GNERouteProbe.h:35
void smooth(GNEUndoList *undoList)
make geometry smooth
Definition: GNEEdge.cpp:1689
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:47
void setShapeStartPos(const Position &pos, bool updateGrid)
change Shape StartPos
Definition: GNEEdge.cpp:1731
void clearGNEConnections()
clear current connections
Definition: GNEEdge.cpp:748
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:182
void removeEdgeFromCrossings(GNEJunction *junction, GNEUndoList *undoList)
remove crossing of junction
Definition: GNEEdge.cpp:1595
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:271
const std::vector< GNEConnection * > & getGNEConnections()
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:879
void commitShapeStartChange(const Position &oldPos, GNEUndoList *undoList)
commit position changing in shape start
Definition: GNEEdge.cpp:198
PositionVector smoothShape(const PositionVector &shape, bool forElevation)
return smoothed shape
Definition: GNEEdge.cpp:1616
void removeLane(GNELane *lane, bool recomputeConnections)
the number of lanes by one. argument is only used to increase robustness (assertions) ...
Definition: GNEEdge.cpp:1413
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:326
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:88
void editEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end, or remove current existent endpoint ...
Definition: GNEEdge.cpp:633
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:383
void setGeometry(PositionVector geom, bool inner, bool updateGrid)
update edge geometry and inform the lanes
Definition: GNEEdge.cpp:691
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:116
static GNEEdge DummyEdge
Dummy edge to use when a reference must be supplied in the no-arguments constructor (FOX technicality...
Definition: GNEEdge.h:277
void updateJunctionPosition(GNEJunction *junction, const Position &origPos, bool updateGrid)
update edge geometry after junction move
Definition: GNEEdge.cpp:401
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:891
void updateGeometry(bool updateGrid)
update pre-computed geometry information
Definition: GNEEdge.cpp:114
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:146
void commitShapeEndChange(const Position &oldPos, GNEUndoList *undoList)
commit position changing in shape end
Definition: GNEEdge.cpp:211
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNEEdge.cpp:1160
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
A list of positions.
GNEEdge * getOppositeEdge() const
get opposite edge
Definition: GNEEdge.cpp:470
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNEEdge.cpp:1175
Representation of a vaporizer in netedit.
Definition: GNEVaporizer.h:35
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:464
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:1541
void startGeometryMoving()
Definition: GNEEdge.cpp:224
bool clickedOverShapeEnd(const Position &pos)
return true if user clicked over ShapeEnd
Definition: GNEEdge.cpp:156
GNEJunction * getGNEJunctionSource() const
returns the source-junction
Definition: GNEEdge.cpp:458
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEEdge.cpp:443
std::vector< GNECrossing * > getGNECrossings()
get GNECrossings vinculated with this Edge
Definition: GNEEdge.cpp:789
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:771
ConnectionVector myGNEConnections
vector with the connections of this edge
Definition: GNEEdge.h:320
int moveVertexShape(const int index, const Position &oldPos, const Position &offset)
change position of a vertex of shape without commiting change
Definition: GNEEdge.cpp:315
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:1211
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1463
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:873
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNEEdge.cpp:1186
PositionVector myMovingShape
variable used to save shape bevore moving (used to avoid inconsistences in GL Tree) ...
Definition: GNEEdge.h:308
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEEdge.cpp:340
GNEEdge & operator=(const GNEEdge &s)=delete
invalidated assignment operator
void mouseOverObject(const GUIVisualizationSettings &s) const
method for check if mouse is over objects
Definition: GNEEdge.cpp:1335
The popup menu of a globject.
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:1071
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(...)
Definition: GNEEdge.cpp:353
LaneVector myLanes
vectgor with the lanes of this edge
Definition: GNEEdge.h:317
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1499
NBEdge & myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:305
void setShapeEndPos(const Position &pos, bool updateGrid)
change Shape EndPos
Definition: GNEEdge.cpp:1742
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:613
std::vector< GNEConnection * > ConnectionVector
Definition of the connection&#39;s vector.
Definition: GNEEdge.h:61
Boundary getBoundary() const
Returns the street&#39;s geometry.
Definition: GNEEdge.cpp:415
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:971
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:677
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNEEdge.cpp:962
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:885
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:619
void removeEdgeOfAdditionalParents(GNEUndoList *undoList)
remove Edge of Additional Parent
Definition: GNEEdge.cpp:806