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 #include <config.h>
26 
27 #include "GNENetElement.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 
113  int getVertexIndex(const Position& pos, bool createIfNoExist = true);
114 
120  int getVertexIndex(const double offset, bool createIfNoExist = true);
121 
127  int moveVertexShape(const int index, const Position& oldPos, const Position& offset);
128 
133  void moveEntireShape(const PositionVector& oldShape, const Position& offset);
134 
139  void commitShapeChange(const PositionVector& oldShape, GNEUndoList* undoList);
140 
142  void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
143 
145  void updateJunctionPosition(GNEJunction* junction, const Position& origPos, bool updateGrid);
146 
148  Boundary getBoundary() const;
149 
152 
160 
167 
172  void drawGL(const GUIVisualizationSettings& s) const;
174 
176  NBEdge* getNBEdge();
177 
180 
183 
185  GNEEdge* getOppositeEdge() const;
186 
188  void editEndpoint(Position pos, GNEUndoList* undoList);
189 
191  void resetEndpoint(const Position& pos, GNEUndoList* undoList);
192 
195  /* @brief method for getting the Attribute of an XML key
196  * @param[in] key The attribute key
197  * @return string with the value associated to key
198  */
199  std::string getAttribute(SumoXMLAttr key) const;
200  std::string getAttributeForSelection(SumoXMLAttr key) const;
201 
202  /* @brief method for setting the attribute and letting the object perform additional changes
203  * @param[in] key The attribute key
204  * @param[in] value The new value
205  * @param[in] undoList The undoList on which to register changes
206  */
207  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
208 
209  /* @brief method for setting the attribute and letting the object perform additional changes
210  * @param[in] key The attribute key
211  * @param[in] value The new value
212  * @param[in] undoList The undoList on which to register changes
213  */
214  bool isValid(SumoXMLAttr key, const std::string& value);
216 
219 
221  bool addGenericParameter(const std::string& key, const std::string& value);
222 
224  bool removeGenericParameter(const std::string& key);
225 
227  bool updateGenericParameter(const std::string& oldKey, const std::string& newKey);
228 
230  bool updateGenericParameterValue(const std::string& key, const std::string& newValue);
231 
233  std::string getGenericParametersStr() const;
234 
236  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
237 
239  void setGenericParametersStr(const std::string& value);
240 
242 
244  void setResponsible(bool newVal);
245 
250  void setGeometry(PositionVector geom, bool inner, bool updateGrid);
251 
253  void remakeGNEConnections();
254 
256  void copyTemplate(GNEEdge* tpl, GNEUndoList* undolist);
257 
259  std::set<GUIGlID> getLaneGlIDs();
260 
262  const std::vector<GNELane*>& getLanes();
263 
265  const std::vector<GNEConnection*>& getGNEConnections();
266 
268  GNEConnection* retrieveGNEConnection(int fromLane, NBEdge* to, int toLane, bool createIfNoExist = true);
269 
271  bool wasSplit();
272 
273  /* @brief compute a splitting position which keeps the resulting edges
274  * straight unless the user clicked near a geometry point */
275  Position getSplitPos(const Position& clickPos);
276 
278  void setMicrosimID(const std::string& newID);
279 
281  bool hasRestrictedLane(SUMOVehicleClass vclass) const;
282 
283  // the radius in which to register clicks for geometry nodes
284  static const double SNAP_RADIUS;
285 
287  void clearGNEConnections();
288 
290  int getRouteProbeRelativePosition(GNERouteProbe* routeProbe) const;
291 
293  std::vector<GNECrossing*> getGNECrossings();
294 
296  void removeEdgeOfAdditionalParents(GNEUndoList* undoList, bool allowEmpty);
297 
299  void smooth(GNEUndoList* undoList);
300 
302  void straightenElevation(GNEUndoList* undoList);
303 
305  void smoothElevation(GNEUndoList* undoList);
306 
308  PositionVector smoothShape(const PositionVector& shape, bool forElevation);
309 
310 protected:
313 
316 
319 
322 
325 
327  LaneVector myLanes;
328 
330  ConnectionVector myGNEConnections;
331 
334 
337 
339  std::string myConnectionStatus;
340 
341 private:
343  void setAttribute(SumoXMLAttr key, const std::string& value);
344 
346  void mouseOverObject(const GUIVisualizationSettings& s) const;
347 
354  void setNumLanes(int numLanes, GNEUndoList* undoList);
355 
357  void addLane(GNELane* lane, const NBEdge::Lane& laneAttrs, bool recomputeConnections);
358 
360  void removeLane(GNELane* lane, bool recomputeConnections);
361 
363  void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation = false);
364 
367 
369  void removeEdgeFromCrossings(GNEJunction* junction, GNEUndoList* undoList);
370 
372  void setShapeStartPos(const Position& pos);
373 
375  void setShapeEndPos(const Position& pos);
376 
378  GNEEdge(const GNEEdge& s) = delete;
379 
381  GNEEdge& operator=(const GNEEdge& s) = delete;
382 };
383 
384 
385 #endif
386 
387 /****************************************************************************/
388 
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
Definition: GNEEdge.cpp:800
GNEJunction * myGNEJunctionSource
pointer to GNEJunction source
Definition: GNEEdge.h:318
void remakeGNEConnections()
remake connections
Definition: GNEEdge.cpp:673
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:1356
bool removeGenericParameter(const std::string &key)
remove generic parameter
Definition: GNEEdge.cpp:1137
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEEdge.h:333
void smoothElevation(GNEUndoList *undoList)
smooth elevation with regard to adjoining edges
Definition: GNEEdge.cpp:1681
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEEdge.cpp:465
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:1376
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:419
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:339
GNEJunction * myGNEJunctionDestiny
pointer to GNEJunction destiny
Definition: GNEEdge.h:321
PositionVector myOrigShape
restore point for undo
Definition: GNEEdge.h:324
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:1555
void endGeometryMoving()
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
Definition: GNEEdge.cpp:233
void straightenElevation(GNEUndoList *undoList)
interpolate z values linear between junctions
Definition: GNEEdge.cpp:1586
std::set< GUIGlID > getLaneGlIDs()
returns GLIDs of all lanes
Definition: GNEEdge.cpp:822
Stores the information about how to visualize structures.
static const double SNAP_RADIUS
Definition: GNEEdge.h:284
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:168
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:1564
Representation of a RouteProbe in netedit.
Definition: GNERouteProbe.h:36
void smooth(GNEUndoList *undoList)
make geometry smooth
Definition: GNEEdge.cpp:1669
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:80
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:47
void setShapeEndPos(const Position &pos)
change Shape EndPos
Definition: GNEEdge.cpp:1722
void clearGNEConnections()
clear current connections
Definition: GNEEdge.cpp:712
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:178
void removeEdgeFromCrossings(GNEJunction *junction, GNEUndoList *undoList)
remove crossing of junction
Definition: GNEEdge.cpp:1575
const std::vector< GNEConnection * > & getGNEConnections()
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:838
void commitShapeStartChange(const Position &oldPos, GNEUndoList *undoList)
commit position changing in shape start
Definition: GNEEdge.cpp:188
PositionVector smoothShape(const PositionVector &shape, bool forElevation)
return smoothed shape
Definition: GNEEdge.cpp:1596
void removeLane(GNELane *lane, bool recomputeConnections)
the number of lanes by one. argument is only used to increase robustness (assertions) ...
Definition: GNEEdge.cpp:1429
bool myWasSplit
whether this edge was created from a split
Definition: GNEEdge.h:336
~GNEEdge()
Destructor.
Definition: GNEEdge.cpp:90
void editEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end, or remove current existent endpoint ...
Definition: GNEEdge.cpp:606
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:372
void setGeometry(PositionVector geom, bool inner, bool updateGrid)
update edge geometry and inform the lanes
Definition: GNEEdge.cpp:655
int getVertexIndex(const Position &pos, bool createIfNoExist=true)
return index of a vertex of shape, or of a new vertex if position is over an shape&#39;s edge ...
Definition: GNEEdge.cpp:261
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:116
void updateJunctionPosition(GNEJunction *junction, const Position &origPos, bool updateGrid)
update edge geometry after junction move
Definition: GNEEdge.cpp:390
bool updateGenericParameter(const std::string &oldKey, const std::string &newKey)
update generic parameter
Definition: GNEEdge.cpp:1148
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:850
void updateGeometry(bool updateGrid)
update pre-computed geometry information
Definition: GNEEdge.cpp:116
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:148
void commitShapeEndChange(const Position &oldPos, GNEUndoList *undoList)
commit position changing in shape end
Definition: GNEEdge.cpp:201
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNEEdge.cpp:1172
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:459
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNEEdge.cpp:1187
Representation of a vaporizer in netedit.
Definition: GNEVaporizer.h:36
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:453
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:1533
void startGeometryMoving()
Definition: GNEEdge.cpp:214
bool clickedOverShapeEnd(const Position &pos)
return true if user clicked over ShapeEnd
Definition: GNEEdge.cpp:158
GNEJunction * getGNEJunctionSource() const
returns the source-junction
Definition: GNEEdge.cpp:447
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEEdge.cpp:432
std::vector< GNECrossing * > getGNECrossings()
get GNECrossings vinculated with this Edge
Definition: GNEEdge.cpp:753
bool updateGenericParameterValue(const std::string &key, const std::string &newValue)
update value generic parameter
Definition: GNEEdge.cpp:1161
GNEEdge(NBEdge &nbe, GNENet *net, bool wasSplit=false, bool loaded=false)
Constructor.
Definition: GNEEdge.cpp:66
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:735
ConnectionVector myGNEConnections
vector with the connections of this edge
Definition: GNEEdge.h:330
int moveVertexShape(const int index, const Position &oldPos, const Position &offset)
change position of a vertex of shape without commiting change
Definition: GNEEdge.cpp:298
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:1223
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1479
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:832
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNEEdge.cpp:1198
PositionVector myMovingShape
variable used to save shape bevore moving (used to avoid inconsistences in GL Tree) ...
Definition: GNEEdge.h:315
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEEdge.cpp:325
bool addGenericParameter(const std::string &key, const std::string &value)
add generic parameter
Definition: GNEEdge.cpp:1126
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:1351
The popup menu of a globject.
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEEdge.cpp:1033
void removeEdgeOfAdditionalParents(GNEUndoList *undoList, bool allowEmpty)
remove Edge of Additional Parent
Definition: GNEEdge.cpp:770
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(...)
Definition: GNEEdge.cpp:342
LaneVector myLanes
vectgor with the lanes of this edge
Definition: GNEEdge.h:327
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1503
NBEdge & myNBEdge
the underlying NBEdge
Definition: GNEEdge.h:312
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:586
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:404
void setShapeStartPos(const Position &pos)
change Shape StartPos
Definition: GNEEdge.cpp:1711
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:932
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
Definition: GNEEdge.cpp:641
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNEEdge.cpp:923
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:844
Position getSplitPos(const Position &clickPos)
Definition: GNEEdge.cpp:592