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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A class for visualizing Lane geometry (adapted from GUILaneWrapper)
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
24 
25 #include "GNENetworkElement.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 GNENetworkElement, public GNECandidateElement, public FXDelegator {
47  FXDECLARE(GNELane)
48 
49 public:
52 
53  public:
56 
58  const double selectionScale;
59 
61  const double exaggeration;
62 
63  // compute lane-marking intersection points)
64  const double halfWidth2;
65 
67  const double halfWidth;
68 
69  private:
72 
75  };
76 
82  GNELane(GNEEdge* edge, const int index);
83 
85  ~GNELane();
86 
88  GNEEdge* getParentEdge() const;
89 
93  const PositionVector& getLaneShape() const;
94 
96  const std::vector<double>& getShapeRotations() const;
97 
99  const std::vector<double>& getShapeLengths() const;
100 
103 
105  void updateGeometry();
106 
108  Position getPositionInView() const;
110 
114  GNEMoveOperation* getMoveOperation(const double shapeOffset);
115 
117  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
119 
121  std::vector<GNEConnection*> getGNEIncomingConnections();
122 
124  std::vector<GNEConnection*> getGNEOutcomingConnections();
125 
127  void updateConnectionIDs();
128 
130  double getLengthGeometryFactor() const;
131 
134  // @brief Returns the name of the parent object (if any)
135  // @return This object's parent id
136  std::string getParentName() const;
137 
146 
148  long onDefault(FXObject*, FXSelector, void*);
149 
151  void updateCenteringBoundary(const bool updateGrid);
152 
157  void drawGL(const GUIVisualizationSettings& s) const;
159 
161  int getIndex() const;
162 
164  double getSpeed() const;
165 
166  /* @brief method for setting the index of the lane
167  * @param[in] index The new index of lane
168  */
169  void setIndex(int index);
170 
174  double getLaneParametricLength() const;
175 
177  double getLaneShapeLength() const;
178 
180  bool isRestricted(SUMOVehicleClass vclass) const;
181 
184 
187  /* @brief method for getting the Attribute of an XML key
188  * @param[in] key The attribute key
189  * @return string with the value associated to key
190  */
191  std::string getAttribute(SumoXMLAttr key) const;
192  std::string getAttributeForSelection(SumoXMLAttr key) const;
193 
194  /* @brief method for setting the attribute and letting the object perform additional changes
195  * @param[in] key The attribute key
196  * @param[in] value The new value
197  * @param[in] undoList The undoList on which to register changes
198  */
199  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
200 
201  /* @brief method for checking if the key and their correspond attribute are valids
202  * @param[in] key The attribute key
203  * @param[in] value The value asociated to key key
204  * @return true if the value is valid, false in other case
205  */
206  bool isValid(SumoXMLAttr key, const std::string& value);
207 
208  /* @brief method for check if the value for certain attribute is set
209  * @param[in] key The attribute key
210  */
211  bool isAttributeEnabled(SumoXMLAttr key) const;
213 
215  const std::map<std::string, std::string>& getACParametersMap() const;
216 
218  void addPathAdditionalElement(GNEAdditional* additionalElement);
219 
221  void removePathAdditionalElement(GNEAdditional* additionalElement);
222 
224  void addPathDemandElement(GNEDemandElement* demandElement);
225 
227  void removePathDemandElement(GNEDemandElement* demandElement);
228 
230  void addPathGenericData(GNEGenericData* genericData);
231 
233  void removePathGenericData(GNEGenericData* genericData);
234 
236  void invalidatePathElements();
237 
238  /* @brief method for setting the special color of the lane
239  * @param[in] color Pointer to new special color
240  */
241  void setSpecialColor(const RGBColor* Color2, double colorValue = std::numeric_limits<double>::max());
242 
244  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
245 
247  bool drawAsRailway(const GUIVisualizationSettings& s) const;
248 
249 protected:
251  GNELane();
252 
253 private:
256 
258  int myIndex;
259 
262 
265 
268 
270  std::vector<Position> myLaneRestrictedTexturePositions;
271 
273  std::vector<double> myLaneRestrictedTextureRotations;
275 
278 
281 
283  mutable std::vector<RGBColor> myShapeColors;
284 
287 
289  std::map<SumoXMLTag, std::vector<GNEAdditional*> > myPathAdditionalElements;
290 
292  std::map<SumoXMLTag, std::vector<GNEDemandElement*> > myPathDemandElements;
293 
295  std::map<SumoXMLTag, std::vector<GNEGenericData*> > myPathGenericDatas;
296 
298  void setAttribute(SumoXMLAttr key, const std::string& value);
299 
301  void setMoveShape(const GNEMoveResult& moveResult);
302 
304  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
305 
307  void drawChildren(const GUIVisualizationSettings& s) const;
308 
311 
314 
317 
319  void drawMarkings(const GUIVisualizationSettings& s, const double exaggeration, const bool drawRailway) const;
320 
322  void drawLinkNo(const GUIVisualizationSettings& s) const;
323 
325  void drawTLSLinkNo(const GUIVisualizationSettings& s) const;
326 
328  void drawLinkRules(const GUIVisualizationSettings& s) const;
329 
331  void drawArrows(const GUIVisualizationSettings& s) const;
332 
334  void drawLane2LaneConnections() const;
335 
337  bool setFunctionalColor(int activeScheme, RGBColor& col) const;
338 
340  bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
341 
343  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
344 
346  void drawDirectionIndicators(const GUIVisualizationSettings& s, double exaggeration, const bool drawAsRailway, const bool spreadSuperposed) const;
347 
349  void drawLaneAsRailway(const GUIVisualizationSettings& s, const LaneDrawingConstants& laneDrawingConstants) const;
350 
352  void drawTextures(const GUIVisualizationSettings& s, const LaneDrawingConstants& laneDrawingConstants) const;
353 
356 
359 
362 
365 
368 
370  GNELane(const GNELane&) = delete;
371 
373  GNELane& operator=(const GNELane&) = delete;
374 };
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
An Element which don't belongs to GNENet but has influency in the simulation.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
An Element which don't belongs to GNENet but has influency in the simulation.
class for pack all variables related with DottedGeometry
Definition: GNEGeometry.h:187
class for NETEDIT geometries over lanes
Definition: GNEGeometry.h:76
class lane2lane connection geometry
Definition: GNEGeometry.h:412
FOX-declaration.
Definition: GNELane.h:51
const double exaggeration
exaggeration
Definition: GNELane.h:61
const double selectionScale
selection scale
Definition: GNELane.h:58
LaneDrawingConstants & operator=(const LaneDrawingConstants &)=delete
Invalidated assignment operator.
LaneDrawingConstants()
default constructor
Definition: GNELane.cpp:72
const double halfWidth
Draw as a normal lane, and reduce width to make sure that a selected edge can still be seen.
Definition: GNELane.h:67
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
const PositionVector & getLaneShape() const
Definition: GNELane.cpp:117
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1557
void drawPathAdditionalElements(const GUIVisualizationSettings &s) const
path additional elements
Definition: GNELane.cpp:575
~GNELane()
Destructor.
Definition: GNELane.cpp:107
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:1551
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:780
const GNEGeometry::DottedGeometry & getDottedLaneGeometry() const
get dotted lane geometry
Definition: GNELane.cpp:135
void removePathDemandElement(GNEDemandElement *demandElement)
remove path demand element (used by GNEPathElement)
Definition: GNELane.cpp:954
void drawLinkRules(const GUIVisualizationSettings &s) const
draw link rules
Definition: GNELane.cpp:312
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition: GNELane.h:273
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:277
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNELane.cpp:219
void addPathGenericData(GNEGenericData *genericData)
add path demand element (used by GNEPathElement)
Definition: GNELane.cpp:966
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:1338
GNEGeometry::DottedGeometry myDottedLaneGeometry
dotted lane geometry
Definition: GNELane.h:264
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1615
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNELane.cpp:902
std::map< SumoXMLTag, std::vector< GNEDemandElement * > > myPathDemandElements
map with references to path demand elements
Definition: GNELane.h:292
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:141
void invalidatePathElements()
invalidate path element childs
Definition: GNELane.cpp:989
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNELane.cpp:1092
GNEEdge * myParentEdge
parent edge (GNELanes cannot use hierarchical structures)
Definition: GNELane.h:255
const GNEGeometry::Lane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:774
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNELane.cpp:815
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:663
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:733
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition: GNELane.cpp:233
GNEGeometry::Lane2laneConnection myLane2laneConnections
lane2lane connections
Definition: GNELane.h:286
void drawStartEndShapePoints(const GUIVisualizationSettings &s) const
draw start and end shape points
Definition: GNELane.cpp:1476
void drawMarkings(const GUIVisualizationSettings &s, const double exaggeration, const bool drawRailway) const
draw lane markings
Definition: GNELane.cpp:608
void buildLaneOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build lane operations contextual menu
Definition: GNELane.cpp:1662
GNELane()
FOX needs this.
Definition: GNELane.cpp:96
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1585
const std::vector< double > & getShapeRotations() const
get rotations of the single shape parts
Definition: GNELane.cpp:123
void drawTextures(const GUIVisualizationSettings &s, const LaneDrawingConstants &laneDrawingConstants) const
draw lane textures
Definition: GNELane.cpp:1438
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:1211
void drawLaneAsRailway(const GUIVisualizationSettings &s, const LaneDrawingConstants &laneDrawingConstants) const
draw lane as railway
Definition: GNELane.cpp:1389
GNEMoveOperation * getMoveOperation(const double shapeOffset)
get move operation for the given shapeOffset
Definition: GNELane.cpp:226
GNEGeometry::Geometry myLaneGeometry
lane geometry
Definition: GNELane.h:261
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS Link Number
Definition: GNELane.cpp:276
GNELane & operator=(const GNELane &)=delete
Invalidated assignment operator.
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:751
GNELane(const GNELane &)=delete
Invalidated copy constructor.
RGBColor setLaneColor(const GUIVisualizationSettings &s) const
set color according to edit mode and visualisation settings
Definition: GNELane.cpp:1104
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:850
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1564
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:1332
void removePathAdditionalElement(GNEAdditional *additionalElement)
remove path additional element (used by GNEPathElement)
Definition: GNELane.cpp:931
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:768
void addPathDemandElement(GNEDemandElement *demandElement)
add path demand element (used by GNEPathElement)
Definition: GNELane.cpp:943
int myIndex
The index of this lane.
Definition: GNELane.h:258
void drawDirectionIndicators(const GUIVisualizationSettings &s, double exaggeration, const bool drawAsRailway, const bool spreadSuperposed) const
direction indicators for lanes
Definition: GNELane.cpp:1344
void setIndex(int index)
Definition: GNELane.cpp:738
void addPathAdditionalElement(GNEAdditional *additionalElement)
add path additional element (used by GNEPathElement)
Definition: GNELane.cpp:920
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:444
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNELane.cpp:914
void setSpecialColor(const RGBColor *Color2, double colorValue=std::numeric_limits< double >::max())
Definition: GNELane.cpp:1017
void drawPathDemandElements(const GUIVisualizationSettings &s) const
path demand elements
Definition: GNELane.cpp:586
void drawArrows(const GUIVisualizationSettings &s) const
draw arrows
Definition: GNELane.cpp:318
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNELane.cpp:723
double mySpecialColorValue
optional value that corresponds to which the special color corresponds
Definition: GNELane.h:280
void drawChildren(const GUIVisualizationSettings &s) const
draw children
Definition: GNELane.cpp:553
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition: GNELane.h:270
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNELane.cpp:1098
double getLaneShapeLength() const
returns the length of the lane's shape
Definition: GNELane.cpp:762
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:283
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:1235
bool setFunctionalColor(int activeScheme, RGBColor &col) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:1197
std::map< SumoXMLTag, std::vector< GNEAdditional * > > myPathAdditionalElements
map with references to path additional elements
Definition: GNELane.h:289
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition: GNELane.cpp:1600
void buildRechableOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build rechable operations contextual menu
Definition: GNELane.cpp:1770
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:396
void removePathGenericData(GNEGenericData *genericData)
remove path demand element (used by GNEPathElement)
Definition: GNELane.cpp:977
std::map< SumoXMLTag, std::vector< GNEGenericData * > > myPathGenericDatas
map with references to path generic data elements
Definition: GNELane.h:295
void buildEdgeOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build edge operations contextual menu
Definition: GNELane.cpp:1626
const std::vector< double > & getShapeLengths() const
get lengths of the single shape parts
Definition: GNELane.cpp:129
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition: GNELane.cpp:239
void drawPathGenericDataElements(const GUIVisualizationSettings &s) const
path generic data elements
Definition: GNELane.cpp:597
double getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:745
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:825
GNEEdge * getParentEdge() const
get arent edge
Definition: GNELane.cpp:111
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
The popup menu of a globject.
Stores the information about how to visualize structures.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
A list of positions.