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-2022 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
99
109 const VehCont& getVehiclesSecure() const override;
110
111
117 void releaseVehicles() const override;
119
120
121
124
127 void planMovements(const SUMOTime t) override;
128
131 void setJunctionApproaches(const SUMOTime t) const override;
132
135 void executeMovements(const SUMOTime t) override;
136
139 void integrateNewVehicles() override;
141
142
145 void detectCollisions(SUMOTime timestep, const std::string& stage) override;
146
147
150 MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) override;
151
153 void removeParking(MSBaseVehicle* veh) override;
154
162 double setPartialOccupation(MSVehicle* v) override;
163
167 void resetPartialOccupation(MSVehicle* v) override;
168
170
171
180
189
191 double getExaggeration(const GUIVisualizationSettings& s) const override;
192
198 Boundary getCenteringBoundary() const override;
199
204 void drawGL(const GUIVisualizationSettings& s) const override;
205
206 double getClickPriority() const override;
208
209 const PositionVector& getShape() const;
210 const std::vector<double>& getShapeRotations() const;
211 const std::vector<double>& getShapeLengths() const;
212
213 double firstWaitingTime() const;
214
216 void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
217
219 void drawBikeMarkings() const;
220
223
225 void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const;
226
228 void debugDrawFoeIntersections() const;
229
230 double getEdgeLaneNumber() const;
231
234 double getStoredEdgeTravelTime() const;
235
238 double getLoadedEdgeWeight() const;
239
240 void setReachability(double value) {
241 myReachability = value;
242 }
243
244 double getReachability() const {
245 return myReachability;
246 }
247
248#ifdef HAVE_OSG
249 void setGeometry(osg::Geometry* geom) {
250 myGeom = geom;
251 }
252
253 void updateColor(const GUIVisualizationSettings& s);
254
255#endif
256
258 void closeTraffic(bool rebuildAllowed = true);
259
260 bool isClosed() const {
261 return myAmClosed;
262 }
263
265 double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
266
268 double getColorValueWithFunctional(const GUIVisualizationSettings& s, int activeScheme) const;
269
271 double getColorValueForTracker() const;
272
274 bool isSelected() const override;
275
276 /* @brief sets the color according to the current scheme index and some lane function
277 * @param[in] id override active scheme when calling from meso gui
278 */
279 bool setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme = -1) const;
280
282 bool drawAsRailway(const GUIVisualizationSettings& s) const;
283
284protected:
286 void swapAfterLaneChange(SUMOTime t) override;
287
300 void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
301 const MSLane::VehCont::iterator& at,
303
304private:
306 void drawLinkNo(const GUIVisualizationSettings& s) const;
307 void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const;
308 void drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const;
309 void drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, const MSLink* link,
310 const PositionVector& shape, double x1, double x2) const;
311 void drawArrows() const;
312 void drawLane2LaneConnections(double exaggeration) const;
313
314
317
319 double getPendingEmits() const;
320
321private:
322
324 double getScaleValue(int activeScheme) const;
325
327 bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
328
331
333 bool drawAsWaterway(const GUIVisualizationSettings& s) const;
334
336 bool isLaneOrEdgeSelected() const;
337
339 std::vector<double> myShapeRotations;
340
342 std::vector<double> myShapeLengths;
343
345 mutable std::vector<RGBColor> myShapeColors;
346
348 std::vector<int> myShapeSegments;
350 std::vector<int> mySegmentStartIndex;
351
354
357
360
362 mutable std::vector<MSParkingArea*>* myParkingAreas;
363
366
367#ifdef HAVE_OSG
368 osg::Geometry* myGeom;
369#endif
370
373
376
377private:
379 mutable FXMutex myLock;
380
383
384
385};
long long int SUMOTime
Definition: GUI.h:36
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
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:1443
const PositionVector & getShape() const
Definition: GUILane.cpp:1009
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition: GUILane.cpp:878
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:342
std::vector< MSParkingArea * > * myParkingAreas
list of parkingAreas on this lane
Definition: GUILane.h:362
const VehCont & getVehiclesSecure() const override
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:132
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:379
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition: GUILane.cpp:1513
void setReachability(double value)
Definition: GUILane.h:240
void drawArrows() const
Definition: GUILane.cpp:396
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:1021
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1367
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:353
double getReachability() const
Definition: GUILane.h:244
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition: GUILane.cpp:1480
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:348
double firstWaitingTime() const
Definition: GUILane.cpp:1027
double setPartialOccupation(MSVehicle *v) override
Sets the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:200
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:356
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:242
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:1078
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition: GUILane.cpp:1518
void drawLane2LaneConnections(double exaggeration) const
Definition: GUILane.cpp:463
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:215
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUILane.cpp:903
static GUIVisualizationSettings * myCachedGUISettings
cached for tracking color value
Definition: GUILane.h:375
void drawJunctionChangeProhibitions() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:787
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:382
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify) override
Definition: GUILane.cpp:165
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:1147
std::string getParentName() const override
Returns the name of the parent object (if any)
Definition: GUILane.h:92
void resetPartialOccupation(MSVehicle *v) override
Removes the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:207
void integrateNewVehicles() override
Definition: GUILane.cpp:186
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition: GUILane.cpp:991
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUILane.cpp:490
std::vector< int > mySegmentStartIndex
the shape indices where the meso segment changes (for segmentsIndex > 0)
Definition: GUILane.h:350
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:281
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:345
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition: GUILane.cpp:1183
bool isClosed() const
Definition: GUILane.h:260
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1464
double getClickPriority() const override
Returns the priority of receiving mouse clicks.
Definition: GUILane.cpp:1523
bool isSelected() const override
whether this lane is selected in the GUI
Definition: GUILane.cpp:1508
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUILane.cpp:948
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed) const
direction indicators for lanes
Definition: GUILane.cpp:850
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:1065
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1437
void removeParking(MSBaseVehicle *veh) override
remove parking vehicle
Definition: GUILane.cpp:172
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:1015
void planMovements(const SUMOTime t) override
Definition: GUILane.cpp:145
double getColorValueForTracker() const
return color value based on cached settings
Definition: GUILane.cpp:1171
double getEdgeLaneNumber() const
Definition: GUILane.cpp:1033
double myReachability
the time distance from a particular edge
Definition: GUILane.h:359
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:1052
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:339
TesselatedPolygon * myTesselation
An object that stores the tesselation.
Definition: GUILane.h:365
void setJunctionApproaches(const SUMOTime t) const override
Definition: GUILane.cpp:151
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:122
~GUILane()
Destructor.
Definition: GUILane.cpp:110
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:73
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, const MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition: GUILane.cpp:331
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:997
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition: GUILane.cpp:1095
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:1039
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition: GUILane.cpp:738
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:760
void executeMovements(const SUMOTime t) override
Definition: GUILane.cpp:158
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:372
void releaseVehicles() const override
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:139
void detectCollisions(SUMOTime timestep, const std::string &stage) override
Definition: GUILane.cpp:193
void swapAfterLaneChange(SUMOTime t) override
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:179
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
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:713
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.