Eclipse SUMO - Simulation of Urban MObility
GUILane.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-2022 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 /****************************************************************************/
20 // Representation of a lane in the micro simulation (gui-version)
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
26 #include <string>
27 #include <utility>
28 #include <microsim/MSLane.h>
29 #include <microsim/MSEdge.h>
30 #include <utils/geom/Position.h>
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class GUINet;
40 class MSVehicle;
41 class MSNet;
42 #ifdef HAVE_OSG
43 namespace osg {
44 class Geometry;
45 }
46 #endif
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
59 class GUILane : public MSLane, public GUIGlObject {
60 public:
74  GUILane(const std::string& id, double maxSpeed,
75  double length, MSEdge* const edge, int numericalID,
76  const PositionVector& shape, double width,
77  SVCPermissions permissions,
78  SVCPermissions changeLeft, SVCPermissions changeRight,
79  int index, bool isRampAccel,
80  const std::string& type);
81 
82 
84  ~GUILane();
85 
90  std::string getParentName() const {
91  return getEdge().getID();
92  }
93 
94 
97 
107  const VehCont& getVehiclesSecure() const;
108 
109 
115  void releaseVehicles() const;
117 
118 
119 
122 
125  void planMovements(const SUMOTime t);
126 
129  void setJunctionApproaches(const SUMOTime t) const;
130 
133  void executeMovements(const SUMOTime t);
134 
137  void integrateNewVehicles();
139 
140 
143  void detectCollisions(SUMOTime timestep, const std::string& stage);
144 
145 
148  MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify);
149 
151  void removeParking(MSBaseVehicle* veh);
152 
160  double setPartialOccupation(MSVehicle* v);
161 
166 
167 
169 
170 
179  GUISUMOAbstractView& parent);
180 
181 
190  GUISUMOAbstractView& parent);
191 
192 
194  double getExaggeration(const GUIVisualizationSettings& s) const;
195 
196 
203 
204 
209  void drawGL(const GUIVisualizationSettings& s) const;
211 
212 
213 
214  const PositionVector& getShape() const;
215  const std::vector<double>& getShapeRotations() const;
216  const std::vector<double>& getShapeLengths() const;
217 
218  double firstWaitingTime() const;
219 
221  void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
222 
224  void drawBikeMarkings() const;
225 
227  void drawJunctionChangeProhibitions() const;
228 
230  void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const;
231 
233  void debugDrawFoeIntersections() const;
234 
235  double getEdgeLaneNumber() const;
236 
239  double getStoredEdgeTravelTime() const;
240 
243  double getLoadedEdgeWeight() const;
244 
245  void setReachability(double value) {
246  myReachability = value;
247  }
248 
249  double getReachability() const {
250  return myReachability;
251  }
252 
253 #ifdef HAVE_OSG
254  void setGeometry(osg::Geometry* geom) {
255  myGeom = geom;
256  }
257 
258  void updateColor(const GUIVisualizationSettings& s);
259 
260 #endif
261 
263  void closeTraffic(bool rebuildAllowed = true);
264 
265  bool isClosed() const {
266  return myAmClosed;
267  }
268 
270  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
271 
273  double getColorValueWithFunctional(const GUIVisualizationSettings& s, int activeScheme) const;
274 
276  double getColorValueForTracker() const;
277 
279  bool isSelected() const;
280 
281  /* @brief sets the color according to the current scheme index and some lane function
282  * @param[in] id override active scheme when calling from meso gui
283  */
284  bool setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme = -1) const;
285 
287  bool drawAsRailway(const GUIVisualizationSettings& s) const;
288 
289 
290 protected:
293 
306  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
307  const MSLane::VehCont::iterator& at,
309 
310 private:
312  void drawLinkNo(const GUIVisualizationSettings& s) const;
313  void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const;
314  void drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const;
315  void drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, const MSLink* link, const PositionVector& shape, double x1, double x2) const;
316  void drawArrows() const;
317  void drawLane2LaneConnections(double exaggeration) const;
318 
319 
322 
324  double getPendingEmits() const;
325 
326 private:
327 
329  double getScaleValue(int activeScheme) const;
330 
332  bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
333 
336 
338  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
339 
341  bool isLaneOrEdgeSelected() const;
342 
344  std::vector<double> myShapeRotations;
345 
347  std::vector<double> myShapeLengths;
348 
350  mutable std::vector<RGBColor> myShapeColors;
351 
353  std::vector<int> myShapeSegments;
355  std::vector<int> mySegmentStartIndex;
356 
359 
362 
365 
367  mutable std::vector<MSParkingArea*>* myParkingAreas;
368 
369 #ifdef HAVE_OSG
370  osg::Geometry* myGeom;
371 #endif
372 
375 
378 
379 private:
381  mutable FXMutex myLock;
382 
385 
386 
387 };
long long int SUMOTime
Definition: SUMOTime.h:32
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
The popup menu of a globject.
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:59
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterway
Definition: GUILane.cpp:1409
const PositionVector & getShape() const
Definition: GUILane.cpp:987
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition: GUILane.cpp:867
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUILane.cpp:1474
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:347
std::vector< MSParkingArea * > * myParkingAreas
list of parkingAreas on this lane
Definition: GUILane.h:367
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify)
Definition: GUILane.cpp:164
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:381
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition: GUILane.cpp:1479
void setReachability(double value)
Definition: GUILane.h:245
void drawArrows() const
Definition: GUILane.cpp:395
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:999
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1333
void integrateNewVehicles()
Definition: GUILane.cpp:185
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:358
double getReachability() const
Definition: GUILane.h:249
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition: GUILane.cpp:1446
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:353
double firstWaitingTime() const
Definition: GUILane.cpp:1005
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:361
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:241
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:1056
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition: GUILane.cpp:1484
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GUILane.h:90
void drawLane2LaneConnections(double exaggeration) const
Definition: GUILane.cpp:462
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:214
void drawJunctionChangeProhibitions() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:776
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:384
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: GUILane.cpp:1125
void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:178
std::vector< int > mySegmentStartIndex
the shape indices where the meso segment changes (for segmentsIndex > 0)
Definition: GUILane.h:355
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:280
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:350
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:975
bool isClosed() const
Definition: GUILane.h:265
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GUILane.cpp:969
void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:138
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1430
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const
direction indicators for lanes
Definition: GUILane.cpp:839
GUILane(const std::string &id, double maxSpeed, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, SVCPermissions changeLeft, SVCPermissions changeRight, int index, bool isRampAccel, const std::string &type)
Constructor.
Definition: GUILane.cpp:74
const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:131
double getColorValueWithFunctional(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index including values for things that set the c...
Definition: GUILane.cpp:1043
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1403
void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:206
void removeParking(MSBaseVehicle *veh)
remove parking vehicle
Definition: GUILane.cpp:171
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:993
void detectCollisions(SUMOTime timestep, const std::string &stage)
Definition: GUILane.cpp:192
double getColorValueForTracker() const
return color value based on cached settings
Definition: GUILane.cpp:1149
double getEdgeLaneNumber() const
Definition: GUILane.cpp:1011
double myReachability
the time distance from a particular edge
Definition: GUILane.h:364
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:1030
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:489
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:344
void executeMovements(const SUMOTime t)
Definition: GUILane.cpp:157
virtual void incorporateVehicle(MSVehicle *veh, double pos, double speed, double posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Inserts the vehicle into this lane, and informs it about entering the network.
Definition: GUILane.cpp:121
~GUILane()
Destructor.
Definition: GUILane.cpp:110
void setJunctionApproaches(const SUMOTime t) const
Definition: GUILane.cpp:150
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, const MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition: GUILane.cpp:330
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition: GUILane.cpp:1073
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:1017
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition: GUILane.cpp:727
double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:199
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:749
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:374
void planMovements(const SUMOTime t)
Definition: GUILane.cpp:144
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUILane.cpp:892
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUILane.cpp:934
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:1161
static const GUIVisualizationSettings * myCachedGUISettings
cached for tracking color value
Definition: GUILane.h:377
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:81
A window containing a gl-object's parameter.
Stores the information about how to visualize structures.
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:51
A road/street connecting two junctions.
Definition: MSEdge.h:77
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:92
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:674
Notification
Definition of a vehicle state.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
The simulated network and simulation perfomer.
Definition: MSNet.h:88
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:75
const std::string & getID() const
Returns the id.
Definition: Named.h:74
A list of positions.