Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2026 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 const PositionVector& outlineShape);
84
85
87 ~GUILane();
88
93 std::string getParentName() const override {
94 return getEdge().getID();
95 }
96
97 void addSecondaryShape(const PositionVector& shape) override;
98
99 double getLengthGeometryFactor(bool secondaryShape) const override {
100 return secondaryShape ? myLengthGeometryFactor2 : myLengthGeometryFactor;
101 }
102
103 void updateMesoGUISegments() override;
104
107
117 const VehCont& getVehiclesSecure() const override;
118
119
125 void releaseVehicles() const override;
127
128
129
132
135 void planMovements(const SUMOTime t) override;
136
139 void setJunctionApproaches() const override;
140
143 void executeMovements(const SUMOTime t) override;
144
147 void integrateNewVehicles() override;
149
150
153 void detectCollisions(SUMOTime timestep, const std::string& stage) override;
154
155
158 MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) override;
159
161 void removeParking(MSBaseVehicle* veh) override;
162
170 double setPartialOccupation(MSVehicle* v) override;
171
175 void resetPartialOccupation(MSVehicle* v) override;
176
178
179
188
197
203 Boundary getCenteringBoundary() const override;
204
209 void drawGL(const GUIVisualizationSettings& s) const override;
210
211 double getClickPriority() const override;
213
214 const PositionVector& getShape(bool secondary) const override;
215 const std::vector<double>& getShapeRotations(bool secondary) const;
216 const std::vector<double>& getShapeLengths(bool secondary) const;
217
218 double firstWaitingTime() const;
219
221 bool neighLaneNotBidi() const;
222
224 void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
225
227 void drawBikeMarkings() const;
228
231
233 void drawDirectionIndicators(double exaggeration, bool spreadSuperposed, bool s2) const;
234
236 void debugDrawFoeIntersections() const;
237
238 double getEdgeLaneNumber() const;
239
242 double getStoredEdgeTravelTime() const;
243
246 double getLoadedEdgeWeight() const;
247
248 void setReachability(double value) {
249 myReachability = value;
250 }
251
252 double getReachability() const {
253 return myReachability;
254 }
255
256#ifdef HAVE_OSG
257 void setGeometry(osg::Geometry* geom) {
258 myGeom = geom;
259 }
260
261 void updateColor(const GUIVisualizationSettings& s);
262
263#endif
264
266 void closeTraffic(bool rebuildAllowed = true);
267
268 bool isClosed() const {
269 return myAmClosed;
270 }
271
273 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
274
276 double getColorValueWithFunctional(const GUIVisualizationSettings& s, int activeScheme) const;
277
279 double getColorValueForTracker() const;
280
282 double getScaleValue(const GUIVisualizationSettings& s, int activeScheme, bool s2) const;
283
285 bool isSelected() const override;
286
287 /* @brief sets the color according to the current scheme index and some lane function
288 * @param[in] id override active scheme when calling from meso gui
289 */
290 bool setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme = -1) const;
291
293 bool drawAsRailway(const GUIVisualizationSettings& s) const;
294
295protected:
297 void swapAfterLaneChange(SUMOTime t) override;
298
311 void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
312 const MSLane::VehCont::iterator& at,
314
315private:
317 void drawLinkNo(const GUIVisualizationSettings& s) const;
318 void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const;
319 void drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const;
320 void drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, const MSLink* link,
321 const PositionVector& shape, double x1, double x2) const;
322 void drawArrows(bool secondaryShape) const;
323 void drawLane2LaneConnections(double exaggeration, bool s2) const;
324
325
328
330 double getPendingEmits() const;
331
332private:
333 void initRotations(const PositionVector& shape,
334 std::vector<double>& rotations,
335 std::vector<double>& lengths,
336 std::vector<RGBColor>& colors);
337
339 bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
340
343
345 bool drawAsWaterway(const GUIVisualizationSettings& s) const;
346
348 bool isLaneOrEdgeSelected() const;
349
350 std::vector<RGBColor>& getShapeColors(bool secondary) const;
351
353 std::vector<double> myShapeRotations;
354 std::vector<double> myShapeRotations2;
355
357 std::vector<double> myShapeLengths;
358 std::vector<double> myShapeLengths2;
359
361 mutable std::vector<RGBColor> myShapeColors;
362 mutable std::vector<RGBColor> myShapeColors2;
363
365 std::vector<int> myShapeSegments;
367 std::vector<int> mySegmentStartIndex;
368
371
374
377
379 mutable std::vector<MSParkingArea*>* myParkingAreas;
380
383
384#ifdef HAVE_OSG
385 osg::Geometry* myGeom;
386#endif
387
390
394
397
398private:
400 mutable FXMutex myLock;
401
404
405
406};
long long int SUMOTime
Definition GUI.h:36
long long 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:68
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:1580
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition GUILane.cpp:986
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition GUILane.h:357
std::vector< MSParkingArea * > * myParkingAreas
list of parkingAreas on this lane
Definition GUILane.h:379
const VehCont & getVehiclesSecure() const override
Returns the vehicles container; locks it for microsimulation.
Definition GUILane.cpp:168
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition GUILane.h:400
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition GUILane.cpp:1651
void setReachability(double value)
Definition GUILane.h:248
void updateMesoGUISegments() override
Definition GUILane.cpp:116
double getLengthGeometryFactor(bool secondaryShape) const override
Definition GUILane.h:99
void initRotations(const PositionVector &shape, std::vector< double > &rotations, std::vector< double > &lengths, std::vector< RGBColor > &colors)
Definition GUILane.cpp:128
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition GUILane.h:370
double getReachability() const
Definition GUILane.h:252
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition GUILane.cpp:1617
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition GUILane.h:365
double firstWaitingTime() const
Definition GUILane.cpp:1150
double setPartialOccupation(MSVehicle *v) override
Sets the information about a vehicle lapping into this lane.
Definition GUILane.cpp:236
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition GUILane.h:373
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition GUILane.cpp:278
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition GUILane.cpp:1201
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition GUILane.cpp:1656
void setJunctionApproaches() const override
Definition GUILane.cpp:187
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition GUILane.cpp:251
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GUILane.cpp:1012
static GUIVisualizationSettings * myCachedGUISettings
cached for tracking color value
Definition GUILane.h:396
void drawJunctionChangeProhibitions() const
bike lane markings on top of an intersection
Definition GUILane.cpp:893
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition GUILane.h:403
std::vector< double > myShapeLengths2
Definition GUILane.h:358
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify) override
Definition GUILane.cpp:201
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:1270
std::string getParentName() const override
Returns the name of the parent object (if any)
Definition GUILane.h:93
void addSecondaryShape(const PositionVector &shape) override
Definition GUILane.cpp:149
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme, bool s2) const
gets the scaling value according to the current scheme index
Definition GUILane.cpp:1501
void resetPartialOccupation(MSVehicle *v) override
Removes the information about a vehicle lapping into this lane.
Definition GUILane.cpp:243
void integrateNewVehicles() override
Definition GUILane.cpp:222
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GUILane.cpp:546
void drawArrows(bool secondaryShape) const
Definition GUILane.cpp:452
std::vector< int > mySegmentStartIndex
the shape indices where the meso segment changes (for segmentsIndex > 0)
Definition GUILane.h:367
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition GUILane.cpp:317
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition GUILane.h:361
bool neighLaneNotBidi() const
whether any of the neighboring lanes is not a bidi-lane
Definition GUILane.cpp:828
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition GUILane.cpp:1314
bool isClosed() const
Definition GUILane.h:268
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition GUILane.cpp:1601
double getClickPriority() const override
Returns the priority of receiving mouse clicks.
Definition GUILane.cpp:1661
bool isSelected() const override
whether this lane is selected in the GUI
Definition GUILane.cpp:1646
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition GUILane.cpp:1058
const std::vector< double > & getShapeRotations(bool secondary) const
Definition GUILane.cpp:1132
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:1188
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition GUILane.cpp:1574
void removeParking(MSBaseVehicle *veh) override
remove parking vehicle
Definition GUILane.cpp:208
std::vector< double > myShapeRotations2
Definition GUILane.h:354
double myLengthGeometryFactor2
Definition GUILane.h:393
void planMovements(const SUMOTime t) override
Definition GUILane.cpp:181
double getColorValueForTracker() const
return color value based on cached settings
Definition GUILane.cpp:1296
std::vector< RGBColor > myShapeColors2
Definition GUILane.h:362
double getEdgeLaneNumber() const
Definition GUILane.cpp:1156
double myReachability
the time distance from a particular edge
Definition GUILane.h:376
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition GUILane.cpp:1175
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition GUILane.h:353
TesselatedPolygon * myTesselation
An object that stores the tesselation.
Definition GUILane.h:382
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:158
~GUILane()
Destructor.
Definition GUILane.cpp:105
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, const MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition GUILane.cpp:372
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GUILane.cpp:1113
std::vector< RGBColor > & getShapeColors(bool secondary) const
Definition GUILane.cpp:1144
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition GUILane.cpp:1218
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition GUILane.cpp:1162
const std::vector< double > & getShapeLengths(bool secondary) const
Definition GUILane.cpp:1138
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition GUILane.cpp:841
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition GUILane.cpp:864
void executeMovements(const SUMOTime t) override
Definition GUILane.cpp:194
PositionVector myShape2
secondary shape for visualization
Definition GUILane.h:392
bool myAmClosed
state for dynamic lane closings
Definition GUILane.h:389
void drawLane2LaneConnections(double exaggeration, bool s2) const
Definition GUILane.cpp:519
void releaseVehicles() const override
Allows to use the container for microsimulation again.
Definition GUILane.cpp:175
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed, bool s2) const
direction indicators for lanes
Definition GUILane.cpp:958
void detectCollisions(SUMOTime timestep, const std::string &stage) override
Definition GUILane.cpp:229
void swapAfterLaneChange(SUMOTime t) override
moves myTmpVehicles int myVehicles after a lane change procedure
Definition GUILane.cpp:215
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.
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:534
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition MSLane.h:1599
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:770
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:74
A list of positions.