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-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 /****************************************************************************/
20 // Representation of a lane in the micro simulation (gui-version)
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <fx.h>
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, int index, bool isRampAccel,
78  const std::string& type);
79 
80 
82  ~GUILane();
83 
88  std::string getParentName() const {
89  return getEdge().getID();
90  }
91 
92 
95 
105  const VehCont& getVehiclesSecure() const;
106 
107 
113  void releaseVehicles() const;
115 
116 
117 
120 
123  void planMovements(const SUMOTime t);
124 
127  void setJunctionApproaches(const SUMOTime t) const;
128 
131  void executeMovements(const SUMOTime t);
132 
135  void integrateNewVehicles();
137 
138 
141  void detectCollisions(SUMOTime timestep, const std::string& stage);
142 
143 
146  MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify);
147 
149  void removeParking(MSVehicle* veh);
150 
158  double setPartialOccupation(MSVehicle* v);
159 
164 
165 
167 
168 
177  GUISUMOAbstractView& parent);
178 
179 
188  GUISUMOAbstractView& parent);
189 
190 
197 
198 
203  void drawGL(const GUIVisualizationSettings& s) const;
205 
206 
207 
208  const PositionVector& getShape() const;
209  const std::vector<double>& getShapeRotations() const;
210  const std::vector<double>& getShapeLengths() const;
211 
212  double firstWaitingTime() const;
213 
215  void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
216 
218  void drawBikeMarkings() const;
219 
221  void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const;
222 
224  void debugDrawFoeIntersections() const;
225 
226  double getEdgeLaneNumber() const;
227 
230  double getStoredEdgeTravelTime() const;
231 
234  double getLoadedEdgeWeight() const;
235 
236  void setReachability(double value) {
237  myReachability = value;
238  }
239 
240  double getReachability() const {
241  return myReachability;
242  }
243 
244 #ifdef HAVE_OSG
245  void setGeometry(osg::Geometry* geom) {
246  myGeom = geom;
247  }
248 
249  void updateColor(const GUIVisualizationSettings& s);
250 
251 #endif
252 
254  void closeTraffic(bool rebuildAllowed = true);
255 
256  bool isClosed() const {
257  return myAmClosed;
258  }
259 
261  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
262 
264  bool isSelected() const;
265 
266  /* @brief sets the color according to the current scheme index and some lane function
267  * @param[in] id override active scheme when calling from meso gui
268  */
269  bool setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme = -1) const;
270 
272  bool drawAsRailway(const GUIVisualizationSettings& s) const;
273 
274 
275 protected:
278 
291  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
292  const MSLane::VehCont::iterator& at,
294 
295 private:
297  void drawLinkNo(const GUIVisualizationSettings& s) const;
298  void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const;
299  void drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const;
300  void drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, const MSLink* link, const PositionVector& shape, double x1, double x2) const;
301  void drawArrows() const;
302  void drawLane2LaneConnections(double exaggeration) const;
303 
304 
307 
309  double getPendingEmits() const;
310 
311 private:
312 
314  double getScaleValue(int activeScheme) const;
315 
317  bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
318 
321 
323  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
324 
326  bool isLaneOrEdgeSelected() const;
327 
329  std::vector<double> myShapeRotations;
330 
332  std::vector<double> myShapeLengths;
333 
335  mutable std::vector<RGBColor> myShapeColors;
336 
338  std::vector<int> myShapeSegments;
339 
342 
345 
348 
349 #ifdef HAVE_OSG
350  osg::Geometry* myGeom;
351 #endif
352 
355 
356 private:
358  mutable FXMutex myLock;
359 
362 
363 
364 };
long long int SUMOTime
Definition: SUMOTime.h:31
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:1297
const PositionVector & getShape() const
Definition: GUILane.cpp:919
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition: GUILane.cpp:808
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUILane.cpp:1362
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:332
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify)
Definition: GUILane.cpp:166
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:358
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition: GUILane.cpp:1367
void setReachability(double value)
Definition: GUILane.h:236
void drawArrows() const
Definition: GUILane.cpp:397
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:931
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1221
void integrateNewVehicles()
Definition: GUILane.cpp:187
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:341
void removeParking(MSVehicle *veh)
remove parking vehicle
Definition: GUILane.cpp:173
double getReachability() const
Definition: GUILane.h:240
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition: GUILane.cpp:1337
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:338
double firstWaitingTime() const
Definition: GUILane.cpp:937
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:344
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:243
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:975
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition: GUILane.cpp:1372
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GUILane.h:88
void drawLane2LaneConnections(double exaggeration) const
Definition: GUILane.cpp:464
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:216
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:361
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:1044
void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:180
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:282
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:335
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:907
bool isClosed() const
Definition: GUILane.h:256
void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:140
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1318
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const
direction indicators for lanes
Definition: GUILane.cpp:780
const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:133
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1291
void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:208
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:925
void detectCollisions(SUMOTime timestep, const std::string &stage)
Definition: GUILane.cpp:194
double getEdgeLaneNumber() const
Definition: GUILane.cpp:943
double myReachability
the time distance from a particular edge
Definition: GUILane.h:347
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:962
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:491
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:329
void executeMovements(const SUMOTime t)
Definition: GUILane.cpp:159
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:123
~GUILane()
Destructor.
Definition: GUILane.cpp:113
void setJunctionApproaches(const SUMOTime t) const
Definition: GUILane.cpp:152
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, const MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition: GUILane.cpp:332
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition: GUILane.cpp:992
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:949
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition: GUILane.cpp:713
double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:201
GUILane(const std::string &id, double maxSpeed, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, int index, bool isRampAccel, const std::string &type)
Constructor.
Definition: GUILane.cpp:80
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:754
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:354
void planMovements(const SUMOTime t)
Definition: GUILane.cpp:146
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUILane.cpp:833
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUILane.cpp:875
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:1069
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.
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:673
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:89
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
const std::string & getID() const
Returns the id.
Definition: Named.h:73
A list of positions.