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-2018 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 class GNEShape;
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
47 class GNELane : public GNENetElement, public FXDelegator {
49  FXDECLARE(GNELane)
50 
51 public:
52 
58  GNELane(GNEEdge& edge, const int index);
59 
61  ~GNELane();
62 
65 
67  std::vector<GNEConnection*> getGNEIncomingConnections();
68 
70  std::vector<GNEConnection*> getGNEOutcomingConnections();
71 
73  void updateConnectionIDs();
74 
76  double getLengthGeometryFactor() const;
77 
81  void startGeometryMoving();
82 
84  void endGeometryMoving();
86 
89  // @brief Returns the name of the parent object (if any)
90  // @return This object's parent id
91  std::string getParentName() const;
92 
101 
103  long onDefault(FXObject*, FXSelector, void*);
104 
111 
116  void drawGL(const GUIVisualizationSettings& s) const;
118 
120  const PositionVector& getShape() const;
121 
123  const std::vector<double>& getShapeRotations() const;
124 
126  const std::vector<double>& getShapeLengths() const;
127 
129  Boundary getBoundary() const;
130 
132  // @note: must be called when geometry changes (i.e. junction moved)
133  void updateGeometry(bool updateGrid);
134 
136  int getIndex() const;
137 
139  double getSpeed() const;
140 
141  /* @brief method for setting the index of the lane
142  * @param[in] index The new index of lane
143  */
144  void setIndex(int index);
145 
149  double getLaneParametricLength() const;
150 
152  double getLaneShapeLength() const;
153 
155  void addShapeChild(GNEShape* shape);
156 
158  void removeShapeChild(GNEShape* shape);
159 
161  const std::vector<GNEShape*>& getShapeChilds() const;
162 
164  bool isRestricted(SUMOVehicleClass vclass) const;
165 
168  /* @brief method for getting the Attribute of an XML key
169  * @param[in] key The attribute key
170  * @return string with the value associated to key
171  */
172  std::string getAttribute(SumoXMLAttr key) const;
173  std::string getAttributeForSelection(SumoXMLAttr key) const;
174 
175  /* @brief method for setting the attribute and letting the object perform additional changes
176  * @param[in] key The attribute key
177  * @param[in] value The new value
178  * @param[in] undoList The undoList on which to register changes
179  */
180  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
181 
182  /* @brief method for checking if the key and their correspond attribute are valids
183  * @param[in] key The attribute key
184  * @param[in] value The value asociated to key key
185  * @return true if the value is valid, false in other case
186  */
187  bool isValid(SumoXMLAttr key, const std::string& value);
189 
192 
194  std::string getGenericParametersStr() const;
195 
197  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
198 
200  void setGenericParametersStr(const std::string& value);
201 
203 
204  /* @brief method for setting the special color of the lane
205  * @param[in] color Pointer to new special color
206  */
207  void setSpecialColor(const RGBColor* Color2);
208 
210  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
211 
213  void removeLaneOfAdditionalParents(GNEUndoList* undoList, bool allowEmpty);
214 
215 protected:
217  GNELane();
218 
221 
224 
226  int myIndex;
227 
231  std::vector<double> myShapeRotations;
232 
234  std::vector<double> myShapeLengths;
235 
237  std::vector<Position> myLaneRestrictedTexturePositions;
238 
240  std::vector<double> myLaneRestrictedTextureRotations;
242 
244  std::vector<GNEShape*> myShapes;
245 
248 
250  mutable std::vector<RGBColor> myShapeColors;
251 
252 private:
254  void setAttribute(SumoXMLAttr key, const std::string& value);
255 
257  void mouseOverObject(const GUIVisualizationSettings& s) const;
258 
260  void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
261 
263  void drawLinkNo(const GUIVisualizationSettings& s) const;
264 
266  void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
267 
269  void drawLinkRules() const;
270 
272  void drawArrows() const;
273 
275  void drawLane2LaneConnections() const;
276 
278  bool setFunctionalColor(int activeScheme) const;
279 
281  bool setMultiColor(const GUIColorer& c) const;
282 
284  bool drawAsRailway(const GUIVisualizationSettings& s) const;
285 
287  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
288 
290  void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const;
291 
293  void setLaneColor(const GUIVisualizationSettings& s) const;
294 
296  GNELane(const GNELane&) = delete;
297 
299  GNELane& operator=(const GNELane&) = delete;
300 };
301 
302 
303 #endif
304 
305 /****************************************************************************/
306 
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GNELane.cpp:1083
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GNELane.h:234
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:201
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:823
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:1247
Boundary myMovingGeometryBoundary
boundary used during moving of elements
Definition: GNELane.h:223
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:484
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:247
void updateGeometry(bool updateGrid)
update pre-computed geometry information
Definition: GNELane.cpp:697
Boundary getBoundary() const
returns the boundry (including lanes)
Definition: GNELane.cpp:687
Stores the information about how to visualize structures.
const std::vector< double > & getShapeRotations() const
returns the vector with the shape rotations
Definition: GNELane.cpp:675
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNELane.cpp:860
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:47
double getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:769
GNELane()
FOX needs this.
Definition: GNELane.cpp:66
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:250
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:1208
void setIndex(int index)
Definition: GNELane.cpp:762
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
int myIndex
The index of this lane.
Definition: GNELane.h:226
bool setFunctionalColor(int activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:1069
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition: GNELane.h:240
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:251
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:1214
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:757
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNELane.cpp:946
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:775
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1260
void endGeometryMoving()
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
Definition: GNELane.cpp:1346
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:870
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNELane.cpp:931
A list of positions.
void removeLaneOfAdditionalParents(GNEUndoList *undoList, bool allowEmpty)
remove lane of Additional Parent
Definition: GNELane.cpp:1178
std::vector< double > myShapeRotations
Definition: GNELane.h:231
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1266
void addShapeChild(GNEShape *shape)
add shape child to this lane
Definition: GNELane.cpp:792
void drawArrows() const
draw arrows
Definition: GNELane.cpp:131
double getLengthGeometryFactor() const
get lenght geometry factor
Definition: GNELane.cpp:1317
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane markings
Definition: GNELane.cpp:443
std::vector< GNEShape * > myShapes
list with the shapes vinculated with this lane
Definition: GNELane.h:244
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNELane.cpp:957
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1287
double getLaneShapeLength() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:786
void startGeometryMoving()
Definition: GNELane.cpp:1328
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:829
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
GNEEdge & myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:220
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:669
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition: GNELane.cpp:1302
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1253
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS Link Number
Definition: GNELane.cpp:103
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition: GNELane.h:237
void setSpecialColor(const RGBColor *Color2)
Definition: GNELane.cpp:982
The popup menu of a globject.
void mouseOverObject(const GUIVisualizationSettings &s) const
method for check if mouse is over objects
Definition: GNELane.cpp:1044
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition: GNELane.cpp:79
void drawLinkRules() const
draw link rules
Definition: GNELane.cpp:126
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const
direction indicators for lanes
Definition: GNELane.cpp:1220
void removeShapeChild(GNEShape *shape)
remove shape child of this lane
Definition: GNELane.cpp:805
void setLaneColor(const GUIVisualizationSettings &s) const
set color according to edit mode and visualisation settings
Definition: GNELane.cpp:1049
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:894
const std::vector< double > & getShapeLengths() const
returns the vector with the shape lengths
Definition: GNELane.cpp:681
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:1105
const std::vector< GNEShape * > & getShapeChilds() const
get shape childs of lane
Definition: GNELane.cpp:817
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:660
~GNELane()
Destructor.
Definition: GNELane.cpp:74