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 
155  double getLaneParametricLength() const;
156 
158  double getLaneShapeLength() const;
159 
161  void addAdditionalChild(GNEAdditional* additional);
162 
164  void removeAdditionalChild(GNEAdditional* additional);
165 
167  const std::vector<GNEAdditional*>& getAdditionalChilds() const;
168 
170  bool isRestricted(SUMOVehicleClass vclass) const;
171 
174  /* @brief method for getting the Attribute of an XML key
175  * @param[in] key The attribute key
176  * @return string with the value associated to key
177  */
178  std::string getAttribute(SumoXMLAttr key) const;
179  std::string getAttributeForSelection(SumoXMLAttr key) const;
180 
181  /* @brief method for setting the attribute and letting the object perform additional changes
182  * @param[in] key The attribute key
183  * @param[in] value The new value
184  * @param[in] undoList The undoList on which to register changes
185  */
186  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
187 
188  /* @brief method for checking if the key and their correspond attribute are valids
189  * @param[in] key The attribute key
190  * @param[in] value The value asociated to key key
191  * @return true if the value is valid, false in other case
192  */
193  bool isValid(SumoXMLAttr key, const std::string& value);
195 
196  /* @brief method for setting the special color of the lane
197  * @param[in] color Pointer to new special color
198  */
199  void setSpecialColor(const RGBColor* Color2);
200 
202  double getColorValue(int activeScheme) const;
203 
204 
205 protected:
207  GNELane();
208 
211 
213  int myIndex;
214 
218  std::vector<double> myShapeRotations;
219 
221  std::vector<double> myShapeLengths;
222 
224  std::vector<Position> myLaneRestrictedTexturePositions;
225 
227  std::vector<double> myLaneRestrictedTextureRotations;
229 
231  AdditionalVector myAdditionals;
232 
235 
237  mutable std::vector<RGBColor> myShapeColors;
238 
241 
242 private:
244  void setAttribute(SumoXMLAttr key, const std::string& value);
245 
247  GNELane(const GNELane&);
248 
250  GNELane& operator=(const GNELane&);
251 
253  void drawMarkings(const bool& selectedEdge, double scale) const;
254 
256  void drawLinkNo(const GUIVisualizationSettings& s) const;
257 
259  void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
260 
262  void drawLinkRules() const;
263 
265  void drawArrows() const;
266 
268  void drawLane2LaneConnections() const;
269 
271  bool setFunctionalColor(int activeScheme) const;
272 
274  bool setMultiColor(const GUIColorer& c) const;
275 
277  bool drawAsRailway(const GUIVisualizationSettings& s) const;
278 
280  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
281 
284  void drawCrossties(double length, double spacing, double halfWidth) const;
285 
287  void drawDirectionIndicators() const;
288 };
289 
290 
291 #endif
292 
293 /****************************************************************************/
294 
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:1014
double getLaneShapeLength() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:730
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GNELane.h:221
const std::string & getParentName() const
Returns the name of the parent object.
Definition: GNELane.cpp:1070
GNETLSEditorFrame * myTLSEditor
the tls-editor for setting multiple links in TLS-mode
Definition: GNELane.h:240
AdditionalVector myAdditionals
list with the additionals vinculated with this lane
Definition: GNELane.h:231
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:456
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:234
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:764
const std::vector< GNEAdditional * > & getAdditionalChilds() const
get additional childs of lane
Definition: GNELane.cpp:758
void removeAdditionalChild(GNEAdditional *additional)
remove additional child to this lane
Definition: GNELane.cpp:746
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNELane.cpp:801
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:920
double getColorValue(int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:956
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:92
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:934
GNELane()
FOX needs this.
Definition: GNELane.cpp:84
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:237
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Boundary getBoundary() const
returns the boundry (including lanes)
Definition: GNELane.cpp:643
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:701
void setIndex(int index)
Definition: GNELane.cpp:706
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
int myIndex
The index of this lane.
Definition: GNELane.h:213
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition: GNELane.h:227
double getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:713
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:1008
void drawDirectionIndicators() const
direction indicators for lanes
Definition: GNELane.cpp:1044
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:220
void drawArrows() const
draw arrows
Definition: GNELane.cpp:150
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1085
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:811
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS Link Number
Definition: GNELane.cpp:122
const std::vector< double > & getShapeRotations() const
returns the vector with the shape rotations
Definition: GNELane.cpp:631
void addAdditionalChild(GNEAdditional *additional)
add additional child to this lane
Definition: GNELane.cpp:735
A list of positions.
std::vector< double > myShapeRotations
Definition: GNELane.h:218
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1091
void drawMarkings(const bool &selectedEdge, double scale) const
draw lane markings
Definition: GNELane.cpp:411
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1112
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:649
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in allGNEAttributeCarrier.
Definition: GNELane.cpp:770
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:58
const std::vector< double > & getShapeLengths() const
returns the vector with the shape lengths
Definition: GNELane.cpp:637
void drawLinkRules() const
draw link rules
Definition: GNELane.cpp:145
GNEEdge & myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:210
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:625
void updateConnectionIDs()
Definition: GNELane.cpp:1127
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1076
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:224
void setSpecialColor(const RGBColor *Color2)
Definition: GNELane.cpp:866
The popup menu of a globject.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:617
void drawCrossties(double length, double spacing, double halfWidth) const
draw crossties for railroads
Definition: GNELane.cpp:1020
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:833
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:719
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNELane.cpp:605
A window containing a gl-object&#39;s parameter.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:270
~GNELane()
Destructor.
Definition: GNELane.cpp:93
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition: GNELane.cpp:98