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-2024 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
105
115 const VehCont& getVehiclesSecure() const override;
116
117
123 void releaseVehicles() const override;
125
126
127
130
133 void planMovements(const SUMOTime t) override;
134
137 void setJunctionApproaches(const SUMOTime t) const override;
138
141 void executeMovements(const SUMOTime t) override;
142
145 void integrateNewVehicles() override;
147
148
151 void detectCollisions(SUMOTime timestep, const std::string& stage) override;
152
153
156 MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) override;
157
159 void removeParking(MSBaseVehicle* veh) override;
160
168 double setPartialOccupation(MSVehicle* v) override;
169
173 void resetPartialOccupation(MSVehicle* v) override;
174
176
177
186
195
201 Boundary getCenteringBoundary() const override;
202
207 void drawGL(const GUIVisualizationSettings& s) const override;
208
209 double getClickPriority() const override;
211
212 const PositionVector& getShape(bool secondary) const override;
213 const std::vector<double>& getShapeRotations(bool secondary) const;
214 const std::vector<double>& getShapeLengths(bool secondary) const;
215
216 double firstWaitingTime() const;
217
219 bool neighLaneNotBidi() const;
220
222 void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
223
225 void drawBikeMarkings() const;
226
229
231 void drawDirectionIndicators(double exaggeration, bool spreadSuperposed, bool s2) const;
232
234 void debugDrawFoeIntersections() const;
235
236 double getEdgeLaneNumber() const;
237
240 double getStoredEdgeTravelTime() const;
241
244 double getLoadedEdgeWeight() const;
245
246 void setReachability(double value) {
247 myReachability = value;
248 }
249
250 double getReachability() const {
251 return myReachability;
252 }
253
254#ifdef HAVE_OSG
255 void setGeometry(osg::Geometry* geom) {
256 myGeom = geom;
257 }
258
259 void updateColor(const GUIVisualizationSettings& s);
260
261#endif
262
264 void closeTraffic(bool rebuildAllowed = true);
265
266 bool isClosed() const {
267 return myAmClosed;
268 }
269
271 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
272
274 double getColorValueWithFunctional(const GUIVisualizationSettings& s, int activeScheme) const;
275
277 double getColorValueForTracker() const;
278
280 double getScaleValue(const GUIVisualizationSettings& s, int activeScheme, bool s2) const;
281
283 bool isSelected() const override;
284
285 /* @brief sets the color according to the current scheme index and some lane function
286 * @param[in] id override active scheme when calling from meso gui
287 */
288 bool setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme = -1) const;
289
291 bool drawAsRailway(const GUIVisualizationSettings& s) const;
292
293protected:
295 void swapAfterLaneChange(SUMOTime t) override;
296
309 void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
310 const MSLane::VehCont::iterator& at,
312
313private:
315 void drawLinkNo(const GUIVisualizationSettings& s) const;
316 void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const;
317 void drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const;
318 void drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, const MSLink* link,
319 const PositionVector& shape, double x1, double x2) const;
320 void drawArrows(bool secondaryShape) const;
321 void drawLane2LaneConnections(double exaggeration, bool s2) const;
322
323
326
328 double getPendingEmits() const;
329
330private:
331 void initRotations(const PositionVector& shape,
332 std::vector<double>& rotations,
333 std::vector<double>& lengths,
334 std::vector<RGBColor>& colors);
335
337 bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
338
341
343 bool drawAsWaterway(const GUIVisualizationSettings& s) const;
344
346 bool isLaneOrEdgeSelected() const;
347
348 std::vector<RGBColor>& getShapeColors(bool secondary) const;
349
351 std::vector<double> myShapeRotations;
352 std::vector<double> myShapeRotations2;
353
355 std::vector<double> myShapeLengths;
356 std::vector<double> myShapeLengths2;
357
359 mutable std::vector<RGBColor> myShapeColors;
360 mutable std::vector<RGBColor> myShapeColors2;
361
363 std::vector<int> myShapeSegments;
365 std::vector<int> mySegmentStartIndex;
366
369
372
375
377 mutable std::vector<MSParkingArea*>* myParkingAreas;
378
381
382#ifdef HAVE_OSG
383 osg::Geometry* myGeom;
384#endif
385
388
392
395
396private:
398 mutable FXMutex myLock;
399
402
403
404};
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: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:1563
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition GUILane.cpp:971
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition GUILane.h:355
std::vector< MSParkingArea * > * myParkingAreas
list of parkingAreas on this lane
Definition GUILane.h:377
const VehCont & getVehiclesSecure() const override
Returns the vehicles container; locks it for microsimulation.
Definition GUILane.cpp:160
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition GUILane.h:398
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition GUILane.cpp:1633
void setReachability(double value)
Definition GUILane.h:246
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:120
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition GUILane.h:368
double getReachability() const
Definition GUILane.h:250
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition GUILane.cpp:1600
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition GUILane.h:363
double firstWaitingTime() const
Definition GUILane.cpp:1133
double setPartialOccupation(MSVehicle *v) override
Sets the information about a vehicle lapping into this lane.
Definition GUILane.cpp:228
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition GUILane.h:371
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition GUILane.cpp:270
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition GUILane.cpp:1184
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition GUILane.cpp:1638
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition GUILane.cpp:243
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GUILane.cpp:997
static GUIVisualizationSettings * myCachedGUISettings
cached for tracking color value
Definition GUILane.h:394
void drawJunctionChangeProhibitions() const
bike lane markings on top of an intersection
Definition GUILane.cpp:878
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition GUILane.h:401
std::vector< double > myShapeLengths2
Definition GUILane.h:356
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify) override
Definition GUILane.cpp:193
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:1253
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:141
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme, bool s2) const
gets the scaling value according to the current scheme index
Definition GUILane.cpp:1484
void resetPartialOccupation(MSVehicle *v) override
Removes the information about a vehicle lapping into this lane.
Definition GUILane.cpp:235
void integrateNewVehicles() override
Definition GUILane.cpp:214
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GUILane.cpp:531
void drawArrows(bool secondaryShape) const
Definition GUILane.cpp:437
std::vector< int > mySegmentStartIndex
the shape indices where the meso segment changes (for segmentsIndex > 0)
Definition GUILane.h:365
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition GUILane.cpp:309
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition GUILane.h:359
bool neighLaneNotBidi() const
whether any of the neighboring lanes is not a bidi-lane
Definition GUILane.cpp:813
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition GUILane.cpp:1297
bool isClosed() const
Definition GUILane.h:266
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition GUILane.cpp:1584
double getClickPriority() const override
Returns the priority of receiving mouse clicks.
Definition GUILane.cpp:1643
bool isSelected() const override
whether this lane is selected in the GUI
Definition GUILane.cpp:1628
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition GUILane.cpp:1043
const std::vector< double > & getShapeRotations(bool secondary) const
Definition GUILane.cpp:1115
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:1171
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition GUILane.cpp:1557
void removeParking(MSBaseVehicle *veh) override
remove parking vehicle
Definition GUILane.cpp:200
std::vector< double > myShapeRotations2
Definition GUILane.h:352
double myLengthGeometryFactor2
Definition GUILane.h:391
void planMovements(const SUMOTime t) override
Definition GUILane.cpp:173
double getColorValueForTracker() const
return color value based on cached settings
Definition GUILane.cpp:1279
std::vector< RGBColor > myShapeColors2
Definition GUILane.h:360
double getEdgeLaneNumber() const
Definition GUILane.cpp:1139
double myReachability
the time distance from a particular edge
Definition GUILane.h:374
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition GUILane.cpp:1158
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition GUILane.h:351
TesselatedPolygon * myTesselation
An object that stores the tesselation.
Definition GUILane.h:380
void setJunctionApproaches(const SUMOTime t) const override
Definition GUILane.cpp:179
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:150
~GUILane()
Destructor.
Definition GUILane.cpp:109
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, const MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition GUILane.cpp:364
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GUILane.cpp:1097
std::vector< RGBColor > & getShapeColors(bool secondary) const
Definition GUILane.cpp:1127
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition GUILane.cpp:1201
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition GUILane.cpp:1145
const std::vector< double > & getShapeLengths(bool secondary) const
Definition GUILane.cpp:1121
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition GUILane.cpp:826
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition GUILane.cpp:849
void executeMovements(const SUMOTime t) override
Definition GUILane.cpp:186
PositionVector myShape2
secondary shape for visualization
Definition GUILane.h:390
bool myAmClosed
state for dynamic lane closings
Definition GUILane.h:387
void drawLane2LaneConnections(double exaggeration, bool s2) const
Definition GUILane.cpp:504
void releaseVehicles() const override
Allows to use the container for microsimulation again.
Definition GUILane.cpp:167
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed, bool s2) const
direction indicators for lanes
Definition GUILane.cpp:943
void detectCollisions(SUMOTime timestep, const std::string &stage) override
Definition GUILane.cpp:221
void swapAfterLaneChange(SUMOTime t) override
moves myTmpVehicles int myVehicles after a lane change procedure
Definition GUILane.cpp:207
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:533
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition MSLane.h:1576
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:764
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.