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-2024 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 checkDrawSelectContour() const;
180
182 bool checkDrawMoveContour() const;
183
185
190
192 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
194
196 std::vector<GNEConnection*> getGNEIncomingConnections();
197
199 std::vector<GNEConnection*> getGNEOutcomingConnections();
200
202 void updateConnectionIDs();
203
205 double getLengthGeometryFactor() const;
206
209 // @brief Returns the name of the parent object (if any)
210 // @return This object's parent id
211 std::string getParentName() const;
212
221
223 long onDefault(FXObject*, FXSelector, void*);
224
226 double getExaggeration(const GUIVisualizationSettings& s) const;
227
230
232 void updateCenteringBoundary(const bool updateGrid);
233
238 void drawGL(const GUIVisualizationSettings& s) const;
239
241 void deleteGLObject();
242
244 void updateGLObject();
246
248 int getIndex() const;
249
251 double getSpeed() const;
252
253 /* @brief method for setting the index of the lane
254 * @param[in] index The new index of lane
255 */
256 void setIndex(int index);
257
261 double getLaneParametricLength() const;
262
264 double getLaneShapeLength() const;
265
267 bool isRestricted(SUMOVehicleClass vclass) const;
268
271
274 /* @brief method for getting the Attribute of an XML key
275 * @param[in] key The attribute key
276 * @return string with the value associated to key
277 */
278 std::string getAttribute(SumoXMLAttr key) const;
279 std::string getAttributeForSelection(SumoXMLAttr key) const;
280
281 /* @brief method for getting the Attribute of an XML key in Position format
282 * @param[in] key The attribute key
283 * @return position with the value associated to key
284 */
286
287 /* @brief method for setting the attribute and letting the object perform additional changes
288 * @param[in] key The attribute key
289 * @param[in] value The new value
290 * @param[in] undoList The undoList on which to register changes
291 */
292 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
293
294 /* @brief method for checking if the key and their correspond attribute are valids
295 * @param[in] key The attribute key
296 * @param[in] value The value associated to key key
297 * @return true if the value is valid, false in other case
298 */
299 bool isValid(SumoXMLAttr key, const std::string& value);
300
301 /* @brief method for check if the value for certain attribute is set
302 * @param[in] key The attribute key
303 */
304 bool isAttributeEnabled(SumoXMLAttr key) const;
305
306 /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
307 * @param[in] key The attribute key
308 */
309 bool isAttributeComputed(SumoXMLAttr key) const;
311
314
315 /* @brief method for setting the special color of the lane
316 * @param[in] color Pointer to new special color
317 */
318 void setSpecialColor(const RGBColor* Color2, double colorValue = std::numeric_limits<double>::max());
319
321 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
322
324 void drawOverlappedRoutes(const int numRoutes) const;
325
327 void drawLaneStopOffset(const GUIVisualizationSettings& s) const;
328
329protected:
331 GNELane();
332
333private:
336
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:148
bool drawSuperposed() const
draw superposed
Definition GNELane.cpp:154
DrawingConstants(const DrawingConstants &)=delete
Invalidated copy constructor.
DrawingConstants()=delete
invalidate default constructor
double getExaggeration() const
get exaggeration
Definition GNELane.cpp:118
double myExaggeration
exaggeration
Definition GNELane.h:87
double getDrawingWidth() const
get lane drawing width
Definition GNELane.cpp:124
double getInternalDrawingWidth() const
get internal lane drawing width
Definition GNELane.cpp:130
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:136
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:142
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:214
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition GNELane.cpp:1916
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:662
~GNELane()
Destructor.
Definition GNELane.cpp:188
std::string getParentName() const
Returns the name of the parent object (if any)
Definition GNELane.cpp:1910
std::string getAttribute(SumoXMLAttr key) const
Definition GNELane.cpp:668
void drawLaneStopOffset(const GUIVisualizationSettings &s) const
draw laneStopOffset
Definition GNELane.cpp:1692
void drawSelectedLane(const GUIVisualizationSettings &s) const
draw selected lane
Definition GNELane.cpp:1055
bool checkDrawMoveContour() const
check if draw move contour (red)
Definition GNELane.cpp:399
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:202
void drawMarkingsAndBoundings(const GUIVisualizationSettings &s) const
draw lane markings
Definition GNELane.cpp:1120
const RGBColor * mySpecialColor
optional special color
Definition GNELane.h:357
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition GNELane.cpp:319
bool isAttributeComputed(SumoXMLAttr key) const
Definition GNELane.cpp:864
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition GNELane.cpp:1716
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
Definition GNELane.cpp:363
double getLengthGeometryFactor() const
get length geometry factor
Definition GNELane.cpp:1974
bool isAttributeEnabled(SumoXMLAttr key) const
Definition GNELane.cpp:850
void drawDirectionIndicators(const GUIVisualizationSettings &s) const
direction indicators for lanes
Definition GNELane.cpp:1722
bool checkDrawSelectContour() const
check if draw select contour (blue)
Definition GNELane.cpp:381
void updateGeometry()
update pre-computed geometry information
Definition GNELane.cpp:242
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition GNELane.cpp:988
GNEEdge * myParentEdge
parent edge (GNELanes cannot use hierarchical structures)
Definition GNELane.h:335
void deleteGLObject()
delete element
Definition GNELane.cpp:476
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition GNELane.cpp:739
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition GNELane.cpp:492
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:620
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition GNELane.cpp:602
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition GNELane.cpp:423
GUIGeometry myLaneGeometry
lane geometry
Definition GNELane.h:341
bool checkDrawOverContour() const
check if draw over contour (orange)
Definition GNELane.cpp:357
void drawShapeEdited(const GUIVisualizationSettings &s) const
draw shape edited
Definition GNELane.cpp:1074
void drawOverlappedRoutes(const int numRoutes) const
draw overlapped routes
Definition GNELane.cpp:1675
void updateGLObject()
update GLObject (geometry, ID, etc.)
Definition GNELane.cpp:485
GNEMoveOperation * getMoveOperation()
get move operation
Definition GNELane.cpp:411
void buildLaneOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build lane operations contextual menu
Definition GNELane.cpp:2044
GNELane()
FOX needs this.
Definition GNELane.cpp:176
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition GNELane.cpp:1944
DrawingConstants * myDrawingConstants
LaneDrawingConstants.
Definition GNELane.h:344
const std::vector< double > & getShapeRotations() const
get rotations of the single shape parts
Definition GNELane.cpp:224
void buildTemplateOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build template oerations contextual menu
Definition GNELane.cpp:2165
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:1539
void calculateLaneContour(const GUIVisualizationSettings &s, const double layer) const
calculate contour
Definition GNELane.cpp:1411
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS link Number
Definition GNELane.cpp:1238
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition GNELane.cpp:876
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition GNELane.cpp:639
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:1429
bool isValid(SumoXMLAttr key, const std::string &value)
Definition GNELane.cpp:787
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition GNELane.cpp:1923
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition GNELane.cpp:656
const DrawingConstants * getDrawingConstants() const
get lane drawing constants (previously calculated in drawGL())
Definition GNELane.cpp:236
int myIndex
The index of this lane.
Definition GNELane.h:338
void drawLaneAsRailway() const
draw lane as railway
Definition GNELane.cpp:1764
void setIndex(int index)
Definition GNELane.cpp:626
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition GNELane.cpp:449
bool checkDrawFromContour() const
check if draw from contour (green)
Definition GNELane.cpp:325
void setSpecialColor(const RGBColor *Color2, double colorValue=std::numeric_limits< double >::max())
Definition GNELane.cpp:882
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:208
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNELane.cpp:608
void drawArrows(const GUIVisualizationSettings &s) const
draw lane arrows
Definition GNELane.cpp:1275
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition GNELane.cpp:614
void drawLane(const GUIVisualizationSettings &s, const double layer) const
draw lane
Definition GNELane.cpp:1006
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:1100
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
Definition GNELane.cpp:351
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:997
double getLaneShapeLength() const
returns the length of the lane's shape
Definition GNELane.cpp:650
void drawStartEndGeometryPoints(const GUIVisualizationSettings &s) const
draw start and end geometry points
Definition GNELane.cpp:1842
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:1563
bool checkDrawToContour() const
check if draw from contour (magenta)
Definition GNELane.cpp:338
bool setFunctionalColor(int activeScheme, RGBColor &col) const
sets the color according to the current scheme index and some lane function
Definition GNELane.cpp:1525
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
void drawLane2LaneConnections() const
draw lane to lane connections
Definition GNELane.cpp:1363
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:230
PositionVector getAttributePositionVector(SumoXMLAttr key) const
Definition GNELane.cpp:727
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition GNELane.cpp:1201
double getSpeed() const
returns the current speed of lane
Definition GNELane.cpp:633
void drawTextures(const GUIVisualizationSettings &s) const
draw lane textures
Definition GNELane.cpp:1810
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition GNELane.cpp:749
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:196
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.