SUMO - Simulation of Urban MObility
GUIBaseVehicle.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // A MSVehicle extended by some values for usage within the gui
21 /****************************************************************************/
22 #ifndef GUIBaseVehicle_h
23 #define GUIBaseVehicle_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <vector>
36 #include <set>
37 #include <string>
38 #include <utils/common/RGBColor.h>
40 #include <utils/geom/GeomHelper.h>
45 #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 double offset = 0) const = 0;
85 
89  virtual double getAngle() const = 0;
90 
92  double getNaviDegree() const {
94  }
95 
97  virtual double getColorValue(int activeScheme) const = 0;
98 
100  virtual bool drawAction_drawCarriageClass(const GUIVisualizationSettings& s, SUMOVehicleShape guiShape, bool asImage) const = 0;
101 
106  virtual double getLastLaneChangeOffset() const = 0;
107 
111  virtual void drawRouteHelper(const GUIVisualizationSettings& s, const MSRoute& r) const = 0;
112 
114  virtual std::string getStopInfo() const = 0;
115 
117  virtual void selectBlockingFoes() const = 0;
118 
127 
135 
136  virtual void drawAction_drawVehicleBlinker(double /*length*/) const {}
137  virtual void drawAction_drawVehicleBrakeLight(double length, bool onlyOne = false) const {
138  UNUSED_PARAMETER(length);
139  UNUSED_PARAMETER(onlyOne);
140  }
141  virtual void drawAction_drawLinkItems(const GUIVisualizationSettings& /*s*/) const {}
144  virtual void drawBestLanes() const {};
145  virtual void drawAction_drawVehicleBlueLight() const {}
146 
147 
148 
149 
150 
152 
153 
162 
163 
170 
171 
177  void drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const double angle) const;
178 
179 
184  void drawGL(const GUIVisualizationSettings& s) const;
185 
186 
191  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
193 
194 
195 
198 
204  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
205 
206 
212  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
213 
214 
220  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
222 
223 
224 
232  FXDECLARE(GUIBaseVehiclePopupMenu)
233  public:
241  GUISUMOAbstractView& parent, GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations);
242 
245 
247  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
249  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
251  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
253  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
255  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
257  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
259  long onCmdStartTrack(FXObject*, FXSelector, void*);
261  long onCmdStopTrack(FXObject*, FXSelector, void*);
263  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
265  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
267  long onCmdShowFoes(FXObject*, FXSelector, void*);
268 
269  protected:
271  std::map<GUISUMOAbstractView*, int>& myVehiclesAdditionalVisualizations;
273  std::map<GUISUMOAbstractView*, int> dummy;
274 
275  protected:
277  GUIBaseVehiclePopupMenu() : myVehiclesAdditionalVisualizations(dummy) { }
278 
279  };
280 
281 
284 
298  };
299 
301  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
302 
303 
309  void drawRoute(const GUIVisualizationSettings& s, int routeNo, double darken) const;
310 
311 
313 
315  static bool setFunctionalColor(int activeScheme, const MSBaseVehicle* veh);
316 
317 protected:
319  void setColor(const GUIVisualizationSettings& s) const;
320 
323  static void drawPoly(double* poses, double offset);
324 
325  void drawAction_drawVehicleAsBoxPlus() const;
328 
329  /* @brief try to draw vehicle as raster image and return true if sucessful
330  * @param[in] length The custom length of the vehicle
331  * (defaults to the * length specified in the vehicle type if -1 is passed)
332  */
333  bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings& s, double length = -1) const;
335 
337  const Position& getSeatPosition(int personIndex) const;
338 
339  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate);
340 
342  inline const MSVehicleType& getVType() const {
343  return myVehicle.getVehicleType();
344  }
345 
346 
347 protected:
349  mutable MFXMutex myLock;
350 
353 
354 private:
357 
359 
360 };
361 
362 
363 #endif
364 
365 /****************************************************************************/
366 
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.
virtual void drawAction_drawVehicleBlueLight() const
const MSVehicleType & getVType() const
A shortcut to myVehicle.myType.
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
std::map< GUISUMOAbstractView *, int > dummy
Needed for parameterless instantiation.
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate)
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:55
virtual void drawRouteHelper(const GUIVisualizationSettings &s, const MSRoute &r) const =0
Draws the route.
virtual void selectBlockingFoes() const =0
adds the blocking foes to the current selection
double getNaviDegree() const
return the current angle in navigational degrees
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
The car-following model and parameter.
Definition: MSVehicleType.h:72
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)
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:186
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &) const
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle&#39;s best lanes shall be shown.
bool drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
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:45
void drawOnPos(const GUIVisualizationSettings &s, const Position &pos, const double angle) const
Draws the object on the specified position with the specified angle.
A list of positions.
long onCmdHideBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle&#39;s best lanes shall be hidden.
virtual double getColorValue(int activeScheme) const =0
gets the color value according to the current scheme index
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.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
VisualisationFeatures
Additional visualisation feature ids.
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
void drawRoute(const GUIVisualizationSettings &s, int routeNo, double darken) const
Chooses the route to draw and draws it, darkening it as given.
GUIBaseVehicle(MSBaseVehicle &vehicle)
GUIBaseVehiclePopupMenu()
default constructor needed by FOX
~GUIBaseVehicle()
destructor
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.
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
const Position & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
virtual double getLastLaneChangeOffset() const =0
Returns the time since the last lane change in seconds.
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 ...
The popup menu of a globject.
show all vehicle&#39;s routes
virtual double getAngle() const =0
Returns the vehicle&#39;s direction in radians.
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
long long int SUMOTime
Definition: TraCIDefs.h:51
virtual void drawBestLanes() const
Draws the vehicle&#39;s best lanes.
static void drawPoly(double *poses, double offset)
MSBaseVehicle & myVehicle
The vehicle to which all calls should be delegated.
static bool setFunctionalColor(int activeScheme, const MSBaseVehicle *veh)
sets the color according to the current scheme index and some vehicle function
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
virtual void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
A window containing a gl-object&#39;s parameter.
show vehicle&#39;s current route
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, double length=-1) const
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.
virtual void drawAction_drawVehicleBlinker(double) const