SUMO - Simulation of Urban MObility
GNELane.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // A class for visualizing Lane geometry (adapted from GUILaneWrapper)
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef GNELane_h
21 #define GNELane_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "GNENetElement.h"
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
39 class PositionVector;
40 class GNETLSEditorFrame;
41 class GNEEdge;
42 class GNENet;
43 class GNEAdditional;
44 class GNEConnection;
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
54 class GNELane : public GNENetElement, public FXDelegator {
56  FXDECLARE(GNELane)
57 
58 public:
60  typedef std::vector<GNEAdditional*> AdditionalVector;
61 
67  GNELane(GNEEdge& edge, const int index);
68 
70  ~GNELane();
71 
74 
76  std::vector<GNEConnection*> getGNEIncomingConnections();
77 
79  std::vector<GNEConnection*> getGNEOutcomingConnections();
80 
81  // update IDs of incoming connections of this lane
82  void updateConnectionIDs();
83 
86  // @brief Returns the name of the parent object (if any)
87  // @return This object's parent id
88  const std::string& getParentName() const;
89 
98 
107 
109  long onDefault(FXObject*, FXSelector, void*);
110 
117 
122  void drawGL(const GUIVisualizationSettings& s) const;
124 
126  const PositionVector& getShape() const;
127 
129  const std::vector<double>& getShapeRotations() const;
130 
132  const std::vector<double>& getShapeLengths() const;
133 
135  Boundary getBoundary() const;
136 
138  // @note: must be called when geometry changes (i.e. junction moved)
139  void updateGeometry();
140 
142  int getIndex() const;
143 
145  double getSpeed() const;
146 
147  /* @brief method for setting the index of the lane
148  * @param[in] index The new index of lane
149  */
150  void setIndex(int index);
151 
154  double getLaneParametricLength() const;
155 
157  double getLaneShapeLength() const;
158 
159  /* @brief returns the relative position of an element in the lane's shape depending of the parametric length
160  * Examples: Lane with Parametric length = 100 and Shape length = 250. Position 50 returns 125, Position 80 returns 200
161  * @param[in] position to calculate their relative position in the lane's shape [0 < position < LaneParametricLength()]
162  * @return the relative position in the lane's shape
163  */
164  double getPositionRelativeToParametricLength(double position) const;
165 
166  /* @brief returns the relative position of an element in the lane's shape depending of the shape's length
167  * Examples: Lane with Parametric length = 100 and Shape length = 250. Position = 100 returns 40, Position 220 returns 88
168  * @param[in] position to calculate their relative position in the lane's shape [0 < position < LaneShapeLength]
169  * @return the relative position in the lane's shape
170  */
171  double getPositionRelativeToShapeLength(double position) const;
172 
174  void addAdditionalChild(GNEAdditional* additional);
175 
177  void removeAdditionalChild(GNEAdditional* additional);
178 
180  const std::vector<GNEAdditional*>& getAdditionalChilds() const;
181 
183  bool isRestricted(SUMOVehicleClass vclass) const;
184 
187  /* @brief method for getting the Attribute of an XML key
188  * @param[in] key The attribute key
189  * @return string with the value associated to key
190  */
191  std::string getAttribute(SumoXMLAttr key) const;
192 
193  /* @brief method for setting the attribute and letting the object perform additional changes
194  * @param[in] key The attribute key
195  * @param[in] value The new value
196  * @param[in] undoList The undoList on which to register changes
197  */
198  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
199 
200  /* @brief method for checking if the key and their correspond attribute are valids
201  * @param[in] key The attribute key
202  * @param[in] value The value asociated to key key
203  * @return true if the value is valid, false in other case
204  */
205  bool isValid(SumoXMLAttr key, const std::string& value);
207 
208  /* @brief method for setting the special color of the lane
209  * @param[in] color Pointer to new special color
210  */
211  void setSpecialColor(const RGBColor* Color2);
212 
213 protected:
215  GNELane();
216 
219 
221  int myIndex;
222 
226  std::vector<double> myShapeRotations;
227 
229  std::vector<double> myShapeLengths;
230 
232  std::vector<Position> myLaneRestrictedTexturePositions;
233 
235  std::vector<double> myLaneRestrictedTextureRotations;
237 
239  AdditionalVector myAdditionals;
240 
243 
245  mutable std::vector<RGBColor> myShapeColors;
246 
249 
250 private:
252  void setAttribute(SumoXMLAttr key, const std::string& value);
253 
255  GNELane(const GNELane&);
256 
258  GNELane& operator=(const GNELane&);
259 
261  void drawMarkings(const bool& selectedEdge, double scale) const;
262 
264  void drawLinkNo(const GUIVisualizationSettings& s) const;
265 
267  void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
268 
270  void drawLinkRules() const;
271 
273  void drawArrows() const;
274 
276  void drawLane2LaneConnections() const;
277 
279  double getColorValue(int activeScheme) const;
280 
282  bool setFunctionalColor(int activeScheme) const;
283 
285  bool setMultiColor(const GUIColorer& c) const;
286 
288  bool drawAsRailway(const GUIVisualizationSettings& s) const;
289 
291  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
292 
295  void drawCrossties(double length, double spacing, double halfWidth) const;
296 
298  void drawDirectionIndicators() const;
299 };
300 
301 
302 #endif
303 
304 /****************************************************************************/
305 
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GNELane.cpp:924
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GNELane.h:229
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:219
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:774
GNETLSEditorFrame * myTLSEditor
the tls-editor for setting multiple links in TLS-mode
Definition: GNELane.h:248
AdditionalVector myAdditionals
list with the additionals vinculated with this lane
Definition: GNELane.h:239
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:452
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:242
std::vector< GNEAdditional * > AdditionalVector
FOX-declaration.
Definition: GNELane.h:60
Boundary getBoundary() const
returns the boundry (including lanes)
Definition: GNELane.cpp:639
Stores the information about how to visualize structures.
void removeAdditionalChild(GNEAdditional *additional)
remove additional child to this lane
Definition: GNELane.cpp:751
GNELane & operator=(const GNELane &)
Invalidated assignment operator.
double getPositionRelativeToParametricLength(double position) const
Definition: GNELane.cpp:727
const std::vector< double > & getShapeRotations() const
returns the vector with the shape rotations
Definition: GNELane.cpp:627
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:88
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:54
double getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:709
GNELane()
FOX needs this.
Definition: GNELane.cpp:83
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:245
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:1001
double getColorValue(int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:946
void setIndex(int index)
Definition: GNELane.cpp:702
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
int myIndex
The index of this lane.
Definition: GNELane.h:221
bool setFunctionalColor(int activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:910
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition: GNELane.h:235
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:269
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:1007
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:697
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:715
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1078
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:812
void addAdditionalChild(GNEAdditional *additional)
add additional child to this lane
Definition: GNELane.cpp:739
A list of positions.
std::vector< double > myShapeRotations
Definition: GNELane.h:226
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1084
void drawArrows() const
draw arrows
Definition: GNELane.cpp:149
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1105
double getLaneShapeLength() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:721
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:645
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:780
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:57
void drawDirectionIndicators() const
direction indicators for lanes
Definition: GNELane.cpp:1037
GNEEdge & myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:218
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:621
void updateConnectionIDs()
Definition: GNELane.cpp:1120
void drawMarkings(const bool &selectedEdge, double scale) const
draw lane markings
Definition: GNELane.cpp:407
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1069
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS Link Number
Definition: GNELane.cpp:121
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:62
void drawCrossties(double length, double spacing, double halfWidth) const
draw crossties for railroads
Definition: GNELane.cpp:1013
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition: GNELane.h:232
void setSpecialColor(const RGBColor *Color2)
Definition: GNELane.cpp:861
The popup menu of a globject.
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition: GNELane.cpp:97
void drawLinkRules() const
draw link rules
Definition: GNELane.cpp:144
const std::string & getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:1063
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:833
const std::vector< double > & getShapeLengths() const
returns the vector with the shape lengths
Definition: GNELane.cpp:633
double getPositionRelativeToShapeLength(double position) const
Definition: GNELane.cpp:733
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNELane.cpp:601
A window containing a gl-object&#39;s parameter.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:613
~GNELane()
Destructor.
Definition: GNELane.cpp:92
const std::vector< GNEAdditional * > & getAdditionalChilds() const
get additional childs of lane
Definition: GNELane.cpp:768