Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNELane.h
Go to the documentation of this file.
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/****************************************************************************/
18// A class for visualizing Lane geometry (adapted from GUILaneWrapper)
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
26
27#include "GNENetworkElement.h"
28
29// ===========================================================================
30// class declarations
31// ===========================================================================
32
33class GNEConnection;
34class GNEEdge;
37class GNENet;
40class PositionVector;
41
42// ===========================================================================
43// class definitions
44// ===========================================================================
45
46class GNELane : public GNENetworkElement, public GNECandidateElement, public FXDelegator {
48 FXDECLARE(GNELane)
49
50public:
53
54 public:
56 DrawingConstants(const GNELane* lane);
57
59 void update(const GUIVisualizationSettings& s);
60
62 double getExaggeration() const;
63
65 double getDrawingWidth() const;
66
68 double getInternalDrawingWidth() const;
69
71 double getOffset() const;
72
75
77 bool drawAsRailway() const;
78
80 bool drawSuperposed() const;
81
82 protected:
85
87 double myExaggeration = 0;
88
90 double myDrawingWidth = 0;
91
94
96 double myOffset = 0;
97
100
102 bool myDrawAsRailway = false;
103
105 bool myDrawSuperposed = false;
106
107 private:
110
113
116 };
117
123 GNELane(GNEEdge* edge, const int index);
124
126 ~GNELane();
127
130
132 GNEMoveElement* getMoveElement() const override;
133
135 Parameterised* getParameters() override;
136
138 const Parameterised* getParameters() const override;
139
141
143 GNEEdge* getParentEdge() const;
144
146 bool allowPedestrians() const;
147
150
152 const GUIGeometry& getLaneGeometry() const;
153
155 const PositionVector& getLaneShape() const;
156
158 const std::vector<double>& getShapeRotations() const;
159
161 const std::vector<double>& getShapeLengths() const;
162
165
167 void updateGeometry() override;
168
171
173
176
178 bool checkDrawFromContour() const override;
179
181 bool checkDrawToContour() const override;
182
184 bool checkDrawRelatedContour() const override;
185
187 bool checkDrawOverContour() const override;
188
190 bool checkDrawDeleteContour() const override;
191
193 bool checkDrawDeleteContourSmall() const override;
194
196 bool checkDrawSelectContour() const override;
197
199 bool checkDrawMoveContour() const override;
200
202
204 std::vector<GNEConnection*> getGNEIncomingConnections();
205
207 std::vector<GNEConnection*> getGNEOutcomingConnections();
208
210 void updateConnectionIDs();
211
213 double getLengthGeometryFactor() const;
214
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
229
231 long onDefault(FXObject*, FXSelector, void*) override;
232
234 double getExaggeration(const GUIVisualizationSettings& s) const override;
235
237 Boundary getCenteringBoundary() const override;
238
240 void updateCenteringBoundary(const bool updateGrid);
241
246 void drawGL(const GUIVisualizationSettings& s) const override;
247
249 void deleteGLObject() override;
250
252 void updateGLObject() override;
254
256 int getIndex() const;
257
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
269 double getLaneParametricLength() const;
270
272 double getLaneShapeLength() const;
273
275 bool isRestricted(SUMOVehicleClass vclass) const;
276
279
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 */
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
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
339 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
340
342 void drawOverlappedRoutes(const int numRoutes) const;
343
345 void drawLaneStopOffset(const GUIVisualizationSettings& s) const;
346
347protected:
349 GNELane();
350
351private:
354
357
360
363
366
368 std::vector<Position> myLaneRestrictedTexturePositions;
369
373
376
379
381 mutable std::vector<RGBColor> myShapeColors;
382
385
387 void setAttribute(SumoXMLAttr key, const std::string& value) override;
388
390 void drawLane(const GUIVisualizationSettings& s, const double layer) const;
391
393 void drawSelectedLane(const GUIVisualizationSettings& s) const;
394
396 void drawShapeEdited(const GUIVisualizationSettings& s) const;
397
399 void drawChildren(const GUIVisualizationSettings& s) const;
400
403
405 void drawLinkNo(const GUIVisualizationSettings& s) const;
406
408 void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
409
411 void drawArrows(const GUIVisualizationSettings& s) const;
412
414 void drawLane2LaneConnections() const;
415
417 void calculateLaneContour(const GUIVisualizationSettings& s, const double layer) const;
418
420 bool setFunctionalColor(int activeScheme, RGBColor& col) const;
421
423 bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
424
426 bool drawAsWaterway(const GUIVisualizationSettings& s) const;
427
430
432 void drawLaneAsRailway() const;
433
435 void drawTextures(const GUIVisualizationSettings& s) const;
436
439
442
445
448
451
454
456 GNELane(const GNELane&) = delete;
457
459 GNELane& operator=(const GNELane&) = delete;
460};
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
class lane2lane connection geometry
FOX-declaration.
Definition GNELane.h:52
const GNELane * myLane
lane
Definition GNELane.h:84
double myInternalDrawingWidth
internal lane drawing width (used for drawing selected lanes)
Definition GNELane.h:93
DrawingConstants & operator=(const DrawingConstants &)=delete
Invalidated assignment operator.
GUIVisualizationSettings::Detail myDetail
detail level
Definition GNELane.h:99
bool drawAsRailway() const
draw as railway
Definition GNELane.cpp:142
bool drawSuperposed() const
draw superposed
Definition GNELane.cpp:148
DrawingConstants(const DrawingConstants &)=delete
Invalidated copy constructor.
DrawingConstants()=delete
invalidate default constructor
double getExaggeration() const
get exaggeration
Definition GNELane.cpp:112
double myExaggeration
exaggeration
Definition GNELane.h:87
double getDrawingWidth() const
get lane drawing width
Definition GNELane.cpp:118
double getInternalDrawingWidth() const
get internal lane drawing width
Definition GNELane.cpp:124
double myDrawingWidth
lane drawing width
Definition GNELane.h:90
bool myDrawAsRailway
draw as railway
Definition GNELane.h:102
double myOffset
lane offset
Definition GNELane.h:96
double getOffset() const
get lane offset
Definition GNELane.cpp:130
bool myDrawSuperposed
draw supersposed (reduced width so that the lane markings below are visible)
Definition GNELane.h:105
GUIVisualizationSettings::Detail getDetail() const
get detail
Definition GNELane.cpp:136
GNELane2laneConnection myLane2laneConnections
lane2lane connections
Definition GNELane.h:384
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:232
bool isAttributeComputed(SumoXMLAttr key) const override
Definition GNELane.cpp:874
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:666
~GNELane()
Destructor.
Definition GNELane.cpp:188
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
return value for lane coloring according to the given scheme
Definition GNELane.cpp:1552
void drawLaneStopOffset(const GUIVisualizationSettings &s) const
draw laneStopOffset
Definition GNELane.cpp:1681
void drawSelectedLane(const GUIVisualizationSettings &s) const
draw selected lane
Definition GNELane.cpp:1043
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition GNELane.h:371
bool allowPedestrians() const
check if current lane allow pedestrians
Definition GNELane.cpp:220
void drawMarkingsAndBoundings(const GUIVisualizationSettings &s) const
draw lane markings
Definition GNELane.cpp:1109
bool checkDrawSelectContour() const override
check if draw select contour (blue)
Definition GNELane.cpp:423
const RGBColor * mySpecialColor
optional special color
Definition GNELane.h:375
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition GNELane.cpp:337
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition GNELane.cpp:1705
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNELane.cpp:612
double getLengthGeometryFactor() const
get length geometry factor
Definition GNELane.cpp:1963
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
Definition GNELane.cpp:741
void drawDirectionIndicators(const GUIVisualizationSettings &s) const
direction indicators for lanes
Definition GNELane.cpp:1711
bool checkDrawOverContour() const override
check if draw over contour (orange)
Definition GNELane.cpp:379
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:624
GNEMoveElementLane * myMoveElementLane
move element lane
Definition GNELane.h:353
GUIGeometry myLaneGeometry
lane geometry
Definition GNELane.h:359
void drawShapeEdited(const GUIVisualizationSettings &s) const
draw shape edited
Definition GNELane.cpp:1062
void drawOverlappedRoutes(const int numRoutes) const
draw overlapped routes
Definition GNELane.cpp:1664
bool checkDrawRelatedContour() const override
check if draw related contour (cyan)
Definition GNELane.cpp:369
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNELane.cpp:496
bool checkDrawToContour() const override
check if draw from contour (magenta)
Definition GNELane.cpp:356
std::string getParentName() const override
Returns the name of the parent object (if any)
Definition GNELane.cpp:1899
void buildLaneOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build lane operations contextual menu
Definition GNELane.cpp:2033
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this lane
Definition GNELane.cpp:196
GNELane()
FOX needs this.
Definition GNELane.cpp:175
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition GNELane.cpp:1933
DrawingConstants * myDrawingConstants
LaneDrawingConstants.
Definition GNELane.h:362
const std::vector< double > & getShapeRotations() const
get rotations of the single shape parts
Definition GNELane.cpp:242
std::string getAttributeForSelection(SumoXMLAttr key) const override
method for getting the attribute in the context of object selection
Definition GNELane.cpp:753
void buildTemplateOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build template oerations contextual menu
Definition GNELane.cpp:2154
GNELane & operator=(const GNELane &)=delete
Invalidated assignment operator.
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition GNELane.cpp:606
bool setMultiColor(const GUIVisualizationSettings &s, const GUIColorer &c, RGBColor &col) const
sets multiple colors according to the current scheme index and some lane function
Definition GNELane.cpp:1528
void calculateLaneContour(const GUIVisualizationSettings &s, const double layer) const
calculate contour
Definition GNELane.cpp:1400
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS link Number
Definition GNELane.cpp:1227
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition GNELane.cpp:643
GNELane(const GNELane &)=delete
Invalidated copy constructor.
RGBColor setLaneColor(const GUIVisualizationSettings &s) const
set color according to edit mode and visualisation settings
Definition GNELane.cpp:1418
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition GNELane.cpp:1912
void updateGeometry() override
update pre-computed geometry information
Definition GNELane.cpp:260
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition GNELane.cpp:660
bool checkDrawFromContour() const override
check if draw from contour (green)
Definition GNELane.cpp:343
const DrawingConstants * getDrawingConstants() const
get lane drawing constants (previously calculated in drawGL())
Definition GNELane.cpp:254
int myIndex
The index of this lane.
Definition GNELane.h:356
void drawLaneAsRailway() const
draw lane as railway
Definition GNELane.cpp:1753
std::string getAttribute(SumoXMLAttr key) const override
Definition GNELane.cpp:672
void setIndex(int index)
Definition GNELane.cpp:630
void setSpecialColor(const RGBColor *Color2, double colorValue=std::numeric_limits< double >::max())
Definition GNELane.cpp:886
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNELane.cpp:453
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:226
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition GNELane.cpp:441
Position getAttributePosition(SumoXMLAttr key) const override
Definition GNELane.cpp:735
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNELane.cpp:729
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
Definition GNELane.cpp:763
void drawArrows(const GUIVisualizationSettings &s) const
draw lane arrows
Definition GNELane.cpp:1264
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition GNELane.cpp:618
void drawLane(const GUIVisualizationSettings &s, const double layer) const
draw lane
Definition GNELane.cpp:989
double mySpecialColorValue
optional value that corresponds to which the special color corresponds
Definition GNELane.h:378
void drawChildren(const GUIVisualizationSettings &s) const
draw children
Definition GNELane.cpp:1088
Parameterised * getParameters() override
get parameters associated with this lane
Definition GNELane.cpp:202
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition GNELane.h:368
long onDefault(FXObject *, FXSelector, void *) override
multiplexes message to two targets
Definition GNELane.cpp:1905
bool checkDrawDeleteContour() const override
check if draw delete contour (pink/white)
Definition GNELane.cpp:399
double getLaneShapeLength() const
returns the length of the lane's shape
Definition GNELane.cpp:654
void updateGLObject() override
update GLObject (geometry, ID, etc.)
Definition GNELane.cpp:489
void drawStartEndGeometryPoints(const GUIVisualizationSettings &s) const
draw start and end geometry points
Definition GNELane.cpp:1831
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition GNELane.h:381
bool checkDrawDeleteContourSmall() const override
check if draw delete contour small (pink/white)
Definition GNELane.cpp:417
bool setFunctionalColor(int activeScheme, RGBColor &col) const
sets the color according to the current scheme index and some lane function
Definition GNELane.cpp:1514
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition GNELane.cpp:1948
void buildRechableOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build rechable operations contextual menu
Definition GNELane.cpp:2180
bool isValid(SumoXMLAttr key, const std::string &value) override
Definition GNELane.cpp:799
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNELane.cpp:860
void drawLane2LaneConnections() const
draw lane to lane connections
Definition GNELane.cpp:1352
void buildEdgeOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build edge operations contextual menu
Definition GNELane.cpp:1974
const std::vector< double > & getShapeLengths() const
get lengths of the single shape parts
Definition GNELane.cpp:248
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition GNELane.cpp:1190
double getSpeed() const
returns the current speed of lane
Definition GNELane.cpp:637
void drawTextures(const GUIVisualizationSettings &s) const
draw lane textures
Definition GNELane.cpp:1799
void deleteGLObject() override
delete element
Definition GNELane.cpp:480
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:214
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
The popup menu of a globject.
Stores the information about how to visualize structures.
An upper class for objects with additional parameters.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.