SUMO - Simulation of Urban MObility
GUIBaseVehicle.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.dlr.de/
13 // Copyright (C) 2001-2015 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 GUIBaseVehicle_h
24 #define GUIBaseVehicle_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 GUIBaseVehicle : public GUIGlObject {
69 public:
70 
71  GUIBaseVehicle(MSBaseVehicle& vehicle);
72 
75 
76 
84  virtual Position getPosition(const SUMOReal offset = 0) const = 0;
85 
89  virtual SUMOReal getAngle() const = 0;
90 
92  virtual SUMOReal getColorValue(size_t activeScheme) const = 0;
93 
95  virtual bool drawAction_drawCarriageClass(const GUIVisualizationSettings& s, SUMOVehicleShape guiShape, bool asImage) const = 0;
96 
101  virtual SUMOReal getLastLaneChangeOffset() const = 0;
102 
106  virtual void drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const = 0;
107 
109  virtual std::string getStopInfo() const = 0;
110 
112  virtual void selectBlockingFoes() const = 0;
113 
122 
123  virtual void drawAction_drawVehicleBlinker(SUMOReal /*length*/) const {}
124  virtual void drawAction_drawVehicleBrakeLight(SUMOReal /*length*/) const {}
125  virtual void drawAction_drawLinkItems(const GUIVisualizationSettings& /*s*/) const {}
128  virtual void drawBestLanes() const {};
129  virtual void drawAction_drawVehicleBlueLight() const {}
130 
131 
132 
133 
134 
136 
137 
146 
147 
154 
155 
160  void drawGL(const GUIVisualizationSettings& s) const;
161 
162 
163 
168  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
170 
171 
172 
175 
181  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
182 
183 
189  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
190 
191 
197  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
199 
200 
201 
209  FXDECLARE(GUIBaseVehiclePopupMenu)
210  public:
218  GUISUMOAbstractView& parent, GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations);
219 
222 
224  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
226  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
228  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
230  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
232  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
234  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
236  long onCmdStartTrack(FXObject*, FXSelector, void*);
238  long onCmdStopTrack(FXObject*, FXSelector, void*);
240  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
242  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
244  long onCmdShowFoes(FXObject*, FXSelector, void*);
245 
246  protected:
248  std::map<GUISUMOAbstractView*, int>& myVehiclesAdditionalVisualizations;
250  std::map<GUISUMOAbstractView*, int> dummy;
251 
252  protected:
254  GUIBaseVehiclePopupMenu() : myVehiclesAdditionalVisualizations(dummy) { }
255 
256  };
257 
258 
261 
275  };
276 
278  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
279 
280 
286  void drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const;
287 
288 
290 
292  static bool setFunctionalColor(size_t activeScheme, const MSBaseVehicle* veh);
293 
294 protected:
296  void setColor(const GUIVisualizationSettings& s) const;
297 
300  static void drawPoly(double* poses, SUMOReal offset);
301 
302  void drawAction_drawVehicleAsBoxPlus() const;
305 
306  /* @brief try to draw vehicle as raster image and return true if sucessful
307  * @param[in] length The custom length of the vehicle
308  * (defaults to the * length specified in the vehicle type if -1 is passed)
309  */
310  bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings& s, SUMOReal length = -1) const;
312 
314  const Position& getSeatPosition(size_t personIndex) const;
315 
316  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate);
317 
318 protected:
320  mutable MFXMutex myLock;
321 
324 
327 
328 private:
331 
334 
336 
337 };
338 
339 
340 #endif
341 
342 /****************************************************************************/
343 
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
void drawAction_drawVehicleAsBoxPlus() const
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
long onCmdStopTrack(FXObject *, FXSelector, void *)
Called if the current shall not be tracked any longer.
long onCmdHideCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
long long int SUMOTime
Definition: SUMOTime.h:43
virtual void drawAction_drawLinkItems(const GUIVisualizationSettings &) const
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
long onCmdStartTrack(FXObject *, FXSelector, void *)
Called if the vehicle shall be tracked.
Stores the information about how to visualize structures.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
show vehicle&#39;s best lanes
std::map< GUISUMOAbstractView *, int > & myVehiclesAdditionalVisualizations
Information which additional visualisations are enabled (per view)
MSDevice_Vehroutes * myRoutes
virtual Position getPosition(const SUMOReal offset=0) const =0
Return current position (x/y, cartesian)
virtual SUMOReal getAngle() const =0
Returns the vehicle&#39;s direction in radians.
std::map< GUISUMOAbstractView *, int > dummy
Needed for parameterless instantiation.
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:52
void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
virtual void selectBlockingFoes() const =0
adds the blocking foes to the current selection
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
The car-following model and parameter.
Definition: MSVehicleType.h:74
long onCmdHideAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
static void drawPoly(double *poses, SUMOReal offset)
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, SUMOReal length=-1) const
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle&#39;s best lanes shall be shown.
long onCmdShowAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
virtual void drawBestLanes() const
Draws the vehicle&#39;s best lanes.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
long onCmdHideBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle&#39;s best lanes shall be hidden.
A MSVehicle extended by some values for usage within the gui.
SUMOReal myCarriageLength
Variable to set with the length of the last drawn carriage or the vehicle length. ...
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void drawRoute(const GUIVisualizationSettings &s, int routeNo, SUMOReal darken) const
Chooses the route to draw and draws it, darkening it as given.
VisualisationFeatures
Additional visualisation feature ids.
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
virtual SUMOReal getColorValue(size_t activeScheme) const =0
gets the color value according to the current scheme index
GUIBaseVehicle(MSBaseVehicle &vehicle)
virtual void drawAction_drawVehicleBlinker(SUMOReal) const
GUIBaseVehiclePopupMenu()
default constructor needed by FOX
bool hasActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) const
Returns whether the named feature is enabled in the given view.
~GUIBaseVehicle()
destructor
virtual SUMOReal getLastLaneChangeOffset() const =0
Returns the time since the last lane change in seconds.
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &) const
static bool setFunctionalColor(size_t activeScheme, const MSBaseVehicle *veh)
sets the color according to the current scheme index and some vehicle function
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate)
long onCmdShowCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own parameter window.
virtual bool drawAction_drawCarriageClass(const GUIVisualizationSettings &s, SUMOVehicleShape guiShape, bool asImage) const =0
draws the given guiShape if it has distinc carriages/modules and eturns true if so ...
virtual void drawRouteHelper(const MSRoute &r, SUMOReal exaggeration) const =0
Draws the route.
The popup menu of a globject.
show all vehicle&#39;s routes
long onCmdShowFoes(FXObject *, FXSelector, void *)
Called when show a vehicles foes.
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
virtual void drawAction_drawVehicleBrakeLight(SUMOReal) const
virtual std::string getStopInfo() const =0
retrieve information about the current stop state
const Position & getSeatPosition(size_t personIndex) const
returns the seat position for the person with the given index
#define SUMOReal
Definition: config.h:214
MSBaseVehicle & myVehicle
The vehicle to which all calls should be delegated.
virtual void drawAction_drawVehicleBlueLight() const
const MSVehicleType & myVType
A shortcut to myVehicle.myType.
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
A window containing a gl-object&#39;s parameter.
show vehicle&#39;s current route
void drawAction_drawVehicleAsTrianglePlus() const
long onCmdShowLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.