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-2016 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 
130 
131  virtual void drawAction_drawVehicleBlinker(SUMOReal /*length*/) const {}
132  virtual void drawAction_drawVehicleBrakeLight(SUMOReal /*length*/) const {}
133  virtual void drawAction_drawLinkItems(const GUIVisualizationSettings& /*s*/) const {}
136  virtual void drawBestLanes() const {};
137  virtual void drawAction_drawVehicleBlueLight() const {}
138 
139 
140 
141 
142 
144 
145 
154 
155 
162 
163 
168  void drawGL(const GUIVisualizationSettings& s) const;
169 
170 
171 
176  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
178 
179 
180 
183 
189  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
190 
191 
197  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
198 
199 
205  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
207 
208 
209 
217  FXDECLARE(GUIBaseVehiclePopupMenu)
218  public:
226  GUISUMOAbstractView& parent, GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations);
227 
230 
232  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
234  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
236  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
238  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
240  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
242  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
244  long onCmdStartTrack(FXObject*, FXSelector, void*);
246  long onCmdStopTrack(FXObject*, FXSelector, void*);
248  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
250  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
252  long onCmdShowFoes(FXObject*, FXSelector, void*);
253 
254  protected:
256  std::map<GUISUMOAbstractView*, int>& myVehiclesAdditionalVisualizations;
258  std::map<GUISUMOAbstractView*, int> dummy;
259 
260  protected:
262  GUIBaseVehiclePopupMenu() : myVehiclesAdditionalVisualizations(dummy) { }
263 
264  };
265 
266 
269 
283  };
284 
286  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
287 
288 
294  void drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const;
295 
296 
298 
300  static bool setFunctionalColor(size_t activeScheme, const MSBaseVehicle* veh);
301 
302 protected:
304  void setColor(const GUIVisualizationSettings& s) 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;
320 
322  const Position& getSeatPosition(size_t personIndex) const;
323 
324  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate);
325 
326 protected:
328  mutable MFXMutex myLock;
329 
332 
335 
336 private:
339 
342 
344 
345 };
346 
347 
348 #endif
349 
350 /****************************************************************************/
351 
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.
virtual GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own type parameter window.
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:213
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.