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-2019 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>
33 #include <utils/geom/Position.h>
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class GUINet;
43 class MSVehicle;
44 class MSNet;
45 #ifdef HAVE_OSG
46 namespace osg {
47 class Geometry;
48 }
49 #endif
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
62 class GUILane : public MSLane, public GUIGlObject {
63 public:
77  GUILane(const std::string& id, double maxSpeed,
78  double length, MSEdge* const edge, int numericalID,
79  const PositionVector& shape, double width,
80  SVCPermissions permissions, int index, bool isRampAccel,
81  const std::string& type);
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) const;
131 
134  void executeMovements(const SUMOTime t);
135 
138  void integrateNewVehicles();
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, bool spreadSuperposed) 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 
267  bool drawAsRailway(const GUIVisualizationSettings& s) const;
268 
269 
270 protected:
272  void swapAfterLaneChange(SUMOTime t);
273 
286  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
287  const MSLane::VehCont::iterator& at,
289 
290 private:
292  void drawLinkNo(const GUIVisualizationSettings& s) const;
293  void drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const;
294  void drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const;
295  void drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, MSLink* link, const PositionVector& shape, double x1, double x2) const;
296  void drawArrows() const;
297  void drawLane2LaneConnections(double exaggeration) const;
298 
299 
301  PositionVector splitAtSegments(const PositionVector& shape);
302 
304  double getPendingEmits() const;
305 
306 private:
307 
309  double getScaleValue(int activeScheme) const;
310 
312  bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;
313 
315  RGBColor setColor(const GUIVisualizationSettings& s) const;
316 
318  bool drawAsWaterway(const GUIVisualizationSettings& s) const;
319 
321  bool isLaneOrEdgeSelected() const;
322 
324  std::vector<double> myShapeRotations;
325 
327  std::vector<double> myShapeLengths;
328 
330  mutable std::vector<RGBColor> myShapeColors;
331 
333  std::vector<int> myShapeSegments;
334 
337 
340 
341 #ifdef HAVE_OSG
342  osg::Geometry* myGeom;
343 #endif
344 
347 
348 private:
350  mutable FXMutex myLock;
351 
354 
355 
356 };
357 
358 
359 #endif
360 
361 /****************************************************************************/
362 
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:333
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:330
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
long long int SUMOTime
Definition: SUMOTime.h:35
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:353
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:327
The simulated network and simulation perfomer.
Definition: MSNet.h:92
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:62
A road/street connecting two junctions.
Definition: MSEdge.h:76
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GUILane.h:91
A list of positions.
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:93
The vehicle has departed (was inserted into the network)
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:83
The popup menu of a globject.
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:324
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:346
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:350
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:336
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:339
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
A window containing a gl-object&#39;s parameter.