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 /****************************************************************************/
15 // A class for visualizing Lane geometry (adapted from GUILaneWrapper)
16 /****************************************************************************/
17 #ifndef GNELane_h
18 #define GNELane_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include "GNENetElement.h"
27 
28 // ===========================================================================
29 // class declarations
30 // ===========================================================================
32 class PositionVector;
33 class GNETLSEditorFrame;
34 class GNEEdge;
35 class GNENet;
36 class GNEConnection;
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
46 class GNELane : public GNENetElement, public FXDelegator {
48  FXDECLARE(GNELane)
49 
50 public:
51 
57  GNELane(GNEEdge& edge, const int index);
58 
60  ~GNELane();
61 
63  std::string generateChildID(SumoXMLTag childTag);
64 
68  void updateGeometry();
69 
73 
76 
78  GNEEdge& getParentEdge() const;
79 
81  std::vector<GNEConnection*> getGNEIncomingConnections();
82 
84  std::vector<GNEConnection*> getGNEOutcomingConnections();
85 
87  void updateConnectionIDs();
88 
90  double getLengthGeometryFactor() const;
91 
95  void startGeometryMoving();
96 
98  void endGeometryMoving();
100 
103  // @brief Returns the name of the parent object (if any)
104  // @return This object's parent id
105  std::string getParentName() const;
106 
115 
117  long onDefault(FXObject*, FXSelector, void*);
118 
125 
130  void drawGL(const GUIVisualizationSettings& s) const;
132 
134  int getIndex() const;
135 
137  double getSpeed() const;
138 
139  /* @brief method for setting the index of the lane
140  * @param[in] index The new index of lane
141  */
142  void setIndex(int index);
143 
147  double getLaneParametricLength() const;
148 
150  double getLaneShapeLength() const;
151 
153  bool isRestricted(SUMOVehicleClass vclass) const;
154 
157  /* @brief method for getting the Attribute of an XML key
158  * @param[in] key The attribute key
159  * @return string with the value associated to key
160  */
161  std::string getAttribute(SumoXMLAttr key) const;
162  std::string getAttributeForSelection(SumoXMLAttr key) const;
163 
164  /* @brief method for setting the attribute and letting the object perform additional changes
165  * @param[in] key The attribute key
166  * @param[in] value The new value
167  * @param[in] undoList The undoList on which to register changes
168  */
169  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
170 
171  /* @brief method for checking if the key and their correspond attribute are valids
172  * @param[in] key The attribute key
173  * @param[in] value The value asociated to key key
174  * @return true if the value is valid, false in other case
175  */
176  bool isValid(SumoXMLAttr key, const std::string& value);
178 
181 
183  std::string getGenericParametersStr() const;
184 
186  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
187 
189  void setGenericParametersStr(const std::string& value);
190 
192 
193  /* @brief method for setting the special color of the lane
194  * @param[in] color Pointer to new special color
195  */
196  void setSpecialColor(const RGBColor* Color2, double colorValue = std::numeric_limits<double>::max());
197 
199  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
200 
202  bool drawAsRailway(const GUIVisualizationSettings& s) const;
203 
204 
205 protected:
207  GNELane();
208 
211 
214 
216  int myIndex;
217 
220 
222  std::vector<Position> myLaneRestrictedTexturePositions;
223 
225  std::vector<double> myLaneRestrictedTextureRotations;
227 
230 
233 
235  mutable std::vector<RGBColor> myShapeColors;
236 
237 private:
239  void setAttribute(SumoXMLAttr key, const std::string& value);
240 
242  void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
243 
245  void drawLinkNo(const GUIVisualizationSettings& s) const;
246 
248  void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
249 
251  void drawLinkRules() const;
252 
254  void drawArrows() const;
255 
257  void drawLane2LaneConnections() const;
258 
260  bool setFunctionalColor(int activeScheme, RGBColor& col) const;
261 
263  bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
264 
266  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
267 
269  void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const;
270 
272  void drawVSSSymbol(const GUIVisualizationSettings& s, GNEAdditional* vss) const;
273 
276 
279 
281  GNELane(const GNELane&) = delete;
282 
284  GNELane& operator=(const GNELane&) = delete;
285 };
286 
287 
288 #endif
289 
290 /****************************************************************************/
291 
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:1027
GNELane::drawVSSSymbol
void drawVSSSymbol(const GUIVisualizationSettings &s, GNEAdditional *vss) const
draw VSS symbol
Definition: GNELane.cpp:1185
GNELane::getParentName
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:1279
GNELane::getPositionInView
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNELane.cpp:146
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:134
GNELane::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:723
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
GNELane::myMovingGeometryBoundary
Boundary myMovingGeometryBoundary
boundary used during moving of elements
Definition: GNELane.h:213
GNELane::operator=
GNELane & operator=(const GNELane &)=delete
Invalidated assignment operator.
GNELane::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:547
GNELane::setLaneColor
RGBColor setLaneColor(const GUIVisualizationSettings &s) const
set color according to edit mode and visualisation settings
Definition: GNELane.cpp:986
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
GNELane::mySpecialColor
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:229
GNELane::isRestricted
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:768
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:78
GNELane::getAttributeForSelection
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNELane.cpp:805
GNELane::GNELane
GNELane()
FOX needs this.
Definition: GNELane.cpp:65
GNELane::myShapeColors
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:235
GNELane::myIndex
int myIndex
The index of this lane.
Definition: GNELane.h:216
PositionVector
A list of positions.
Definition: PositionVector.h:46
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:48
GNELane::setIndex
void setIndex(int index)
Definition: GNELane.cpp:738
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:42
GNELane::drawAsRailway
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:1147
GNELane::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:324
GNELane::getSpeed
double getSpeed() const
@nrief returns the current speed of lane
Definition: GNELane.cpp:745
GNELane::getIndex
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:733
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
GNELane::getLaneParametricLength
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:751
RGBColor
Definition: RGBColor.h:40
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:1396
GNELane::drawAsWaterway
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:1153
GNELane::getGenericParameters
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNELane.cpp:891
GNENetElement.h
GNELane::getLengthGeometryFactor
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1355
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GNELane::getParentEdge
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1292
GNELane::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:815
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:1041
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GNELane::getGenericParametersStr
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNELane.cpp:876
GNENetElement
Definition: GNENetElement.h:42
GNELane::getLaneShapeLength
double getLaneShapeLength() const
returns the length of the lane's shape
Definition: GNELane.cpp:762
GNELane::getGNEIncomingConnections
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1304
GNELane::drawArrows
void drawArrows() const
draw arrows
Definition: GNELane.cpp:205
GNELane::setSpecialColor
void setSpecialColor(const RGBColor *Color2, double colorValue=std::numeric_limits< double >::max())
Definition: GNELane.cpp:927
GNELane::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:774
GNELane::drawMarkings
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane markings
Definition: GNELane.cpp:506
GNELane::setGenericParametersStr
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNELane.cpp:902
GNELane::getGNEOutcomingConnections
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1325
GNELane::startGeometryMoving
void startGeometryMoving()
Definition: GNELane.cpp:1366
GNELane::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:84
GUIMainWindow
Definition: GUIMainWindow.h:47
GNELane::onDefault
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1285
GNELane::myLaneRestrictedTexturePositions
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition: GNELane.h:222
GNELane::drawLinkRules
void drawLinkRules() const
draw link rules
Definition: GNELane.cpp:200
GNELane::myParentEdge
GNEEdge & myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:210
GNELane::updateConnectionIDs
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition: GNELane.cpp:1340
GNELane::generateChildID
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNELane.cpp:77
GNELane::drawDirectionIndicators
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const
direction indicators for lanes
Definition: GNELane.cpp:1159
GNEConnection
Definition: GNEConnection.h:38
GNELane::drawStartEndShapePoints
void drawStartEndShapePoints(const GUIVisualizationSettings &s) const
draw start and end shape points
Definition: GNELane.cpp:1233
GNELane::drawTLSLinkNo
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS Link Number
Definition: GNELane.cpp:177
config.h
GNELane::getColorValue
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:1065
GNELane::drawLinkNo
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition: GNELane.cpp:153
GNETLSEditorFrame
Definition: GNETLSEditorFrame.h:41
GNEUndoList
Definition: GNEUndoList.h:49
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:373
GNELane::~GNELane
~GNELane()
Destructor.
Definition: GNELane.cpp:73
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
GNELane::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:839
GNELane::drawLane2LaneConnections
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:274
GUIPropertySchemeStorage< GUIColorScheme >