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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // A MSVehicle extended by some values for usage within the gui
19 /****************************************************************************/
20 #ifndef GUIBaseVehicle_h
21 #define GUIBaseVehicle_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <vector>
30 #include <set>
31 #include <string>
32 #include <utils/common/RGBColor.h>
34 #include <utils/geom/GeomHelper.h>
39 #include <microsim/MSVehicle.h>
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
47 class MSDevice_Vehroutes;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
62 class GUIBaseVehicle : public GUIGlObject {
63 public:
64 
65  GUIBaseVehicle(MSBaseVehicle& vehicle);
66 
69 
70 
78  virtual Position getPosition(const double offset = 0) const = 0;
79 
83  virtual double getAngle() const = 0;
84 
86  double getNaviDegree() const {
88  }
89 
91  virtual double getColorValue(int activeScheme) const = 0;
92 
94  virtual bool drawAction_drawCarriageClass(const GUIVisualizationSettings& s, SUMOVehicleShape guiShape, bool asImage) const = 0;
95 
100  virtual double getLastLaneChangeOffset() const = 0;
101 
105  virtual void drawRouteHelper(const GUIVisualizationSettings& s, const MSRoute& r) const = 0;
106 
108  virtual std::string getStopInfo() const = 0;
109 
111  virtual void selectBlockingFoes() const = 0;
112 
121 
129 
130  virtual void drawAction_drawVehicleBlinker(double /*length*/) const {}
131  virtual void drawAction_drawVehicleBrakeLight(double length, bool onlyOne = false) const {
132  UNUSED_PARAMETER(length);
133  UNUSED_PARAMETER(onlyOne);
134  }
135  virtual void drawAction_drawLinkItems(const GUIVisualizationSettings& /*s*/) const {}
138  virtual void drawBestLanes() const {};
139  virtual void drawAction_drawVehicleBlueLight() const {}
140 
141 
142 
143 
144 
146 
147 
156 
157 
164 
165 
171  void drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const double angle) const;
172 
173 
178  void drawGL(const GUIVisualizationSettings& s) const;
179 
180 
185  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
187 
188 
189 
192 
198  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
199 
200 
206  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
207 
208 
214  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
216 
217 
218 
226  FXDECLARE(GUIBaseVehiclePopupMenu)
227  public:
235  GUISUMOAbstractView& parent, GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations);
236 
239 
241  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
243  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
245  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
247  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
249  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
251  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
253  long onCmdStartTrack(FXObject*, FXSelector, void*);
255  long onCmdStopTrack(FXObject*, FXSelector, void*);
257  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
259  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
261  long onCmdShowFoes(FXObject*, FXSelector, void*);
262 
263  protected:
265  std::map<GUISUMOAbstractView*, int>& myVehiclesAdditionalVisualizations;
267  std::map<GUISUMOAbstractView*, int> dummy;
268 
269  protected:
271  GUIBaseVehiclePopupMenu() : myVehiclesAdditionalVisualizations(dummy) { }
272 
273  };
274 
275 
278 
292  };
293 
295  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
296 
297 
303  void drawRoute(const GUIVisualizationSettings& s, int routeNo, double darken) const;
304 
305 
307 
309  static bool setFunctionalColor(int activeScheme, const MSBaseVehicle* veh);
310 
311 protected:
313  void setColor(const GUIVisualizationSettings& s) const;
314 
317  static void drawPoly(double* poses, double offset);
318 
319  void drawAction_drawVehicleAsBoxPlus() const;
322 
323  /* @brief try to draw vehicle as raster image and return true if sucessful
324  * @param[in] length The custom length of the vehicle
325  * (defaults to the * length specified in the vehicle type if -1 is passed)
326  */
327  bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings& s, double length = -1) const;
329 
331  const Position& getSeatPosition(int personIndex) const;
332 
333  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate);
334 
336  inline const MSVehicleType& getVType() const {
337  return myVehicle.getVehicleType();
338  }
339 
340 
341 protected:
343  mutable MFXMutex myLock;
344 
347 
348 private:
351 
353 
354 };
355 
356 
357 #endif
358 
359 /****************************************************************************/
360 
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:36
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)
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &s) const
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:52
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:33
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
The car-following model and parameter.
Definition: MSVehicleType.h:66
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:180
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:39
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
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