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 class GNEConnection;
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
55 class GNELane : public GNENetElement, public FXDelegator {
57  FXDECLARE(GNELane)
58 
59 public:
61  typedef std::vector<GNEAdditional*> AdditionalVector;
62 
64  typedef std::vector<GNEAdditionalSet*> AdditionalSetVector;
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 
107  std::vector<GNEConnection*> getGNEIncomingConnections();
108 
110  std::vector<GNEConnection*> getGNEOutcomingConnections();
111 
118 
123  void drawGL(const GUIVisualizationSettings& s) const;
125 
127  const PositionVector& getShape() const;
128 
130  const std::vector<SUMOReal>& getShapeRotations() const;
131 
133  const std::vector<SUMOReal>& getShapeLengths() const;
134 
136  Boundary getBoundary() const;
137 
139  // @note: must be called when geometry changes (i.e. junction moved)
140  void updateGeometry();
141 
143  int getIndex() const;
144 
146  SUMOReal getSpeed() const;
147 
148  /* @brief method for setting the index of the lane
149  * @param[in] index The new index of lane
150  */
151  void setIndex(int index);
152 
156 
159 
160  /* @brief returns the relative position of an element in the lane's shape depending of the parametric lenght
161  * Examples: Lane with Parametric lenght = 100 and Shape lenght = 250. Position 50 returns 125, Position 80 returns 200
162  * @param[in] position to calculate their relative position in the lane's shape [0 < position < LaneParametricLenght()]
163  * @return the relative position in the lane's shape
164  */
166 
167  /* @brief returns the relative position of an element in the lane's shape depending of the shape's lenght
168  * Examples: Lane with Parametric lenght = 100 and Shape lenght = 250. Position = 100 returns 40, Position 220 returns 88
169  * @param[in] position to calculate their relative position in the lane's shape [0 < position < LaneShapeLenght]
170  * @return the relative position in the lane's shape
171  */
173 
175  void addAdditionalChild(GNEAdditional* additional);
176 
178  void removeAdditionalChild(GNEAdditional* additional);
179 
181  const std::vector<GNEAdditional*>& getAdditionalChilds() const;
182 
184  bool addAdditionalSet(GNEAdditionalSet* additionalSet);
185 
187  bool removeAdditionalGeometrySet(GNEAdditionalSet* additionalSet);
188 
190  const std::vector<GNEAdditionalSet*>& getAdditionalSetParents();
191 
193  bool isRestricted(SUMOVehicleClass vclass) const;
194 
197  /* @brief method for getting the Attribute of an XML key
198  * @param[in] key The attribute key
199  * @return string with the value associated to key
200  */
201  std::string getAttribute(SumoXMLAttr key) const;
202 
203  /* @brief method for setting the attribute and letting the object perform additional changes
204  * @param[in] key The attribute key
205  * @param[in] value The new value
206  * @param[in] undoList The undoList on which to register changes
207  */
208  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
209 
210  /* @brief method for checking if the key and their correspond attribute are valids
211  * @param[in] key The attribute key
212  * @param[in] value The value asociated to key key
213  * @return true if the value is valid, false in other case
214  */
215  bool isValid(SumoXMLAttr key, const std::string& value);
217 
218  /* @brief method for setting the special color of the lane
219  * @param[in] color Pointer to new special color
220  */
221  void setSpecialColor(const RGBColor* Color2);
222 
223 protected:
225  GNELane();
226 
229 
231  int myIndex;
232 
236  std::vector<SUMOReal> myShapeRotations;
237 
239  std::vector<SUMOReal> myShapeLengths;
240 
242  std::vector<Position> myLaneRestrictedTexturePositions;
243 
245  std::vector<SUMOReal> myLaneRestrictedTextureRotations;
247 
249  AdditionalVector myAdditionals;
250 
252  AdditionalSetVector myAdditionalSetParents;
253 
256 
258  mutable std::vector<RGBColor> myShapeColors;
259 
262 
263 private:
265  void setAttribute(SumoXMLAttr key, const std::string& value);
266 
268  GNELane(const GNELane&);
269 
271  GNELane& operator=(const GNELane&);
272 
274  void drawMarkings(const bool& selectedEdge, SUMOReal scale) const;
275 
277  void drawLinkNo() const;
278 
280  void drawTLSLinkNo() const;
281 
283  void drawLinkRules() const;
284 
286  void drawArrows() const;
287 
289  void drawLane2LaneConnections() const;
290 
292  SUMOReal getColorValue(int activeScheme) const;
293 
295  bool setFunctionalColor(int activeScheme) const;
296 
298  bool setMultiColor(const GUIColorer& c) const;
299 
301  bool drawAsRailway(const GUIVisualizationSettings& s) const;
302 
304  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
305 
308  void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const;
309 
311  void drawDirectionIndicators() const;
312 };
313 
314 
315 #endif
316 
317 /****************************************************************************/
318 
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GNELane.cpp:910
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:187
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:774
void drawTLSLinkNo() const
draw TLS Link Number
Definition: GNELane.cpp:107
GNETLSEditorFrame * myTLSEditor
the tls-editor for setting multiple links in TLS-mode
Definition: GNELane.h:261
AdditionalVector myAdditionals
list with the additonals vinculated with this lane
Definition: GNELane.h:249
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...
std::vector< GNEAdditionalSet * > AdditionalSetVector
Definition of the additionalSets vector.
Definition: GNELane.h:64
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:255
std::vector< GNEAdditional * > AdditionalVector
FOX-declaration.
Definition: GNELane.h:61
Boundary getBoundary() const
returns the boundry (including lanes)
Definition: GNELane.cpp:601
Stores the information about how to visualize structures.
void removeAdditionalChild(GNEAdditional *additional)
remove additional child to this lane
Definition: GNELane.cpp:717
GNELane & operator=(const GNELane &)
Invalidated assignment operator.
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:55
GNELane()
FOX needs this.
Definition: GNELane.cpp:88
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:258
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
const std::vector< SUMOReal > & getShapeLengths() const
returns the vector with the shape lengths
Definition: GNELane.cpp:595
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:984
void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const
draw crossties for railroads
Definition: GNELane.cpp:996
An Element wich group additionalSet elements.
std::vector< SUMOReal > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition: GNELane.h:245
SUMOReal getLaneParametricLenght() const
returns the parameteric length of the lane
Definition: GNELane.cpp:681
void setIndex(int index)
Definition: GNELane.cpp:668
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
int myIndex
The index of this lane.
Definition: GNELane.h:231
bool setFunctionalColor(int activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:896
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:237
SUMOReal getColorValue(int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:932
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:990
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:663
SUMOReal getLaneShapeLenght() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:687
const std::vector< GNEAdditionalSet * > & getAdditionalSetParents()
return list of additionalSets parents of this lane
Definition: GNELane.cpp:768
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1061
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:814
void drawLinkNo() const
draw link Number
Definition: GNELane.cpp:102
void addAdditionalChild(GNEAdditional *additional)
add additional child to this lane
Definition: GNELane.cpp:705
A list of positions.
SUMOReal getPositionRelativeToShapeLenght(SUMOReal position) const
Definition: GNELane.cpp:699
std::vector< SUMOReal > myShapeRotations
Definition: GNELane.h:236
bool removeAdditionalGeometrySet(GNEAdditionalSet *additionalSet)
remove GNEAdditionalSet from this lane
Definition: GNELane.cpp:754
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1067
void drawArrows() const
draw arrows
Definition: GNELane.cpp:117
void drawMarkings(const bool &selectedEdge, SUMOReal scale) const
draw lane markings
Definition: GNELane.cpp:369
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1089
SUMOReal getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:675
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:607
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:788
bool addAdditionalSet(GNEAdditionalSet *additionalSet)
add GNEAdditionalSet to this lane
Definition: GNELane.cpp:740
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:55
void drawDirectionIndicators() const
direction indicators for lanes
Definition: GNELane.cpp:1020
GNEEdge & myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:228
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:583
const std::vector< SUMOReal > & getShapeRotations() const
returns the vector with the shape rotations
Definition: GNELane.cpp:589
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1052
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:63
AdditionalSetVector myAdditionalSetParents
list with the additonalSets parents of this lane
Definition: GNELane.h:252
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition: GNELane.h:242
std::vector< SUMOReal > myShapeLengths
The lengths of the shape parts.
Definition: GNELane.h:239
SUMOReal getPositionRelativeToParametricLenght(SUMOReal position) const
Definition: GNELane.cpp:693
void setSpecialColor(const RGBColor *Color2)
Definition: GNELane.cpp:856
The popup menu of a globject.
void drawLinkRules() const
draw link rules
Definition: GNELane.cpp:112
#define SUMOReal
Definition: config.h:213
const std::string & getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:1046
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:834
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNELane.cpp:563
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:575
~GNELane()
Destructor.
Definition: GNELane.cpp:97
const std::vector< GNEAdditional * > & getAdditionalChilds() const
get additional childs of lane
Definition: GNELane.cpp:734