Eclipse SUMO - Simulation of Urban MObility
GNEConnection.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2016-2024 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 class for represent connections between Lanes
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 #include "GNENetworkElement.h"
23 
24 #include <netbuild/NBEdge.h>
25 
26 // ===========================================================================
27 // class declarations
28 // ===========================================================================
29 class GNEEdge;
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
35 
37 public:
43  GNEConnection(GNELane* from, GNELane* to);
44 
47 
50 
52  const PositionVector& getConnectionShape() const;
53 
55  void updateGeometry();
56 
59 
61 
64 
66  bool checkDrawFromContour() const;
67 
69  bool checkDrawToContour() const;
70 
72  bool checkDrawRelatedContour() const;
73 
75  bool checkDrawOverContour() const;
76 
78  bool checkDrawDeleteContour() const;
79 
81  bool checkDrawSelectContour() const;
82 
84  bool checkDrawMoveContour() const;
85 
87 
90 
93 
95  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
96 
98 
100  GNEEdge* getEdgeFrom() const;
101 
103  GNEEdge* getEdgeTo() const;
104 
106  GNELane* getLaneFrom() const;
107 
109  GNELane* getLaneTo() const;
110 
112  int getFromLaneIndex() const;
113 
115  int getToLaneIndex() const;
118 
121 
123  LinkState getLinkState() const;
124 
127 
129  void updateConnectionID();
130 
132  void updateLinkState();
133 
135  void smootShape();
136 
139 
147 
149  double getExaggeration(const GUIVisualizationSettings& s) const;
150 
153 
155  void updateCenteringBoundary(const bool updateGrid);
156 
161  void drawGL(const GUIVisualizationSettings& s) const;
162 
164  void deleteGLObject();
165 
167  void updateGLObject();
168 
170 
171  /* @brief method for setting the special color of the connection
172  * @param[in] color Pointer to new special color
173  */
174  void setSpecialColor(const RGBColor* Color2);
175 
178  /* @brief method for getting the Attribute of an XML key
179  * @param[in] key The attribute key
180  * @return string with the value associated to key
181  */
182  std::string getAttribute(SumoXMLAttr key) const;
183 
184  /* @brief method for getting the Attribute of an XML key in PositionVector format
185  * @param[in] key The attribute key
186  * @return position with the value associated to key
187  */
189 
190  /* @brief method for setting the attribute and letting the object perform additional changes
191  * @param[in] key The attribute key
192  * @param[in] value The new value
193  * @param[in] undoList The undoList on which to register changes
194  */
195  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
196 
197  /* @brief method for checking if the key and their conrrespond attribute are valids
198  * @param[in] key The attribute key
199  * @param[in] value The value associated to key key
200  * @return true if the value is valid, false in other case
201  */
202  bool isValid(SumoXMLAttr key, const std::string& value);
203 
204  /* @brief method for check if the value for certain attribute is set
205  * @param[in] key The attribute key
206  */
207  bool isAttributeEnabled(SumoXMLAttr key) const;
208 
209  /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
210  * @param[in] key The attribute key
211  */
212  bool isAttributeComputed(SumoXMLAttr key) const;
214 
216  const Parameterised::Map& getACParametersMap() const;
217 
218 protected:
221 
224 
227 
230 
233 
236 
239 
240 private:
242  void setAttribute(SumoXMLAttr key, const std::string& value);
243 
245  void setMoveShape(const GNEMoveResult& moveResult);
246 
248  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
249 
251  void changeTLIndex(SumoXMLAttr key, int tlIndex, int tlIndex2, GNEUndoList* undoList);
252 
254  bool existNBEdgeConnection() const;
255 
257  bool checkDrawConnection() const;
258 
261 
264  const PositionVector& shape, const double exaggeration) const;
265 
267  void drawConnectionArrows(const GUIVisualizationSettings& s, const RGBColor& color) const;
268 
270  void drawEdgeValues(const GUIVisualizationSettings& s, const PositionVector& shape) const;
271 
274  const PositionVector& shape, const double exaggeration) const;
275 
277  GNEConnection(const GNEConnection&) = delete;
278 
281 };
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
void updateConnectionID()
update internal ID of Connection
NBConnection getNBConnection() const
get NBConnection
Position getPositionInView() const
Returns position of hierarchical element in view.
GNELane * getLaneFrom() const
@briefthe get lane of the incoming lane
void smootShape()
smoothShape
const PositionVector & getConnectionShape() const
get connection shape
bool checkDrawSelectContour() const
check if draw select contour (blue)
GNELane * getLaneTo() const
@briefthe get lane of the outgoing lane
GNELane * myFromLane
incoming lane of this connection
LinkState getLinkState() const
get LinkState
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
int getFromLaneIndex() const
@briefthe get lane index of the incoming lane
void deleteGLObject()
delete element
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
GUIGeometry myConnectionGeometry
connection geometry
GNELane * myToLane
outgoing lane of this connection
bool checkDrawOverContour() const
check if draw over contour (orange)
void drawEdgeValues(const GUIVisualizationSettings &s, const PositionVector &shape) const
draw edge value
bool checkDrawFromContour() const
check if draw from contour (green)
bool existNBEdgeConnection() const
check if the edgeConnection vinculated with this connection exists
std::string getAttribute(SumoXMLAttr key) const
GNEEdge * getEdgeFrom() const
get the name of the edge the vehicles leave
bool isAttributeComputed(SumoXMLAttr key) const
void markConnectionGeometryDeprecated()
check that connection's Geometry has to be updated
PositionVector getAttributePositionVector(SumoXMLAttr key) const
GNEConnection(GNELane *from, GNELane *to)
void drawConnection(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const PositionVector &shape, const double exaggeration) const
draw connection
GNEEdge * getEdgeTo() const
get the name of the edge the vehicles may reach when leaving "from"
NBEdge::Connection & getNBEdgeConnection() const
get Edge::Connection
void setSpecialColor(const RGBColor *Color2)
void drawConnectionArrows(const GUIVisualizationSettings &s, const RGBColor &color) const
draw arrows over connections
GNEMoveOperation * getMoveOperation()
get move operation for the given shapeOffset (can be nullptr)
void updateGeometry()
update pre-computed geometry information
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
GNEConnection(const GNEConnection &)=delete
Invalidated copy constructor.
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
bool isValid(SumoXMLAttr key, const std::string &value)
const RGBColor * mySpecialColor
optional special color
~GNEConnection()
Destructor.
int getToLaneIndex() const
@briefthe get lane index of the outgoing lane
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
bool myShapeDeprecated
flag to indicate that connection's shape has to be updated
void calculateConnectionContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const PositionVector &shape, const double exaggeration) const
calculate connection contour
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
void updateLinkState()
recompute cached myLinkState
const Parameterised::Map & getACParametersMap() const
get parameters map
bool checkDrawConnection() const
check if draw connection
PositionVector myInternalJunctionMarker
waiting position for internal junction
RGBColor getConnectionColor(const GUIVisualizationSettings &s) const
get connection color
bool checkDrawMoveContour() const
check if draw move contour (red)
bool isAttributeEnabled(SumoXMLAttr key) const
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
GNEConnection & operator=(const GNEConnection &)=delete
Invalidated assignment operator.
LinkState myLinkState
Linkstate.
void updateGLObject()
update GLObject (geometry, ID, etc.)
bool checkDrawToContour() const
check if draw from contour (magenta)
void changeTLIndex(SumoXMLAttr key, int tlIndex, int tlIndex2, GNEUndoList *undoList)
manage change of tlLinkindices
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
move operation
move result
The popup menu of a globject.
Stores the information about how to visualize structures.
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
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:201