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  void setJunctionApproaches(const SUMOTime t);
131 
134  bool executeMovements(SUMOTime t, std::vector<MSLane*>& into);
135 
138  bool integrateNewVehicle(SUMOTime t);
140 
141 
144  void detectCollisions(SUMOTime timestep, const std::string& stage);
145 
146 
149  MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify);
150 
152  void removeParking(MSVehicle* veh);
153 
161  double setPartialOccupation(MSVehicle* v);
162 
166  void resetPartialOccupation(MSVehicle* v);
167 
168 
170 
171 
179  GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app,
180  GUISUMOAbstractView& parent);
181 
182 
190  GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app,
191  GUISUMOAbstractView& parent);
192 
193 
199  Boundary getCenteringBoundary() const;
200 
201 
206  void drawGL(const GUIVisualizationSettings& s) const;
208 
209 
210 
211  const PositionVector& getShape() const;
212  const std::vector<double>& getShapeRotations() const;
213  const std::vector<double>& getShapeLengths() const;
214 
215  double firstWaitingTime() const;
216 
218  void drawMarkings(const GUIVisualizationSettings& s, double scale) const;
219 
221  void drawBikeMarkings() const;
222 
224  void drawDirectionIndicators(double exaggeration) const;
225 
227  void debugDrawFoeIntersections() const;
228 
229  double getEdgeLaneNumber() const;
230 
233  double getStoredEdgeTravelTime() const;
234 
237  double getLoadedEdgeWeight() const;
238 
239 #ifdef HAVE_OSG
240  void setGeometry(osg::Geometry* geom) {
241  myGeom = geom;
242  }
243 
244  void updateColor(const GUIVisualizationSettings& s);
245 
246 #endif
247 
249  void closeTraffic(bool rebuildAllowed = true);
250 
251  bool isClosed() const {
252  return myAmClosed;
253  }
254 
256  double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
257 
259  bool isSelected() const;
260 
261  /* @brief sets the color according to the current scheme index and some lane function
262  * @param[in] id override active scheme when calling from meso gui
263  */
264  bool setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme=-1) const;
265 
266 protected:
268  void swapAfterLaneChange(SUMOTime t);
269 
282  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
283  const MSLane::VehCont::iterator& at,
285 
286 private:
288  void drawLinkNo(const GUIVisualizationSettings& s) const;
289  void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const;
290  void drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const;
291  void drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, MSLink* link, const PositionVector& shape, double x1, double x2) const;
292  void drawArrows() const;
293  void drawLane2LaneConnections(double exaggeration) const;
294 
295 
297  PositionVector splitAtSegments(const PositionVector& shape);
298 
300  double getPendingEmits() const;
301 
302 private:
303 
305  double getScaleValue(int activeScheme) const;
306 
308  bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
309 
311  RGBColor setColor(const GUIVisualizationSettings& s) const;
312 
314  bool drawAsRailway(const GUIVisualizationSettings& s) const;
315 
317  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
318 
320  bool isLaneOrEdgeSelected() const;
321 
323  std::vector<double> myShapeRotations;
324 
326  std::vector<double> myShapeLengths;
327 
329  mutable std::vector<RGBColor> myShapeColors;
330 
332  std::vector<int> myShapeSegments;
333 
336 
339 
340 #ifdef HAVE_OSG
341  osg::Geometry* myGeom;
342 #endif
343 
346 
347 private:
349  mutable MFXMutex myLock;
350 
353 
354 
355 };
356 
357 
358 #endif
359 
360 /****************************************************************************/
361 
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:332
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:329
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:352
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:251
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:326
The simulated network and simulation perfomer.
Definition: MSNet.h:84
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:349
A list of positions.
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:90
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:323
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:345
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:335
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:338
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
A window containing a gl-object&#39;s parameter.