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 
65 
71  GNELane(GNEEdge& edge, const int index);
72 
74  ~GNELane();
75 
78  // @brief Returns the name of the parent object (if any)
79  // @return This object's parent id
80  const std::string& getParentName() const;
81 
90 
99 
101  long onDefault(FXObject*, FXSelector, void*);
102 
105 
112 
117  void drawGL(const GUIVisualizationSettings& s) const;
119 
121  const PositionVector& getShape() const;
122 
124  const std::vector<SUMOReal>& getShapeRotations() const;
125 
127  const std::vector<SUMOReal>& getShapeLengths() const;
128 
130  Boundary getBoundary() const;
131 
133  // @note: must be called when geometry changes (i.e. junction moved)
134  void updateGeometry();
135 
137  unsigned int getIndex() const;
138 
140  SUMOReal getSpeed() const;
141 
142  /* @brief method for setting the index of the lane
143  * @param[in] index The new index of lane
144  */
145  void setIndex(unsigned int index);
146 
150 
153 
154  /* @brief returns the relative position of an element in the lane's shape depending of the parametric lenght
155  * Examples: Lane with Parametric lenght = 100 and Shape lenght = 250. Position 50 returns 125, Position 80 returns 200
156  * @param[in] position to calculate their relative position in the lane's shape [0 < position < LaneParametricLenght()]
157  * @return the relative position in the lane's shape
158  */
160 
161  /* @brief returns the relative position of an element in the lane's shape depending of the shape's lenght
162  * Examples: Lane with Parametric lenght = 100 and Shape lenght = 250. Position = 100 returns 40, Position 220 returns 88
163  * @param[in] position to calculate their relative position in the lane's shape [0 < position < LaneShapeLenght]
164  * @return the relative position in the lane's shape
165  */
167 
168  /* @brief method for adding a reference of a additional element placed in this lane
169  * @param[in] additional Pointer to additional element
170  */
171  void addAdditional(GNEAdditional* additional);
172 
173  /* @brief method for remove a reference of a additional element placed in this lane
174  * @param[in] additional Pointer to additional element previously added
175  @return true if additional element was sucesfully removed, flase in other case
176  */
177  bool removeAdditional(GNEAdditional* additional);
178 
181  const std::vector<GNEAdditional*>& getAdditionals() const;
182 
184  bool addAdditionalSet(GNEAdditionalSet* additionalSet);
185 
187  bool removeAdditionalSet(GNEAdditionalSet* additionalSet);
188 
190  const std::vector<GNEAdditionalSet*>& getAdditionalSets();
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 
200  /* @brief method for setting the attribute and letting the object perform additional changes
201  * @param[in] key The attribute key
202  * @param[in] value The new value
203  * @param[in] undoList The undoList on which to register changes
204  */
205  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
206 
207  /* @brief method for checking if the key and their correspond attribute are valids
208  * @param[in] key The attribute key
209  * @param[in] value The value asociated to key key
210  * @return true if the value is valid, false in other case
211  */
212  bool isValid(SumoXMLAttr key, const std::string& value);
214 
215  /* @brief method for setting the special color of the lane
216  * @param[in] color Pointer to new special color
217  */
218  void setSpecialColor(const RGBColor* Color2);
219 
220 protected:
222  GNELane();
223 
226 
228  int myIndex;
229 
233  std::vector<SUMOReal> myShapeRotations;
234 
236  std::vector<SUMOReal> myShapeLengths;
238 
240  AdditionalVector myAdditionals;
241 
243  AdditionalSetVector myAdditionalSets;
244 
247 
249  mutable std::vector<RGBColor> myShapeColors;
250 
253 
254 private:
256  void setAttribute(SumoXMLAttr key, const std::string& value);
257 
259  GNELane(const GNELane&);
260 
262  GNELane& operator=(const GNELane&);
263 
265  void drawMarkings(const bool& selectedEdge, SUMOReal scale) const;
266 
268  void drawLinkNo() const;
269 
271  void drawTLSLinkNo() const;
272 
274  void drawLinkRules() const;
275 
277  void drawArrows() const;
278 
280  void drawLane2LaneConnections() const;
281 
283  SUMOReal getColorValue(size_t activeScheme) const;
284 
286  bool setFunctionalColor(size_t activeScheme) const;
287 
289  bool setMultiColor(const GUIColorer& c) const;
290 
292  bool drawAsRailway(const GUIVisualizationSettings& s) const;
293 
295  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
296 
299  void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const;
300 };
301 
302 
303 #endif
304 
305 /****************************************************************************/
306 
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:784
const std::string & getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:814
const std::vector< SUMOReal > & getShapeRotations() const
returns the vector with the shape rotations
Definition: GNELane.cpp:440
GNETLSEditorFrame * myTLSEditor
the tls-editor for setting multiple links in TLS-mode
Definition: GNELane.h:252
AdditionalVector myAdditionals
list with the additonals vinculated with this lane
Definition: GNELane.h:240
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:354
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:309
SUMOReal getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:497
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:246
SUMOReal getPositionRelativeToShapeLenght(SUMOReal position) const
Definition: GNELane.cpp:521
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.
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:704
GNELane()
FOX needs this.
Definition: GNELane.cpp:86
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:249
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void drawTLSLinkNo() const
draw TLS Link Number
Definition: GNELane.cpp:109
unsigned int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:485
An Element wich group additionalSet elements.
Boundary getBoundary() const
returns the boundry (including lanes)
Definition: GNELane.cpp:452
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
int myIndex
The index of this lane.
Definition: GNELane.h:228
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:778
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:828
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:612
SUMOReal getLaneParametricLenght() const
returns the parameteric length of the lane
Definition: GNELane.cpp:503
SUMOReal getPositionRelativeToParametricLenght(SUMOReal position) const
Definition: GNELane.cpp:515
bool setFunctionalColor(size_t activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:690
A list of positions.
std::vector< SUMOReal > myShapeRotations
Definition: GNELane.h:233
AdditionalSetVector myAdditionalSets
list with the additonalSets vinculated with this lane
Definition: GNELane.h:243
bool removeAdditionalSet(GNEAdditionalSet *additionalSet)
remove GNEAdditionalSet from this lane
Definition: GNELane.cpp:566
bool removeAdditional(GNEAdditional *additional)
Definition: GNELane.cpp:533
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:458
void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const
draw crossties for railroads
Definition: GNELane.cpp:790
bool addAdditionalSet(GNEAdditionalSet *additionalSet)
add GNEAdditionalSet to this lane
Definition: GNELane.cpp:552
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:586
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:225
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:434
SUMOReal getLaneShapeLenght() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:509
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:820
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:546
std::vector< SUMOReal > myShapeLengths
The lengths of the shape parts.
Definition: GNELane.h:236
void setSpecialColor(const RGBColor *Color2)
Definition: GNELane.cpp:654
The popup menu of a globject.
const std::vector< SUMOReal > & getShapeLengths() const
returns the vector with the shape lengths
Definition: GNELane.cpp:446
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:426
#define SUMOReal
Definition: config.h:214
void addAdditional(GNEAdditional *additional)
Definition: GNELane.cpp:527
void setIndex(unsigned int index)
Definition: GNELane.cpp:490
const std::vector< GNEAdditionalSet * > & getAdditionalSets()
return list of additionalSets associated with this lane
Definition: GNELane.cpp:580
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:632
void drawLinkNo() const
draw link Number
Definition: GNELane.cpp:104
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNELane.cpp:414
A window containing a gl-object&#39;s parameter.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:238
~GNELane()
Destructor.
Definition: GNELane.cpp:95
SUMOReal getColorValue(size_t activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:726