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 <string>
34 #include <vector>
37 #include "GNEAttributeCarrier.h"
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
43 class PositionVector;
44 class GNETLSEditor;
45 class GNEEdge;
46 class GNENet;
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
56 class GNELane : public GUIGlObject, public GNEAttributeCarrier, public FXDelegator {
57  // FOX-declarations
58  FXDECLARE(GNELane)
59 
60 public:
66  GNELane(GNEEdge& edge, const int index);
67 
68 
70  virtual ~GNELane() ;
71 
72 
74 
75 
78  const std::string& getParentName() const;
79 
88  GUISUMOAbstractView& parent) ;
89 
90 
99  GUISUMOAbstractView& parent) ;
100 
102  long onDefault(FXObject*, FXSelector, void*);
103 
109  return myParentEdge;
110  };
111 
112 
119 
120 
125  void drawGL(const GUIVisualizationSettings& s) const ;
127 
128  const PositionVector& getShape() const;
129  const std::vector<SUMOReal>& getShapeRotations() const;
130  const std::vector<SUMOReal>& getShapeLengths() const;
131 
133  Boundary getBoundary() const;
134 
136  // @note: must be called when geometry changes (i.e. junction moved)
137  void updateGeometry();
138 
139  unsigned int getIndex() const {
140  return myIndex;
141  }
142 
143  void setIndex(unsigned int index);
144 
145  //@name inherited from GNEAttributeCarrier
147  std::string getAttribute(SumoXMLAttr key) const;
148 
149  /* @brief method for setting the attribute and letting the object perform additional changes
150  * @param[in] key The attribute key
151  * @param[in] value The new value
152  * @param[in] undoList The undoList on which to register changes
153  */
154  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
155 
156  bool isValid(SumoXMLAttr key, const std::string& value);
158 
159  void setSpecialColor(const RGBColor* color) {
160  mySpecialColor = color;
161  }
162 
163 protected:
165  GNELane();
166 
167 private:
170 
172  int myIndex;
173 
175 
176  std::vector<SUMOReal> myShapeRotations;
178 
180  std::vector<SUMOReal> myShapeLengths;
182 
185 
186 private:
187  void setAttribute(SumoXMLAttr key, const std::string& value);
188 
190  GNELane(const GNELane&);
191 
193  GNELane& operator=(const GNELane&);
194 
195  //@brief draw lane markings
196  void drawMarkings(const bool& selectedEdge, SUMOReal scale) const;
197 
198  // drawing methods
199  void drawLinkNo() const;
200  void drawTLSLinkNo() const;
201  void drawLinkRules() const;
202  void drawArrows() const;
203  void drawLane2LaneConnections() const;
204 
205  // @brief return value for lane coloring according to the given scheme
206  SUMOReal getColorValue(size_t activeScheme) const;
207 
209  bool setFunctionalColor(size_t activeScheme) const;
210 
212  bool setMultiColor(const GUIColorer& c) const;
213 
215  bool drawAsRailway(const GUIVisualizationSettings& s) const;
216 
218  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
219 
220  /* @brief draw crossties for railroads
221  * @todo: XXX This duplicates the code of GUILane::drawCrossties and needs to be */
222  void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const;
223 
224 
226  mutable std::vector<RGBColor> myShapeColors;
227 
230 
231 };
232 
233 
234 #endif
235 
236 /****************************************************************************/
237 
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:670
const std::string & getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:700
const std::vector< SUMOReal > & getShapeRotations() const
Definition: GNELane.cpp:433
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:349
void drawMarkings(const bool &selectedEdge, SUMOReal scale) const
Definition: GNELane.cpp:304
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:184
Stores the information about how to visualize structures.
GNELane & operator=(const GNELane &)
Invalidated assignment operator.
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.h:108
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:56
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GNELane.cpp:590
GNELane()
FOX needs this.
Definition: GNELane.cpp:85
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:226
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void drawTLSLinkNo() const
Definition: GNELane.cpp:103
unsigned int getIndex() const
Definition: GNELane.h:139
Boundary getBoundary() const
returns the boundry (including lanes)
Definition: GNELane.cpp:445
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
int myIndex
The index of this lane.
Definition: GNELane.h:172
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:664
void drawLane2LaneConnections() const
Definition: GNELane.cpp:183
void drawArrows() const
Definition: GNELane.cpp:113
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:503
void setSpecialColor(const RGBColor *color)
Definition: GNELane.h:159
bool setFunctionalColor(size_t activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:576
A list of positions.
std::vector< SUMOReal > myShapeRotations
The rotations of the shape parts.
Definition: GNELane.h:177
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:451
void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const
Definition: GNELane.cpp:676
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:477
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:61
void drawLinkRules() const
Definition: GNELane.cpp:108
GNEEdge & myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:169
const PositionVector & getShape() const
Definition: GNELane.cpp:427
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:706
std::vector< SUMOReal > myShapeLengths
The lengths of the shape parts.
Definition: GNELane.h:180
The popup menu of a globject.
const std::vector< SUMOReal > & getShapeLengths() const
Definition: GNELane.cpp:439
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:419
#define SUMOReal
Definition: config.h:213
void setIndex(unsigned int index)
Definition: GNELane.cpp:470
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:523
void drawLinkNo() const
Definition: GNELane.cpp:98
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNELane.cpp:406
A window containing a gl-object&#39;s parameter.
GNETLSEditor * myTLSEditor
the tls-editor for setting multiple links in TLS-mode
Definition: GNELane.h:229
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:233
virtual ~GNELane()
Destructor.
Definition: GNELane.cpp:94
SUMOReal getColorValue(size_t activeScheme) const
Definition: GNELane.cpp:612