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
25
26#include "GNENetworkElement.h"
27
28// ===========================================================================
29// class declarations
30// ===========================================================================
32class PositionVector;
34class GNEEdge;
35class GNENet;
36class GNEConnection;
37
38// ===========================================================================
39// class definitions
40// ===========================================================================
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
129 GNEEdge* getParentEdge() const;
130
132 bool allowPedestrians() const;
133
136
138 const GUIGeometry& getLaneGeometry() const;
139
141 const PositionVector& getLaneShape() const;
142
144 const std::vector<double>& getShapeRotations() const;
145
147 const std::vector<double>& getShapeLengths() const;
148
151
153 void updateGeometry();
154
157
159
162
164 bool checkDrawFromContour() const;
165
167 bool checkDrawToContour() const;
168
170 bool checkDrawRelatedContour() const;
171
173 bool checkDrawOverContour() const;
174
176 bool checkDrawDeleteContour() const;
177
179 bool checkDrawDeleteContourSmall() const;
180
182 bool checkDrawSelectContour() const;
183
185 bool checkDrawMoveContour() const;
186
188
193
195 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
197
199 std::vector<GNEConnection*> getGNEIncomingConnections();
200
202 std::vector<GNEConnection*> getGNEOutcomingConnections();
203
205 void updateConnectionIDs();
206
208 double getLengthGeometryFactor() const;
209
212 // @brief Returns the name of the parent object (if any)
213 // @return This object's parent id
214 std::string getParentName() const;
215
224
226 long onDefault(FXObject*, FXSelector, void*);
227
229 double getExaggeration(const GUIVisualizationSettings& s) const;
230
233
235 void updateCenteringBoundary(const bool updateGrid);
236
241 void drawGL(const GUIVisualizationSettings& s) const;
242
244 void deleteGLObject();
245
247 void updateGLObject();
249
251 int getIndex() const;
252
254 double getSpeed() const;
255
256 /* @brief method for setting the index of the lane
257 * @param[in] index The new index of lane
258 */
259 void setIndex(int index);
260
264 double getLaneParametricLength() const;
265
267 double getLaneShapeLength() const;
268
270 bool isRestricted(SUMOVehicleClass vclass) const;
271
274
277 /* @brief method for getting the Attribute of an XML key
278 * @param[in] key The attribute key
279 * @return string with the value associated to key
280 */
281 std::string getAttribute(SumoXMLAttr key) const;
282 std::string getAttributeForSelection(SumoXMLAttr key) const;
283
284 /* @brief method for getting the Attribute of an XML key in Position format
285 * @param[in] key The attribute key
286 * @return position with the value associated to key
287 */
289
290 /* @brief method for setting the attribute and letting the object perform additional changes
291 * @param[in] key The attribute key
292 * @param[in] value The new value
293 * @param[in] undoList The undoList on which to register changes
294 */
295 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
296
297 /* @brief method for checking if the key and their correspond attribute are valids
298 * @param[in] key The attribute key
299 * @param[in] value The value associated to key key
300 * @return true if the value is valid, false in other case
301 */
302 bool isValid(SumoXMLAttr key, const std::string& value);
303
304 /* @brief method for check if the value for certain attribute is set
305 * @param[in] key The attribute key
306 */
307 bool isAttributeEnabled(SumoXMLAttr key) const;
308
309 /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
310 * @param[in] key The attribute key
311 */
312 bool isAttributeComputed(SumoXMLAttr key) const;
314
317
318 /* @brief method for setting the special color of the lane
319 * @param[in] color Pointer to new special color
320 */
321 void setSpecialColor(const RGBColor* Color2, double colorValue = std::numeric_limits<double>::max());
322
324 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
325
327 void drawOverlappedRoutes(const int numRoutes) const;
328
330 void drawLaneStopOffset(const GUIVisualizationSettings& s) const;
331
332protected:
334 GNELane();
335
336private:
339
342
345
348
350 std::vector<Position> myLaneRestrictedTexturePositions;
351
355
358
361
363 mutable std::vector<RGBColor> myShapeColors;
364
367
369 void setAttribute(SumoXMLAttr key, const std::string& value);
370
372 void setMoveShape(const GNEMoveResult& moveResult);
373
375 void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
376
378 void drawLane(const GUIVisualizationSettings& s, const double layer) const;
379
381 void drawSelectedLane(const GUIVisualizationSettings& s) const;
382
384 void drawShapeEdited(const GUIVisualizationSettings& s) const;
385
387 void drawChildren(const GUIVisualizationSettings& s) const;
388
391
393 void drawLinkNo(const GUIVisualizationSettings& s) const;
394
396 void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
397
399 void drawArrows(const GUIVisualizationSettings& s) const;
400
402 void drawLane2LaneConnections() const;
403
405 void calculateLaneContour(const GUIVisualizationSettings& s, const double layer) const;
406
408 bool setFunctionalColor(int activeScheme, RGBColor& col) const;
409
411 bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
412
414 bool drawAsWaterway(const GUIVisualizationSettings& s) const;
415
418
420 void drawLaneAsRailway() const;
421
423 void drawTextures(const GUIVisualizationSettings& s) const;
424
427
430
433
436
439
442
444 GNELane(const GNELane&) = delete;
445
447 GNELane& operator=(const GNELane&) = delete;
448};
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
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
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:151
bool drawSuperposed() const
draw superposed
Definition GNELane.cpp:157
DrawingConstants(const DrawingConstants &)=delete
Invalidated copy constructor.
DrawingConstants()=delete
invalidate default constructor
double getExaggeration() const
get exaggeration
Definition GNELane.cpp:121
double myExaggeration
exaggeration
Definition GNELane.h:87
double getDrawingWidth() const
get lane drawing width
Definition GNELane.cpp:127
double getInternalDrawingWidth() const
get internal lane drawing width
Definition GNELane.cpp:133
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:139
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:145
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
GNELane2laneConnection myLane2laneConnections
lane2lane connections
Definition GNELane.h:366
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:221
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition GNELane.cpp:1944
bool checkDrawDeleteContourSmall() const
check if draw delete contour small (pink/white)
Definition GNELane.cpp:406
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:693
~GNELane()
Destructor.
Definition GNELane.cpp:195
std::string getParentName() const
Returns the name of the parent object (if any)
Definition GNELane.cpp:1938
std::string getAttribute(SumoXMLAttr key) const
Definition GNELane.cpp:699
void drawLaneStopOffset(const GUIVisualizationSettings &s) const
draw laneStopOffset
Definition GNELane.cpp:1720
void drawSelectedLane(const GUIVisualizationSettings &s) const
draw selected lane
Definition GNELane.cpp:1082
bool checkDrawMoveContour() const
check if draw move contour (red)
Definition GNELane.cpp:430
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition GNELane.h:353
bool allowPedestrians() const
check if current lane allow pedestrians
Definition GNELane.cpp:209
void drawMarkingsAndBoundings(const GUIVisualizationSettings &s) const
draw lane markings
Definition GNELane.cpp:1148
const RGBColor * mySpecialColor
optional special color
Definition GNELane.h:357
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition GNELane.cpp:326
bool isAttributeComputed(SumoXMLAttr key) const
Definition GNELane.cpp:889
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition GNELane.cpp:1744
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
Definition GNELane.cpp:388
double getLengthGeometryFactor() const
get length geometry factor
Definition GNELane.cpp:2002
bool isAttributeEnabled(SumoXMLAttr key) const
Definition GNELane.cpp:875
void drawDirectionIndicators(const GUIVisualizationSettings &s) const
direction indicators for lanes
Definition GNELane.cpp:1750
bool checkDrawSelectContour() const
check if draw select contour (blue)
Definition GNELane.cpp:412
void updateGeometry()
update pre-computed geometry information
Definition GNELane.cpp:249
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition GNELane.cpp:1010
void deleteGLObject()
delete element
Definition GNELane.cpp:507
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition GNELane.cpp:768
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition GNELane.cpp:523
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:651
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition GNELane.cpp:633
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition GNELane.cpp:454
GUIGeometry myLaneGeometry
lane geometry
Definition GNELane.h:341
bool checkDrawOverContour() const
check if draw over contour (orange)
Definition GNELane.cpp:368
void drawShapeEdited(const GUIVisualizationSettings &s) const
draw shape edited
Definition GNELane.cpp:1101
void drawOverlappedRoutes(const int numRoutes) const
draw overlapped routes
Definition GNELane.cpp:1703
void updateGLObject()
update GLObject (geometry, ID, etc.)
Definition GNELane.cpp:516
GNEMoveOperation * getMoveOperation()
get move operation
Definition GNELane.cpp:442
void buildLaneOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build lane operations contextual menu
Definition GNELane.cpp:2072
GNELane()
FOX needs this.
Definition GNELane.cpp:183
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition GNELane.cpp:1972
DrawingConstants * myDrawingConstants
LaneDrawingConstants.
Definition GNELane.h:344
const std::vector< double > & getShapeRotations() const
get rotations of the single shape parts
Definition GNELane.cpp:231
void buildTemplateOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build template oerations contextual menu
Definition GNELane.cpp:2193
GNELane & operator=(const GNELane &)=delete
Invalidated assignment operator.
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:1567
void calculateLaneContour(const GUIVisualizationSettings &s, const double layer) const
calculate contour
Definition GNELane.cpp:1439
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS link Number
Definition GNELane.cpp:1266
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition GNELane.cpp:901
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition GNELane.cpp:670
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:1457
bool isValid(SumoXMLAttr key, const std::string &value)
Definition GNELane.cpp:814
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition GNELane.cpp:1951
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition GNELane.cpp:687
const DrawingConstants * getDrawingConstants() const
get lane drawing constants (previously calculated in drawGL())
Definition GNELane.cpp:243
int myIndex
The index of this lane.
Definition GNELane.h:338
void drawLaneAsRailway() const
draw lane as railway
Definition GNELane.cpp:1792
void setIndex(int index)
Definition GNELane.cpp:657
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition GNELane.cpp:480
bool checkDrawFromContour() const
check if draw from contour (green)
Definition GNELane.cpp:332
void setSpecialColor(const RGBColor *Color2, double colorValue=std::numeric_limits< double >::max())
Definition GNELane.cpp:907
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:215
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNELane.cpp:639
void drawArrows(const GUIVisualizationSettings &s) const
draw lane arrows
Definition GNELane.cpp:1303
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition GNELane.cpp:645
void drawLane(const GUIVisualizationSettings &s, const double layer) const
draw lane
Definition GNELane.cpp:1028
double mySpecialColorValue
optional value that corresponds to which the special color corresponds
Definition GNELane.h:360
void drawChildren(const GUIVisualizationSettings &s) const
draw children
Definition GNELane.cpp:1127
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
Definition GNELane.cpp:358
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition GNELane.h:350
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition GNELane.cpp:1019
double getLaneShapeLength() const
returns the length of the lane's shape
Definition GNELane.cpp:681
void drawStartEndGeometryPoints(const GUIVisualizationSettings &s) const
draw start and end geometry points
Definition GNELane.cpp:1870
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition GNELane.h:363
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
return value for lane coloring according to the given scheme
Definition GNELane.cpp:1591
bool checkDrawToContour() const
check if draw from contour (magenta)
Definition GNELane.cpp:345
bool setFunctionalColor(int activeScheme, RGBColor &col) const
sets the color according to the current scheme index and some lane function
Definition GNELane.cpp:1553
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition GNELane.cpp:1987
void buildRechableOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build rechable operations contextual menu
Definition GNELane.cpp:2219
void drawLane2LaneConnections() const
draw lane to lane connections
Definition GNELane.cpp:1391
void buildEdgeOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build edge operations contextual menu
Definition GNELane.cpp:2013
const std::vector< double > & getShapeLengths() const
get lengths of the single shape parts
Definition GNELane.cpp:237
PositionVector getAttributePositionVector(SumoXMLAttr key) const
Definition GNELane.cpp:756
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition GNELane.cpp:1229
double getSpeed() const
returns the current speed of lane
Definition GNELane.cpp:664
void drawTextures(const GUIVisualizationSettings &s) const
draw lane textures
Definition GNELane.cpp:1838
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition GNELane.cpp:778
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:203
move operation
move result
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.
std::map< std::string, std::string > Map
parameters map
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.