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.sourceforge.net/
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 GUILaneWrapper;
54 class MSDevice_Vehroutes;
55 #ifdef HAVE_OSG
56 class GUIOSGView;
57 namespace osg {
58 class ShapeDrawable;
59 }
60 #endif
61 
62 
63 // ===========================================================================
64 // class definitions
65 // ===========================================================================
75 class GUIVehicle : public MSVehicle, public GUIGlObject {
76 public:
85  GUIVehicle(SUMOVehicleParameter* pars, const MSRoute* route,
86  const MSVehicleType* type, SUMOReal speedFactor, int vehicleIndex);
87 
88 
90  ~GUIVehicle();
91 
92 
94 
95 
104 
105 
114 
115 
122 
123 
128  void drawGL(const GUIVisualizationSettings& s) const;
129 
130 
131 
136  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
138 
139 
140 
143 
149  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
150 
151 
157  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
158 
159 
165  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
167 
168 
169 
176  }
177 
178 
186  const std::vector<LaneQ>& getBestLanes() const;
187 
188 
196  FXDECLARE(GUIVehiclePopupMenu)
197  public:
205  GUISUMOAbstractView& parent, GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations);
206 
209 
211  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
213  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
215  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
217  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
219  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
221  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
223  long onCmdStartTrack(FXObject*, FXSelector, void*);
225  long onCmdStopTrack(FXObject*, FXSelector, void*);
227  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
229  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
230 
231  protected:
233  std::map<GUISUMOAbstractView*, int>& myVehiclesAdditionalVisualizations;
235  std::map<GUISUMOAbstractView*, int> dummy;
236 
237  protected:
240 
241  };
242 
243 
246 
260  };
261 
263  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
264 
265 
269  void draw(const MSRoute& r) const;
270 
271 
277  void drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const;
278 
279 
282  void drawBestLanes() const;
284 
285 #ifdef HAVE_OSG
286  void setGeometry(GUIOSGView* view, osg::ShapeDrawable* geom) {
287  myGeom[view] = geom;
288  }
289 
290  void updateColor(GUIOSGView* view);
291 #endif
292 
293 
294 private:
296  void setColor(const GUIVisualizationSettings& s) const;
297 
299  SUMOReal getColorValue(size_t activeScheme) const;
300 
302  bool setFunctionalColor(size_t activeScheme) const;
303 
306 
309  static void drawPoly(double* poses, SUMOReal offset);
310 
311  void drawAction_drawVehicleAsBoxPlus() const;
314 
315  /* @brief try to draw vehicle as raster image and return true if sucessful
316  * @param[in] length The custom length of the vehicle
317  * (defaults to the * length specified in the vehicle type if -1 is passed)
318  */
319  bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings& s, SUMOReal length = -1) const;
320 
321  /* @brief draw train with individual carriages. The number of carriages is
322  * determined from defaultLength of carriages and vehicle length
323  * passengerSeats are computed beginning at firstPassengerCarriage */
324  void drawAction_drawRailCarriages(const GUIVisualizationSettings& s, SUMOReal defaultLength, int firstPassengerCarriage = 0, bool asImage = false) const;
326 
327  /* @brief return the previous lane in this vehicles route including internal lanes
328  * @param[in] current The lane of which the predecessor should be returned
329  * @param[in,out] routeIndex The index of the current or previous non-internal edge in the route
330  */
331  MSLane* getPreviousLane(MSLane* current, int& routeIndex) const;
332 
334  const Position& getSeatPosition(size_t personIndex) const;
335 
337  int getNumPassengers() const;
338 
340  void computeSeats(const Position& front, const Position& back, int& requiredSeats) const;
341 
342  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate);
343 
344 
345 private:
347  mutable MFXMutex myLock;
348 
350 
353 
354 #ifdef HAVE_OSG
355  std::map<GUIOSGView*, osg::ShapeDrawable*> myGeom;
356 #endif
357 
358 };
359 
360 
361 #endif
362 
363 /****************************************************************************/
364