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.dev/sumo
3// Copyright (C) 2001-2023 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// ===========================================================================
39class GUINet;
40class MSVehicle;
41class MSNet;
43#ifdef HAVE_OSG
44namespace osg {
45class Geometry;
46}
47#endif
48
49// ===========================================================================
50// class definitions
51// ===========================================================================
60class GUILane : public MSLane, public GUIGlObject {
61public:
76 GUILane(const std::string& id, double maxSpeed, double friction,
77 double length, MSEdge* const edge, int numericalID,
78 const PositionVector& shape, double width,
79 SVCPermissions permissions,
80 SVCPermissions changeLeft, SVCPermissions changeRight,
81 int index, bool isRampAccel,
82 const std::string& type);
83
84
86 ~GUILane();
87
92 std::string getParentName() const override {
93 return getEdge().getID();
94 }
95
96 void addSecondaryShape(const PositionVector& shape) override;
97
98 double getLengthGeometryFactor(bool secondaryShape) const override {
99 return secondaryShape ? myLengthGeometryFactor2 : myLengthGeometryFactor;
100 }
101
104
114 const VehCont& getVehiclesSecure() const override;
115
116
122 void releaseVehicles() const override;
124
125
126
129
132 void planMovements(const SUMOTime t) override;
133
136 void setJunctionApproaches(const SUMOTime t) const override;
137
140 void executeMovements(const SUMOTime t) override;
141
144 void integrateNewVehicles() override;
146
147
150 void detectCollisions(SUMOTime timestep, const std::string& stage) override;
151
152
155 MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) override;
156
158 void removeParking(MSBaseVehicle* veh) override;
159
167 double setPartialOccupation(MSVehicle* v) override;
168
172 void resetPartialOccupation(MSVehicle* v) override;
173
175
176
185
194
200 Boundary getCenteringBoundary() const override;
201
206 void drawGL(const GUIVisualizationSettings& s) const override;
207
208 double getClickPriority() const override;
210
211 const PositionVector& getShape(bool secondary) const override;
212 const std::vector<double>& getShapeRotations(bool secondary) const;
213 const std::vector<double>& getShapeLengths(bool secondary) const;
214
215 double firstWaitingTime() const;
216
218 bool neighLaneNotBidi() const;
219
221 void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
222
224 void drawBikeMarkings() const;
225
228
230 void drawDirectionIndicators(double exaggeration, bool spreadSuperposed, bool s2) 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 override;
271
273 double getColorValueWithFunctional(const GUIVisualizationSettings& s, int activeScheme) const;
274
276 double getColorValueForTracker() const;
277
279 double getScaleValue(const GUIVisualizationSettings& s, int activeScheme, bool s2) const;
280
282 bool isSelected() const override;
283
284 /* @brief sets the color according to the current scheme index and some lane function
285 * @param[in] id override active scheme when calling from meso gui
286 */
287 bool setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme = -1) const;
288
290 bool drawAsRailway(const GUIVisualizationSettings& s) const;
291
292protected:
294 void swapAfterLaneChange(SUMOTime t) override;
295
308 void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
309 const MSLane::VehCont::iterator& at,
311
312private:
314 void drawLinkNo(const GUIVisualizationSettings& s) const;
315 void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const;
316 void drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const;
317 void drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, const MSLink* link,
318 const PositionVector& shape, double x1, double x2) const;
319 void drawArrows(bool secondaryShape) const;
320 void drawLane2LaneConnections(double exaggeration, bool s2) const;
321
322
325
327 double getPendingEmits() const;
328
329private:
330 void initRotations(const PositionVector& shape,
331 std::vector<double>& rotations,
332 std::vector<double>& lengths,
333 std::vector<RGBColor>& colors);
334
336 bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
337
340
342 bool drawAsWaterway(const GUIVisualizationSettings& s) const;
343
345 bool isLaneOrEdgeSelected() const;
346
347 std::vector<RGBColor>& getShapeColors(bool secondary) const;
348
350 std::vector<double> myShapeRotations;
351 std::vector<double> myShapeRotations2;
352
354 std::vector<double> myShapeLengths;
355 std::vector<double> myShapeLengths2;
356
358 mutable std::vector<RGBColor> myShapeColors;
359 mutable std::vector<RGBColor> myShapeColors2;
360
362 std::vector<int> myShapeSegments;
364 std::vector<int> mySegmentStartIndex;
365
368
371
374
376 mutable std::vector<MSParkingArea*>* myParkingAreas;
377
380
381#ifdef HAVE_OSG
382 osg::Geometry* myGeom;
383#endif
384
387
391
394
395private:
397 mutable FXMutex myLock;
398
401
402
403};
long long int SUMOTime
Definition: GUI.h:36
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const double INVALID_DOUBLE
invalid double
Definition: StdDefs.h:64
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:60
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterway
Definition: GUILane.cpp:1505
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition: GUILane.cpp:934
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:354
std::vector< MSParkingArea * > * myParkingAreas
list of parkingAreas on this lane
Definition: GUILane.h:376
const VehCont & getVehiclesSecure() const override
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:154
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:397
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition: GUILane.cpp:1575
void setReachability(double value)
Definition: GUILane.h:245
double getLengthGeometryFactor(bool secondaryShape) const override
Definition: GUILane.h:98
void initRotations(const PositionVector &shape, std::vector< double > &rotations, std::vector< double > &lengths, std::vector< RGBColor > &colors)
Definition: GUILane.cpp:114
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:367
double getReachability() const
Definition: GUILane.h:249
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition: GUILane.cpp:1542
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:362
double firstWaitingTime() const
Definition: GUILane.cpp:1084
double setPartialOccupation(MSVehicle *v) override
Sets the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:222
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:370
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:264
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:1135
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition: GUILane.cpp:1580
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:237
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUILane.cpp:959
static GUIVisualizationSettings * myCachedGUISettings
cached for tracking color value
Definition: GUILane.h:393
void drawJunctionChangeProhibitions() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:841
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:400
std::vector< double > myShapeLengths2
Definition: GUILane.h:355
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify) override
Definition: GUILane.cpp:187
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:1204
std::string getParentName() const override
Returns the name of the parent object (if any)
Definition: GUILane.h:92
void addSecondaryShape(const PositionVector &shape) override
Definition: GUILane.cpp:135
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme, bool s2) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1426
void resetPartialOccupation(MSVehicle *v) override
Removes the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:229
void integrateNewVehicles() override
Definition: GUILane.cpp:208
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUILane.cpp:525
void drawArrows(bool secondaryShape) const
Definition: GUILane.cpp:431
std::vector< int > mySegmentStartIndex
the shape indices where the meso segment changes (for segmentsIndex > 0)
Definition: GUILane.h:364
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:303
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:358
bool neighLaneNotBidi() const
whether any of the neighboring lanes is not a bidi-lane
Definition: GUILane.cpp:776
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition: GUILane.cpp:1242
bool isClosed() const
Definition: GUILane.h:265
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1526
double getClickPriority() const override
Returns the priority of receiving mouse clicks.
Definition: GUILane.cpp:1585
bool isSelected() const override
whether this lane is selected in the GUI
Definition: GUILane.cpp:1570
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUILane.cpp:1005
const std::vector< double > & getShapeRotations(bool secondary) const
Definition: GUILane.cpp:1066
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:1122
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1499
void removeParking(MSBaseVehicle *veh) override
remove parking vehicle
Definition: GUILane.cpp:194
std::vector< double > myShapeRotations2
Definition: GUILane.h:351
double myLengthGeometryFactor2
Definition: GUILane.h:390
void planMovements(const SUMOTime t) override
Definition: GUILane.cpp:167
double getColorValueForTracker() const
return color value based on cached settings
Definition: GUILane.cpp:1230
std::vector< RGBColor > myShapeColors2
Definition: GUILane.h:359
double getEdgeLaneNumber() const
Definition: GUILane.cpp:1090
double myReachability
the time distance from a particular edge
Definition: GUILane.h:373
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:1109
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:350
TesselatedPolygon * myTesselation
An object that stores the tesselation.
Definition: GUILane.h:379
void setJunctionApproaches(const SUMOTime t) const override
Definition: GUILane.cpp:173
void incorporateVehicle(MSVehicle *veh, double pos, double speed, double posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED) override
Inserts the vehicle into this lane, and informs it about entering the network.
Definition: GUILane.cpp:144
~GUILane()
Destructor.
Definition: GUILane.cpp:103
GUILane(const std::string &id, double maxSpeed, double friction, 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
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, const MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition: GUILane.cpp:358
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:1048
std::vector< RGBColor > & getShapeColors(bool secondary) const
Definition: GUILane.cpp:1078
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition: GUILane.cpp:1152
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:1096
const std::vector< double > & getShapeLengths(bool secondary) const
Definition: GUILane.cpp:1072
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition: GUILane.cpp:789
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:812
void executeMovements(const SUMOTime t) override
Definition: GUILane.cpp:180
PositionVector myShape2
secondary shape for visualization
Definition: GUILane.h:389
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:386
void drawLane2LaneConnections(double exaggeration, bool s2) const
Definition: GUILane.cpp:498
void releaseVehicles() const override
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:161
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed, bool s2) const
direction indicators for lanes
Definition: GUILane.cpp:906
void detectCollisions(SUMOTime timestep, const std::string &stage) override
Definition: GUILane.cpp:215
void swapAfterLaneChange(SUMOTime t) override
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:201
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:82
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:55
A road/street connecting two junctions.
Definition: MSEdge.h:77
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:119
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:524
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1533
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:745
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:77
const std::string & getID() const
Returns the id.
Definition: Named.h:74
A list of positions.