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-2026 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 {
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
218 bool isVisible(const GUIVisualizationSettings& s) const override;
219
220 // @brief Returns the name of the parent object (if any)
221 // @return This object's parent id
222 std::string getParentName() const override;
223
232
234 long onDefault(FXObject*, FXSelector, void*) override;
235
237 double getExaggeration(const GUIVisualizationSettings& s) const override;
238
240 Boundary getCenteringBoundary() const override;
241
243 void updateCenteringBoundary(const bool updateGrid);
244
249 void drawGL(const GUIVisualizationSettings& s) const override;
250
252 void deleteGLObject() override;
253
255 void updateGLObject() override;
257
259 int getIndex() const;
260
262 double getSpeed() const;
263
264 /* @brief method for setting the index of the lane
265 * @param[in] index The new index of lane
266 */
267 void setIndex(int index);
268
272 double getLaneParametricLength() const;
273
275 double getLaneShapeLength() const;
276
278 bool isRestricted(SUMOVehicleClass vclass) const;
279
282
285 /* @brief method for getting the Attribute of an XML key
286 * @param[in] key The attribute key
287 * @return string with the value associated to key
288 */
289 std::string getAttribute(SumoXMLAttr key) const override;
290 std::string getAttributeForSelection(SumoXMLAttr key) const override;
291
292 /* @brief method for getting the Attribute of an XML key in double format
293 * @param[in] key The attribute key
294 * @return double with the value associated to key
295 */
296 double getAttributeDouble(SumoXMLAttr key) const override;
297
298 /* @brief method for getting the Attribute of an XML key in position format
299 * @param[in] key The attribute key
300 * @return position with the value associated to key
301 */
302 Position getAttributePosition(SumoXMLAttr key) const override;
303
304 /* @brief method for getting the Attribute of an XML key in Position format
305 * @param[in] key The attribute key
306 * @return position with the value associated to key
307 */
309
310 /* @brief method for setting the attribute and letting the object perform additional changes
311 * @param[in] key The attribute key
312 * @param[in] value The new value
313 * @param[in] undoList The undoList on which to register changes
314 */
315 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
316
317 /* @brief method for checking if the key and their correspond attribute are valids
318 * @param[in] key The attribute key
319 * @param[in] value The value associated to key key
320 * @return true if the value is valid, false in other case
321 */
322 bool isValid(SumoXMLAttr key, const std::string& value) override;
323
324 /* @brief method for check if the value for certain attribute is set
325 * @param[in] key The attribute key
326 */
327 bool isAttributeEnabled(SumoXMLAttr key) const override;
328
329 /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
330 * @param[in] key The attribute key
331 */
332 bool isAttributeComputed(SumoXMLAttr key) const override;
333
335
336 /* @brief method for setting the special color of the lane
337 * @param[in] color Pointer to new special color
338 */
339 void setSpecialColor(const RGBColor* Color2, double colorValue = std::numeric_limits<double>::max());
340
342 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
343
345 void drawOverlappedRoutes(const int numRoutes) const;
346
348 void drawLaneStopOffset(const GUIVisualizationSettings& s) const;
349
350protected:
352 GNELane();
353
354private:
357
360
363
366
369
371 std::vector<Position> myLaneRestrictedTexturePositions;
372
376
379
382
384 mutable std::vector<RGBColor> myShapeColors;
385
388
390 void setAttribute(SumoXMLAttr key, const std::string& value) override;
391
393 void drawLane(const GUIVisualizationSettings& s, const double layer) const;
394
396 void drawSelectedLane(const GUIVisualizationSettings& s) const;
397
399 void drawShapeEdited(const GUIVisualizationSettings& s) const;
400
402 void drawChildren(const GUIVisualizationSettings& s) const;
403
406
408 void drawLinkNo(const GUIVisualizationSettings& s) const;
409
411 void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
412
414 void drawArrows(const GUIVisualizationSettings& s) const;
415
417 void drawLane2LaneConnections() const;
418
420 void calculateLaneContour(const GUIVisualizationSettings& s, const double layer) const;
421
423 bool setFunctionalColor(int activeScheme, RGBColor& col) const;
424
426 bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
427
429 bool drawAsWaterway(const GUIVisualizationSettings& s) const;
430
433
435 void drawLaneAsRailway() const;
436
438 void drawTextures(const GUIVisualizationSettings& s) const;
439
442
445
448
451
454
457
459 GNELane(const GNELane&) = delete;
460
462 GNELane& operator=(const GNELane&) = delete;
463};
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:387
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:1557
void drawLaneStopOffset(const GUIVisualizationSettings &s) const
draw laneStopOffset
Definition GNELane.cpp:1686
void drawSelectedLane(const GUIVisualizationSettings &s) const
draw selected lane
Definition GNELane.cpp:1046
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition GNELane.h:374
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:1112
bool checkDrawSelectContour() const override
check if draw select contour (blue)
Definition GNELane.cpp:423
const RGBColor * mySpecialColor
optional special color
Definition GNELane.h:378
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:1710
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:1974
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
Definition GNELane.cpp:741
void drawDirectionIndicators(const GUIVisualizationSettings &s) const
direction indicators for lanes
Definition GNELane.cpp:1716
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:356
GUIGeometry myLaneGeometry
lane geometry
Definition GNELane.h:362
void drawShapeEdited(const GUIVisualizationSettings &s) const
draw shape edited
Definition GNELane.cpp:1065
void drawOverlappedRoutes(const int numRoutes) const
draw overlapped routes
Definition GNELane.cpp:1669
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:1910
void buildLaneOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build lane operations contextual menu
Definition GNELane.cpp:2044
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:1944
DrawingConstants * myDrawingConstants
LaneDrawingConstants.
Definition GNELane.h:365
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:2165
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:1533
void calculateLaneContour(const GUIVisualizationSettings &s, const double layer) const
calculate contour
Definition GNELane.cpp:1405
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS link Number
Definition GNELane.cpp:1230
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:1423
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition GNELane.cpp:1923
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:359
void drawLaneAsRailway() const
draw lane as railway
Definition GNELane.cpp:1758
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:1267
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:381
void drawChildren(const GUIVisualizationSettings &s) const
draw children
Definition GNELane.cpp:1091
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:371
long onDefault(FXObject *, FXSelector, void *) override
multiplexes message to two targets
Definition GNELane.cpp:1916
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:1836
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition GNELane.h:384
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:1519
bool isVisible(const GUIVisualizationSettings &s) const override
check if object is visible (Currently used only in netedit)
Definition GNELane.cpp:1904
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition GNELane.cpp:1959
void buildRechableOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build rechable operations contextual menu
Definition GNELane.cpp:2191
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:1357
void buildEdgeOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build edge operations contextual menu
Definition GNELane.cpp:1985
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:1193
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:1804
void deleteGLObject() override
delete element
Definition GNELane.cpp:480
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:214
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.
#define FXDECLARE_OVERRIDE(classname)
Macro to set up class declaration including an override. We should update this whenever the original ...
Definition fxheader.h:37