SUMO - Simulation of Urban MObility
GNELane.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // A class for visualizing Lane geometry (adapted from GUILaneWrapper)
18 /****************************************************************************/
19 #ifndef GNELane_h
20 #define GNELane_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include "GNENetElement.h"
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
38 class PositionVector;
39 class GNETLSEditorFrame;
40 class GNEEdge;
41 class GNENet;
42 class GNEConnection;
43 class GNEShape;
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
53 class GNELane : public GNENetElement, public FXDelegator {
55  FXDECLARE(GNELane)
56 
57 public:
58 
64  GNELane(GNEEdge& edge, const int index);
65 
67  ~GNELane();
68 
71 
73  std::vector<GNEConnection*> getGNEIncomingConnections();
74 
76  std::vector<GNEConnection*> getGNEOutcomingConnections();
77 
78  // update IDs of incoming connections of this lane
79  void updateConnectionIDs();
80 
83  // @brief Returns the name of the parent object (if any)
84  // @return This object's parent id
85  const std::string& getParentName() const;
86 
95 
97  long onDefault(FXObject*, FXSelector, void*);
98 
105 
110  void drawGL(const GUIVisualizationSettings& s) const;
112 
114  const PositionVector& getShape() const;
115 
117  const std::vector<double>& getShapeRotations() const;
118 
120  const std::vector<double>& getShapeLengths() const;
121 
123  Boundary getBoundary() const;
124 
126  // @note: must be called when geometry changes (i.e. junction moved)
127  void updateGeometry();
128 
130  int getIndex() const;
131 
133  double getSpeed() const;
134 
135  /* @brief method for setting the index of the lane
136  * @param[in] index The new index of lane
137  */
138  void setIndex(int index);
139 
143  double getLaneParametricLength() const;
144 
146  double getLaneShapeLength() const;
147 
149  void addShapeChild(GNEShape* shape);
150 
152  void removeShapeChild(GNEShape* shape);
153 
155  const std::vector<GNEShape*>& getShapeChilds() const;
156 
158  bool isRestricted(SUMOVehicleClass vclass) const;
159 
162  /* @brief method for getting the Attribute of an XML key
163  * @param[in] key The attribute key
164  * @return string with the value associated to key
165  */
166  std::string getAttribute(SumoXMLAttr key) const;
167  std::string getAttributeForSelection(SumoXMLAttr key) const;
168 
169  /* @brief method for setting the attribute and letting the object perform additional changes
170  * @param[in] key The attribute key
171  * @param[in] value The new value
172  * @param[in] undoList The undoList on which to register changes
173  */
174  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
175 
176  /* @brief method for checking if the key and their correspond attribute are valids
177  * @param[in] key The attribute key
178  * @param[in] value The value asociated to key key
179  * @return true if the value is valid, false in other case
180  */
181  bool isValid(SumoXMLAttr key, const std::string& value);
183 
184  /* @brief method for setting the special color of the lane
185  * @param[in] color Pointer to new special color
186  */
187  void setSpecialColor(const RGBColor* Color2);
188 
190  double getColorValue(int activeScheme) const;
191 
193  void removeLaneOfAdditionalParents(GNEUndoList* undoList, bool allowEmpty);
194 
195 protected:
197  GNELane();
198 
201 
203  int myIndex;
204 
208  std::vector<double> myShapeRotations;
209 
211  std::vector<double> myShapeLengths;
212 
214  std::vector<Position> myLaneRestrictedTexturePositions;
215 
217  std::vector<double> myLaneRestrictedTextureRotations;
219 
221  std::vector<GNEShape*> myShapes;
222 
225 
227  mutable std::vector<RGBColor> myShapeColors;
228 
231 
232 private:
234  void setAttribute(SumoXMLAttr key, const std::string& value);
235 
237  void drawMarkings(const bool& selectedEdge, double scale) const;
238 
240  void drawLinkNo(const GUIVisualizationSettings& s) const;
241 
243  void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
244 
246  void drawLinkRules() const;
247 
249  void drawArrows() const;
250 
252  void drawLane2LaneConnections() const;
253 
255  bool setFunctionalColor(int activeScheme) const;
256 
258  bool setMultiColor(const GUIColorer& c) const;
259 
261  bool drawAsRailway(const GUIVisualizationSettings& s) const;
262 
264  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
265 
268  void drawCrossties(double length, double spacing, double halfWidth) const;
269 
271  void drawDirectionIndicators() const;
272 
274  void setLaneColor(const GUIVisualizationSettings& s) const;
275 
277  GNELane(const GNELane&) = delete;
278 
280  GNELane& operator=(const GNELane&) = delete;
281 };
282 
283 
284 #endif
285 
286 /****************************************************************************/
287 
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GNELane.cpp:941
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GNELane.h:211
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:220
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:749
GNETLSEditorFrame * myTLSEditor
the tls-editor for setting multiple links in TLS-mode
Definition: GNELane.h:230
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:444
GNELane & operator=(const GNELane &)=delete
Invalidated assignment operator.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:224
Boundary getBoundary() const
returns the boundry (including lanes)
Definition: GNELane.cpp:617
Stores the information about how to visualize structures.
const std::vector< double > & getShapeRotations() const
returns the vector with the shape rotations
Definition: GNELane.cpp:605
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNELane.cpp:786
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:91
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:53
double getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:695
GNELane()
FOX needs this.
Definition: GNELane.cpp:84
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:227
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:1045
double getColorValue(int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:963
void setIndex(int index)
Definition: GNELane.cpp:688
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
int myIndex
The index of this lane.
Definition: GNELane.h:203
bool setFunctionalColor(int activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:927
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition: GNELane.h:217
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:269
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:1051
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:683
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:701
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1121
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:796
A list of positions.
void removeLaneOfAdditionalParents(GNEUndoList *undoList, bool allowEmpty)
remove lane of Additional Parent
Definition: GNELane.cpp:1015
std::vector< double > myShapeRotations
Definition: GNELane.h:208
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1127
void addShapeChild(GNEShape *shape)
add shape child to this lane
Definition: GNELane.cpp:718
void drawArrows() const
draw arrows
Definition: GNELane.cpp:150
std::vector< GNEShape * > myShapes
list with the shapes vinculated with this lane
Definition: GNELane.h:221
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1148
double getLaneShapeLength() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:712
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:623
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in all GNEAttributeCarriers.
Definition: GNELane.cpp:755
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:56
void drawDirectionIndicators() const
direction indicators for lanes
Definition: GNELane.cpp:1081
GNEEdge & myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:200
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:599
void updateConnectionIDs()
Definition: GNELane.cpp:1163
void drawMarkings(const bool &selectedEdge, double scale) const
draw lane markings
Definition: GNELane.cpp:399
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1112
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS Link Number
Definition: GNELane.cpp:122
void drawCrossties(double length, double spacing, double halfWidth) const
draw crossties for railroads
Definition: GNELane.cpp:1057
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition: GNELane.h:214
void setSpecialColor(const RGBColor *Color2)
Definition: GNELane.cpp:851
The popup menu of a globject.
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition: GNELane.cpp:98
void drawLinkRules() const
draw link rules
Definition: GNELane.cpp:145
void removeShapeChild(GNEShape *shape)
remove shape child of this lane
Definition: GNELane.cpp:731
const std::string & getParentName() const
Returns the name of the parent object.
Definition: GNELane.cpp:1106
void setLaneColor(const GUIVisualizationSettings &s) const
set color according to edit mode and visualisation settings
Definition: GNELane.cpp:905
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:818
const std::vector< double > & getShapeLengths() const
returns the vector with the shape lengths
Definition: GNELane.cpp:611
const std::vector< GNEShape * > & getShapeChilds() const
get shape childs of lane
Definition: GNELane.cpp:743
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:591
~GNELane()
Destructor.
Definition: GNELane.cpp:93