Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/network/GNELane.h
185790 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-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 GNELane.h
15
/// @author Jakob Erdmann
16
/// @date Feb 2011
17
///
18
// A class for visualizing Lane geometry (adapted from GUILaneWrapper)
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netedit/elements/GNECandidateElement.h>
24
#include <netedit/elements/moving/GNEMoveResult.h>
25
#include <netedit/GNELane2laneConnection.h>
26
27
#include "GNENetworkElement.h"
28
29
// ===========================================================================
30
// class declarations
31
// ===========================================================================
32
33
class GNEConnection;
34
class GNEEdge;
35
class GNEMoveElementLane;
36
class GNEMoveOperation;
37
class GNENet;
38
class GNETLSEditorFrame;
39
class GUIGLObjectPopupMenu;
40
class PositionVector;
41
42
// ===========================================================================
43
// class definitions
44
// ===========================================================================
45
46
class GNELane : public GNENetworkElement, public GNECandidateElement, public FXDelegator {
47
/// @brief FOX-declaration
48
FXDECLARE_OVERRIDE(GNELane)
49
50
public:
51
/// @brief class for lane drawing constants
52
class DrawingConstants {
53
54
public:
55
/// @brief parameter constructor
56
DrawingConstants(const GNELane* lane);
57
58
/// @brief update lane drawing constants
59
void update(const GUIVisualizationSettings& s);
60
61
/// @brief get exaggeration
62
double getExaggeration() const;
63
64
/// @brief get lane drawing width
65
double getDrawingWidth() const;
66
67
/// @brief get internal lane drawing width
68
double getInternalDrawingWidth() const;
69
70
/// @brief get lane offset
71
double getOffset() const;
72
73
/// @brief get detail
74
GUIVisualizationSettings::Detail getDetail() const;
75
76
/// @brief draw as railway
77
bool drawAsRailway() const;
78
79
/// @brief draw superposed
80
bool drawSuperposed() const;
81
82
protected:
83
/// @brief lane
84
const GNELane* myLane;
85
86
/// @brief exaggeration
87
double myExaggeration = 0;
88
89
/// @brief lane drawing width
90
double myDrawingWidth = 0;
91
92
/// @brief internal lane drawing width (used for drawing selected lanes)
93
double myInternalDrawingWidth = 0;
94
95
/// @brief lane offset
96
double myOffset = 0;
97
98
/// @brief detail level
99
GUIVisualizationSettings::Detail myDetail = GUIVisualizationSettings::Detail::Level4;
100
101
/// @brief draw as railway
102
bool myDrawAsRailway = false;
103
104
/// @brief draw supersposed (reduced width so that the lane markings below are visible)
105
bool myDrawSuperposed = false;
106
107
private:
108
/// @brief invalidate default constructor
109
DrawingConstants() = delete;
110
111
/// @brief Invalidated copy constructor.
112
DrawingConstants(const DrawingConstants&) = delete;
113
114
/// @brief Invalidated assignment operator.
115
DrawingConstants& operator=(const DrawingConstants&) = delete;
116
};
117
118
/**@brief Constructor
119
* @param[in] idStorage The storage of gl-ids to get the one for this lane representation from
120
* @param[in] the edge this lane belongs to
121
* @param[in] the index of this lane
122
*/
123
GNELane(GNEEdge* edge, const int index);
124
125
/// @brief Destructor
126
~GNELane();
127
128
/// @brief methods to retrieve the elements linked to this lane
129
/// @{
130
131
/// @brief get GNEMoveElement associated with this lane
132
GNEMoveElement* getMoveElement() const override;
133
134
/// @brief get parameters associated with this lane
135
Parameterised* getParameters() override;
136
137
/// @brief get parameters associated with this lane
138
const Parameterised* getParameters() const override;
139
140
/// @}
141
142
/// @brief get parent edge
143
GNEEdge* getParentEdge() const;
144
145
/// @brief check if current lane allow pedestrians
146
bool allowPedestrians() const;
147
148
/// @name Functions related with geometry of element
149
/// @{
150
151
/// @brief get lane geometry
152
const GUIGeometry& getLaneGeometry() const;
153
154
/// @brief get elements shape
155
const PositionVector& getLaneShape() const;
156
157
/// @brief get rotations of the single shape parts
158
const std::vector<double>& getShapeRotations() const;
159
160
/// @brief get lengths of the single shape parts
161
const std::vector<double>& getShapeLengths() const;
162
163
/// @brief get lane drawing constants (previously calculated in drawGL())
164
const DrawingConstants* getDrawingConstants() const;
165
166
/// @brief update pre-computed geometry information
167
void updateGeometry() override;
168
169
/// @brief Returns position of hierarchical element in view
170
Position getPositionInView() const;
171
172
/// @}
173
174
/// @name Function related with contour drawing
175
/// @{
176
177
/// @brief check if draw from contour (green)
178
bool checkDrawFromContour() const override;
179
180
/// @brief check if draw from contour (magenta)
181
bool checkDrawToContour() const override;
182
183
/// @brief check if draw related contour (cyan)
184
bool checkDrawRelatedContour() const override;
185
186
/// @brief check if draw over contour (orange)
187
bool checkDrawOverContour() const override;
188
189
/// @brief check if draw delete contour (pink/white)
190
bool checkDrawDeleteContour() const override;
191
192
/// @brief check if draw delete contour small (pink/white)
193
bool checkDrawDeleteContourSmall() const override;
194
195
/// @brief check if draw select contour (blue)
196
bool checkDrawSelectContour() const override;
197
198
/// @brief check if draw move contour (red)
199
bool checkDrawMoveContour() const override;
200
201
/// @}
202
203
/// @brief returns a vector with the incoming GNEConnections of this lane
204
std::vector<GNEConnection*> getGNEIncomingConnections();
205
206
/// @brief returns a vector with the outgoing GNEConnections of this lane
207
std::vector<GNEConnection*> getGNEOutcomingConnections();
208
209
/// @brief update IDs of incoming connections of this lane
210
void updateConnectionIDs();
211
212
/// @brief get length geometry factor
213
double getLengthGeometryFactor() const;
214
215
/// @name inherited from GUIGlObject
216
/// @{
217
// @brief Returns the name of the parent object (if any)
218
// @return This object's parent id
219
std::string getParentName() const override;
220
221
/**@brief Returns an own popup-menu
222
*
223
* @param[in] app The application needed to build the popup-menu
224
* @param[in] parent The parent window needed to build the popup-menu
225
* @return The built popup-menu
226
* @see GUIGlObject::getPopUpMenu
227
*/
228
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
229
230
/// @brief multiplexes message to two targets
231
long onDefault(FXObject*, FXSelector, void*) override;
232
233
/// @brief return exaggeration associated with this GLObject
234
double getExaggeration(const GUIVisualizationSettings& s) const override;
235
236
/// @brief Returns the boundary to which the view shall be centered in order to show the object
237
Boundary getCenteringBoundary() const override;
238
239
/// @brief update centering boundary (implies change in RTREE)
240
void updateCenteringBoundary(const bool updateGrid);
241
242
/**@brief Draws the object
243
* @param[in] s The settings for the current view (may influence drawing)
244
* @see GUIGlObject::drawGL
245
*/
246
void drawGL(const GUIVisualizationSettings& s) const override;
247
248
/// @brief delete element
249
void deleteGLObject() override;
250
251
/// @brief update GLObject (geometry, ID, etc.)
252
void updateGLObject() override;
253
/// @}
254
255
/// @brief returns the index of the lane
256
int getIndex() const;
257
258
/// @brief returns the current speed of lane
259
double getSpeed() const;
260
261
/* @brief method for setting the index of the lane
262
* @param[in] index The new index of lane
263
*/
264
void setIndex(int index);
265
266
/** @brief returns the parameteric length of the lane
267
* @note is the same as their Edge parent, and cannot be never nullptr
268
*/
269
double getLaneParametricLength() const;
270
271
/// @brief returns the length of the lane's shape
272
double getLaneShapeLength() const;
273
274
/// @brief check if this lane is restricted
275
bool isRestricted(SUMOVehicleClass vclass) const;
276
277
/// @brief get Lane2laneConnection struct
278
const GNELane2laneConnection& getLane2laneConnections() const;
279
280
/// @name inherited from GNEAttributeCarrier
281
/// @{
282
/* @brief method for getting the Attribute of an XML key
283
* @param[in] key The attribute key
284
* @return string with the value associated to key
285
*/
286
std::string getAttribute(SumoXMLAttr key) const override;
287
std::string getAttributeForSelection(SumoXMLAttr key) const override;
288
289
/* @brief method for getting the Attribute of an XML key in double format
290
* @param[in] key The attribute key
291
* @return double with the value associated to key
292
*/
293
double getAttributeDouble(SumoXMLAttr key) const override;
294
295
/* @brief method for getting the Attribute of an XML key in position format
296
* @param[in] key The attribute key
297
* @return position with the value associated to key
298
*/
299
Position getAttributePosition(SumoXMLAttr key) const override;
300
301
/* @brief method for getting the Attribute of an XML key in Position format
302
* @param[in] key The attribute key
303
* @return position with the value associated to key
304
*/
305
PositionVector getAttributePositionVector(SumoXMLAttr key) const override;
306
307
/* @brief method for setting the attribute and letting the object perform additional changes
308
* @param[in] key The attribute key
309
* @param[in] value The new value
310
* @param[in] undoList The undoList on which to register changes
311
*/
312
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
313
314
/* @brief method for checking if the key and their correspond attribute are valids
315
* @param[in] key The attribute key
316
* @param[in] value The value associated to key key
317
* @return true if the value is valid, false in other case
318
*/
319
bool isValid(SumoXMLAttr key, const std::string& value) override;
320
321
/* @brief method for check if the value for certain attribute is set
322
* @param[in] key The attribute key
323
*/
324
bool isAttributeEnabled(SumoXMLAttr key) const override;
325
326
/* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
327
* @param[in] key The attribute key
328
*/
329
bool isAttributeComputed(SumoXMLAttr key) const override;
330
331
/// @}
332
333
/* @brief method for setting the special color of the lane
334
* @param[in] color Pointer to new special color
335
*/
336
void setSpecialColor(const RGBColor* Color2, double colorValue = std::numeric_limits<double>::max());
337
338
/// @brief return value for lane coloring according to the given scheme
339
double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
340
341
/// @brief draw overlapped routes
342
void drawOverlappedRoutes(const int numRoutes) const;
343
344
/// @brief draw laneStopOffset
345
void drawLaneStopOffset(const GUIVisualizationSettings& s) const;
346
347
protected:
348
/// @brief FOX needs this
349
GNELane();
350
351
private:
352
/// @brief move element lane
353
GNEMoveElementLane* myMoveElementLane = nullptr;
354
355
/// @brief The index of this lane
356
int myIndex;
357
358
/// @brief lane geometry
359
GUIGeometry myLaneGeometry;
360
361
/// @brief LaneDrawingConstants
362
DrawingConstants* myDrawingConstants;
363
364
/// @name computed only once (for performance) in updateGeometry()
365
/// @{
366
367
/// @brief Position of textures of restricted lanes
368
std::vector<Position> myLaneRestrictedTexturePositions;
369
370
/// @brief Rotations of textures of restricted lanes
371
std::vector<double> myLaneRestrictedTextureRotations;
372
/// @}
373
374
/// @brief optional special color
375
const RGBColor* mySpecialColor;
376
377
/// @brief optional value that corresponds to which the special color corresponds
378
double mySpecialColorValue;
379
380
/// @brief The color of the shape parts (cached)
381
mutable std::vector<RGBColor> myShapeColors;
382
383
/// @brief lane2lane connections
384
GNELane2laneConnection myLane2laneConnections;
385
386
/// @brief set attribute after validation
387
void setAttribute(SumoXMLAttr key, const std::string& value) override;
388
389
/// @brief draw lane
390
void drawLane(const GUIVisualizationSettings& s, const double layer) const;
391
392
/// @brief draw selected lane
393
void drawSelectedLane(const GUIVisualizationSettings& s) const;
394
395
/// @brief draw shape edited
396
void drawShapeEdited(const GUIVisualizationSettings& s) const;
397
398
/// @brief draw children
399
void drawChildren(const GUIVisualizationSettings& s) const;
400
401
/// @brief draw lane markings
402
void drawMarkingsAndBoundings(const GUIVisualizationSettings& s) const;
403
404
/// @brief draw link Number
405
void drawLinkNo(const GUIVisualizationSettings& s) const;
406
407
/// @brief draw TLS link Number
408
void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
409
410
/// @brief draw lane arrows
411
void drawArrows(const GUIVisualizationSettings& s) const;
412
413
/// @brief draw lane to lane connections
414
void drawLane2LaneConnections() const;
415
416
/// @brief calculate contour
417
void calculateLaneContour(const GUIVisualizationSettings& s, const double layer) const;
418
419
/// @brief sets the color according to the current scheme index and some lane function
420
bool setFunctionalColor(int activeScheme, RGBColor& col) const;
421
422
/// @brief sets multiple colors according to the current scheme index and some lane function
423
bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
424
425
/// @brief whether to draw this lane as a waterways
426
bool drawAsWaterway(const GUIVisualizationSettings& s) const;
427
428
/// @brief direction indicators for lanes
429
void drawDirectionIndicators(const GUIVisualizationSettings& s) const;
430
431
/// @brief draw lane as railway
432
void drawLaneAsRailway() const;
433
434
/// @brief draw lane textures
435
void drawTextures(const GUIVisualizationSettings& s) const;
436
437
/// @brief draw start and end geometry points
438
void drawStartEndGeometryPoints(const GUIVisualizationSettings& s) const;
439
440
/// @brief set color according to edit mode and visualisation settings
441
RGBColor setLaneColor(const GUIVisualizationSettings& s) const;
442
443
/// @brief build edge operations contextual menu
444
void buildEdgeOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret);
445
446
/// @brief build lane operations contextual menu
447
void buildLaneOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret);
448
449
/// @brief build template oerations contextual menu
450
void buildTemplateOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret);
451
452
/// @brief build rechable operations contextual menu
453
void buildRechableOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret);
454
455
/// @brief Invalidated copy constructor.
456
GNELane(const GNELane&) = delete;
457
458
/// @brief Invalidated assignment operator.
459
GNELane& operator=(const GNELane&) = delete;
460
};
461
462