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-2014 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 
55 
56 // ===========================================================================
57 // class definitions
58 // ===========================================================================
68 class GUIVehicle : public MSVehicle, public GUIGlObject {
69 public:
78  GUIVehicle(SUMOVehicleParameter* pars, const MSRoute* route,
79  const MSVehicleType* type, SUMOReal speedFactor);
80 
81 
83  ~GUIVehicle();
84 
85 
87 
88 
97 
98 
107 
108 
115 
116 
121  void drawGL(const GUIVisualizationSettings& s) const;
122 
123 
124 
129  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
131 
132 
133 
136 
142  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
143 
144 
150  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
151 
152 
158  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
160 
161 
162 
168 
169 
177  FXDECLARE(GUIVehiclePopupMenu)
178  public:
186  GUISUMOAbstractView& parent, GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations);
187 
190 
192  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
194  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
196  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
198  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
200  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
202  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
204  long onCmdStartTrack(FXObject*, FXSelector, void*);
206  long onCmdStopTrack(FXObject*, FXSelector, void*);
208  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
210  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
212  long onCmdShowFoes(FXObject*, FXSelector, void*);
213 
214  protected:
216  std::map<GUISUMOAbstractView*, int>& myVehiclesAdditionalVisualizations;
218  std::map<GUISUMOAbstractView*, int> dummy;
219 
220  protected:
223 
224  };
225 
226 
229 
243  };
244 
246  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
247 
248 
252  void drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const;
253 
254 
260  void drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const;
261 
262 
265  void drawBestLanes() const;
267 
269  void selectBlockingFoes() const;
270 
272  SUMOReal getColorValue(size_t activeScheme) const;
273 
274 
275 private:
277  void setColor(const GUIVisualizationSettings& s) const;
278 
280  bool setFunctionalColor(size_t activeScheme) const;
281 
284  static void drawPoly(double* poses, SUMOReal offset);
285 
286  void drawAction_drawVehicleAsBoxPlus() const;
289 
290  /* @brief try to draw vehicle as raster image and return true if sucessful
291  * @param[in] length The custom length of the vehicle
292  * (defaults to the * length specified in the vehicle type if -1 is passed)
293  */
294  bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings& s, SUMOReal length = -1) const;
295 
296  /* @brief draw train with individual carriages. The number of carriages is
297  * determined from defaultLength of carriages and vehicle length
298  * passengerSeats are computed beginning at firstPassengerCarriage */
299  void drawAction_drawRailCarriages(const GUIVisualizationSettings& s, SUMOReal defaultLength, SUMOReal carriageGap,
300  int firstPassengerCarriage, bool asImage) const;
302 
304  bool drawAction_drawCarriageClass(const GUIVisualizationSettings& s, SUMOVehicleShape guiShape, bool asImage) const;
305 
306  /* @brief return the previous lane in this vehicles route including internal lanes
307  * @param[in] current The lane of which the predecessor should be returned
308  * @param[in,out] routeIndex The index of the current or previous non-internal edge in the route
309  */
310  MSLane* getPreviousLane(MSLane* current, int& furtherIndex) const;
311 
313  const Position& getSeatPosition(size_t personIndex) const;
314 
316  int getNumPassengers() const;
317 
319  void computeSeats(const Position& front, const Position& back, int& requiredSeats) const;
320 
322  std::string getStopInfo() const;
323 
324  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate);
325 
326 private:
328  mutable MFXMutex myLock;
329 
332 
334 
337 
338 };
339 
340 
341 #endif
342 
343 /****************************************************************************/
344