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>
39 #include <utils/common/RGBColor.h>
41 #include <utils/geom/GeomHelper.h>
46 #include <microsim/MSVehicle.h>
47 
48 
49 // ===========================================================================
50 // class declarations
51 // ===========================================================================
54 class MSDevice_Vehroutes;
55 
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
69 class GUIBaseVehicle : public GUIGlObject {
70 public:
71 
72  GUIBaseVehicle(MSBaseVehicle& vehicle);
73 
76 
77 
85  virtual Position getPosition(const SUMOReal offset = 0) const = 0;
86 
90  virtual SUMOReal getAngle() const = 0;
91 
95  }
96 
98  virtual SUMOReal getColorValue(int activeScheme) const = 0;
99 
101  virtual bool drawAction_drawCarriageClass(const GUIVisualizationSettings& s, SUMOVehicleShape guiShape, bool asImage) const = 0;
102 
107  virtual SUMOReal getLastLaneChangeOffset() const = 0;
108 
112  virtual void drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const = 0;
113 
115  virtual std::string getStopInfo() const = 0;
116 
118  virtual void selectBlockingFoes() const = 0;
119 
128 
136 
137  virtual void drawAction_drawVehicleBlinker(SUMOReal /*length*/) const {}
138  virtual void drawAction_drawVehicleBrakeLight(SUMOReal length, bool onlyOne = false) const {
139  UNUSED_PARAMETER(length);
140  UNUSED_PARAMETER(onlyOne);
141  }
142  virtual void drawAction_drawLinkItems(const GUIVisualizationSettings& /*s*/) const {}
145  virtual void drawBestLanes() const {};
146  virtual void drawAction_drawVehicleBlueLight() const {}
147 
148 
149 
150 
151 
153 
154 
163 
164 
171 
172 
178  void drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const SUMOReal angle) const;
179 
180 
185  void drawGL(const GUIVisualizationSettings& s) const;
186 
187 
192  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
194 
195 
196 
199 
205  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
206 
207 
213  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
214 
215 
221  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
223 
224 
225 
233  FXDECLARE(GUIBaseVehiclePopupMenu)
234  public:
242  GUISUMOAbstractView& parent, GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations);
243 
246 
248  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
250  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
252  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
254  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
256  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
258  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
260  long onCmdStartTrack(FXObject*, FXSelector, void*);
262  long onCmdStopTrack(FXObject*, FXSelector, void*);
264  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
266  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
268  long onCmdShowFoes(FXObject*, FXSelector, void*);
269 
270  protected:
272  std::map<GUISUMOAbstractView*, int>& myVehiclesAdditionalVisualizations;
274  std::map<GUISUMOAbstractView*, int> dummy;
275 
276  protected:
278  GUIBaseVehiclePopupMenu() : myVehiclesAdditionalVisualizations(dummy) { }
279 
280  };
281 
282 
285 
301  };
302 
304  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
305 
306 
312  void drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const;
313 
314 
316 
318  static bool setFunctionalColor(int activeScheme, const MSBaseVehicle* veh);
319 
320 protected:
322  void setColor(const GUIVisualizationSettings& s) const;
323 
326  static void drawPoly(double* poses, SUMOReal offset);
327 
328  void drawAction_drawVehicleAsBoxPlus() const;
331 
332  /* @brief try to draw vehicle as raster image and return true if sucessful
333  * @param[in] length The custom length of the vehicle
334  * (defaults to the * length specified in the vehicle type if -1 is passed)
335  */
336  bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings& s, SUMOReal length = -1) const;
338 
340  const Position& getSeatPosition(int personIndex) const;
341 
342  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate);
343 
344 protected:
346  mutable MFXMutex myLock;
347 
350 
353 
354 private:
357 
360 
362 
363 };
364 
365 
366 #endif
367 
368 /****************************************************************************/
369 
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
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_drawVehicleBlueLight() const
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
void drawAction_drawVehicleAsBoxPlus() const
long onCmdStartTrack(FXObject *, FXSelector, void *)
Called if the vehicle shall be tracked.
Stores the information about how to visualize structures.
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
show vehicle&#39;s best lanes
std::map< GUISUMOAbstractView *, int > & myVehiclesAdditionalVisualizations
Information which additional visualisations are enabled (per view)
MSDevice_Vehroutes * myRoutes
virtual void drawAction_drawLinkItems(const GUIVisualizationSettings &) const
virtual void drawAction_drawVehicleBrakeLight(SUMOReal length, bool onlyOne=false) const
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:56
virtual void selectBlockingFoes() const =0
adds the blocking foes to the current selection
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
The car-following model and parameter.
Definition: MSVehicleType.h:74
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
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)
void drawRoute(const GUIVisualizationSettings &s, int routeNo, SUMOReal darken) const
Chooses the route to draw and draws it, darkening it as given.
static void drawPoly(double *poses, SUMOReal offset)
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &) const
virtual void drawAction_drawVehicleBlinker(SUMOReal) 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.
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.
void drawAction_drawVehicleAsTrianglePlus() const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
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 getNaviDegree() const
return the current angle in navigational degrees
SUMOReal myCarriageLength
Variable to set with the length of the last drawn carriage or the vehicle length. ...
VisualisationFeatures
Additional visualisation feature ids.
static SUMOReal naviDegree(const SUMOReal angle)
Definition: GeomHelper.cpp:191
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
GUIBaseVehicle(MSBaseVehicle &vehicle)
GUIBaseVehiclePopupMenu()
default constructor needed by FOX
~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.
draw vehicle outside the road network
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, SUMOReal length=-1) const
const Position & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
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
void drawOnPos(const GUIVisualizationSettings &s, const Position &pos, const SUMOReal angle) const
Draws the object on the specified position with the specified angle.
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 std::string getStopInfo() const =0
retrieve information about the current stop state
#define SUMOReal
Definition: config.h:213
virtual void drawBestLanes() const
Draws the vehicle&#39;s best lanes.
MSBaseVehicle & myVehicle
The vehicle to which all calls should be delegated.
virtual SUMOReal getColorValue(int activeScheme) const =0
gets the color value according to the current scheme index
static bool setFunctionalColor(int activeScheme, const MSBaseVehicle *veh)
sets the color according to the current scheme index and some vehicle function
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
long onCmdShowLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
bool hasActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) const
Returns whether the named feature is enabled in the given view.