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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Representation of a lane in the micro simulation (gui-version)
18 /****************************************************************************/
19 #ifndef GUILane_h
20 #define GUILane_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <fx.h>
29 #include <string>
30 #include <utility>
31 #include <microsim/MSLane.h>
32 #include <microsim/MSEdge.h>
34 #include <utils/geom/Position.h>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class GUINet;
44 class MSVehicle;
45 class MSNet;
46 #ifdef HAVE_OSG
47 namespace osg {
48 class Geometry;
49 }
50 #endif
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
63 class GUILane : public MSLane, public GUIGlObject {
64 public:
78  GUILane(const std::string& id, double maxSpeed,
79  double length, MSEdge* const edge, int numericalID,
80  const PositionVector& shape, double width,
81  SVCPermissions permissions, int index, bool isRampAccel);
82 
83 
85  ~GUILane();
86 
91  std::string getParentName() const {
92  return getEdge().getID();
93  }
94 
95 
98 
108  const VehCont& getVehiclesSecure() const;
109 
110 
116  void releaseVehicles() const;
118 
119 
120 
123 
126  void planMovements(const SUMOTime t);
127 
130  bool executeMovements(SUMOTime t, std::vector<MSLane*>& into);
131 
134  bool integrateNewVehicle(SUMOTime t);
136 
137 
140  void detectCollisions(SUMOTime timestep, const std::string& stage);
141 
142 
145  MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify);
146 
148  void removeParking(MSVehicle* veh);
149 
157  double setPartialOccupation(MSVehicle* v);
158 
162  void resetPartialOccupation(MSVehicle* v);
163 
164 
166 
167 
175  GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app,
176  GUISUMOAbstractView& parent);
177 
178 
186  GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app,
187  GUISUMOAbstractView& parent);
188 
189 
195  Boundary getCenteringBoundary() const;
196 
197 
202  void drawGL(const GUIVisualizationSettings& s) const;
204 
205 
206 
207  const PositionVector& getShape() const;
208  const std::vector<double>& getShapeRotations() const;
209  const std::vector<double>& getShapeLengths() const;
210 
211  double firstWaitingTime() const;
212 
214  void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
215 
217  void drawBikeMarkings() const;
218 
220  void drawDirectionIndicators(double exaggeration) const;
221 
223  void debugDrawFoeIntersections() const;
224 
225  double getEdgeLaneNumber() const;
226 
229  double getStoredEdgeTravelTime() const;
230 
233  double getLoadedEdgeWeight() const;
234 
235 #ifdef HAVE_OSG
236  void setGeometry(osg::Geometry* geom) {
237  myGeom = geom;
238  }
239 
240  void updateColor(const GUIVisualizationSettings& s);
241 
242 #endif
243 
245  void closeTraffic(bool rebuildAllowed = true);
246 
247  bool isClosed() const {
248  return myAmClosed;
249  }
250 
252  double getColorValue(int activeScheme) const;
253 
255  bool isSelected() const;
256 
257 protected:
259  void swapAfterLaneChange(SUMOTime t);
260 
273  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
274  const MSLane::VehCont::iterator& at,
276 
277 private:
279  void drawLinkNo(const GUIVisualizationSettings& s) const;
280  void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) 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, double x1, double x2) const;
283  void drawArrows() const;
284  void drawLane2LaneConnections(double exaggeration) const;
285 
286 
288  PositionVector splitAtSegments(const PositionVector& shape);
289 
291  double getPendingEmits() const;
292 
293 private:
294 
296  double getScaleValue(int activeScheme) const;
297 
299  bool setFunctionalColor(int activeScheme, RGBColor& col) const;
300 
302  bool setMultiColor(const GUIColorer& c, RGBColor& col) const;
303 
305  RGBColor setColor(const GUIVisualizationSettings& s) const;
306 
308  bool drawAsRailway(const GUIVisualizationSettings& s) const;
309 
311  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
312 
314  bool isLaneOrEdgeSelected() const;
315 
317  std::vector<double> myShapeRotations;
318 
320  std::vector<double> myShapeLengths;
321 
323  mutable std::vector<RGBColor> myShapeColors;
324 
326  std::vector<int> myShapeSegments;
327 
330 
333 
334 #ifdef HAVE_OSG
335  osg::Geometry* myGeom;
336 #endif
337 
340 
341 private:
343  mutable MFXMutex myLock;
344 
347 
348 
349 };
350 
351 
352 #endif
353 
354 /****************************************************************************/
355 
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:326
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:323
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79
long long int SUMOTime
Definition: SUMOTime.h:36
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:346
Stores the information about how to visualize structures.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
bool isClosed() const
Definition: GUILane.h:247
Notification
Definition of a vehicle state.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:320
The simulated network and simulation perfomer.
Definition: MSNet.h:85
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:63
A road/street connecting two junctions.
Definition: MSEdge.h:75
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GUILane.h:91
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:343
A list of positions.
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:83
The vehicle has departed (was inserted into the network)
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:82
The popup menu of a globject.
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:317
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:339
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:329
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:332
Representation of a lane in the micro simulation.
Definition: MSLane.h:71
A window containing a gl-object&#39;s parameter.