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-2013 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 #ifdef HAVE_OSG
55 class GUIOSGView;
56 namespace osg {
57 class ShapeDrawable;
58 }
59 #endif
60 
61 
62 // ===========================================================================
63 // class definitions
64 // ===========================================================================
74 class GUIVehicle : public MSVehicle, public GUIGlObject {
75 public:
84  GUIVehicle(SUMOVehicleParameter* pars, const MSRoute* route,
85  const MSVehicleType* type, SUMOReal speedFactor, int vehicleIndex);
86 
87 
89  ~GUIVehicle();
90 
91 
93 
94 
103 
104 
113 
114 
121 
122 
127  void drawGL(const GUIVisualizationSettings& s) const;
128 
129 
130 
135  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
137 
138 
139 
142 
148  bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
149 
150 
156  void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
157 
158 
164  void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
166 
167 
168 
174 
175 
183  const std::vector<LaneQ>& getBestLanes() const;
184 
185 
193  FXDECLARE(GUIVehiclePopupMenu)
194  public:
202  GUISUMOAbstractView& parent, GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations);
203 
206 
208  long onCmdShowAllRoutes(FXObject*, FXSelector, void*);
210  long onCmdHideAllRoutes(FXObject*, FXSelector, void*);
212  long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
214  long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
216  long onCmdShowBestLanes(FXObject*, FXSelector, void*);
218  long onCmdHideBestLanes(FXObject*, FXSelector, void*);
220  long onCmdStartTrack(FXObject*, FXSelector, void*);
222  long onCmdStopTrack(FXObject*, FXSelector, void*);
224  long onCmdShowLFLinkItems(FXObject*, FXSelector, void*);
226  long onCmdHideLFLinkItems(FXObject*, FXSelector, void*);
228  long onCmdShowFoes(FXObject*, FXSelector, void*);
229 
230  protected:
232  std::map<GUISUMOAbstractView*, int>& myVehiclesAdditionalVisualizations;
234  std::map<GUISUMOAbstractView*, int> dummy;
235 
236  protected:
239 
240  };
241 
242 
245 
259  };
260 
262  std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
263 
264 
268  void drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const;
269 
270 
276  void drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const;
277 
278 
281  void drawBestLanes() const;
283 
285  void selectBlockingFoes() const;
286 
287 #ifdef HAVE_OSG
288  void setGeometry(GUIOSGView* view, osg::ShapeDrawable* geom) {
289  myGeom[view] = geom;
290  }
291 
292  void updateColor(GUIOSGView* view);
293 #endif
294 
295 
296 private:
298  void setColor(const GUIVisualizationSettings& s) const;
299 
301  SUMOReal getColorValue(size_t activeScheme) const;
302 
304  bool setFunctionalColor(size_t activeScheme) const;
305 
308  static void drawPoly(double* poses, SUMOReal offset);
309 
310  void drawAction_drawVehicleAsBoxPlus() const;
313 
314  /* @brief try to draw vehicle as raster image and return true if sucessful
315  * @param[in] length The custom length of the vehicle
316  * (defaults to the * length specified in the vehicle type if -1 is passed)
317  */
318  bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings& s, SUMOReal length = -1) const;
319 
320  /* @brief draw train with individual carriages. The number of carriages is
321  * determined from defaultLength of carriages and vehicle length
322  * passengerSeats are computed beginning at firstPassengerCarriage */
323  void drawAction_drawRailCarriages(const GUIVisualizationSettings& s, SUMOReal defaultLength, int firstPassengerCarriage = 0, bool asImage = false) const;
325 
326  /* @brief return the previous lane in this vehicles route including internal lanes
327  * @param[in] current The lane of which the predecessor should be returned
328  * @param[in,out] routeIndex The index of the current or previous non-internal edge in the route
329  */
330  MSLane* getPreviousLane(MSLane* current, int& routeIndex) const;
331 
333  const Position& getSeatPosition(size_t personIndex) const;
334 
336  int getNumPassengers() const;
337 
339  void computeSeats(const Position& front, const Position& back, int& requiredSeats) const;
340 
342  std::string getStopInfo() const;
343 
344  static void drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate);
345 
346 private:
348  mutable MFXMutex myLock;
349 
351 
354 
355 #ifdef HAVE_OSG
356  std::map<GUIOSGView*, osg::ShapeDrawable*> myGeom;
357 #endif
358 
359 };
360 
361 
362 #endif
363 
364 /****************************************************************************/
365 
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIVehicle.cpp:323
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
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle&#39;s best lanes shall be shown.
Definition: GUIVehicle.cpp:186
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:203
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIVehicle.cpp:277
MSLane * getPreviousLane(MSLane *current, int &routeIndex) const
void drawBestLanes() const
Draws the vehicle&#39;s best lanes.
Stores the information about how to visualize structures.
track vehicle
Definition: GUIVehicle.h:256
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&#39;s routes
Definition: GUIVehicle.h:254
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIVehicle.cpp:372
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:827
long onCmdHideAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:161
long onCmdHideBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle&#39;s best lanes shall be hidden.
Definition: GUIVehicle.cpp:195
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:178
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:231
void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
Definition: GUIVehicle.cpp:430
long onCmdShowCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
Definition: GUIVehicle.cpp:169
void drawAction_drawVehicleAsTrianglePlus() const
Definition: GUIVehicle.cpp:396
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:238
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
Definition: GUIVehicle.h:262
long onCmdShowLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
Definition: GUIVehicle.cpp:222
show vehicle&#39;s current route
Definition: GUIVehicle.h:252
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
std::map< GUISUMOAbstractView *, int > & myVehiclesAdditionalVisualizations
Information which additional visualisations are enabled (per view)
Definition: GUIVehicle.h:232
~GUIVehicle()
destructor
Definition: GUIVehicle.cpp:260
static void drawPoly(double *poses, SUMOReal offset)
Definition: GUIVehicle.cpp:414
long onCmdStopTrack(FXObject *, FXSelector, void *)
Called if the current shall not be tracked any longer.
Definition: GUIVehicle.cpp:213
MSDevice_Vehroutes * myRoutes
Definition: GUIVehicle.h:350
int getNumPassengers() const
return the number of passengers
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
Definition: GUIVehicle.h:353
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate)
VisualisationFeatures
Additional visualisation feature ids.
Definition: GUIVehicle.h:248
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUIVehicle.h:348
GUIVehicle(SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, SUMOReal speedFactor, int vehicleIndex)
Constructor.
Definition: GUIVehicle.cpp:248
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:898
Structure representing possible vehicle parameter.
void drawAction_drawVehicleAsBoxPlus() const
Definition: GUIVehicle.cpp:381
std::map< GUISUMOAbstractView *, int > dummy
Needed for parameterless instantiation.
Definition: GUIVehicle.h:234
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:238
#define SUMOReal
Definition: config.h:221
void drawAction_drawRailCarriages(const GUIVisualizationSettings &s, SUMOReal defaultLength, int firstPassengerCarriage=0, bool asImage=false) const
show vehicle&#39;s best lanes
Definition: GUIVehicle.h:250
void drawRouteHelper(const MSRoute &r, SUMOReal exaggeration) const
Draws the route.
Representation of a lane in the micro simulation.
Definition: MSLane.h:73
A window containing a gl-object&#39;s parameter.
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
long onCmdShowAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
Definition: GUIVehicle.cpp:152
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:74