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-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
99 return myShape2;
100 }
101
102 double getLengthGeometryFactor(bool secondaryShape) const override {
103 return secondaryShape ? myLengthGeometryFactor2 : myLengthGeometryFactor;
104 }
105
108
118 const VehCont& getVehiclesSecure() const override;
119
120
126 void releaseVehicles() const override;
128
129
130
133
136 void planMovements(const SUMOTime t) override;
137
140 void setJunctionApproaches(const SUMOTime t) const override;
141
144 void executeMovements(const SUMOTime t) override;
145
148 void integrateNewVehicles() override;
150
151
154 void detectCollisions(SUMOTime timestep, const std::string& stage) override;
155
156
159 MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) override;
160
162 void removeParking(MSBaseVehicle* veh) override;
163
171 double setPartialOccupation(MSVehicle* v) override;
172
176 void resetPartialOccupation(MSVehicle* v) override;
177
179
180
189
198
204 Boundary getCenteringBoundary() const override;
205
210 void drawGL(const GUIVisualizationSettings& s) const override;
211
212 double getClickPriority() const override;
214
215 const PositionVector& getShape(bool secondary) const override;
216 const std::vector<double>& getShapeRotations(bool secondary) const;
217 const std::vector<double>& getShapeLengths(bool secondary) const;
218
219 double firstWaitingTime() const;
220
222 bool neighLaneNotBidi() const;
223
225 void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
226
228 void drawBikeMarkings() const;
229
232
234 void drawDirectionIndicators(double exaggeration, bool spreadSuperposed, bool s2) const;
235
237 void debugDrawFoeIntersections() const;
238
239 double getEdgeLaneNumber() const;
240
243 double getStoredEdgeTravelTime() const;
244
247 double getLoadedEdgeWeight() const;
248
249 void setReachability(double value) {
250 myReachability = value;
251 }
252
253 double getReachability() const {
254 return myReachability;
255 }
256
257#ifdef HAVE_OSG
258 void setGeometry(osg::Geometry* geom) {
259 myGeom = geom;
260 }
261
262 void updateColor(const GUIVisualizationSettings& s);
263
264#endif
265
267 void closeTraffic(bool rebuildAllowed = true);
268
269 bool isClosed() const {
270 return myAmClosed;
271 }
272
274 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
275
277 double getColorValueWithFunctional(const GUIVisualizationSettings& s, int activeScheme) const;
278
280 double getColorValueForTracker() const;
281
283 double getScaleValue(const GUIVisualizationSettings& s, int activeScheme, bool s2) const;
284
286 bool isSelected() const override;
287
288 /* @brief sets the color according to the current scheme index and some lane function
289 * @param[in] id override active scheme when calling from meso gui
290 */
291 bool setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme = -1) const;
292
294 bool drawAsRailway(const GUIVisualizationSettings& s) const;
295
296protected:
298 void swapAfterLaneChange(SUMOTime t) override;
299
312 void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
313 const MSLane::VehCont::iterator& at,
315
316private:
318 void drawLinkNo(const GUIVisualizationSettings& s) const;
319 void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const;
320 void drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const;
321 void drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, const MSLink* link,
322 const PositionVector& shape, double x1, double x2) const;
323 void drawArrows(bool secondaryShape) const;
324 void drawLane2LaneConnections(double exaggeration, bool s2) const;
325
326
329
331 double getPendingEmits() const;
332
333private:
334 void initRotations(const PositionVector& shape,
335 std::vector<double>& rotations,
336 std::vector<double>& lengths,
337 std::vector<RGBColor>& colors);
338
340 bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
341
344
346 bool drawAsWaterway(const GUIVisualizationSettings& s) const;
347
349 bool isLaneOrEdgeSelected() const;
350
351 std::vector<RGBColor>& getShapeColors(bool secondary) const;
352
354 std::vector<double> myShapeRotations;
355 std::vector<double> myShapeRotations2;
356
358 std::vector<double> myShapeLengths;
359 std::vector<double> myShapeLengths2;
360
362 mutable std::vector<RGBColor> myShapeColors;
363 mutable std::vector<RGBColor> myShapeColors2;
364
366 std::vector<int> myShapeSegments;
368 std::vector<int> mySegmentStartIndex;
369
372
375
378
380 mutable std::vector<MSParkingArea*>* myParkingAreas;
381
384
385#ifdef HAVE_OSG
386 osg::Geometry* myGeom;
387#endif
388
391
395
398
399private:
401 mutable FXMutex myLock;
402
405
406
407};
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:1504
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition: GUILane.cpp:933
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:358
std::vector< MSParkingArea * > * myParkingAreas
list of parkingAreas on this lane
Definition: GUILane.h:380
const VehCont & getVehiclesSecure() const override
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:153
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:401
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition: GUILane.cpp:1574
void setReachability(double value)
Definition: GUILane.h:249
double getLengthGeometryFactor(bool secondaryShape) const override
Definition: GUILane.h:102
void initRotations(const PositionVector &shape, std::vector< double > &rotations, std::vector< double > &lengths, std::vector< RGBColor > &colors)
Definition: GUILane.cpp:113
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:371
double getReachability() const
Definition: GUILane.h:253
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition: GUILane.cpp:1541
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:366
double firstWaitingTime() const
Definition: GUILane.cpp:1083
double setPartialOccupation(MSVehicle *v) override
Sets the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:221
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:374
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:263
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:1134
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition: GUILane.cpp:1579
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:236
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUILane.cpp:958
static GUIVisualizationSettings * myCachedGUISettings
cached for tracking color value
Definition: GUILane.h:397
void drawJunctionChangeProhibitions() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:840
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:404
std::vector< double > myShapeLengths2
Definition: GUILane.h:359
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify) override
Definition: GUILane.cpp:186
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:1203
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:134
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme, bool s2) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1425
void resetPartialOccupation(MSVehicle *v) override
Removes the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:228
void integrateNewVehicles() override
Definition: GUILane.cpp:207
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUILane.cpp:524
void drawArrows(bool secondaryShape) const
Definition: GUILane.cpp:430
std::vector< int > mySegmentStartIndex
the shape indices where the meso segment changes (for segmentsIndex > 0)
Definition: GUILane.h:368
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:302
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:362
bool neighLaneNotBidi() const
whether any of the neighboring lanes is not a bidi-lane
Definition: GUILane.cpp:775
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition: GUILane.cpp:1241
bool isClosed() const
Definition: GUILane.h:269
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1525
double getClickPriority() const override
Returns the priority of receiving mouse clicks.
Definition: GUILane.cpp:1584
bool isSelected() const override
whether this lane is selected in the GUI
Definition: GUILane.cpp:1569
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUILane.cpp:1004
const std::vector< double > & getShapeRotations(bool secondary) const
Definition: GUILane.cpp:1065
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:1121
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1498
void removeParking(MSBaseVehicle *veh) override
remove parking vehicle
Definition: GUILane.cpp:193
std::vector< double > myShapeRotations2
Definition: GUILane.h:355
double myLengthGeometryFactor2
Definition: GUILane.h:394
void planMovements(const SUMOTime t) override
Definition: GUILane.cpp:166
double getColorValueForTracker() const
return color value based on cached settings
Definition: GUILane.cpp:1229
std::vector< RGBColor > myShapeColors2
Definition: GUILane.h:363
double getEdgeLaneNumber() const
Definition: GUILane.cpp:1089
double myReachability
the time distance from a particular edge
Definition: GUILane.h:377
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:1108
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:354
TesselatedPolygon * myTesselation
An object that stores the tesselation.
Definition: GUILane.h:383
void setJunctionApproaches(const SUMOTime t) const override
Definition: GUILane.cpp:172
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:143
const PositionVector & getSecondaryShape()
Definition: GUILane.h:98
~GUILane()
Destructor.
Definition: GUILane.cpp:102
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:357
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:1047
std::vector< RGBColor > & getShapeColors(bool secondary) const
Definition: GUILane.cpp:1077
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition: GUILane.cpp:1151
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:1095
const std::vector< double > & getShapeLengths(bool secondary) const
Definition: GUILane.cpp:1071
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition: GUILane.cpp:788
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:811
void executeMovements(const SUMOTime t) override
Definition: GUILane.cpp:179
PositionVector myShape2
secondary shape for visualization
Definition: GUILane.h:393
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:390
void drawLane2LaneConnections(double exaggeration, bool s2) const
Definition: GUILane.cpp:497
void releaseVehicles() const override
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:160
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed, bool s2) const
direction indicators for lanes
Definition: GUILane.cpp:905
void detectCollisions(SUMOTime timestep, const std::string &stage) override
Definition: GUILane.cpp:214
void swapAfterLaneChange(SUMOTime t) override
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:200
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:1521
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.