SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GUILane.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Representation of a lane in the micro simulation (gui-version)
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef GUILane_h
23 #define GUILane_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <fx.h>
36 #include <string>
37 #include <utility>
38 #include <microsim/MSLane.h>
39 #include <microsim/MSEdge.h>
41 #include <utils/geom/Position.h>
45 
46 
47 // ===========================================================================
48 // class declarations
49 // ===========================================================================
50 class GUINet;
51 class MSVehicle;
52 class MSNet;
53 #ifdef HAVE_OSG
54 namespace osg {
55 class Geometry;
56 }
57 #endif
58 
59 // ===========================================================================
60 // class definitions
61 // ===========================================================================
70 class GUILane : public MSLane, public GUIGlObject {
71 public:
85  GUILane(const std::string& id, SUMOReal maxSpeed,
86  SUMOReal length, MSEdge* const edge, int numericalID,
87  const PositionVector& shape, SUMOReal width,
88  SVCPermissions permissions, int index);
89 
90 
92  ~GUILane();
93 
98  const std::string& getParentName() const {
99  return getEdge().getID();
100  }
101 
102 
105 
115  const VehCont& getVehiclesSecure() const;
116 
117 
123  void releaseVehicles() const;
125 
126 
127 
130 
133  void planMovements(const SUMOTime t);
134 
137  bool executeMovements(SUMOTime t, std::vector<MSLane*>& into);
138 
143 
144 
147  void detectCollisions(SUMOTime timestep, const std::string& stage);
148 
149 
152  MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify);
153 
154 
163 
168 
169 
171 
172 
181  GUISUMOAbstractView& parent);
182 
183 
192  GUISUMOAbstractView& parent);
193 
194 
201 
202 
207  void drawGL(const GUIVisualizationSettings& s) const;
209 
210 
211 
212  const PositionVector& getShape() const;
213  const std::vector<SUMOReal>& getShapeRotations() const;
214  const std::vector<SUMOReal>& getShapeLengths() const;
215 
216  SUMOReal firstWaitingTime() const;
217 
219  void drawMarkings(const GUIVisualizationSettings& s, SUMOReal scale) const;
220 
222  void drawBikeMarkings() const;
223 
225  void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const;
226 
228  void drawDirectionIndicators() const;
229 
230  SUMOReal getEdgeLaneNumber() const;
231 
235 
239 
240 #ifdef HAVE_OSG
241  void setGeometry(osg::Geometry* geom) {
242  myGeom = geom;
243  }
244 
245  void updateColor(const GUIVisualizationSettings& s);
246 
247 #endif
248 
250  void closeTraffic(bool rebuildAllowed = true);
251 
252  bool isClosed() const {
253  return myAmClosed;
254  }
255 
256 protected:
259 
272  virtual void incorporateVehicle(MSVehicle* veh, SUMOReal pos, SUMOReal speed, SUMOReal posLat,
273  const MSLane::VehCont::iterator& at,
275 
276 private:
278  void drawLinkNo(const GUIVisualizationSettings& s) const;
279  void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const;
280  void drawTextAtEnd(const std::string& text, const PositionVector& shape, SUMOReal x, const GUIVisualizationTextSettings& settings) const;
281  void drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const;
282  void drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, MSLink* link, const PositionVector& shape, SUMOReal x1, SUMOReal x2) const;
283  void drawArrows() const;
284  void drawLane2LaneConnections() const;
285 
286 
289 
290 private:
292  SUMOReal getColorValue(int activeScheme) const;
293 
295  SUMOReal getScaleValue(int activeScheme) const;
296 
298  bool setFunctionalColor(int activeScheme) const;
299 
301  bool setMultiColor(const GUIColorer& c) const;
302 
304  void setColor(const GUIVisualizationSettings& s) const;
305 
307  bool drawAsRailway(const GUIVisualizationSettings& s) const;
308 
310  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
311 
313  std::vector<SUMOReal> myShapeRotations;
314 
316  std::vector<SUMOReal> myShapeLengths;
317 
319  mutable std::vector<RGBColor> myShapeColors;
320 
322  std::vector<int> myShapeSegments;
323 
326 
329 
330 #ifdef HAVE_OSG
331  osg::Geometry* myGeom;
332 #endif
333 
336 
337 private:
339  mutable MFXMutex myLock;
340 
341 
342 };
343 
344 
345 #endif
346 
347 /****************************************************************************/
348 
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:322
virtual void incorporateVehicle(MSVehicle *veh, SUMOReal pos, SUMOReal speed, SUMOReal posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Inserts the vehicle into this lane, and informs it about entering the network.
Definition: GUILane.cpp:116
void drawLane2LaneConnections() const
Definition: GUILane.cpp:422
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:319
const std::vector< SUMOReal > & getShapeRotations() const
Definition: GUILane.cpp:813
SUMOReal getColorValue(int activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:908
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:571
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:82
long long int SUMOTime
Definition: SUMOTime.h:43
SUMOReal getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:850
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:863
void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:188
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:271
~GUILane()
Destructor.
Definition: GUILane.cpp:106
bool isClosed() const
Definition: GUILane.h:252
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1105
Stores the information about how to visualize structures.
int SVCPermissions
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition: GUILane.cpp:1121
const std::string & getParentName() const
Returns the name of the parent object (if any)
Definition: GUILane.h:98
void drawTextAtEnd(const std::string &text, const PositionVector &shape, SUMOReal x, const GUIVisualizationTextSettings &settings) const
Definition: GUILane.cpp:258
bool setFunctionalColor(int activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GUILane.cpp:872
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:441
Notification
Definition of a vehicle state.
void drawMarkings(const GUIVisualizationSettings &s, SUMOReal scale) const
draw lane borders and white markings
Definition: GUILane.cpp:617
SUMOReal getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1011
const std::vector< SUMOReal > & getShapeLengths() const
Definition: GUILane.cpp:819
void drawArrows() const
Definition: GUILane.cpp:355
void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const
draw crossties for railroads or pedestrian crossings
Definition: GUILane.cpp:680
bool integrateNewVehicle(SUMOTime t)
Definition: GUILane.cpp:167
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GUILane.cpp:886
The simulated network and simulation perfomer.
Definition: MSNet.h:93
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:655
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:70
std::vector< SUMOReal > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:313
const std::string & getID() const
Returns the id.
Definition: Named.h:66
A road/street connecting two junctions.
Definition: MSEdge.h:80
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUILane.cpp:765
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:196
bool executeMovements(SUMOTime t, std::vector< MSLane * > &into)
Definition: GUILane.cpp:146
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:339
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:790
A list of positions.
void planMovements(const SUMOTime t)
Definition: GUILane.cpp:139
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterway
Definition: GUILane.cpp:1088
std::vector< SUMOReal > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:316
SUMOReal setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:181
SUMOReal firstWaitingTime() const
Definition: GUILane.cpp:825
void drawDirectionIndicators() const
direction indicators for lanes
Definition: GUILane.cpp:704
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify)
Definition: GUILane.cpp:153
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:91
SUMOReal getEdgeLaneNumber() const
Definition: GUILane.cpp:831
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, MSLink *link, const PositionVector &shape, SUMOReal x1, SUMOReal x2) const
Definition: GUILane.cpp:299
void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:160
The vehicle has departed (was inserted into the network)
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:224
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:89
GUILane(const std::string &id, SUMOReal maxSpeed, SUMOReal length, MSEdge *const edge, int numericalID, const PositionVector &shape, SUMOReal width, SVCPermissions permissions, int index)
Constructor.
Definition: GUILane.cpp:78
SUMOReal getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:837
void detectCollisions(SUMOTime timestep, const std::string &stage)
Definition: GUILane.cpp:174
The popup menu of a globject.
SUMOReal myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:325
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1082
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:335
SUMOReal myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:328
const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:126
#define SUMOReal
Definition: config.h:214
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUILane.cpp:730
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
A window containing a gl-object's parameter.
void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:133
const PositionVector & getShape() const
Definition: GUILane.cpp:807