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-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 /****************************************************************************/
16 // Representation of a lane in the micro simulation (gui-version)
17 /****************************************************************************/
18 #ifndef GUILane_h
19 #define GUILane_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <fx.h>
28 #include <string>
29 #include <utility>
30 #include <microsim/MSLane.h>
31 #include <microsim/MSEdge.h>
32 #include <utils/geom/Position.h>
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class GUINet;
42 class MSVehicle;
43 class MSNet;
44 #ifdef HAVE_OSG
45 namespace osg {
46 class Geometry;
47 }
48 #endif
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
61 class GUILane : public MSLane, public GUIGlObject {
62 public:
76  GUILane(const std::string& id, double maxSpeed,
77  double length, MSEdge* const edge, int numericalID,
78  const PositionVector& shape, double width,
79  SVCPermissions permissions, 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(MSVehicle* veh);
152 
160  double setPartialOccupation(MSVehicle* v);
161 
166 
167 
169 
170 
179  GUISUMOAbstractView& parent);
180 
181 
190  GUISUMOAbstractView& parent);
191 
192 
199 
200 
205  void drawGL(const GUIVisualizationSettings& s) const;
207 
208 
209 
210  const PositionVector& getShape() const;
211  const std::vector<double>& getShapeRotations() const;
212  const std::vector<double>& getShapeLengths() const;
213 
214  double firstWaitingTime() const;
215 
217  void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
218 
220  void drawBikeMarkings() const;
221 
223  void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const;
224 
226  void debugDrawFoeIntersections() const;
227 
228  double getEdgeLaneNumber() const;
229 
232  double getStoredEdgeTravelTime() const;
233 
236  double getLoadedEdgeWeight() const;
237 
238  void setReachability(double value) {
239  myReachability = value;
240  }
241 
242  double getReachability() const {
243  return myReachability;
244  }
245 
246 #ifdef HAVE_OSG
247  void setGeometry(osg::Geometry* geom) {
248  myGeom = geom;
249  }
250 
251  void updateColor(const GUIVisualizationSettings& s);
252 
253 #endif
254 
256  void closeTraffic(bool rebuildAllowed = true);
257 
258  bool isClosed() const {
259  return myAmClosed;
260  }
261 
263  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
264 
266  bool isSelected() const;
267 
268  /* @brief sets the color according to the current scheme index and some lane function
269  * @param[in] id override active scheme when calling from meso gui
270  */
271  bool setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme = -1) const;
272 
274  bool drawAsRailway(const GUIVisualizationSettings& s) const;
275 
276 
277 protected:
280 
293  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
294  const MSLane::VehCont::iterator& at,
296 
297 private:
299  void drawLinkNo(const GUIVisualizationSettings& s) const;
300  void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const;
301  void drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const;
302  void drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, MSLink* link, const PositionVector& shape, double x1, double x2) const;
303  void drawArrows() const;
304  void drawLane2LaneConnections(double exaggeration) const;
305 
306 
309 
311  double getPendingEmits() const;
312 
313 private:
314 
316  double getScaleValue(int activeScheme) const;
317 
319  bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
320 
323 
325  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
326 
328  bool isLaneOrEdgeSelected() const;
329 
331  std::vector<double> myShapeRotations;
332 
334  std::vector<double> myShapeLengths;
335 
337  mutable std::vector<RGBColor> myShapeColors;
338 
340  std::vector<int> myShapeSegments;
341 
344 
347 
350 
351 #ifdef HAVE_OSG
352  osg::Geometry* myGeom;
353 #endif
354 
357 
358 private:
360  mutable FXMutex myLock;
361 
364 
365 
366 };
367 
368 
369 #endif
370 
371 /****************************************************************************/
372 
GUILane::detectCollisions
void detectCollisions(SUMOTime timestep, const std::string &stage)
Definition: GUILane.cpp:187
GUILane::splitAtSegments
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition: GUILane.cpp:1321
GUIGlObject.h
GUILane::drawTLSLinkNo
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:237
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:62
GUILane::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: GUILane.cpp:1032
GUILane::myQuarterLaneWidth
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:346
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
GUILane::myShapeSegments
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:340
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:91
GUILane::getEdgeLaneNumber
double getEdgeLaneNumber() const
Definition: GUILane.cpp:931
GUILane::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUILane.cpp:863
GUILane::debugDrawFoeIntersections
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition: GUILane.cpp:796
GUILane::getLoadedEdgeWeight
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:950
GUILane::drawLinkNo
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:209
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSLane::VehCont
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:92
GUILane::setFunctionalColor
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition: GUILane.cpp:980
MSEdge.h
GUILane::isLaneOrEdgeSelected
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition: GUILane.cpp:1351
GUILane::isSelected
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUILane.cpp:1346
GUILane::drawDirectionIndicators
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const
direction indicators for lanes
Definition: GUILane.cpp:768
GUILane::getParentName
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GUILane.h:90
GUILane::incorporateVehicle
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:116
PositionVector
A list of positions.
Definition: PositionVector.h:45
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
GUILane::closeTraffic
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1302
GUILane::MESO_USE_LANE_COLOR
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:363
GUILane::removeVehicle
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify)
Definition: GUILane.cpp:159
GUILane::drawBikeMarkings
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:742
GUILane::isClosed
bool isClosed() const
Definition: GUILane.h:258
GUILane::drawLinkRules
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:277
GUILane::resetPartialOccupation
void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:201
GUILane::executeMovements
void executeMovements(const SUMOTime t)
Definition: GUILane.cpp:152
GUILane::integrateNewVehicles
void integrateNewVehicles()
Definition: GUILane.cpp:180
GUILane::GUILane
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:73
RGBColor
Definition: RGBColor.h:39
GUILane::setColor
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:963
GUILane::getShape
const PositionVector & getShape() const
Definition: GUILane.cpp:907
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:218
GUILane::setReachability
void setReachability(double value)
Definition: GUILane.h:238
GUILane::drawAsRailway
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1275
GUILane::getShapeRotations
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:913
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GUILane::drawAsWaterway
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterway
Definition: GUILane.cpp:1281
GUILane::setJunctionApproaches
void setJunctionApproaches(const SUMOTime t) const
Definition: GUILane.cpp:145
GUILane::getShapeLengths
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:919
GUILane::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:895
GUILane::drawMarkings
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition: GUILane.cpp:701
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
GUILane::myShapeRotations
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:331
GUILane::firstWaitingTime
double firstWaitingTime() const
Definition: GUILane.cpp:925
GUIGlObject
Definition: GUIGlObject.h:65
MSMoveReminder::NOTIFICATION_DEPARTED
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
Definition: MSMoveReminder.h:93
GUILane::myShapeLengths
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:334
GUILane::setPartialOccupation
double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:194
GUILane::getStoredEdgeTravelTime
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:937
GUILane::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:483
GUILane::myHalfLaneWidth
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:343
MSLane::getEdge
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:669
GUILane::myAmClosed
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:356
GUILane::getPendingEmits
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition: GUILane.cpp:1356
Position.h
GUILane
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:61
GUILane::releaseVehicles
void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:133
GUILane::removeParking
void removeParking(MSVehicle *veh)
remove parking vehicle
Definition: GUILane.cpp:166
GUIMainWindow
Definition: GUIMainWindow.h:46
GUILane::myLock
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:360
GUIPropertySchemeStorage.h
GUILane::getVehiclesSecure
const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:126
GUILane::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUILane.cpp:821
GUILane::planMovements
void planMovements(const SUMOTime t)
Definition: GUILane.cpp:139
GUILane::myShapeColors
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:337
GUILane::myReachability
double myReachability
the time distance from a particular edge
Definition: GUILane.h:349
config.h
GUILane::getColorValue
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:1057
GUILane::~GUILane
~GUILane()
Destructor.
Definition: GUILane.cpp:106
GUILane::drawArrows
void drawArrows() const
Definition: GUILane.cpp:389
GUILane::getScaleValue
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1205
MSLane.h
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GUINet
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:82
GUILane::drawLane2LaneConnections
void drawLane2LaneConnections(double exaggeration) const
Definition: GUILane.cpp:456
GUILane::swapAfterLaneChange
void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:173
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
PositionVector.h
GUILane::getReachability
double getReachability() const
Definition: GUILane.h:242
GUILane::drawLinkRule
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition: GUILane.cpp:328
GUIPropertySchemeStorage< GUIColorScheme >
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79