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-2019 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 <fx.h>
33 #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(const GUIVisualizationSettings& s, int activeScheme) const = 0;
92 
94  virtual void drawAction_drawCarriageClass(const GUIVisualizationSettings& s, bool asImage) const = 0;
95 
100  virtual double getLastLaneChangeOffset() const = 0;
101 
105  virtual void drawRouteHelper(const GUIVisualizationSettings& s, const MSRoute& r, bool future) 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 
166  const std::string getOptionalName() const;
167 
173  void drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const double angle) const;
174 
175 
180  void drawGL(const GUIVisualizationSettings& s) const;
181 
182 
187  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
189 
190 
191 
194 
200  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
201 
202 
208  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
209 
210 
216  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
218 
220  int getNumPassengers() const;
221 
223  int getNumContainers() const;
224 
225 
226 
234  FXDECLARE(GUIBaseVehiclePopupMenu)
235  public:
243  GUISUMOAbstractView& parent, GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations);
244 
247 
249  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
251  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
253  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
255  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
257  long onCmdShowFutureRoute(FXObject*, FXSelector, void*);
259  long onCmdHideFutureRoute(FXObject*, FXSelector, void*);
261  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
263  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
265  long onCmdStartTrack(FXObject*, FXSelector, void*);
267  long onCmdStopTrack(FXObject*, FXSelector, void*);
269  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
271  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
273  long onCmdShowFoes(FXObject*, FXSelector, void*);
275  long onCmdRemoveObject(FXObject*, FXSelector, void*);
276 
277  protected:
279  std::map<GUISUMOAbstractView*, int>& myVehiclesAdditionalVisualizations;
281  std::map<GUISUMOAbstractView*, int> dummy;
282 
283  protected:
285  GUIBaseVehiclePopupMenu() : myVehiclesAdditionalVisualizations(dummy) { }
286 
287  };
288 
289 
292 
308  };
309 
311  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
312 
313 
319  void drawRoute(const GUIVisualizationSettings& s, int routeNo, double darken, bool future = false) const;
320 
321 
323 
325  static bool setFunctionalColor(int activeScheme, const MSBaseVehicle* veh);
326 
327 protected:
329  void setColor(const GUIVisualizationSettings& s) const;
330 
332  const Position& getSeatPosition(int personIndex) const;
333 
334  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate);
335 
337  inline const MSVehicleType& getVType() const {
338  return myVehicle.getVehicleType();
339  }
340 
342  bool drawAction_drawVehicleAsPolyWithCarriagges(const GUIVisualizationSettings& s, bool asImage = false) const;
343 
345  void computeSeats(const Position& front, const Position& back, int maxSeats, double exaggeration, int& requiredSeats) const;
346 
347 
348 protected:
350  mutable FXMutex myLock;
351 
354 
355 private:
358 
360 
361 };
362 
363 
364 #endif
365 
366 /****************************************************************************/
367 
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.
show vehicle&#39;s current continued from the current position
long onCmdHideCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
long long int SUMOTime
Definition: SUMOTime.h:35
virtual void drawAction_drawVehicleBlueLight() const
virtual void drawRouteHelper(const GUIVisualizationSettings &s, const MSRoute &r, bool future) const =0
Draws the route.
const MSVehicleType & getVType() const
A shortcut to myVehicle.myType.
long onCmdStartTrack(FXObject *, FXSelector, void *)
Called if the vehicle shall be tracked.
Stores the information about how to visualize structures.
void computeSeats(const Position &front, const Position &back, int maxSeats, double exaggeration, int &requiredSeats) const
add seats to mySeatPositions and update requiredSeats
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
void drawRoute(const GUIVisualizationSettings &s, int routeNo, double darken, bool future=false) const
Chooses the route to draw and draws it, darkening it as given.
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
std::map< GUISUMOAbstractView *, int > dummy
Needed for parameterless instantiation.
virtual void drawAction_drawCarriageClass(const GUIVisualizationSettings &s, bool asImage) const =0
draws the given guiShape with distinct carriages/modules
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 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:32
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 onCmdHideFutureRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
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)
virtual double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const =0
gets the color value according to the current scheme index
const std::string getOptionalName() const
Returns the value for generic parameter &#39;name&#39; or &#39;&#39;.
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:194
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: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.
long onCmdRemoveObject(FXObject *, FXSelector, void *)
Called when removing the vehicle.
long onCmdShowFutureRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
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.
int getNumPassengers() const
return the number of passengers
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
bool drawAction_drawVehicleAsPolyWithCarriagges(const GUIVisualizationSettings &s, bool asImage=false) const
draw vehicle body and return whether carriages are being drawn
VisualisationFeatures
Additional visualisation feature ids.
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
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
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.
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.
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
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
int getNumContainers() const
return the number of passengers