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 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 
313  const Parameterised::Map& getACParametersMap() const;
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 
329 protected:
331  GNELane();
332 
333 private:
336 
338  int myIndex;
339 
342 
345 
348 
350  std::vector<Position> myLaneRestrictedTexturePositions;
351 
353  std::vector<double> myLaneRestrictedTextureRotations;
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;
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;
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
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: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:1925
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:657
~GNELane()
Destructor.
Definition: GNELane.cpp:188
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:1919
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:663
void drawLaneStopOffset(const GUIVisualizationSettings &s) const
draw laneStopOffset
Definition: GNELane.cpp:1701
void drawSelectedLane(const GUIVisualizationSettings &s) const
draw selected lane
Definition: GNELane.cpp:1066
bool checkDrawMoveContour() const
check if draw move contour (red)
Definition: GNELane.cpp:401
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:1129
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:863
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:1725
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
Definition: GNELane.cpp:365
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1983
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNELane.cpp:849
void drawDirectionIndicators(const GUIVisualizationSettings &s) const
direction indicators for lanes
Definition: GNELane.cpp:1731
bool checkDrawSelectContour() const
check if draw select contour (blue)
Definition: GNELane.cpp:383
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:242
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNELane.cpp:993
GNEEdge * myParentEdge
parent edge (GNELanes cannot use hierarchical structures)
Definition: GNELane.h:335
void deleteGLObject()
delete element
Definition: GNELane.cpp:471
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNELane.cpp:736
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:487
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:615
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition: GNELane.cpp:597
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition: GNELane.cpp:425
GUIGeometry myLaneGeometry
lane geometry
Definition: GNELane.h:341
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:1085
void drawOverlappedRoutes(const int numRoutes) const
draw overlapped routes
Definition: GNELane.cpp:1684
void calculateLaneContour(const GUIVisualizationSettings &s) const
calculate contour
Definition: GNELane.cpp:1420
void updateGLObject()
update GLObject (geometry, ID, etc.)
Definition: GNELane.cpp:480
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNELane.cpp:413
void drawLane(const GUIVisualizationSettings &s) const
draw lane
Definition: GNELane.cpp:1011
void buildLaneOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build lane operations contextual menu
Definition: GNELane.cpp:2053
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:1953
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:2174
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:1548
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS link Number
Definition: GNELane.cpp:1247
GNELane & operator=(const GNELane &)=delete
Invalidated assignment operator.
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition: GNELane.cpp:875
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:634
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:1436
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:784
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1932
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:651
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:1773
void setIndex(int index)
Definition: GNELane.cpp:621
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:451
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:881
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:603
void drawArrows(const GUIVisualizationSettings &s) const
draw lane arrows
Definition: GNELane.cpp:1284
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNELane.cpp:609
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:1111
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:350
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNELane.cpp:1002
double getLaneShapeLength() const
returns the length of the lane's shape
Definition: GNELane.cpp:645
void drawStartEndGeometryPoints(const GUIVisualizationSettings &s) const
draw start and end geometry points
Definition: GNELane.cpp:1851
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:1572
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:1534
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition: GNELane.cpp:1968
void buildRechableOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build rechable operations contextual menu
Definition: GNELane.cpp:2200
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:1372
void buildEdgeOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build edge operations contextual menu
Definition: GNELane.cpp:1994
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:724
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition: GNELane.cpp:1210
double getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:628
void drawTextures(const GUIVisualizationSettings &s) const
draw lane textures
Definition: GNELane.cpp:1819
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:746
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.