SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GUIVehicle.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-2015 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 GUIVehicle_h
24 #define GUIVehicle_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>
40 #include <utils/common/RGBColor.h>
42 #include <microsim/MSVehicle.h>
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
53 class MSDevice_Vehroutes;
54 
55 
56 // ===========================================================================
57 // class definitions
58 // ===========================================================================
68 class GUIVehicle : public MSVehicle, public GUIGlObject {
69 public:
77  GUIVehicle(SUMOVehicleParameter* pars, const MSRoute* route,
78  const MSVehicleType* type, const SUMOReal speedFactor);
79 
80 
82  ~GUIVehicle();
83 
84 
86 
87 
96 
97 
106 
107 
114 
115 
120  void drawGL(const GUIVisualizationSettings& s) const;
121 
122 
123 
128  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
130 
131 
132 
135 
141  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
142 
143 
149  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
150 
151 
157  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
159 
160 
161 
167 
168 
176  FXDECLARE(GUIVehiclePopupMenu)
177  public:
185  GUISUMOAbstractView& parent, GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations);
186 
189 
191  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
193  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
195  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
197  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
199  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
201  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
203  long onCmdStartTrack(FXObject*, FXSelector, void*);
205  long onCmdStopTrack(FXObject*, FXSelector, void*);
207  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
209  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
211  long onCmdShowFoes(FXObject*, FXSelector, void*);
212 
213  protected:
215  std::map<GUISUMOAbstractView*, int>& myVehiclesAdditionalVisualizations;
217  std::map<GUISUMOAbstractView*, int> dummy;
218 
219  protected:
221  GUIVehiclePopupMenu() : myVehiclesAdditionalVisualizations(dummy) { }
222 
223  };
224 
225 
228 
242  };
243 
245  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
246 
247 
251  void drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const;
252 
253 
259  void drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const;
260 
261 
264  void drawBestLanes() const;
266 
268  void selectBlockingFoes() const;
269 
271  SUMOReal getColorValue(size_t activeScheme) const;
272 
274  static bool setFunctionalColor(size_t activeScheme, const MSBaseVehicle* veh);
275 
276 private:
278  void setColor(const GUIVisualizationSettings& s) const;
279 
280 
283  static void drawPoly(double* poses, SUMOReal offset);
284 
285  void drawAction_drawVehicleAsBoxPlus() const;
288 
289  /* @brief try to draw vehicle as raster image and return true if sucessful
290  * @param[in] length The custom length of the vehicle
291  * (defaults to the * length specified in the vehicle type if -1 is passed)
292  */
293  bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings& s, SUMOReal length = -1) const;
294 
295  /* @brief draw train with individual carriages. The number of carriages is
296  * determined from defaultLength of carriages and vehicle length
297  * passengerSeats are computed beginning at firstPassengerCarriage */
298  void drawAction_drawRailCarriages(const GUIVisualizationSettings& s, SUMOReal defaultLength, SUMOReal carriageGap,
299  int firstPassengerCarriage, bool asImage) const;
301 
303  bool drawAction_drawCarriageClass(const GUIVisualizationSettings& s, SUMOVehicleShape guiShape, bool asImage) const;
304 
305  /* @brief return the previous lane in this vehicles route including internal lanes
306  * @param[in] current The lane of which the predecessor should be returned
307  * @param[in,out] routeIndex The index of the current or previous non-internal edge in the route
308  */
309  MSLane* getPreviousLane(MSLane* current, int& furtherIndex) const;
310 
312  const Position& getSeatPosition(size_t personIndex) const;
313 
315  int getNumPassengers() const;
316 
318  void computeSeats(const Position& front, const Position& back, int& requiredSeats) const;
319 
321  std::string getStopInfo() const;
322 
323  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate);
324 
325 private:
327  mutable MFXMutex myLock;
328 
331 
333 
336 
337 };
338 
339 
340 #endif
341 
342 /****************************************************************************/
343 
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIVehicle.cpp:322
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
void selectBlockingFoes() const
adds the blocking foes to the current selection
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
SUMOReal getColorValue(size_t activeScheme) const
gets the color value according to the current scheme index
bool drawAction_drawCarriageClass(const GUIVisualizationSettings &s, SUMOVehicleShape guiShape, bool asImage) const
draws the given guiShape if it has distinc carriages/modules and eturns true if so ...
Definition: GUIVehicle.cpp:880
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be shown.
Definition: GUIVehicle.cpp:191
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
long onCmdStartTrack(FXObject *, FXSelector, void *)
Called if the vehicle shall be tracked.
Definition: GUIVehicle.cpp:208
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIVehicle.cpp:276
static bool setFunctionalColor(size_t activeScheme, const MSBaseVehicle *veh)
sets the color according to the current scheme index and some vehicle function
void drawBestLanes() const
Draws the vehicle's best lanes.
Stores the information about how to visualize structures.
track vehicle
Definition: GUIVehicle.h:239
bool hasActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) const
Returns whether the named feature is enabled in the given view.
SUMOReal getLastLaneChangeOffset() const
Returns the time since the last lane change in seconds.
show all vehicle's routes
Definition: GUIVehicle.h:237
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIVehicle.cpp:400
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:52
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, SUMOReal length=-1) const
Definition: GUIVehicle.cpp:861
long onCmdHideAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:166
long onCmdHideBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be hidden.
Definition: GUIVehicle.cpp:200
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
The car-following model and parameter.
Definition: MSVehicleType.h:74
std::string getStopInfo() const
retrieve information about the current stop state
long onCmdHideCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:183
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:236
void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
Definition: GUIVehicle.cpp:458
long onCmdShowCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
Definition: GUIVehicle.cpp:174
void drawAction_drawVehicleAsTrianglePlus() const
Definition: GUIVehicle.cpp:424
GUIVehicle(SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, const SUMOReal speedFactor)
Constructor.
Definition: GUIVehicle.cpp:253
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
GUIVehiclePopupMenu()
default constructor needed by FOX
Definition: GUIVehicle.h:221
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
Definition: GUIVehicle.h:245
long onCmdShowLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
Definition: GUIVehicle.cpp:227
show vehicle's current route
Definition: GUIVehicle.h:235
MSLane * getPreviousLane(MSLane *current, int &furtherIndex) const
std::map< GUISUMOAbstractView *, int > & myVehiclesAdditionalVisualizations
Information which additional visualisations are enabled (per view)
Definition: GUIVehicle.h:215
~GUIVehicle()
destructor
Definition: GUIVehicle.cpp:264
static void drawPoly(double *poses, SUMOReal offset)
Definition: GUIVehicle.cpp:442
long onCmdStopTrack(FXObject *, FXSelector, void *)
Called if the current shall not be tracked any longer.
Definition: GUIVehicle.cpp:218
MSDevice_Vehroutes * myRoutes
Definition: GUIVehicle.h:332
int getNumPassengers() const
return the number of passengers
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
Definition: GUIVehicle.h:335
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate)
VisualisationFeatures
Additional visualisation feature ids.
Definition: GUIVehicle.h:231
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUIVehicle.h:327
void computeSeats(const Position &front, const Position &back, int &requiredSeats) const
add seats to mySeatPositions and update requiredSeats
const Position & getSeatPosition(size_t personIndex) const
returns the seat position for the person with the given index
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIVehicle.cpp:957
Structure representing possible vehicle parameter.
void drawAction_drawVehicleAsBoxPlus() const
Definition: GUIVehicle.cpp:409
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
std::map< GUISUMOAbstractView *, int > dummy
Needed for parameterless instantiation.
Definition: GUIVehicle.h:217
void drawRoute(const GUIVisualizationSettings &s, int routeNo, SUMOReal darken) const
Chooses the route to draw and draws it, darkening it as given.
The popup menu of a globject.
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
int SUMOTime
Definition: SUMOTime.h:43
long onCmdShowFoes(FXObject *, FXSelector, void *)
Called when show a vehicles foes.
Definition: GUIVehicle.cpp:243
void drawAction_drawRailCarriages(const GUIVisualizationSettings &s, SUMOReal defaultLength, SUMOReal carriageGap, int firstPassengerCarriage, bool asImage) const
#define SUMOReal
Definition: config.h:218
show vehicle's best lanes
Definition: GUIVehicle.h:233
void drawRouteHelper(const MSRoute &r, SUMOReal exaggeration) const
Draws the route.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
A window containing a gl-object's parameter.
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
SUMOReal myCarriageLength
Variable to set with the length of the last drawn carriage or the vehicle length. ...
Definition: GUIVehicle.h:330
long onCmdShowAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
Definition: GUIVehicle.cpp:157
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:68