SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIVehicle.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // A MSVehicle extended by some values for usage within the gui
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef GUIVehicle_h
24 #define GUIVehicle_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <vector>
37 #include <set>
38 #include <string>
40 #include <utils/common/RGBColor.h>
42 #include <microsim/MSVehicle.h>
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
53 class MSDevice_Vehroutes;
54 #ifdef HAVE_OSG
55 class GUIOSGView;
56 namespace osg {
57 class ShapeDrawable;
58 }
59 #endif
60 
61 
62 // ===========================================================================
63 // class definitions
64 // ===========================================================================
74 class GUIVehicle : public MSVehicle, public GUIGlObject {
75 public:
84  GUIVehicle(SUMOVehicleParameter* pars, const MSRoute* route,
85  const MSVehicleType* type, SUMOReal speedFactor, int vehicleIndex);
86 
87 
89  ~GUIVehicle();
90 
91 
93 
94 
103 
104 
113 
114 
121 
122 
127  void drawGL(const GUIVisualizationSettings& s) const;
128 
129 
130 
135  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
137 
138 
139 
142 
148  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
149 
150 
156  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
157 
158 
164  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
166 
167 
168 
174 
175 
183  const std::vector<LaneQ>& getBestLanes() const;
184 
185 
193  FXDECLARE(GUIVehiclePopupMenu)
194  public:
202  GUISUMOAbstractView& parent, GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations);
203 
206 
208  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
210  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
212  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
214  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
216  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
218  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
220  long onCmdStartTrack(FXObject*, FXSelector, void*);
222  long onCmdStopTrack(FXObject*, FXSelector, void*);
224  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
226  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
228  long onCmdShowFoes(FXObject*, FXSelector, void*);
229 
230  protected:
232  std::map<GUISUMOAbstractView*, int>& myVehiclesAdditionalVisualizations;
234  std::map<GUISUMOAbstractView*, int> dummy;
235 
236  protected:
239 
240  };
241 
242 
245 
259  };
260 
262  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
263 
264 
268  void drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const;
269 
270 
276  void drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const;
277 
278 
281  void drawBestLanes() const;
283 
285  void selectBlockingFoes() const;
286 
287 #ifdef HAVE_OSG
288  void setGeometry(GUIOSGView* view, osg::ShapeDrawable* geom) {
289  myGeom[view] = geom;
290  }
291 
292  void updateColor(GUIOSGView* view);
293 #endif
294 
295 
296 private:
298  void setColor(const GUIVisualizationSettings& s) const;
299 
301  SUMOReal getColorValue(size_t activeScheme) const;
302 
304  bool setFunctionalColor(size_t activeScheme) const;
305 
308  static void drawPoly(double* poses, SUMOReal offset);
309 
310  void drawAction_drawVehicleAsBoxPlus() const;
313 
314  /* @brief try to draw vehicle as raster image and return true if sucessful
315  * @param[in] length The custom length of the vehicle
316  * (defaults to the * length specified in the vehicle type if -1 is passed)
317  */
318  bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings& s, SUMOReal length = -1) const;
319 
320  /* @brief draw train with individual carriages. The number of carriages is
321  * determined from defaultLength of carriages and vehicle length
322  * passengerSeats are computed beginning at firstPassengerCarriage */
323  void drawAction_drawRailCarriages(const GUIVisualizationSettings& s, SUMOReal defaultLength, int firstPassengerCarriage = 0, bool asImage = false) const;
325 
326  /* @brief return the previous lane in this vehicles route including internal lanes
327  * @param[in] current The lane of which the predecessor should be returned
328  * @param[in,out] routeIndex The index of the current or previous non-internal edge in the route
329  */
330  MSLane* getPreviousLane(MSLane* current, int& routeIndex) const;
331 
333  const Position& getSeatPosition(size_t personIndex) const;
334 
336  int getNumPassengers() const;
337 
339  void computeSeats(const Position& front, const Position& back, int& requiredSeats) const;
340 
342  std::string getStopInfo() const;
343 
344  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate);
345 
346 private:
348  mutable MFXMutex myLock;
349 
351 
354 
355 #ifdef HAVE_OSG
356  std::map<GUIOSGView*, osg::ShapeDrawable*> myGeom;
357 #endif
358 
359 };
360 
361 
362 #endif
363 
364 /****************************************************************************/
365