Eclipse 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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // A MSVehicle extended by some values for usage within the gui
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <vector>
27 #include <set>
28 #include <string>
30 #include <utils/common/RGBColor.h>
31 #include <utils/geom/GeomHelper.h>
36 #include <microsim/MSVehicle.h>
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
44 class MSDevice_Vehroutes;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
59 class GUIBaseVehicle : public GUIGlObject {
60 public:
61 
62  GUIBaseVehicle(MSBaseVehicle& vehicle);
63 
66 
67  struct Seat {
69 
70  Seat(const Position& _pos, double _angle):
71  pos(_pos), angle(_angle) {}
72 
74  double angle;
75  };
76  typedef std::vector<Seat> Seats;
77 
85  virtual Position getPosition(const double offset = 0) const = 0;
86 
90  virtual double getAngle() const = 0;
91 
93  double getNaviDegree() const {
95  }
96 
98  virtual double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const = 0;
99 
101  virtual void drawAction_drawCarriageClass(const GUIVisualizationSettings& s, bool asImage) const = 0;
102 
107  virtual double getLastLaneChangeOffset() const = 0;
108 
112  virtual void drawRouteHelper(const GUIVisualizationSettings& s, const MSRoute& r, bool future, bool noLoop, const RGBColor& col) 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(double /*length*/) const {}
138  virtual void drawAction_drawVehicleBrakeLight(double 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 
165  void removedPopupMenu();
166 
168  double getExaggeration(const GUIVisualizationSettings& s) const;
169 
175  virtual Boundary getCenteringBoundary() const;
176 
178  const std::string getOptionalName() const;
179 
185  void drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const double angle) const;
186 
187 
192  void drawGL(const GUIVisualizationSettings& s) const;
193 
194 
199  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
201 
202 
203 
206 
212  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
213 
214 
220  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
221 
222 
228  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
230 
232  int getNumPassengers() const;
233 
235  int getNumContainers() const;
236 
238  std::string getDeviceDescription();
239 
247  FXDECLARE(GUIBaseVehiclePopupMenu)
248  public:
255 
258 
260  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
262  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
264  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
266  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
268  long onCmdShowFutureRoute(FXObject*, FXSelector, void*);
270  long onCmdHideFutureRoute(FXObject*, FXSelector, void*);
272  long onCmdShowRouteNoLoops(FXObject*, FXSelector, void*);
274  long onCmdHideRouteNoLoops(FXObject*, FXSelector, void*);
276  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
278  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
280  long onCmdStartTrack(FXObject*, FXSelector, void*);
282  long onCmdStopTrack(FXObject*, FXSelector, void*);
284  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
286  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
288  long onCmdShowFoes(FXObject*, FXSelector, void*);
290  long onCmdSelectTransported(FXObject*, FXSelector, void*);
292  long onCmdRemoveObject(FXObject*, FXSelector, void*);
294  long onCmdToggleStop(FXObject*, FXSelector, void*);
295 
296  protected:
297  FOX_CONSTRUCTOR(GUIBaseVehiclePopupMenu)
298 
299  };
300 
301 
304 
322  };
323 
325  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
326 
327 
333  void drawRoute(const GUIVisualizationSettings& s, int routeNo, double darken, bool future = false, bool noLoop = false) const;
334 
335  void drawStopLabels(const GUIVisualizationSettings& s, bool noLoop, const RGBColor& col) const;
336 
337  void drawParkingInfo(const GUIVisualizationSettings& s, const RGBColor& col) const;
339 
341  return myVehicle;
342  }
343 
345  double getScaleValue(const GUIVisualizationSettings& s, int activeScheme) const;
346 
348  static bool setFunctionalColor(int activeScheme, const MSBaseVehicle* veh, RGBColor& col);
349 
350 protected:
351 
354 
356  const Seat& getSeatPosition(int personIndex) const;
357  const Seat& getContainerPosition(int containerIndex) const;
358 
359  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate);
360 
362  inline const MSVehicleType& getVType() const {
363  return myVehicle.getVehicleType();
364  }
365 
367  bool drawAction_drawVehicleAsPolyWithCarriagges(const GUIVisualizationSettings& s, double scaledLength, bool asImage = false) const;
368 
370  void computeSeats(const Position& front, const Position& back, double seatOffset, int maxSeats, double exaggeration, int& requiredSeats, Seats& into) const;
371 
372 
373 protected:
375  mutable FXMutex myLock;
376 
380 
381 private:
384 
386 
389 
390 };
long long int SUMOTime
Definition: SUMOTime.h:32
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
long onCmdHideFutureRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
long onCmdStartTrack(FXObject *, FXSelector, void *)
Called if the vehicle shall be tracked.
long onCmdHideBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be hidden.
long onCmdHideCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be shown.
long onCmdShowRouteNoLoops(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
long onCmdShowLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
long onCmdShowFoes(FXObject *, FXSelector, void *)
Called to show (select) a vehicles foes.
long onCmdHideRouteNoLoops(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
long onCmdShowFutureRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
long onCmdShowAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
long onCmdToggleStop(FXObject *, FXSelector, void *)
Called when toggling stop state.
long onCmdStopTrack(FXObject *, FXSelector, void *)
Called if the current shall not be tracked any longer.
long onCmdSelectTransported(FXObject *, FXSelector, void *)
Called to select all riding persons and continers.
long onCmdRemoveObject(FXObject *, FXSelector, void *)
Called when removing the vehicle.
long onCmdHideAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
GUIBaseVehiclePopupMenu(GUIMainWindow &app, GUISUMOAbstractView &parent, GUIGlObject &o)
Constructor.
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
long onCmdShowCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
A MSVehicle extended by some values for usage within the gui.
void drawParkingInfo(const GUIVisualizationSettings &s, const RGBColor &col) const
const Seat & getContainerPosition(int containerIndex) const
static bool setFunctionalColor(int activeScheme, const MSBaseVehicle *veh, RGBColor &col)
sets the color according to the current scheme index and some vehicle function
const std::string getOptionalName() const
Returns the value for generic parameter 'name' or ''.
virtual void drawAction_drawLinkItems(const GUIVisualizationSettings &) const
const Seat & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
int getNumContainers() const
return the number of passengers
void drawOnPos(const GUIVisualizationSettings &s, const Position &pos, const double angle) const
Draws the object on the specified position with the specified angle.
GUIGLObjectPopupMenu * myPopup
current popup (to clean up in destructor). GUIBaseVehicle is not responsible for removal
virtual double getLastLaneChangeOffset() const =0
Returns the time since the last lane change in seconds.
GUIBaseVehicle(MSBaseVehicle &vehicle)
const MSBaseVehicle & getVehicle()
MSDevice_Vehroutes * myRoutes
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &s) const
bool hasActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) const
Returns whether the named feature is enabled in the given view.
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own parameter window.
void drawRoute(const GUIVisualizationSettings &s, int routeNo, double darken, bool future=false, bool noLoop=false) const
Chooses the route to draw and draws it, darkening it as given.
std::vector< Seat > Seats
MSBaseVehicle & myVehicle
The vehicle to which all calls should be delegated.
virtual void drawAction_drawVehicleBlinker(double) const
void removedPopupMenu()
notify object about popup menu removal
virtual GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own type parameter window.
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate)
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the size multiplier value according to the current scheme index
virtual void drawBestLanes() const
Draws the vehicle's best lanes.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void computeSeats(const Position &front, const Position &back, double seatOffset, int maxSeats, double exaggeration, int &requiredSeats, Seats &into) const
add seats to mySeatPositions and update requiredSeats
virtual Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
VisualisationFeatures
Additional visualisation feature ids.
@ VO_SHOW_LFLINKITEMS
LFLinkItems.
@ VO_SHOW_ALL_ROUTES
show all vehicle's routes
@ VO_SHOW_ROUTE_NOLOOP
show vehicle's routes without loops
@ VO_DRAW_OUTSIDE_NETWORK
draw vehicle outside the road network
@ VO_SHOW_FUTURE_ROUTE
show vehicle's current continued from the current position
@ VO_SHOW_ROUTE
show vehicle's current route
@ VO_SHOW_BEST_LANES
show vehicle's best lanes
virtual std::string getStopInfo() const =0
retrieve information about the current stop state
virtual void drawAction_drawCarriageClass(const GUIVisualizationSettings &s, bool asImage) const =0
draws the given guiShape with distinct carriages/modules
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
Seats myContainerPositions
virtual double getAngle() const =0
Returns the vehicle's direction in radians.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
double getNaviDegree() const
return the current angle in navigational degrees
virtual void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
virtual double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const =0
gets the color value according to the current scheme index
int getNumPassengers() const
return the number of passengers
bool drawAction_drawVehicleAsPolyWithCarriagges(const GUIVisualizationSettings &s, double scaledLength, bool asImage=false) const
draw vehicle body and return whether carriages are being drawn
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
~GUIBaseVehicle()
destructor
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
virtual void drawAction_drawVehicleBlueLight() const
virtual void drawRouteHelper(const GUIVisualizationSettings &s, const MSRoute &r, bool future, bool noLoop, const RGBColor &col) const =0
Draws the route.
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
virtual void selectBlockingFoes() const =0
adds the blocking foes to the current selection
void drawStopLabels(const GUIVisualizationSettings &s, bool noLoop, const RGBColor &col) const
Seats mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
std::string getDeviceDescription()
lists equipped device (types) for the current vehicle
const MSVehicleType & getVType() const
A shortcut to myVehicle.myType.
The popup menu of a globject.
A window containing a gl-object's parameter.
Stores the information about how to visualize structures.
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:192
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:51
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
A device which collects info on the vehicle trip (mainly on departure and arrival)
The car-following model and parameter.
Definition: MSVehicleType.h:62
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
Seat(const Position &_pos, double _angle)