Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // A class for visualizing Lane geometry (adapted from GUILaneWrapper)
15 /****************************************************************************/
16 #ifndef GNELane_h
17 #define GNELane_h
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include "GNENetElement.h"
26 
27 // ===========================================================================
28 // class declarations
29 // ===========================================================================
31 class PositionVector;
32 class GNETLSEditorFrame;
33 class GNEEdge;
34 class GNENet;
35 class GNEConnection;
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
45 class GNELane : public GNENetElement, public FXDelegator {
47  FXDECLARE(GNELane)
48 
49 public:
55  GNELane(GNEEdge* edge, const int index);
56 
58  ~GNELane();
59 
61  std::string generateChildID(SumoXMLTag childTag);
62 
66  const PositionVector& getLaneShape() const;
67 
69  const std::vector<double>& getShapeRotations() const;
70 
72  const std::vector<double>& getShapeLengths() const;
73 
75  void updateGeometry();
76 
80 
82  GNEEdge* getParentEdge() const;
83 
85  std::vector<GNEConnection*> getGNEIncomingConnections();
86 
88  std::vector<GNEConnection*> getGNEOutcomingConnections();
89 
91  void updateConnectionIDs();
92 
94  double getLengthGeometryFactor() const;
95 
99  void startGeometryMoving();
100 
102  void endGeometryMoving();
104 
107  // @brief Returns the name of the parent object (if any)
108  // @return This object's parent id
109  std::string getParentName() const;
110 
119 
121  long onDefault(FXObject*, FXSelector, void*);
122 
129 
134  void drawGL(const GUIVisualizationSettings& s) const;
136 
138  int getIndex() const;
139 
141  double getSpeed() const;
142 
143  /* @brief method for setting the index of the lane
144  * @param[in] index The new index of lane
145  */
146  void setIndex(int index);
147 
151  double getLaneParametricLength() const;
152 
154  double getLaneShapeLength() const;
155 
157  bool isRestricted(SUMOVehicleClass vclass) const;
158 
161 
164  /* @brief method for getting the Attribute of an XML key
165  * @param[in] key The attribute key
166  * @return string with the value associated to key
167  */
168  std::string getAttribute(SumoXMLAttr key) const;
169  std::string getAttributeForSelection(SumoXMLAttr key) const;
170 
171  /* @brief method for setting the attribute and letting the object perform additional changes
172  * @param[in] key The attribute key
173  * @param[in] value The new value
174  * @param[in] undoList The undoList on which to register changes
175  */
176  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
177 
178  /* @brief method for checking if the key and their correspond attribute are valids
179  * @param[in] key The attribute key
180  * @param[in] value The value asociated to key key
181  * @return true if the value is valid, false in other case
182  */
183  bool isValid(SumoXMLAttr key, const std::string& value);
184 
185  /* @brief method for check if the value for certain attribute is set
186  * @param[in] key The attribute key
187  */
188  bool isAttributeEnabled(SumoXMLAttr key) const;
190 
191  /* @brief method for setting the special color of the lane
192  * @param[in] color Pointer to new special color
193  */
194  void setSpecialColor(const RGBColor* Color2, double colorValue = std::numeric_limits<double>::max());
195 
197  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
198 
200  bool drawAsRailway(const GUIVisualizationSettings& s) const;
201 
203  void drawPartialE2DetectorPlan(const GUIVisualizationSettings& s, const GNEAdditional* E2Detector, const GNEJunction* junction) const;
204 
205 protected:
207  GNELane();
208 
211 
213  int myIndex;
214 
217 
220 
222  std::vector<Position> myLaneRestrictedTexturePositions;
223 
225  std::vector<double> myLaneRestrictedTextureRotations;
227 
229  const RGBColor* mySpecialColor = nullptr;
230 
232  double mySpecialColorValue = -1;
233 
235  mutable std::vector<RGBColor> myShapeColors;
236 
239 
240 private:
242  void setAttribute(SumoXMLAttr key, const std::string& value);
243 
245  void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
246 
248  void drawLinkNo(const GUIVisualizationSettings& s) const;
249 
251  void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
252 
254  void drawLinkRules(const GUIVisualizationSettings& s) const;
255 
257  void drawArrows(const GUIVisualizationSettings& s) const;
258 
260  void drawLane2LaneConnections() const;
261 
263  bool setFunctionalColor(int activeScheme, RGBColor& col) const;
264 
266  bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
267 
269  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
270 
272  void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const;
273 
275  void drawVSSSymbol(const GUIVisualizationSettings& s, GNEAdditional* vss) const;
276 
279 
282 
284  GNELane(const GNELane&) = delete;
285 
287  GNELane& operator=(const GNELane&) = delete;
288 };
289 
290 
291 #endif
292 
293 /****************************************************************************/
294 
GNELane::setFunctionalColor
bool setFunctionalColor(int activeScheme, RGBColor &col) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:1096
GNELane::drawVSSSymbol
void drawVSSSymbol(const GUIVisualizationSettings &s, GNEAdditional *vss) const
draw VSS symbol
Definition: GNELane.cpp:1260
GNELane::getParentName
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:1358
GNELane::getPositionInView
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNELane.cpp:166
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
GNELane::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:764
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
GNELane::operator=
GNELane & operator=(const GNELane &)=delete
Invalidated assignment operator.
GNEGeometry::Lane2laneConnection
lane2lane struct
Definition: GNEGeometry.h:255
GNELane::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:584
GNELane::setLaneColor
RGBColor setLaneColor(const GUIVisualizationSettings &s) const
set color according to edit mode and visualisation settings
Definition: GNELane.cpp:1055
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GNELane::mySpecialColor
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:229
GNELane::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNELane.cpp:922
GNELane::isRestricted
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:809
GNELane::myLane2laneConnections
GNEGeometry::Lane2laneConnection myLane2laneConnections
lane2lane connections
Definition: GNELane.h:238
GNELane::drawPartialE2DetectorPlan
void drawPartialE2DetectorPlan(const GUIVisualizationSettings &s, const GNEAdditional *E2Detector, const GNEJunction *junction) const
draw partial E2 detector plan
Definition: GNELane.cpp:941
GNELane::getParentEdge
GNEEdge * getParentEdge() const
Returns underlying parent edge.
Definition: GNELane.cpp:1371
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
GNELane::getAttributeForSelection
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNELane.cpp:852
GNELane::drawArrows
void drawArrows(const GUIVisualizationSettings &s) const
draw arrows
Definition: GNELane.cpp:224
GNELane::GNELane
GNELane()
FOX needs this.
Definition: GNELane.cpp:66
GNELane::myShapeColors
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:235
GNELane::getShapeRotations
const std::vector< double > & getShapeRotations() const
get rotations of the single shape parts
Definition: GNELane.cpp:92
GNELane::myIndex
int myIndex
The index of this lane.
Definition: GNELane.h:213
PositionVector
A list of positions.
Definition: PositionVector.h:45
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
GNELane::setIndex
void setIndex(int index)
Definition: GNELane.cpp:779
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
GNELane::drawAsRailway
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:1222
GNELane::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:343
GNELane::getSpeed
double getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:786
GNELane::getIndex
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:774
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:51
GNELane::myLaneGeometry
GNEGeometry::Geometry myLaneGeometry
lane geometry
Definition: GNELane.h:216
GNELane::getLaneParametricLength
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:792
RGBColor
Definition: RGBColor.h:39
GNELane::mySpecialColorValue
double mySpecialColorValue
optional value that corresponds to which the special color corresponds
Definition: GNELane.h:232
GNELane::myLaneRestrictedTextureRotations
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition: GNELane.h:225
GNELane::endGeometryMoving
void endGeometryMoving()
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
Definition: GNELane.cpp:1469
GNELane::getLaneShape
const PositionVector & getLaneShape() const
Definition: GNELane.cpp:86
GNELane::drawAsWaterway
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:1228
GNENetElement.h
GNELane::getLane2laneConnections
const GNEGeometry::Lane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:815
GNELane::getLengthGeometryFactor
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1428
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GNELane::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:862
GNELane::setMultiColor
bool setMultiColor(const GUIVisualizationSettings &s, const GUIColorer &c, RGBColor &col) const
sets multiple colors according to the current scheme index and some lane function
Definition: GNELane.cpp:1110
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GNEGeometry::Geometry
struct for pack all variables related with geometry of stop
Definition: GNEGeometry.h:56
GNENetElement
Definition: GNENetElement.h:43
GNELane::getLaneShapeLength
double getLaneShapeLength() const
returns the length of the lane's shape
Definition: GNELane.cpp:803
GNELane::getGNEIncomingConnections
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1377
GNELane::setSpecialColor
void setSpecialColor(const RGBColor *Color2, double colorValue=std::numeric_limits< double >::max())
Definition: GNELane.cpp:934
GNELane::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:821
GNELane::drawMarkings
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane markings
Definition: GNELane.cpp:547
GNELane::getGNEOutcomingConnections
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1398
GNELane::startGeometryMoving
void startGeometryMoving()
Definition: GNELane.cpp:1439
GNELane::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:104
GUIMainWindow
Definition: GUIMainWindow.h:46
GNELane::onDefault
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1364
GNELane::myLaneRestrictedTexturePositions
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition: GNELane.h:222
GNELane::updateConnectionIDs
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition: GNELane.cpp:1413
GNELane::generateChildID
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNELane.cpp:79
GNELane::drawDirectionIndicators
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const
direction indicators for lanes
Definition: GNELane.cpp:1234
GNEConnection
Definition: GNEConnection.h:38
GNELane::drawStartEndShapePoints
void drawStartEndShapePoints(const GUIVisualizationSettings &s) const
draw start and end shape points
Definition: GNELane.cpp:1312
GNELane::drawTLSLinkNo
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS Link Number
Definition: GNELane.cpp:196
config.h
GNELane::getShapeLengths
const std::vector< double > & getShapeLengths() const
get lengths of the single shape parts
Definition: GNELane.cpp:98
GNELane::getColorValue
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:1134
GNELane::drawLinkRules
void drawLinkRules(const GUIVisualizationSettings &s) const
draw link rules
Definition: GNELane.cpp:218
GNELane::drawLinkNo
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition: GNELane.cpp:173
GNETLSEditorFrame
Definition: GNETLSEditorFrame.h:40
GNEUndoList
Definition: GNEUndoList.h:48
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GNEJunction
Definition: GNEJunction.h:47
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
GNELane::~GNELane
~GNELane()
Destructor.
Definition: GNELane.cpp:76
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
GNELane::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:886
GNELane::drawLane2LaneConnections
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:293
GUIPropertySchemeStorage< GUIColorScheme >
GNELane::myParentEdge
GNEEdge * myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:210