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-2023 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 drawLaneArrows(const GUIVisualizationSettings& s, const double exaggeration, const bool spreadSuperposed) const;
296
298 void drawShapeEdited(const GUIVisualizationSettings& s) const;
299
301 void checkMouseOverLane(const double laneWidth) const;
302
304 void drawDottedContours(const GUIVisualizationSettings& s, const bool drawRailway, const double laneWidth) const;
305
307 void drawChildren(const GUIVisualizationSettings& s) const;
308
310 void drawMarkings(const GUIVisualizationSettings& s, const double exaggeration, const bool drawRailway) const;
311
313 void drawLinkNo(const GUIVisualizationSettings& s) const;
314
316 void drawArrows(const GUIVisualizationSettings& s, const bool spreadSuperposed) const;
317
319 void drawLane2LaneConnections() const;
320
322 bool setFunctionalColor(int activeScheme, RGBColor& col) const;
323
325 bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
326
328 bool drawAsWaterway(const GUIVisualizationSettings& s) const;
329
331 void drawDirectionIndicators(const GUIVisualizationSettings& s, double exaggeration, const bool drawAsRailway, const bool spreadSuperposed) const;
332
334 void drawLaneAsRailway(const GUIVisualizationSettings& s, const LaneDrawingConstants& laneDrawingConstants) const;
335
337 void drawTextures(const GUIVisualizationSettings& s, const LaneDrawingConstants& laneDrawingConstants) const;
338
341
344
347
350
353
356
358 GNELane(const GNELane&) = delete;
359
361 GNELane& operator=(const GNELane&) = delete;
362};
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
const double exaggeration
exaggeration
Definition GNELane.h:62
const double selectionScale
selection scale
Definition GNELane.h:59
LaneDrawingConstants()
default constructor
Definition GNELane.cpp:79
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:136
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition GNELane.cpp:1766
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:829
~GNELane()
Destructor.
Definition GNELane.cpp:114
std::string getParentName() const
Returns the name of the parent object (if any)
Definition GNELane.cpp:1760
std::string getAttribute(SumoXMLAttr key) const
Definition GNELane.cpp:835
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:124
const RGBColor * mySpecialColor
optional special color
Definition GNELane.h:274
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition GNELane.cpp:235
bool isAttributeComputed(SumoXMLAttr key) const
Definition GNELane.cpp:1008
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition GNELane.cpp:1547
double getLengthGeometryFactor() const
get length geometry factor
Definition GNELane.cpp:1824
bool isAttributeEnabled(SumoXMLAttr key) const
Definition GNELane.cpp:996
void updateGeometry()
update pre-computed geometry information
Definition GNELane.cpp:158
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition GNELane.cpp:1138
GNEEdge * myParentEdge
parent edge (GNELanes cannot use hierarchical structures)
Definition GNELane.h:255
void deleteGLObject()
delete element
Definition GNELane.cpp:597
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition GNELane.cpp:890
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition GNELane.cpp:662
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:788
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition GNELane.cpp:772
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition GNELane.cpp:254
GUIGeometry myLaneGeometry
lane geometry
Definition GNELane.h:261
void drawShapeEdited(const GUIVisualizationSettings &s) const
draw shape edited
Definition GNELane.cpp:1176
void drawStartEndShapePoints(const GUIVisualizationSettings &s) const
draw start and end shape points
Definition GNELane.cpp:1685
void drawMarkings(const GUIVisualizationSettings &s, const double exaggeration, const bool drawRailway) const
draw lane markings
Definition GNELane.cpp:628
void drawOverlappedRoutes(const int numRoutes) const
draw overlapped routes
Definition GNELane.cpp:1509
void updateGLObject()
update GLObject (geometry, ID, etc.)
Definition GNELane.cpp:606
GNEMoveOperation * getMoveOperation()
get move operation
Definition GNELane.cpp:241
void buildLaneOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build lane operations contextual menu
Definition GNELane.cpp:1894
GNELane()
FOX needs this.
Definition GNELane.cpp:103
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition GNELane.cpp:1794
const std::vector< double > & getShapeRotations() const
get rotations of the single shape parts
Definition GNELane.cpp:146
void drawTextures(const GUIVisualizationSettings &s, const LaneDrawingConstants &laneDrawingConstants) const
draw lane textures
Definition GNELane.cpp:1647
void buildTemplateOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build template oerations contextual menu
Definition GNELane.cpp:2015
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:1368
void drawLaneAsRailway(const GUIVisualizationSettings &s, const LaneDrawingConstants &laneDrawingConstants) const
draw lane as railway
Definition GNELane.cpp:1598
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition GNELane.cpp:1020
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition GNELane.cpp:806
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:1253
bool isValid(SumoXMLAttr key, const std::string &value)
Definition GNELane.cpp:931
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition GNELane.cpp:1773
void checkMouseOverLane(const double laneWidth) const
check if mouse is over lane
Definition GNELane.cpp:1201
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition GNELane.cpp:1501
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition GNELane.cpp:823
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:1553
void setIndex(int index)
Definition GNELane.cpp:793
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition GNELane.cpp:485
void setSpecialColor(const RGBColor *Color2, double colorValue=std::numeric_limits< double >::max())
Definition GNELane.cpp:1026
const GUIGeometry & getLaneGeometry() const
Definition GNELane.cpp:130
void drawLaneArrows(const GUIVisualizationSettings &s, const double exaggeration, const bool spreadSuperposed) const
draw lane arrows
Definition GNELane.cpp:1156
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition GNELane.cpp:778
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:612
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:1147
double getLaneShapeLength() const
returns the length of the lane's shape
Definition GNELane.cpp:817
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:1392
bool setFunctionalColor(int activeScheme, RGBColor &col) const
sets the color according to the current scheme index and some lane function
Definition GNELane.cpp:1354
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition GNELane.cpp:1809
void drawArrows(const GUIVisualizationSettings &s, const bool spreadSuperposed) const
draw arrows
Definition GNELane.cpp:351
void buildRechableOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build rechable operations contextual menu
Definition GNELane.cpp:2042
void drawLaneStopOffset(const GUIVisualizationSettings &s, const double offset) const
draw laneStopOffset
Definition GNELane.cpp:1526
void drawLane2LaneConnections() const
draw lane to lane connections
Definition GNELane.cpp:437
void buildEdgeOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build edge operations contextual menu
Definition GNELane.cpp:1835
const std::vector< double > & getShapeLengths() const
get lengths of the single shape parts
Definition GNELane.cpp:152
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition GNELane.cpp:280
double getSpeed() const
returns the current speed of lane
Definition GNELane.cpp:800
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition GNELane.cpp:900
void drawDottedContours(const GUIVisualizationSettings &s, const bool drawRailway, const double laneWidth) const
draw dotted contours
Definition GNELane.cpp:1222
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:118
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.