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  // @brief Returns the name of the parent object (if any)
75  // @return This object's parent id
76  const std::string& getParentName() const;
77 
86 
95 
97  long onDefault(FXObject*, FXSelector, void*);
98 
101 
103  std::vector<GNEConnection*> getGNEIncomingConnections();
104 
106  std::vector<GNEConnection*> getGNEOutcomingConnections();
107 
114 
119  void drawGL(const GUIVisualizationSettings& s) const;
121 
123  const PositionVector& getShape() const;
124 
126  const std::vector<SUMOReal>& getShapeRotations() const;
127 
129  const std::vector<SUMOReal>& getShapeLengths() const;
130 
132  Boundary getBoundary() const;
133 
135  // @note: must be called when geometry changes (i.e. junction moved)
136  void updateGeometry();
137 
139  int getIndex() const;
140 
142  SUMOReal getSpeed() const;
143 
144  /* @brief method for setting the index of the lane
145  * @param[in] index The new index of lane
146  */
147  void setIndex(int index);
148 
152 
155 
156  /* @brief returns the relative position of an element in the lane's shape depending of the parametric lenght
157  * Examples: Lane with Parametric lenght = 100 and Shape lenght = 250. Position 50 returns 125, Position 80 returns 200
158  * @param[in] position to calculate their relative position in the lane's shape [0 < position < LaneParametricLenght()]
159  * @return the relative position in the lane's shape
160  */
162 
163  /* @brief returns the relative position of an element in the lane's shape depending of the shape's lenght
164  * Examples: Lane with Parametric lenght = 100 and Shape lenght = 250. Position = 100 returns 40, Position 220 returns 88
165  * @param[in] position to calculate their relative position in the lane's shape [0 < position < LaneShapeLenght]
166  * @return the relative position in the lane's shape
167  */
169 
171  void addAdditionalChild(GNEAdditional* additional);
172 
174  void removeAdditionalChild(GNEAdditional* additional);
175 
177  const std::vector<GNEAdditional*>& getAdditionalChilds() const;
178 
180  bool isRestricted(SUMOVehicleClass vclass) const;
181 
184  /* @brief method for getting the Attribute of an XML key
185  * @param[in] key The attribute key
186  * @return string with the value associated to key
187  */
188  std::string getAttribute(SumoXMLAttr key) const;
189 
190  /* @brief method for setting the attribute and letting the object perform additional changes
191  * @param[in] key The attribute key
192  * @param[in] value The new value
193  * @param[in] undoList The undoList on which to register changes
194  */
195  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
196 
197  /* @brief method for checking if the key and their correspond attribute are valids
198  * @param[in] key The attribute key
199  * @param[in] value The value asociated to key key
200  * @return true if the value is valid, false in other case
201  */
202  bool isValid(SumoXMLAttr key, const std::string& value);
204 
205  /* @brief method for setting the special color of the lane
206  * @param[in] color Pointer to new special color
207  */
208  void setSpecialColor(const RGBColor* Color2);
209 
210 protected:
212  GNELane();
213 
216 
218  int myIndex;
219 
223  std::vector<SUMOReal> myShapeRotations;
224 
226  std::vector<SUMOReal> myShapeLengths;
227 
229  std::vector<Position> myLaneRestrictedTexturePositions;
230 
232  std::vector<SUMOReal> myLaneRestrictedTextureRotations;
234 
236  AdditionalVector myAdditionals;
237 
240 
242  mutable std::vector<RGBColor> myShapeColors;
243 
246 
247 private:
249  void setAttribute(SumoXMLAttr key, const std::string& value);
250 
252  GNELane(const GNELane&);
253 
255  GNELane& operator=(const GNELane&);
256 
258  void drawMarkings(const bool& selectedEdge, SUMOReal scale) const;
259 
261  void drawLinkNo() const;
262 
264  void drawTLSLinkNo() const;
265 
267  void drawLinkRules() const;
268 
270  void drawArrows() const;
271 
273  void drawLane2LaneConnections() const;
274 
276  SUMOReal getColorValue(int activeScheme) const;
277 
279  bool setFunctionalColor(int activeScheme) const;
280 
282  bool setMultiColor(const GUIColorer& c) const;
283 
285  bool drawAsRailway(const GUIVisualizationSettings& s) const;
286 
288  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
289 
292  void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const;
293 
295  void drawDirectionIndicators() const;
296 };
297 
298 
299 #endif
300 
301 /****************************************************************************/
302 
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:956
const std::string & getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:1012
const std::vector< SUMOReal > & getShapeRotations() const
returns the vector with the shape rotations
Definition: GNELane.cpp:589
GNETLSEditorFrame * myTLSEditor
the tls-editor for setting multiple links in TLS-mode
Definition: GNELane.h:245
AdditionalVector myAdditionals
list with the additonals vinculated with this lane
Definition: GNELane.h:236
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:414
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
void drawMarkings(const bool &selectedEdge, SUMOReal scale) const
draw lane markings
Definition: GNELane.cpp:369
SUMOReal getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:671
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:239
SUMOReal getPositionRelativeToShapeLenght(SUMOReal position) const
Definition: GNELane.cpp:695
std::vector< GNEAdditional * > AdditionalVector
FOX-declaration.
Definition: GNELane.h:60
Stores the information about how to visualize structures.
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:736
const std::vector< GNEAdditional * > & getAdditionalChilds() const
get additional childs of lane
Definition: GNELane.cpp:730
void removeAdditionalChild(GNEAdditional *additional)
remove additional child to this lane
Definition: GNELane.cpp:713
GNELane & operator=(const GNELane &)
Invalidated assignment operator.
bool setFunctionalColor(int activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:862
SUMOReal getColorValue(int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:898
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:87
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:54
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GNELane.cpp:876
GNELane()
FOX needs this.
Definition: GNELane.cpp:88
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:242
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void drawTLSLinkNo() const
draw TLS Link Number
Definition: GNELane.cpp:107
Boundary getBoundary() const
returns the boundry (including lanes)
Definition: GNELane.cpp:601
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:659
std::vector< SUMOReal > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition: GNELane.h:232
void setIndex(int index)
Definition: GNELane.cpp:664
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
int myIndex
The index of this lane.
Definition: GNELane.h:218
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:950
void drawDirectionIndicators() const
direction indicators for lanes
Definition: GNELane.cpp:986
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:187
void drawArrows() const
draw arrows
Definition: GNELane.cpp:117
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1027
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:772
SUMOReal getLaneParametricLenght() const
returns the parameteric length of the lane
Definition: GNELane.cpp:677
SUMOReal getPositionRelativeToParametricLenght(SUMOReal position) const
Definition: GNELane.cpp:689
void addAdditionalChild(GNEAdditional *additional)
add additional child to this lane
Definition: GNELane.cpp:701
A list of positions.
std::vector< SUMOReal > myShapeRotations
Definition: GNELane.h:223
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1033
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1054
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:607
void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const
draw crossties for railroads
Definition: GNELane.cpp:962
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:742
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:54
void drawLinkRules() const
draw link rules
Definition: GNELane.cpp:112
GNEEdge & myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:215
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:583
SUMOReal getLaneShapeLenght() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:683
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1018
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:62
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition: GNELane.h:229
std::vector< SUMOReal > myShapeLengths
The lengths of the shape parts.
Definition: GNELane.h:226
void setSpecialColor(const RGBColor *Color2)
Definition: GNELane.cpp:818
The popup menu of a globject.
const std::vector< SUMOReal > & getShapeLengths() const
returns the vector with the shape lengths
Definition: GNELane.cpp:595
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:575
#define SUMOReal
Definition: config.h:208
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:792
void drawLinkNo() const
draw link Number
Definition: GNELane.cpp:102
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNELane.cpp:563
A window containing a gl-object&#39;s parameter.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:237
~GNELane()
Destructor.
Definition: GNELane.cpp:97