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 /****************************************************************************/
17 // Representation of a lane in the micro simulation (gui-version)
18 /****************************************************************************/
19 #ifndef GUILane_h
20 #define GUILane_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <fx.h>
29 #include <string>
30 #include <utility>
31 #include <microsim/MSLane.h>
32 #include <microsim/MSEdge.h>
33 #include <utils/geom/Position.h>
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class GUINet;
43 class MSVehicle;
44 class MSNet;
45 #ifdef HAVE_OSG
46 namespace osg {
47 class Geometry;
48 }
49 #endif
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
62 class GUILane : public MSLane, public GUIGlObject {
63 public:
77  GUILane(const std::string& id, double maxSpeed,
78  double length, MSEdge* const edge, int numericalID,
79  const PositionVector& shape, double width,
80  SVCPermissions permissions, int index, bool isRampAccel,
81  const std::string& type);
82 
83 
85  ~GUILane();
86 
91  std::string getParentName() const {
92  return getEdge().getID();
93  }
94 
95 
98 
108  const VehCont& getVehiclesSecure() const;
109 
110 
116  void releaseVehicles() const;
118 
119 
120 
123 
126  void planMovements(const SUMOTime t);
127 
130  void setJunctionApproaches(const SUMOTime t) const;
131 
134  void executeMovements(const SUMOTime t);
135 
138  void integrateNewVehicles();
140 
141 
144  void detectCollisions(SUMOTime timestep, const std::string& stage);
145 
146 
149  MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify);
150 
152  void removeParking(MSVehicle* veh);
153 
161  double setPartialOccupation(MSVehicle* v);
162 
167 
168 
170 
171 
180  GUISUMOAbstractView& parent);
181 
182 
191  GUISUMOAbstractView& parent);
192 
193 
200 
201 
206  void drawGL(const GUIVisualizationSettings& s) const;
208 
209 
210 
211  const PositionVector& getShape() const;
212  const std::vector<double>& getShapeRotations() const;
213  const std::vector<double>& getShapeLengths() const;
214 
215  double firstWaitingTime() const;
216 
218  void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
219 
221  void drawBikeMarkings() const;
222 
224  void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const;
225 
227  void debugDrawFoeIntersections() const;
228 
229  double getEdgeLaneNumber() const;
230 
233  double getStoredEdgeTravelTime() const;
234 
237  double getLoadedEdgeWeight() const;
238 
239 #ifdef HAVE_OSG
240  void setGeometry(osg::Geometry* geom) {
241  myGeom = geom;
242  }
243 
244  void updateColor(const GUIVisualizationSettings& s);
245 
246 #endif
247 
249  void closeTraffic(bool rebuildAllowed = true);
250 
251  bool isClosed() const {
252  return myAmClosed;
253  }
254 
256  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
257 
259  bool isSelected() const;
260 
261  /* @brief sets the color according to the current scheme index and some lane function
262  * @param[in] id override active scheme when calling from meso gui
263  */
264  bool setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme = -1) const;
265 
267  bool drawAsRailway(const GUIVisualizationSettings& s) const;
268 
269 
270 protected:
273 
286  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
287  const MSLane::VehCont::iterator& at,
289 
290 private:
292  void drawLinkNo(const GUIVisualizationSettings& s) const;
293  void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const;
294  void drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const;
295  void drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, MSLink* link, const PositionVector& shape, double x1, double x2) const;
296  void drawArrows() const;
297  void drawLane2LaneConnections(double exaggeration) const;
298 
299 
302 
304  double getPendingEmits() const;
305 
306 private:
307 
309  double getScaleValue(int activeScheme) const;
310 
312  bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
313 
316 
318  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
319 
321  bool isLaneOrEdgeSelected() const;
322 
324  std::vector<double> myShapeRotations;
325 
327  std::vector<double> myShapeLengths;
328 
330  mutable std::vector<RGBColor> myShapeColors;
331 
333  std::vector<int> myShapeSegments;
334 
337 
340 
341 #ifdef HAVE_OSG
342  osg::Geometry* myGeom;
343 #endif
344 
347 
348 private:
350  mutable FXMutex myLock;
351 
354 
355 
356 };
357 
358 
359 #endif
360 
361 /****************************************************************************/
362 
GUILane::detectCollisions
void detectCollisions(SUMOTime timestep, const std::string &stage)
Definition: GUILane.cpp:188
GUILane::splitAtSegments
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition: GUILane.cpp:1309
GUIGlObject.h
GUILane::drawTLSLinkNo
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:238
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:63
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:1024
GUILane::myQuarterLaneWidth
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:339
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
GUILane::myShapeSegments
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:333
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:92
GUILane::getEdgeLaneNumber
double getEdgeLaneNumber() const
Definition: GUILane.cpp:923
GUILane::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUILane.cpp:855
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:942
GUILane::drawLinkNo
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:210
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
MSLane::VehCont
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:93
GUILane::setFunctionalColor
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition: GUILane.cpp:972
MSEdge.h
GUILane::isLaneOrEdgeSelected
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition: GUILane.cpp:1339
GUILane::isSelected
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUILane.cpp:1334
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:91
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:117
PositionVector
A list of positions.
Definition: PositionVector.h:46
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:48
GUILane::closeTraffic
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1290
GUILane::MESO_USE_LANE_COLOR
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:353
GUILane::removeVehicle
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify)
Definition: GUILane.cpp:160
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:251
GUILane::drawLinkRules
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:278
GUILane::resetPartialOccupation
void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:202
GUILane::executeMovements
void executeMovements(const SUMOTime t)
Definition: GUILane.cpp:153
GUILane::integrateNewVehicles
void integrateNewVehicles()
Definition: GUILane.cpp:181
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:74
RGBColor
Definition: RGBColor.h:40
GUILane::setColor
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:955
GUILane::getShape
const PositionVector & getShape() const
Definition: GUILane.cpp:899
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:219
GUILane::drawAsRailway
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1263
GUILane::getShapeRotations
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:905
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GUILane::drawAsWaterway
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterway
Definition: GUILane.cpp:1269
GUILane::setJunctionApproaches
void setJunctionApproaches(const SUMOTime t) const
Definition: GUILane.cpp:146
GUILane::getShapeLengths
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:911
GUILane::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:887
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:76
GUILane::myShapeRotations
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:324
GUILane::firstWaitingTime
double firstWaitingTime() const
Definition: GUILane.cpp:917
GUIGlObject
Definition: GUIGlObject.h:66
MSMoveReminder::NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
Definition: MSMoveReminder.h:91
GUILane::myShapeLengths
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:327
GUILane::setPartialOccupation
double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:195
GUILane::getStoredEdgeTravelTime
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:929
GUILane::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:484
GUILane::myHalfLaneWidth
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:336
MSLane::getEdge
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:670
GUILane::myAmClosed
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:346
GUILane::getPendingEmits
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition: GUILane.cpp:1344
Position.h
GUILane
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:62
GUILane::releaseVehicles
void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:134
GUILane::removeParking
void removeParking(MSVehicle *veh)
remove parking vehicle
Definition: GUILane.cpp:167
GUIMainWindow
Definition: GUIMainWindow.h:47
GUILane::myLock
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:350
GUIPropertySchemeStorage.h
GUILane::getVehiclesSecure
const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:127
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:140
GUILane::myShapeColors
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:330
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:1049
GUILane::~GUILane
~GUILane()
Destructor.
Definition: GUILane.cpp:107
GUILane::drawArrows
void drawArrows() const
Definition: GUILane.cpp:390
GUILane::getScaleValue
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1193
MSLane.h
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
GUINet
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:83
GUILane::drawLane2LaneConnections
void drawLane2LaneConnections(double exaggeration) const
Definition: GUILane.cpp:457
GUILane::swapAfterLaneChange
void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:174
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:77
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:89
PositionVector.h
GUILane::drawLinkRule
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition: GUILane.cpp:329
GUIPropertySchemeStorage< GUIColorScheme >
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80