Eclipse SUMO - Simulation of Urban MObility
GNELane.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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:
57
59 const double selectionScale;
60
62 const double exaggeration;
63
64 // compute lane-marking intersection points)
65 const double halfWidth2;
66
68 const double halfWidth;
69
70 private:
73 };
74
80 GNELane(GNEEdge* edge, const int index);
81
83 ~GNELane();
84
86 GNEEdge* getParentEdge() const;
87
89 bool allowPedestrians() const;
90
94 const GUIGeometry& getLaneGeometry() const;
95
97 const PositionVector& getLaneShape() const;
98
100 const std::vector<double>& getShapeRotations() const;
101
103 const std::vector<double>& getShapeLengths() const;
104
106 void updateGeometry();
107
111
116
118 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
120
122 std::vector<GNEConnection*> getGNEIncomingConnections();
123
125 std::vector<GNEConnection*> getGNEOutcomingConnections();
126
128 void updateConnectionIDs();
129
131 double getLengthGeometryFactor() const;
132
135 // @brief Returns the name of the parent object (if any)
136 // @return This object's parent id
137 std::string getParentName() const;
138
147
149 long onDefault(FXObject*, FXSelector, void*);
150
152 double getExaggeration(const GUIVisualizationSettings& s) const;
153
155 void updateCenteringBoundary(const bool updateGrid);
156
161 void drawGL(const GUIVisualizationSettings& s) const;
162
164 void deleteGLObject();
165
167 void updateGLObject();
169
171 int getIndex() const;
172
174 double getSpeed() const;
175
176 /* @brief method for setting the index of the lane
177 * @param[in] index The new index of lane
178 */
179 void setIndex(int index);
180
184 double getLaneParametricLength() const;
185
187 double getLaneShapeLength() const;
188
190 bool isRestricted(SUMOVehicleClass vclass) const;
191
194
197 /* @brief method for getting the Attribute of an XML key
198 * @param[in] key The attribute key
199 * @return string with the value associated to key
200 */
201 std::string getAttribute(SumoXMLAttr key) const;
202 std::string getAttributeForSelection(SumoXMLAttr key) const;
203
204 /* @brief method for setting the attribute and letting the object perform additional changes
205 * @param[in] key The attribute key
206 * @param[in] value The new value
207 * @param[in] undoList The undoList on which to register changes
208 */
209 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
210
211 /* @brief method for checking if the key and their correspond attribute are valids
212 * @param[in] key The attribute key
213 * @param[in] value The value associated to key key
214 * @return true if the value is valid, false in other case
215 */
216 bool isValid(SumoXMLAttr key, const std::string& value);
217
218 /* @brief method for check if the value for certain attribute is set
219 * @param[in] key The attribute key
220 */
221 bool isAttributeEnabled(SumoXMLAttr key) const;
222
223 /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
224 * @param[in] key The attribute key
225 */
226 bool isAttributeComputed(SumoXMLAttr key) const;
228
231
232 /* @brief method for setting the special color of the lane
233 * @param[in] color Pointer to new special color
234 */
235 void setSpecialColor(const RGBColor* Color2, double colorValue = std::numeric_limits<double>::max());
236
238 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
239
241 bool drawAsRailway(const GUIVisualizationSettings& s) const;
242
244 void drawOverlappedRoutes(const int numRoutes) const;
245
247 void drawLaneStopOffset(const GUIVisualizationSettings& s, const double offset) const;
248
249protected:
251 GNELane();
252
253private:
256
259
262
265
267 std::vector<Position> myLaneRestrictedTexturePositions;
268
272
275
278
280 mutable std::vector<RGBColor> myShapeColors;
281
284
286 void setAttribute(SumoXMLAttr key, const std::string& value);
287
289 void setMoveShape(const GNEMoveResult& moveResult);
290
292 void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
293
295 void drawChildren(const GUIVisualizationSettings& s) const;
296
298 void drawMarkings(const GUIVisualizationSettings& s, const double exaggeration, const bool drawRailway) const;
299
301 void drawLinkNo(const GUIVisualizationSettings& s) const;
302
304 void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
305
307 void drawLinkRules(const GUIVisualizationSettings& s) const;
308
310 void drawArrows(const GUIVisualizationSettings& s, const bool spreadSuperposed) const;
311
313 void drawLane2LaneConnections() const;
314
316 bool setFunctionalColor(int activeScheme, RGBColor& col) const;
317
319 bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
320
322 bool drawAsWaterway(const GUIVisualizationSettings& s) const;
323
325 void drawDirectionIndicators(const GUIVisualizationSettings& s, double exaggeration, const bool drawAsRailway, const bool spreadSuperposed) const;
326
328 void drawLaneAsRailway(const GUIVisualizationSettings& s, const LaneDrawingConstants& laneDrawingConstants) const;
329
331 void drawTextures(const GUIVisualizationSettings& s, const LaneDrawingConstants& laneDrawingConstants) const;
332
335
338
341
344
347
350
352 GNELane(const GNELane&) = delete;
353
355 GNELane& operator=(const GNELane&) = delete;
356};
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
class lane2lane connection geometry
FOX-declaration.
Definition: GNELane.h:52
const double exaggeration
exaggeration
Definition: GNELane.h:62
const double selectionScale
selection scale
Definition: GNELane.h:59
LaneDrawingConstants()
default constructor
Definition: GNELane.cpp:77
const double halfWidth
Draw as a normal lane, and reduce width to make sure that a selected edge can still be seen.
Definition: GNELane.h:68
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:283
const PositionVector & getLaneShape() const
get elements shape
Definition: GNELane.cpp:142
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1749
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:917
~GNELane()
Destructor.
Definition: GNELane.cpp:120
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:1743
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:923
void drawLinkRules(const GUIVisualizationSettings &s) const
draw link rules
Definition: GNELane.cpp:359
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition: GNELane.h:270
bool allowPedestrians() const
check if current lane allow pedestrians
Definition: GNELane.cpp:130
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:274
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNELane.cpp:241
bool isAttributeComputed(SumoXMLAttr key) const
Definition: GNELane.cpp:1096
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:1530
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1807
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNELane.cpp:1084
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:164
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNELane.cpp:1226
GNEEdge * myParentEdge
parent edge (GNELanes cannot use hierarchical structures)
Definition: GNELane.h:255
void deleteGLObject()
delete element
Definition: GNELane.cpp:685
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNELane.cpp:978
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:750
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:876
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition: GNELane.cpp:860
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition: GNELane.cpp:260
GUIGeometry myLaneGeometry
lane geometry
Definition: GNELane.h:261
void drawStartEndShapePoints(const GUIVisualizationSettings &s) const
draw start and end shape points
Definition: GNELane.cpp:1668
void drawMarkings(const GUIVisualizationSettings &s, const double exaggeration, const bool drawRailway) const
draw lane markings
Definition: GNELane.cpp:716
void drawOverlappedRoutes(const int numRoutes) const
draw overlapped routes
Definition: GNELane.cpp:1492
void updateGLObject()
update GLObject (geometry, ID, etc.)
Definition: GNELane.cpp:694
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNELane.cpp:247
void buildLaneOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build lane operations contextual menu
Definition: GNELane.cpp:1877
GNELane()
FOX needs this.
Definition: GNELane.cpp:106
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1777
const std::vector< double > & getShapeRotations() const
get rotations of the single shape parts
Definition: GNELane.cpp:152
void drawTextures(const GUIVisualizationSettings &s, const LaneDrawingConstants &laneDrawingConstants) const
draw lane textures
Definition: GNELane.cpp:1630
void buildTemplateOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build template oerations contextual menu
Definition: GNELane.cpp:1993
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:1351
void drawLaneAsRailway(const GUIVisualizationSettings &s, const LaneDrawingConstants &laneDrawingConstants) const
draw lane as railway
Definition: GNELane.cpp:1581
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS Link Number
Definition: GNELane.cpp:323
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition: GNELane.cpp:1108
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:894
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:1244
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:1019
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1756
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:1484
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:911
int myIndex
The index of this lane.
Definition: GNELane.h:258
void drawDirectionIndicators(const GUIVisualizationSettings &s, double exaggeration, const bool drawAsRailway, const bool spreadSuperposed) const
direction indicators for lanes
Definition: GNELane.cpp:1536
void setIndex(int index)
Definition: GNELane.cpp:881
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:499
void setSpecialColor(const RGBColor *Color2, double colorValue=std::numeric_limits< double >::max())
Definition: GNELane.cpp:1114
const GUIGeometry & getLaneGeometry() const
Definition: GNELane.cpp:136
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNELane.cpp:866
double mySpecialColorValue
optional value that corresponds to which the special color corresponds
Definition: GNELane.h:277
void drawChildren(const GUIVisualizationSettings &s) const
draw children
Definition: GNELane.cpp:700
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition: GNELane.h:267
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNELane.cpp:1235
double getLaneShapeLength() const
returns the length of the lane's shape
Definition: GNELane.cpp:905
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:280
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:1375
bool setFunctionalColor(int activeScheme, RGBColor &col) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:1337
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition: GNELane.cpp:1792
void drawArrows(const GUIVisualizationSettings &s, const bool spreadSuperposed) const
draw arrows
Definition: GNELane.cpp:365
void buildRechableOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build rechable operations contextual menu
Definition: GNELane.cpp:2020
void drawLaneStopOffset(const GUIVisualizationSettings &s, const double offset) const
draw laneStopOffset
Definition: GNELane.cpp:1509
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:451
void buildEdgeOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build edge operations contextual menu
Definition: GNELane.cpp:1818
const std::vector< double > & getShapeLengths() const
get lengths of the single shape parts
Definition: GNELane.cpp:158
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition: GNELane.cpp:286
double getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:888
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:988
GNEEdge * getParentEdge() const
get parent edge
Definition: GNELane.cpp:124
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
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.