Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/network/GNEConnection.h
185790 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2016-2025 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
/****************************************************************************/
14
/// @file GNEConnection.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Jun 2016
17
///
18
// A class for represent connections between Lanes
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netbuild/NBEdge.h>
24
#include <utils/gui/div/GUIGeometry.h>
25
26
#include "GNENetworkElement.h"
27
28
// ===========================================================================
29
// class declarations
30
// ===========================================================================
31
32
class GNEEdge;
33
class GNEMoveElementConnection;
34
35
// ===========================================================================
36
// class definitions
37
// ===========================================================================
38
39
class GNEConnection : public GNENetworkElement {
40
41
/// @brief friend classses
42
friend class GNEMoveElementConnection;
43
44
public:
45
/** Constructor
46
* @param[in] from The edge the vehicles leave
47
* @param[in] connection NBEdge::Connection in which the rest of parameters are defined
48
* @param[in] uncontrolled if set to true, This connection will not be TLS-controlled despite its node being controlled.
49
**/
50
GNEConnection(GNELane* from, GNELane* to);
51
52
/// @brief Destructor
53
~GNEConnection();
54
55
/// @brief methods to retrieve the elements linked to this connection
56
/// @{
57
58
/// @brief get GNEMoveElement associated with this connection
59
GNEMoveElement* getMoveElement() const override;
60
61
/// @brief get parameters associated with this connection
62
Parameterised* getParameters() override;
63
64
/// @brief get parameters associated with this connection (constant)
65
const Parameterised* getParameters() const override;
66
67
/// @}
68
69
/// @name Functions related with geometry of element
70
/// @{
71
72
/// @brief get connection shape
73
const PositionVector& getConnectionShape() const;
74
75
/// @brief update pre-computed geometry information
76
void updateGeometry() override;
77
78
/// @brief Returns position of hierarchical element in view
79
Position getPositionInView() const;
80
81
/// @}
82
83
/// @name Function related with contour drawing
84
/// @{
85
86
/// @brief check if draw from contour (green)
87
bool checkDrawFromContour() const override;
88
89
/// @brief check if draw from contour (magenta)
90
bool checkDrawToContour() const override;
91
92
/// @brief check if draw related contour (cyan)
93
bool checkDrawRelatedContour() const override;
94
95
/// @brief check if draw over contour (orange)
96
bool checkDrawOverContour() const override;
97
98
/// @brief check if draw delete contour (pink/white)
99
bool checkDrawDeleteContour() const override;
100
101
/// @brief check if draw delete contour small (pink/white)
102
bool checkDrawDeleteContourSmall() const override;
103
104
/// @brief check if draw select contour (blue)
105
bool checkDrawSelectContour() const override;
106
107
/// @brief check if draw move contour (red)
108
bool checkDrawMoveContour() const override;
109
110
/// @}
111
112
/// @brief get the name of the edge the vehicles leave
113
GNEEdge* getEdgeFrom() const;
114
115
/// @brief get the name of the edge the vehicles may reach when leaving "from"
116
GNEEdge* getEdgeTo() const;
117
118
/// @briefthe get lane of the incoming lane
119
GNELane* getLaneFrom() const;
120
121
/// @briefthe get lane of the outgoing lane
122
GNELane* getLaneTo() const;
123
124
/// @briefthe get lane index of the incoming lane
125
int getFromLaneIndex() const;
126
127
/// @briefthe get lane index of the outgoing lane
128
int getToLaneIndex() const;
129
130
/// @brief get Edge::Connection
131
NBEdge::Connection& getNBEdgeConnection() const;
132
133
/// @brief get NBConnection
134
NBConnection getNBConnection() const;
135
136
/// @brief get LinkState
137
LinkState getLinkState() const;
138
139
/// @brief check that connection's Geometry has to be updated
140
void markConnectionGeometryDeprecated();
141
142
/// @brief update internal ID of Connection
143
void updateConnectionID();
144
145
/// @brief recompute cached myLinkState
146
void updateLinkState();
147
148
/// @brief smoothShape
149
void smootShape();
150
151
/// @name inherited from GUIGlObject
152
/// @{
153
/**@brief Returns an own popup-menu
154
*
155
* @param[in] app The application needed to build the popup-menu
156
* @param[in] parent The parent window needed to build the popup-menu
157
* @return The built popup-menu
158
* @see GUIGlObject::getPopUpMenu
159
*/
160
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
161
162
/// @brief return exaggeration associated with this GLObject
163
double getExaggeration(const GUIVisualizationSettings& s) const override;
164
165
/// @brief Returns the boundary to which the view shall be centered in order to show the object
166
Boundary getCenteringBoundary() const override;
167
168
/// @brief update centering boundary (implies change in RTREE)
169
void updateCenteringBoundary(const bool updateGrid);
170
171
/**@brief Draws the object
172
* @param[in] s The settings for the current view (may influence drawing)
173
* @see GUIGlObject::drawGL
174
*/
175
void drawGL(const GUIVisualizationSettings& s) const override;
176
177
/// @brief delete element
178
void deleteGLObject() override;
179
180
/// @brief update GLObject (geometry, ID, etc.)
181
void updateGLObject() override;
182
183
/// @}
184
185
/* @brief method for setting the special color of the connection
186
* @param[in] color Pointer to new special color
187
*/
188
void setSpecialColor(const RGBColor* Color2);
189
190
/// @name inherited from GNEAttributeCarrier
191
/// @{
192
/* @brief method for getting the Attribute of an XML key
193
* @param[in] key The attribute key
194
* @return string with the value associated to key
195
*/
196
std::string getAttribute(SumoXMLAttr key) const override;
197
198
/* @brief method for getting the Attribute of an XML key in double format
199
* @param[in] key The attribute key
200
* @return double with the value associated to key
201
*/
202
double getAttributeDouble(SumoXMLAttr key) const override;
203
204
/* @brief method for getting the Attribute of an XML key in position format
205
* @param[in] key The attribute key
206
* @return position with the value associated to key
207
*/
208
Position getAttributePosition(SumoXMLAttr key) const override;
209
210
/* @brief method for getting the Attribute of an XML key in positionVector format
211
* @param[in] key The attribute key
212
* @return positionVector with the value associated to key
213
*/
214
PositionVector getAttributePositionVector(SumoXMLAttr key) const override;
215
216
/* @brief method for setting the attribute and letting the object perform additional changes
217
* @param[in] key The attribute key
218
* @param[in] value The new value
219
* @param[in] undoList The undoList on which to register changes
220
*/
221
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
222
223
/* @brief method for checking if the key and their conrrespond attribute are valids
224
* @param[in] key The attribute key
225
* @param[in] value The value associated to key key
226
* @return true if the value is valid, false in other case
227
*/
228
bool isValid(SumoXMLAttr key, const std::string& value) override;
229
230
/* @brief method for check if the value for certain attribute is set
231
* @param[in] key The attribute key
232
*/
233
bool isAttributeEnabled(SumoXMLAttr key) const override;
234
235
/* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
236
* @param[in] key The attribute key
237
*/
238
bool isAttributeComputed(SumoXMLAttr key) const override;
239
240
/// @}
241
242
protected:
243
/// @brief move element connection
244
GNEMoveElementConnection* myMoveElementConnection = nullptr;
245
246
/// @brief Linkstate. @note cached because after 'undo' the connection needs to be drawn while the node logic (NBRequest) has not been recomputed
247
LinkState myLinkState;
248
249
/// @brief optional special color
250
const RGBColor* mySpecialColor;
251
252
/// @brief connection geometry
253
GUIGeometry myConnectionGeometry;
254
255
/// @brief junction maker geometry
256
GUIGeometry myInternalJunctionMarkerGeometry;
257
258
/// @brief flag to indicate that connection's shape has to be updated
259
bool myShapeDeprecated;
260
261
private:
262
/// @brief set attribute after validation
263
void setAttribute(SumoXMLAttr key, const std::string& value) override;
264
265
/// @brief manage change of tlLinkindices
266
void changeTLIndex(SumoXMLAttr key, int tlIndex, int tlIndex2, GNEUndoList* undoList);
267
268
/// @brief check if the edgeConnection vinculated with this connection exists
269
bool existNBEdgeConnection() const;
270
271
/// @brief check if draw connection
272
bool checkDrawConnection() const;
273
274
/// @brief get connection color
275
RGBColor getConnectionColor(const GUIVisualizationSettings& s) const;
276
277
/// @brief draw connection
278
void drawConnection(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
279
const GUIGeometry& superposedGeometry, const double exaggeration) const;
280
281
/// @brief draw arrows over connections
282
void drawConnectionArrows(const GUIVisualizationSettings& s, const GUIGeometry& superposedGeometry,
283
const RGBColor& color) const;
284
285
/// @brief draw edge value
286
void drawEdgeValues(const GUIVisualizationSettings& s, const PositionVector& shape) const;
287
288
/// @brief calculate connection contour
289
void calculateConnectionContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
290
const PositionVector& shape, const double exaggeration) const;
291
292
/// @brief Invalidated copy constructor.
293
GNEConnection(const GNEConnection&) = delete;
294
295
/// @brief Invalidated assignment operator.
296
GNEConnection& operator=(const GNEConnection&) = delete;
297
};
298
299