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-2016 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 GNEAdditionalSet;
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 
63  typedef std::vector<GNEAdditionalSet*> AdditionalSetVector;
64 
70  GNELane(GNEEdge& edge, const int index);
71 
73  ~GNELane();
74 
77  // @brief Returns the name of the parent object (if any)
78  // @return This object's parent id
79  const std::string& getParentName() const;
80 
89 
98 
100  long onDefault(FXObject*, FXSelector, void*);
101 
104 
111 
116  void drawGL(const GUIVisualizationSettings& s) const;
118 
120  const PositionVector& getShape() const;
121 
123  const std::vector<SUMOReal>& getShapeRotations() const;
124 
126  const std::vector<SUMOReal>& getShapeLengths() const;
127 
129  // @note: must be called when geometry changes (i.e. junction moved)
130  void updateGeometry();
131 
133  Boundary getBoundary() const;
134 
136  int getIndex() const;
137 
139  SUMOReal getSpeed() const;
140 
141  /* @brief method for setting the index of the lane
142  * @param[in] index The new index of lane
143  */
144  void setIndex(int index);
145 
149 
152 
153  /* @brief returns the relative position of an element in the lane's shape depending of the parametric lenght
154  * Examples: Lane with Parametric lenght = 100 and Shape lenght = 250. Position 50 returns 125, Position 80 returns 200
155  * @param[in] position to calculate their relative position in the lane's shape [0 < position < LaneParametricLenght()]
156  * @return the relative position in the lane's shape
157  */
159 
160  /* @brief returns the relative position of an element in the lane's shape depending of the shape's lenght
161  * Examples: Lane with Parametric lenght = 100 and Shape lenght = 250. Position = 100 returns 40, Position 220 returns 88
162  * @param[in] position to calculate their relative position in the lane's shape [0 < position < LaneShapeLenght]
163  * @return the relative position in the lane's shape
164  */
166 
167  /* @brief method for adding a reference of a additional element placed in this lane
168  * @param[in] additional Pointer to additional element
169  */
170  void addAdditional(GNEAdditional* additional);
171 
172  /* @brief method for remove a reference of a additional element placed in this lane
173  * @param[in] additional Pointer to additional element previously added
174  @return true if additional element was sucesfully removed, flase in other case
175  */
176  bool removeAdditional(GNEAdditional* additional);
177 
180  const std::vector<GNEAdditional*>& getAdditionals() const;
181 
183  bool addAdditionalSet(GNEAdditionalSet* additionalSet);
184 
186  bool removeAdditionalSet(GNEAdditionalSet* additionalSet);
187 
189  const std::vector<GNEAdditionalSet*>& getAdditionalSets();
190 
193  /* @brief method for getting the Attribute of an XML key
194  * @param[in] key The attribute key
195  * @return string with the value associated to key
196  */
197  std::string getAttribute(SumoXMLAttr key) const;
198 
199  /* @brief method for setting the attribute and letting the object perform additional changes
200  * @param[in] key The attribute key
201  * @param[in] value The new value
202  * @param[in] undoList The undoList on which to register changes
203  */
204  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
205 
206  /* @brief method for checking if the key and their correspond attribute are valids
207  * @param[in] key The attribute key
208  * @param[in] value The value asociated to key key
209  * @return true if the value is valid, false in other case
210  */
211  bool isValid(SumoXMLAttr key, const std::string& value);
213 
214  /* @brief method for setting the special color of the lane
215  * @param[in] color Pointer to new special color
216  */
217  void setSpecialColor(const RGBColor* Color2);
218 
219 protected:
221  GNELane();
222 
225 
227  int myIndex;
228 
232  std::vector<SUMOReal> myShapeRotations;
233 
235  std::vector<SUMOReal> myShapeLengths;
237 
239  AdditionalVector myAdditionals;
240 
242  AdditionalSetVector myAdditionalSets;
243 
246 
248  mutable std::vector<RGBColor> myShapeColors;
249 
252 
253 private:
255  void setAttribute(SumoXMLAttr key, const std::string& value);
256 
258  GNELane(const GNELane&);
259 
261  GNELane& operator=(const GNELane&);
262 
264  void drawMarkings(const bool& selectedEdge, SUMOReal scale) const;
265 
267  void drawLinkNo() const;
268 
270  void drawTLSLinkNo() const;
271 
273  void drawLinkRules() const;
274 
276  void drawArrows() const;
277 
279  void drawLane2LaneConnections() const;
280 
282  SUMOReal getColorValue(int activeScheme) const;
283 
285  bool setFunctionalColor(int activeScheme) const;
286 
288  bool setMultiColor(const GUIColorer& c) const;
289 
291  bool drawAsRailway(const GUIVisualizationSettings& s) const;
292 
294  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
295 
298  void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const;
299 
301  void drawDirectionIndicators() const;
302 };
303 
304 
305 #endif
306 
307 /****************************************************************************/
308 
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:799
const std::string & getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:855
const std::vector< SUMOReal > & getShapeRotations() const
returns the vector with the shape rotations
Definition: GNELane.cpp:462
GNETLSEditorFrame * myTLSEditor
the tls-editor for setting multiple links in TLS-mode
Definition: GNELane.h:251
AdditionalVector myAdditionals
list with the additonals vinculated with this lane
Definition: GNELane.h:239
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:371
std::vector< GNEAdditionalSet * > AdditionalSetVector
Definition of the additionalSets vector.
Definition: GNELane.h:63
void drawMarkings(const bool &selectedEdge, SUMOReal scale) const
draw lane markings
Definition: GNELane.cpp:326
SUMOReal getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:512
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:245
SUMOReal getPositionRelativeToShapeLenght(SUMOReal position) const
Definition: GNELane.cpp:536
std::vector< GNEAdditional * > AdditionalVector
FOX-declaration.
Definition: GNELane.h:60
Stores the information about how to visualize structures.
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:705
SUMOReal getColorValue(int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:741
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:86
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:719
GNELane()
FOX needs this.
Definition: GNELane.cpp:86
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:248
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void drawTLSLinkNo() const
draw TLS Link Number
Definition: GNELane.cpp:109
An Element wich group additionalSet elements.
Boundary getBoundary() const
returns the boundry (including lanes)
Definition: GNELane.cpp:442
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:500
void setIndex(int index)
Definition: GNELane.cpp:505
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
int myIndex
The index of this lane.
Definition: GNELane.h:227
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:793
void drawDirectionIndicators() const
direction indicators for lanes
Definition: GNELane.cpp:829
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:189
void drawArrows() const
draw arrows
Definition: GNELane.cpp:119
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:870
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:627
SUMOReal getLaneParametricLenght() const
returns the parameteric length of the lane
Definition: GNELane.cpp:518
SUMOReal getPositionRelativeToParametricLenght(SUMOReal position) const
Definition: GNELane.cpp:530
A list of positions.
std::vector< SUMOReal > myShapeRotations
Definition: GNELane.h:232
AdditionalSetVector myAdditionalSets
list with the additonalSets vinculated with this lane
Definition: GNELane.h:242
bool removeAdditionalSet(GNEAdditionalSet *additionalSet)
remove GNEAdditionalSet from this lane
Definition: GNELane.cpp:581
bool removeAdditional(GNEAdditional *additional)
Definition: GNELane.cpp:548
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:473
void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const
draw crossties for railroads
Definition: GNELane.cpp:805
bool addAdditionalSet(GNEAdditionalSet *additionalSet)
add GNEAdditionalSet to this lane
Definition: GNELane.cpp:567
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:601
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:54
void drawLinkRules() const
draw link rules
Definition: GNELane.cpp:114
GNEEdge & myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:224
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:456
SUMOReal getLaneShapeLenght() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:524
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:861
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:63
const std::vector< GNEAdditional * > & getAdditionals() const
method to obtain a list of additional elements associated to this lane
Definition: GNELane.cpp:561
std::vector< SUMOReal > myShapeLengths
The lengths of the shape parts.
Definition: GNELane.h:235
void setSpecialColor(const RGBColor *Color2)
Definition: GNELane.cpp:669
The popup menu of a globject.
const std::vector< SUMOReal > & getShapeLengths() const
returns the vector with the shape lengths
Definition: GNELane.cpp:468
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:448
#define SUMOReal
Definition: config.h:213
void addAdditional(GNEAdditional *additional)
Definition: GNELane.cpp:542
const std::vector< GNEAdditionalSet * > & getAdditionalSets()
return list of additionalSets associated with this lane
Definition: GNELane.cpp:595
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:647
void drawLinkNo() const
draw link Number
Definition: GNELane.cpp:104
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNELane.cpp:431
A window containing a gl-object&#39;s parameter.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:239
~GNELane()
Destructor.
Definition: GNELane.cpp:95