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.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 // ===========================================================================
32 class PositionVector;
33 class GNETLSEditorFrame;
34 class GNEEdge;
35 class GNENet;
36 class GNEConnection;
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
46 class GNELane : public GNENetworkElement, public GNECandidateElement, public FXDelegator {
48  FXDECLARE(GNELane)
49 
50 public:
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:
84  const GNELane* myLane;
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:
109  DrawingConstants() = delete;
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 
150  const DrawingConstants* getDrawingConstants() const;
151 
153  void updateGeometry();
154 
156  Position getPositionInView() const;
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 setting the attribute and letting the object perform additional changes
282  * @param[in] key The attribute key
283  * @param[in] value The new value
284  * @param[in] undoList The undoList on which to register changes
285  */
286  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
287 
288  /* @brief method for checking if the key and their correspond attribute are valids
289  * @param[in] key The attribute key
290  * @param[in] value The value associated to key key
291  * @return true if the value is valid, false in other case
292  */
293  bool isValid(SumoXMLAttr key, const std::string& value);
294 
295  /* @brief method for check if the value for certain attribute is set
296  * @param[in] key The attribute key
297  */
298  bool isAttributeEnabled(SumoXMLAttr key) const;
299 
300  /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
301  * @param[in] key The attribute key
302  */
303  bool isAttributeComputed(SumoXMLAttr key) const;
305 
307  const Parameterised::Map& getACParametersMap() const;
308 
309  /* @brief method for setting the special color of the lane
310  * @param[in] color Pointer to new special color
311  */
312  void setSpecialColor(const RGBColor* Color2, double colorValue = std::numeric_limits<double>::max());
313 
315  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
316 
318  void drawOverlappedRoutes(const int numRoutes) const;
319 
321  void drawLaneStopOffset(const GUIVisualizationSettings& s) const;
322 
323 protected:
325  GNELane();
326 
327 private:
330 
332  int myIndex;
333 
336 
339 
342 
344  std::vector<Position> myLaneRestrictedTexturePositions;
345 
347  std::vector<double> myLaneRestrictedTextureRotations;
349 
352 
355 
357  mutable std::vector<RGBColor> myShapeColors;
358 
361 
363  void setAttribute(SumoXMLAttr key, const std::string& value);
364 
366  void setMoveShape(const GNEMoveResult& moveResult);
367 
369  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
370 
372  void drawLane(const GUIVisualizationSettings& s) const;
373 
375  void drawSelectedLane(const GUIVisualizationSettings& s) const;
376 
378  void drawShapeEdited(const GUIVisualizationSettings& s) const;
379 
381  void drawChildren(const GUIVisualizationSettings& s) const;
382 
385 
387  void drawLinkNo(const GUIVisualizationSettings& s) const;
388 
390  void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
391 
393  void drawArrows(const GUIVisualizationSettings& s) const;
394 
396  void drawLane2LaneConnections() const;
397 
399  void calculateLaneContour(const GUIVisualizationSettings& s) const;
400 
402  bool setFunctionalColor(int activeScheme, RGBColor& col) const;
403 
405  bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
406 
408  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
409 
412 
414  void drawLaneAsRailway() const;
415 
417  void drawTextures(const GUIVisualizationSettings& s) const;
418 
421 
424 
427 
430 
433 
436 
438  GNELane(const GNELane&) = delete;
439 
441  GNELane& operator=(const GNELane&) = delete;
442 };
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
void update(const GUIVisualizationSettings &s)
update lane drawing constants
Definition: GNELane.cpp:74
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
DrawingConstants & operator=(const DrawingConstants &)=delete
Invalidated assignment operator.
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:360
const PositionVector & getLaneShape() const
get elements shape
Definition: GNELane.cpp:214
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1906
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:684
~GNELane()
Destructor.
Definition: GNELane.cpp:188
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:1900
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:690
void drawLaneStopOffset(const GUIVisualizationSettings &s) const
draw laneStopOffset
Definition: GNELane.cpp:1682
void drawSelectedLane(const GUIVisualizationSettings &s) const
draw selected lane
Definition: GNELane.cpp:1072
bool checkDrawMoveContour() const
check if draw move contour (red)
Definition: GNELane.cpp:429
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition: GNELane.h:347
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:1138
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:351
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNELane.cpp:319
bool isAttributeComputed(SumoXMLAttr key) const
Definition: GNELane.cpp:869
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:1706
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
Definition: GNELane.cpp:393
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1964
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNELane.cpp:855
void drawDirectionIndicators(const GUIVisualizationSettings &s) const
direction indicators for lanes
Definition: GNELane.cpp:1712
bool checkDrawSelectContour() const
check if draw select contour (blue)
Definition: GNELane.cpp:411
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:242
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNELane.cpp:999
GNEEdge * myParentEdge
parent edge (GNELanes cannot use hierarchical structures)
Definition: GNELane.h:329
void deleteGLObject()
delete element
Definition: GNELane.cpp:498
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNELane.cpp:749
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:514
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:642
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition: GNELane.cpp:624
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition: GNELane.cpp:452
GUIGeometry myLaneGeometry
lane geometry
Definition: GNELane.h:335
bool checkDrawOverContour() const
check if draw over contour (orange)
Definition: GNELane.cpp:359
void drawShapeEdited(const GUIVisualizationSettings &s) const
draw shape edited
Definition: GNELane.cpp:1091
void drawOverlappedRoutes(const int numRoutes) const
draw overlapped routes
Definition: GNELane.cpp:1665
void calculateLaneContour(const GUIVisualizationSettings &s) const
calculate contour
Definition: GNELane.cpp:1401
void updateGLObject()
update GLObject (geometry, ID, etc.)
Definition: GNELane.cpp:507
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNELane.cpp:440
void drawLane(const GUIVisualizationSettings &s) const
draw lane
Definition: GNELane.cpp:1017
void buildLaneOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build lane operations contextual menu
Definition: GNELane.cpp:2034
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:1934
DrawingConstants * myDrawingConstants
LaneDrawingConstants.
Definition: GNELane.h:338
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:2155
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:1529
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS link Number
Definition: GNELane.cpp:1228
GNELane & operator=(const GNELane &)=delete
Invalidated assignment operator.
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition: GNELane.cpp:881
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:661
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:1417
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:790
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1913
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:678
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:332
void drawLaneAsRailway() const
draw lane as railway
Definition: GNELane.cpp:1754
void setIndex(int index)
Definition: GNELane.cpp:648
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:478
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:887
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:630
void drawArrows(const GUIVisualizationSettings &s) const
draw lane arrows
Definition: GNELane.cpp:1265
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNELane.cpp:636
double mySpecialColorValue
optional value that corresponds to which the special color corresponds
Definition: GNELane.h:354
void drawChildren(const GUIVisualizationSettings &s) const
draw children
Definition: GNELane.cpp:1117
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
Definition: GNELane.cpp:353
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition: GNELane.h:344
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNELane.cpp:1008
double getLaneShapeLength() const
returns the length of the lane's shape
Definition: GNELane.cpp:672
void drawStartEndGeometryPoints(const GUIVisualizationSettings &s) const
draw start and end geometry points
Definition: GNELane.cpp:1832
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:357
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:1553
bool checkDrawToContour() const
check if draw from contour (magenta)
Definition: GNELane.cpp:339
bool setFunctionalColor(int activeScheme, RGBColor &col) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:1515
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition: GNELane.cpp:1949
void buildRechableOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build rechable operations contextual menu
Definition: GNELane.cpp:2181
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:1353
void buildEdgeOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build edge operations contextual menu
Definition: GNELane.cpp:1975
const std::vector< double > & getShapeLengths() const
get lengths of the single shape parts
Definition: GNELane.cpp:230
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition: GNELane.cpp:1191
double getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:655
void drawTextures(const GUIVisualizationSettings &s) const
draw lane textures
Definition: GNELane.cpp:1800
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:759
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
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.