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 // ===========================================================================
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:
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 
76  };
77 
83  GNELane(GNEEdge* edge, const int index);
84 
86  ~GNELane();
87 
89  GNEEdge* getParentEdge() const;
90 
92  bool allowPedestrians() const;
93 
97  const GUIGeometry& getLaneGeometry() const;
98 
100  const PositionVector& getLaneShape() const;
101 
103  const std::vector<double>& getShapeRotations() const;
104 
106  const std::vector<double>& getShapeLengths() const;
107 
109  void updateGeometry();
110 
112  Position getPositionInView() const;
114 
119 
121  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
123 
125  std::vector<GNEConnection*> getGNEIncomingConnections();
126 
128  std::vector<GNEConnection*> getGNEOutcomingConnections();
129 
131  void updateConnectionIDs();
132 
134  double getLengthGeometryFactor() const;
135 
138  // @brief Returns the name of the parent object (if any)
139  // @return This object's parent id
140  std::string getParentName() const;
141 
150 
152  long onDefault(FXObject*, FXSelector, void*);
153 
155  double getExaggeration(const GUIVisualizationSettings& s) const;
156 
158  void updateCenteringBoundary(const bool updateGrid);
159 
164  void drawGL(const GUIVisualizationSettings& s) const;
166 
168  int getIndex() const;
169 
171  double getSpeed() const;
172 
173  /* @brief method for setting the index of the lane
174  * @param[in] index The new index of lane
175  */
176  void setIndex(int index);
177 
181  double getLaneParametricLength() const;
182 
184  double getLaneShapeLength() const;
185 
187  bool isRestricted(SUMOVehicleClass vclass) const;
188 
191 
194  /* @brief method for getting the Attribute of an XML key
195  * @param[in] key The attribute key
196  * @return string with the value associated to key
197  */
198  std::string getAttribute(SumoXMLAttr key) const;
199  std::string getAttributeForSelection(SumoXMLAttr key) const;
200 
201  /* @brief method for setting the attribute and letting the object perform additional changes
202  * @param[in] key The attribute key
203  * @param[in] value The new value
204  * @param[in] undoList The undoList on which to register changes
205  */
206  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
207 
208  /* @brief method for checking if the key and their correspond attribute are valids
209  * @param[in] key The attribute key
210  * @param[in] value The value asociated to key key
211  * @return true if the value is valid, false in other case
212  */
213  bool isValid(SumoXMLAttr key, const std::string& value);
214 
215  /* @brief method for check if the value for certain attribute is set
216  * @param[in] key The attribute key
217  */
218  bool isAttributeEnabled(SumoXMLAttr key) const;
219 
220  /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
221  * @param[in] key The attribute key
222  */
223  bool isAttributeComputed(SumoXMLAttr key) const;
225 
227  const std::map<std::string, std::string>& getACParametersMap() const;
228 
229  /* @brief method for setting the special color of the lane
230  * @param[in] color Pointer to new special color
231  */
232  void setSpecialColor(const RGBColor* Color2, double colorValue = std::numeric_limits<double>::max());
233 
235  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
236 
238  bool drawAsRailway(const GUIVisualizationSettings& s) const;
239 
241  void drawOverlappedRoutes(const int numRoutes) const;
242 
244  void drawLaneStopOffset(const GUIVisualizationSettings& s, const double offset) const;
245 
246 protected:
248  GNELane();
249 
250 private:
253 
255  int myIndex;
256 
259 
262 
264  std::vector<Position> myLaneRestrictedTexturePositions;
265 
267  std::vector<double> myLaneRestrictedTextureRotations;
269 
272 
275 
277  mutable std::vector<RGBColor> myShapeColors;
278 
281 
283  void setAttribute(SumoXMLAttr key, const std::string& value);
284 
286  void setMoveShape(const GNEMoveResult& moveResult);
287 
289  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
290 
292  void drawChildren(const GUIVisualizationSettings& s) const;
293 
295  void drawMarkings(const GUIVisualizationSettings& s, const double exaggeration, const bool drawRailway) const;
296 
298  void drawLinkNo(const GUIVisualizationSettings& s) const;
299 
301  void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
302 
304  void drawLinkRules(const GUIVisualizationSettings& s) const;
305 
307  void drawArrows(const GUIVisualizationSettings& s, const bool spreadSuperposed) const;
308 
310  void drawLane2LaneConnections() const;
311 
313  bool setFunctionalColor(int activeScheme, RGBColor& col) const;
314 
316  bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
317 
319  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
320 
322  void drawDirectionIndicators(const GUIVisualizationSettings& s, double exaggeration, const bool drawAsRailway, const bool spreadSuperposed) const;
323 
325  void drawLaneAsRailway(const GUIVisualizationSettings& s, const LaneDrawingConstants& laneDrawingConstants) const;
326 
328  void drawTextures(const GUIVisualizationSettings& s, const LaneDrawingConstants& laneDrawingConstants) const;
329 
332 
335 
338 
341 
344 
346  GNELane(const GNELane&) = delete;
347 
349  GNELane& operator=(const GNELane&) = delete;
350 };
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 & operator=(const LaneDrawingConstants &)=delete
Invalidated assignment operator.
LaneDrawingConstants()
default constructor
Definition: GNELane.cpp:74
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:280
const PositionVector & getLaneShape() const
get elements shape
Definition: GNELane.cpp:131
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1655
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:838
~GNELane()
Destructor.
Definition: GNELane.cpp:109
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:1649
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:844
void drawLinkRules(const GUIVisualizationSettings &s) const
draw link rules
Definition: GNELane.cpp:356
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition: GNELane.h:267
bool allowPedestrians() const
check if current lane allow pedestrians
Definition: GNELane.cpp:119
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:271
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNELane.cpp:238
bool isAttributeComputed(SumoXMLAttr key) const
Definition: GNELane.cpp:1013
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:1436
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1713
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNELane.cpp:1001
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:153
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNELane.cpp:1140
GNEEdge * myParentEdge
parent edge (GNELanes cannot use hierarchical structures)
Definition: GNELane.h:252
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNELane.cpp:897
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:684
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:797
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GNELane.cpp:781
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition: GNELane.cpp:257
GUIGeometry myLaneGeometry
lane geometry
Definition: GNELane.h:258
void drawStartEndShapePoints(const GUIVisualizationSettings &s) const
draw start and end shape points
Definition: GNELane.cpp:1574
void drawMarkings(const GUIVisualizationSettings &s, const double exaggeration, const bool drawRailway) const
draw lane markings
Definition: GNELane.cpp:650
void drawOverlappedRoutes(const int numRoutes) const
draw overlapped routes
Definition: GNELane.cpp:1398
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNELane.cpp:244
void buildLaneOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build lane operations contextual menu
Definition: GNELane.cpp:1764
GNELane()
FOX needs this.
Definition: GNELane.cpp:98
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1683
const std::vector< double > & getShapeRotations() const
get rotations of the single shape parts
Definition: GNELane.cpp:141
void drawTextures(const GUIVisualizationSettings &s, const LaneDrawingConstants &laneDrawingConstants) const
draw lane textures
Definition: GNELane.cpp:1536
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:1265
void drawLaneAsRailway(const GUIVisualizationSettings &s, const LaneDrawingConstants &laneDrawingConstants) const
draw lane as railway
Definition: GNELane.cpp:1487
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS Link Number
Definition: GNELane.cpp:320
GNELane & operator=(const GNELane &)=delete
Invalidated assignment operator.
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:815
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:1158
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:937
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1662
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:1390
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:832
int myIndex
The index of this lane.
Definition: GNELane.h:255
void drawDirectionIndicators(const GUIVisualizationSettings &s, double exaggeration, const bool drawAsRailway, const bool spreadSuperposed) const
direction indicators for lanes
Definition: GNELane.cpp:1442
void setIndex(int index)
Definition: GNELane.cpp:802
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:496
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNELane.cpp:1025
void setSpecialColor(const RGBColor *Color2, double colorValue=std::numeric_limits< double >::max())
Definition: GNELane.cpp:1031
const GUIGeometry & getLaneGeometry() const
Definition: GNELane.cpp:125
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNELane.cpp:787
double mySpecialColorValue
optional value that corresponds to which the special color corresponds
Definition: GNELane.h:274
void drawChildren(const GUIVisualizationSettings &s) const
draw children
Definition: GNELane.cpp:630
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition: GNELane.h:264
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNELane.cpp:1149
double getLaneShapeLength() const
returns the length of the lane's shape
Definition: GNELane.cpp:826
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:277
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:1289
bool setFunctionalColor(int activeScheme, RGBColor &col) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:1251
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition: GNELane.cpp:1698
void drawArrows(const GUIVisualizationSettings &s, const bool spreadSuperposed) const
draw arrows
Definition: GNELane.cpp:362
void buildRechableOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build rechable operations contextual menu
Definition: GNELane.cpp:1879
void drawLaneStopOffset(const GUIVisualizationSettings &s, const double offset) const
draw laneStopOffset
Definition: GNELane.cpp:1415
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:448
void buildEdgeOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build edge operations contextual menu
Definition: GNELane.cpp:1724
const std::vector< double > & getShapeLengths() const
get lengths of the single shape parts
Definition: GNELane.cpp:147
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition: GNELane.cpp:283
double getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:809
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:907
GNEEdge * getParentEdge() const
get arent edge
Definition: GNELane.cpp:113
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.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.