SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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-sim.org/
13 // Copyright (C) 2001-2014 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:
78  GUIVehicle(SUMOVehicleParameter* pars, const MSRoute* route,
79  const MSVehicleType* type, SUMOReal speedFactor);
80 
81 
83  ~GUIVehicle();
84 
85 
87 
88 
97 
98 
107 
108 
115 
116 
121  void drawGL(const GUIVisualizationSettings& s) const;
122 
123 
124 
129  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
131 
132 
133 
136 
142  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
143 
144 
150  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
151 
152 
158  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
160 
161 
162 
168 
169 
177  FXDECLARE(GUIVehiclePopupMenu)
178  public:
186  GUISUMOAbstractView& parent, GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations);
187 
190 
192  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
194  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
196  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
198  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
200  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
202  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
204  long onCmdStartTrack(FXObject*, FXSelector, void*);
206  long onCmdStopTrack(FXObject*, FXSelector, void*);
208  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
210  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
212  long onCmdShowFoes(FXObject*, FXSelector, void*);
213 
214  protected:
216  std::map<GUISUMOAbstractView*, int>& myVehiclesAdditionalVisualizations;
218  std::map<GUISUMOAbstractView*, int> dummy;
219 
220  protected:
223 
224  };
225 
226 
229 
243  };
244 
246  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
247 
248 
252  void drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const;
253 
254 
260  void drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const;
261 
262 
265  void drawBestLanes() const;
267 
269  void selectBlockingFoes() const;
270 
272  SUMOReal getColorValue(size_t activeScheme) const;
273 
274 
275 private:
277  void setColor(const GUIVisualizationSettings& s) const;
278 
280  bool setFunctionalColor(size_t activeScheme) const;
281 
284  static void drawPoly(double* poses, SUMOReal offset);
285 
286  void drawAction_drawVehicleAsBoxPlus() const;
289 
290  /* @brief try to draw vehicle as raster image and return true if sucessful
291  * @param[in] length The custom length of the vehicle
292  * (defaults to the * length specified in the vehicle type if -1 is passed)
293  */
294  bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings& s, SUMOReal length = -1) const;
295 
296  /* @brief draw train with individual carriages. The number of carriages is
297  * determined from defaultLength of carriages and vehicle length
298  * passengerSeats are computed beginning at firstPassengerCarriage */
299  void drawAction_drawRailCarriages(const GUIVisualizationSettings& s, SUMOReal defaultLength, SUMOReal carriageGap,
300  int firstPassengerCarriage, bool asImage) const;
302 
304  bool drawAction_drawCarriageClass(const GUIVisualizationSettings& s, SUMOVehicleShape guiShape, bool asImage) const;
305 
306  /* @brief return the previous lane in this vehicles route including internal lanes
307  * @param[in] current The lane of which the predecessor should be returned
308  * @param[in,out] routeIndex The index of the current or previous non-internal edge in the route
309  */
310  MSLane* getPreviousLane(MSLane* current, int& furtherIndex) const;
311 
313  const Position& getSeatPosition(size_t personIndex) const;
314 
316  int getNumPassengers() const;
317 
319  void computeSeats(const Position& front, const Position& back, int& requiredSeats) const;
320 
322  std::string getStopInfo() const;
323 
324  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate);
325 
326 private:
328  mutable MFXMutex myLock;
329 
332 
334 
337 
338 };
339 
340 
341 #endif
342 
343 /****************************************************************************/
344 
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIVehicle.cpp:315
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:841
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be shown.
Definition: GUIVehicle.cpp:183
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
long onCmdStartTrack(FXObject *, FXSelector, void *)
Called if the vehicle shall be tracked.
Definition: GUIVehicle.cpp:200
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIVehicle.cpp:269
void drawBestLanes() const
Draws the vehicle's best lanes.
Stores the information about how to visualize structures.
track vehicle
Definition: GUIVehicle.h:240
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:238
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIVehicle.cpp:384
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, SUMOReal length=-1) const
Definition: GUIVehicle.cpp:823
long onCmdHideAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:158
long onCmdHideBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be hidden.
Definition: GUIVehicle.cpp:192
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
bool setFunctionalColor(size_t activeScheme) const
sets the color according to the current scheme index and some vehicle function
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:175
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:228
void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
Definition: GUIVehicle.cpp:442
long onCmdShowCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
Definition: GUIVehicle.cpp:166
void drawAction_drawVehicleAsTrianglePlus() const
Definition: GUIVehicle.cpp:408
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:222
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
Definition: GUIVehicle.h:246
long onCmdShowLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
Definition: GUIVehicle.cpp:219
show vehicle's current route
Definition: GUIVehicle.h:236
MSLane * getPreviousLane(MSLane *current, int &furtherIndex) const
std::map< GUISUMOAbstractView *, int > & myVehiclesAdditionalVisualizations
Information which additional visualisations are enabled (per view)
Definition: GUIVehicle.h:216
~GUIVehicle()
destructor
Definition: GUIVehicle.cpp:257
static void drawPoly(double *poses, SUMOReal offset)
Definition: GUIVehicle.cpp:426
GUIVehicle(SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, SUMOReal speedFactor)
Constructor.
Definition: GUIVehicle.cpp:245
long onCmdStopTrack(FXObject *, FXSelector, void *)
Called if the current shall not be tracked any longer.
Definition: GUIVehicle.cpp:210
MSDevice_Vehroutes * myRoutes
Definition: GUIVehicle.h:333
int getNumPassengers() const
return the number of passengers
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
Definition: GUIVehicle.h:336
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate)
VisualisationFeatures
Additional visualisation feature ids.
Definition: GUIVehicle.h:232
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUIVehicle.h:328
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:918
Structure representing possible vehicle parameter.
void drawAction_drawVehicleAsBoxPlus() const
Definition: GUIVehicle.cpp:393
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
std::map< GUISUMOAbstractView *, int > dummy
Needed for parameterless instantiation.
Definition: GUIVehicle.h:218
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) ...
long onCmdShowFoes(FXObject *, FXSelector, void *)
Called when show a vehicles foes.
Definition: GUIVehicle.cpp:235
void drawAction_drawRailCarriages(const GUIVisualizationSettings &s, SUMOReal defaultLength, SUMOReal carriageGap, int firstPassengerCarriage, bool asImage) const
#define SUMOReal
Definition: config.h:215
show vehicle's best lanes
Definition: GUIVehicle.h:234
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:331
long onCmdShowAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
Definition: GUIVehicle.cpp:149
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:68