SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIVehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A MSVehicle extended by some values for usage within the gui
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <cmath>
34 #include <vector>
35 #include <string>
36 #ifdef HAVE_OSG
37 #include <osg/ShapeDrawable>
38 #include <osgview/GUIOSGView.h>
39 #endif
49 #include <utils/gui/div/GLHelper.h>
52 #include <microsim/MSVehicle.h>
53 #include <microsim/MSLane.h>
61 #include <gui/GUIGlobals.h>
62 #include "GUIVehicle.h"
63 #include "GUIPerson.h"
64 #include "GUINet.h"
65 #include "GUIEdge.h"
66 #include "GUILane.h"
67 
68 #ifdef CHECK_MEMORY_LEAKS
69 #include <foreign/nvwa/debug_new.h>
70 #endif // CHECK_MEMORY_LEAKS
71 
72 
73 // ===========================================================================
74 // FOX callback mapping
75 // ===========================================================================
76 FXDEFMAP(GUIVehicle::GUIVehiclePopupMenu) GUIVehiclePopupMenuMap[] = {
88 };
89 
90 // Object implementation
91 FXIMPLEMENT(GUIVehicle::GUIVehiclePopupMenu, GUIGLObjectPopupMenu, GUIVehiclePopupMenuMap, ARRAYNUMBER(GUIVehiclePopupMenuMap))
92 
93 
94 
95 // ===========================================================================
96 // data definitions
97 // ===========================================================================
98 /* -------------------------------------------------------------------------
99  * drawed shapes
100  * ----------------------------------------------------------------------- */
101 double vehiclePoly_PassengerCarBody[] = { .5, 0, 0, 0, 0, .3, 0.08, .44, 0.25, .5, 0.95, .5, 1., .4, 1., -.4, 0.95, -.5, 0.25, -.5, 0.08, -.44, 0, -.3, 0, 0, -10000 };
102 double vehiclePoly_PassengerCarBodyFront[] = { 0.1, 0, 0.025, 0, 0.025, 0.25, 0.27, 0.4, 0.27, -.4, 0.025, -0.25, 0.025, 0, -10000 };
103 double vehiclePoly_PassengerFrontGlass[] = { 0.35, 0, 0.3, 0, 0.3, 0.4, 0.43, 0.3, 0.43, -0.3, 0.3, -0.4, 0.3, 0, -10000 };
104 double vehiclePoly_PassengerSedanRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.77, -.47, 0.67, -.37, 0.45, -.37, 0.34, -.47, -10000 };
105 double vehiclePoly_PassengerSedanLeftGlass[] = { 0.36, .43, 0.34, .47, 0.77, .47, 0.67, .37, 0.45, .37, 0.34, .47, -10000 };
106 double vehiclePoly_PassengerSedanBackGlass[] = { 0.80, 0, 0.70, 0, 0.70, 0.3, 0.83, 0.4, 0.83, -.4, 0.70, -.3, 0.70, 0, -10000 };
107 double vehiclePoly_PassengerHatchbackRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.80, -.37, 0.45, -.37, 0.34, -.47, -10000 };
108 double vehiclePoly_PassengerHatchbackLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.80, .37, 0.45, .37, 0.34, .47, -10000 };
109 double vehiclePoly_PassengerHatchbackBackGlass[] = { 0.92, 0, 0.80, 0, 0.80, 0.3, 0.95, 0.4, 0.95, -.4, 0.80, -.3, 0.80, 0, -10000 };
110 double vehiclePoly_PassengerWagonRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.87, -.37, 0.45, -.37, 0.34, -.47, -10000 };
111 double vehiclePoly_PassengerWagonLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.87, .37, 0.45, .37, 0.34, .47, -10000 };
112 double vehiclePoly_PassengerWagonBackGlass[] = { 0.92, 0, 0.90, 0, 0.90, 0.3, 0.95, 0.4, 0.95, -.4, 0.90, -.3, 0.90, 0, -10000 };
113 
114 double vehiclePoly_PassengerVanBody[] = { .5, 0, 0, 0, 0, .4, 0.1, .5, 0.97, .5, 1., .47, 1., -.47, 0.97, -.5, 0.1, -.5, 0, -.4, 0, 0, -10000 };
115 double vehiclePoly_PassengerVanBodyFront[] = { 0.1, 0, 0.025, 0, 0.025, 0.25, 0.13, 0.4, 0.13, -.4, 0.025, -0.25, 0.025, 0, -10000 };
116 double vehiclePoly_PassengerVanFrontGlass[] = { 0.21, 0, 0.16, 0, 0.16, 0.4, 0.29, 0.3, 0.29, -0.3, 0.16, -0.4, 0.16, 0, -10000 };
117 double vehiclePoly_PassengerVanRightGlass[] = { 0.36, -.43, 0.20, -.47, 0.98, -.47, 0.91, -.37, 0.31, -.37, 0.20, -.47, -10000 };
118 double vehiclePoly_PassengerVanLeftGlass[] = { 0.36, .43, 0.20, .47, 0.98, .47, 0.91, .37, 0.31, .37, 0.20, .47, -10000 };
119 double vehiclePoly_PassengerVanBackGlass[] = { 0.95, 0, 0.94, 0, 0.94, 0.3, 0.98, 0.4, 0.98, -.4, 0.94, -.3, 0.94, 0, -10000 };
120 
121 double vehiclePoly_DeliveryMediumRightGlass[] = { 0.21, -.43, 0.20, -.47, 0.38, -.47, 0.38, -.37, 0.31, -.37, 0.20, -.47, -10000 };
122 double vehiclePoly_DeliveryMediumLeftGlass[] = { 0.21, .43, 0.20, .47, 0.38, .47, 0.38, .37, 0.31, .37, 0.20, .47, -10000 };
123 
124 double vehiclePoly_TransportBody[] = { .5, 0, 0, 0, 0, .45, 0.05, .5, 2.25, .5, 2.25, -.5, 0.05, -.5, 0, -.45, 0, 0, -10000 };
125 double vehiclePoly_TransportFrontGlass[] = { 0.1, 0, 0.05, 0, 0.05, 0.45, 0.25, 0.4, 0.25, -.4, 0.05, -0.45, 0.05, 0, -10000 };
126 double vehiclePoly_TransportRightGlass[] = { 0.36, -.47, 0.10, -.48, 1.25, -.48, 1.25, -.4, 0.3, -.4, 0.10, -.48, -10000 };
127 double vehiclePoly_TransportLeftGlass[] = { 0.36, .47, 0.10, .48, 1.25, .48, 1.25, .4, 0.3, .4, 0.10, .48, -10000 };
128 
129 double vehiclePoly_EVehicleBody[] = { .5, 0, 0, 0, 0, .3, 0.08, .44, 0.25, .5, 0.75, .5, .92, .44, 1, .3, 1, -.3, .92, -.44, .75, -.5, .25, -.5, 0.08, -.44, 0, -.3, 0, 0, -1000 };
130 double vehiclePoly_EVehicleFrontGlass[] = { .5, 0, 0.05, .05, 0.05, .25, 0.13, .39, 0.3, .45, 0.70, .45, .87, .39, .95, .25, .95, -.25, .87, -.39, .70, -.45, .3, -.45, 0.13, -.39, 0.05, -.25, 0.05, 0.05, -1000 };
131 //double vehiclePoly_EVehicleFrontGlass[] = { 0.35,0, 0.1,0, 0.1,0.4, 0.43,0.3, 0.43,-0.3, 0.1,-0.4, 0.1,0, -10000 };
132 double vehiclePoly_EVehicleBackGlass[] = { 0.65, 0, 0.9, 0, 0.9, 0.4, 0.57, 0.3, 0.57, -0.3, 0.9, -0.4, 0.9, 0, -10000 };
133 
134 
135 // ===========================================================================
136 // method definitions
137 // ===========================================================================
138 /* -------------------------------------------------------------------------
139  * GUIVehicle::GUIVehiclePopupMenu - methods
140  * ----------------------------------------------------------------------- */
142  GUIMainWindow& app, GUISUMOAbstractView& parent,
143  GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations)
144  : GUIGLObjectPopupMenu(app, parent, o), myVehiclesAdditionalVisualizations(additionalVisualizations) {
145 }
146 
147 
149 
150 
151 long
153  assert(myObject->getType() == GLO_VEHICLE);
154  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES)) {
155  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES);
156  }
157  return 1;
158 }
159 
160 long
162  assert(myObject->getType() == GLO_VEHICLE);
163  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES);
164  return 1;
165 }
166 
167 
168 long
170  assert(myObject->getType() == GLO_VEHICLE);
171  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ROUTE)) {
172  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_ROUTE);
173  }
174  return 1;
175 }
176 
177 long
179  assert(myObject->getType() == GLO_VEHICLE);
180  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_ROUTE);
181  return 1;
182 }
183 
184 
185 long
187  assert(myObject->getType() == GLO_VEHICLE);
188  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES)) {
189  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES);
190  }
191  return 1;
192 }
193 
194 long
196  assert(myObject->getType() == GLO_VEHICLE);
197  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES);
198  return 1;
199 }
200 
201 
202 long
204  assert(myObject->getType() == GLO_VEHICLE);
205  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_TRACKED)) {
206  myParent->startTrack(static_cast<GUIVehicle*>(myObject)->getGlID());
207  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_TRACKED);
208  }
209  return 1;
210 }
211 
212 long
214  assert(myObject->getType() == GLO_VEHICLE);
215  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_TRACKED);
216  myParent->stopTrack();
217  return 1;
218 }
219 
220 
221 long
223  assert(myObject->getType() == GLO_VEHICLE);
224  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS)) {
225  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS);
226  }
227  return 1;
228 }
229 
230 long
232  assert(myObject->getType() == GLO_VEHICLE);
233  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS);
234  return 1;
235 }
236 
237 long
239  assert(myObject->getType() == GLO_VEHICLE);
240  static_cast<GUIVehicle*>(myObject)->selectBlockingFoes();
241  return 1;
242 }
243 
244 
245 /* -------------------------------------------------------------------------
246  * GUIVehicle - methods
247  * ----------------------------------------------------------------------- */
249  const MSVehicleType* type,
250  SUMOReal speedFactor) :
251  MSVehicle(pars, route, type, speedFactor),
252  GUIGlObject(GLO_VEHICLE, pars->id) {
253  // as it is possible to show all vehicle routes, we have to store them... (bug [ 2519761 ])
255  myMoveReminders.push_back(std::make_pair(myRoutes, 0.));
256  mySeatPositions.push_back(Position(0, 0)); // ensure length 1
257 }
258 
259 
261  myLock.lock();
262  for (std::map<GUISUMOAbstractView*, int>::iterator i = myAdditionalVisualizations.begin(); i != myAdditionalVisualizations.end(); ++i) {
263  while (i->first->removeAdditionalGLVisualisation(this));
264  }
265 #ifdef HAVE_OSG
266  for (std::map<GUIOSGView*, osg::ShapeDrawable*>::iterator i = myGeom.begin(); i != myGeom.end(); ++i) {
267  i->first->remove(this);
268  }
269 #endif
270  myLock.unlock();
272  delete myRoutes;
273 }
274 
275 
278  GUISUMOAbstractView& parent) {
280  buildPopupHeader(ret, app);
284  //
286  new FXMenuCommand(ret, "Hide Current Route", 0, ret, MID_HIDE_CURRENTROUTE);
287  } else {
288  new FXMenuCommand(ret, "Show Current Route", 0, ret, MID_SHOW_CURRENTROUTE);
289  }
291  new FXMenuCommand(ret, "Hide All Routes", 0, ret, MID_HIDE_ALLROUTES);
292  } else {
293  new FXMenuCommand(ret, "Show All Routes", 0, ret, MID_SHOW_ALLROUTES);
294  }
296  new FXMenuCommand(ret, "Hide Best Lanes", 0, ret, MID_HIDE_BEST_LANES);
297  } else {
298  new FXMenuCommand(ret, "Show Best Lanes", 0, ret, MID_SHOW_BEST_LANES);
299  }
301  new FXMenuCommand(ret, "Hide Link Items", 0, ret, MID_HIDE_LFLINKITEMS);
302  } else {
303  new FXMenuCommand(ret, "Show Link Items", 0, ret, MID_SHOW_LFLINKITEMS);
304  }
305  new FXMenuSeparator(ret);
306  int trackedID = parent.getTrackedID();
307  if (trackedID < 0 || (size_t)trackedID != getGlID()) {
308  new FXMenuCommand(ret, "Start Tracking", 0, ret, MID_START_TRACK);
309  } else {
310  new FXMenuCommand(ret, "Stop Tracking", 0, ret, MID_STOP_TRACK);
311  }
312  new FXMenuCommand(ret, "Select Foes", 0, ret, MID_SHOW_FOES);
313 
314  new FXMenuSeparator(ret);
315  //
317  buildPositionCopyEntry(ret, false);
318  return ret;
319 }
320 
321 
326  new GUIParameterTableWindow(app, *this, 33);
327  // add items
328  ret->mkItem("lane [id]", false, myLane->getID());
329  ret->mkItem("position [m]", true,
331  ret->mkItem("speed [m/s]", true,
333  ret->mkItem("angle [degree]", true,
335  if (getChosenSpeedFactor() != 1) {
336  ret->mkItem("speed factor", false, getChosenSpeedFactor());
337  }
338  ret->mkItem("waiting time [s]", true,
340  ret->mkItem("impatience", true,
342  ret->mkItem("last lane change [s]", true,
344  ret->mkItem("desired depart [s]", false, time2string(getParameter().depart));
345  if (getParameter().repetitionNumber > 0) {
346  ret->mkItem("left same route [#]", false, (unsigned int) getParameter().repetitionNumber);
347  }
348  if (getParameter().repetitionOffset > 0) {
349  ret->mkItem("insertion period [s]", false, time2string(getParameter().repetitionOffset));
350  }
351  ret->mkItem("stop info", false, getStopInfo());
352  ret->mkItem("CO2 (HBEFA) [mg/s]", true,
354  ret->mkItem("CO (HBEFA) [mg/s]", true,
356  ret->mkItem("HC (HBEFA) [mg/s]", true,
358  ret->mkItem("NOx (HBEFA) [mg/s]", true,
360  ret->mkItem("PMx (HBEFA) [mg/s]", true,
362  ret->mkItem("fuel (HBEFA) [ml/s]", true,
364  ret->mkItem("noise (Harmonoise) [dB]", true,
366  ret->mkItem("parameters [key:val]", false, toString(getParameter().getMap()));
367  ret->mkItem("", false, "");
368  ret->mkItem("Type Information:", false, "");
369  ret->mkItem("type [id]", false, myType->getID());
370  ret->mkItem("length", false, myType->getLength());
371  ret->mkItem("minGap", false, myType->getMinGap());
372  ret->mkItem("vehicle class", false, SumoVehicleClassStrings.getString(myType->getVehicleClass()));
373  ret->mkItem("emission class", false, SumoEmissionClassStrings.getString(myType->getEmissionClass()));
374  ret->mkItem("maximum acceleration [m/s^2]", false, getCarFollowModel().getMaxAccel());
375  ret->mkItem("maximum deceleration [m/s^2]", false, getCarFollowModel().getMaxDecel());
376  ret->mkItem("imperfection (sigma)", false, getCarFollowModel().getImperfection());
377  ret->mkItem("reaction time (tau)", false, getCarFollowModel().getHeadwayTime());
378  ret->mkItem("type parameters [key:val]", false, toString(myType->getParameter().getMap()));
379  // close building
380  ret->closeBuilding();
381  return ret;
382 }
383 
384 
385 Boundary
387  Boundary b;
388  b.add(getPosition());
389  b.grow(20);
390  return b;
391 }
392 
393 
394 void
396  glPushMatrix();
397  glScaled(getVehicleType().getWidth(), getVehicleType().getLength(), 1.);
398  glBegin(GL_TRIANGLE_STRIP);
399  glVertex2d(0., 0.);
400  glVertex2d(-.5, .15);
401  glVertex2d(.5, .15);
402  glVertex2d(-.5, 1.);
403  glVertex2d(.5, 1.);
404  glEnd();
405  glPopMatrix();
406 }
407 
408 
409 void
411  const SUMOReal length = getVehicleType().getLength();
412  if (length >= 8.) {
414  return;
415  }
416  glPushMatrix();
417  glScaled(getVehicleType().getWidth(), length, 1.);
418  glBegin(GL_TRIANGLES);
419  glVertex2d(0., 0.);
420  glVertex2d(-.5, 1.);
421  glVertex2d(.5, 1.);
422  glEnd();
423  glPopMatrix();
424 }
425 
426 
427 void
428 GUIVehicle::drawPoly(double* poses, SUMOReal offset) {
429  glPushMatrix();
430  glTranslated(0, 0, offset * .1);
431  glPolygonOffset(0, offset * -1);
432  glBegin(GL_TRIANGLE_FAN);
433  int i = 0;
434  while (poses[i] > -999) {
435  glVertex2d(poses[i], poses[i + 1]);
436  i = i + 2;
437  }
438  glEnd();
439  glPopMatrix();
440 }
441 
442 
443 void
445  RGBColor current = GLHelper::getColor();
446  RGBColor lighter = current.changedBrightness(51);
447  RGBColor darker = current.changedBrightness(-51);
448 
449  const SUMOReal length = getVehicleType().getLength();
450  const SUMOReal width = getVehicleType().getWidth();
451  glPushMatrix();
452  glRotated(90, 0, 0, 1);
453  glScaled(length, width, 1.);
455 
456  // draw main body
457  switch (shape) {
458  case SVS_UNKNOWN:
460  GLHelper::setColor(lighter);
461  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
462  glColor3d(0, 0, 0);
463  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
464  break;
465  case SVS_PEDESTRIAN:
466  glTranslated(0, 0, .045);
468  glTranslated(0, 0, -.045);
469  glScaled(.7, 2, 1);
470  glTranslated(0, 0, .04);
471  GLHelper::setColor(lighter);
473  glTranslated(0, 0, -.04);
474  break;
475  case SVS_BICYCLE:
476  case SVS_MOTORCYCLE: {
477  glPushMatrix();
478  glTranslated(.5, 0, 0);
479  glScaled(.25 / (length), 1, 1.);
480  glTranslated(0, 0, .045);
482  glScaled(.7, 2, 1);
483  glTranslated(0, 0, -.045);
484  glTranslated(0, 0, .04);
485  GLHelper::setColor(lighter);
487  glTranslated(0, 0, -.04);
488  glPopMatrix();
489  }
490  break;
491  case SVS_PASSENGER:
492  case SVS_PASSENGER_SEDAN:
494  case SVS_PASSENGER_WAGON:
496  GLHelper::setColor(lighter);
497  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
498  glColor3d(0, 0, 0);
499  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
500  break;
501  case SVS_PASSENGER_VAN:
502  drawPoly(vehiclePoly_PassengerVanBody, 4);
503  GLHelper::setColor(lighter);
504  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
505  glColor3d(0, 0, 0);
506  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
507  drawPoly(vehiclePoly_PassengerVanRightGlass, 4.5);
508  drawPoly(vehiclePoly_PassengerVanLeftGlass, 4.5);
509  drawPoly(vehiclePoly_PassengerVanBackGlass, 4.5);
510  break;
511  case SVS_DELIVERY:
512  drawPoly(vehiclePoly_PassengerVanBody, 4);
513  GLHelper::setColor(lighter);
514  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
515  glColor3d(0, 0, 0);
516  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
517  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
518  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
519  break;
520  case SVS_TRANSPORT:
523  glScaled(1. / (length), 1, 1.);
524  drawPoly(vehiclePoly_TransportBody, 4);
525  glColor3d(0, 0, 0);
526  drawPoly(vehiclePoly_TransportFrontGlass, 4.5);
527  drawPoly(vehiclePoly_TransportRightGlass, 4.5);
528  drawPoly(vehiclePoly_TransportLeftGlass, 4.5);
529  break;
530  case SVS_BUS:
531  case SVS_BUS_TROLLEY:
533  case SVS_BUS_CITY: {
534  SUMOReal ml = length;
535  glScaled(1. / (length), 1, 1.);
536  glTranslated(0, 0, .04);
537  glBegin(GL_TRIANGLE_FAN);
538  glVertex2d(ml / 2., 0);
539  glVertex2d(0, 0);
540  glVertex2d(0, -.45);
541  glVertex2d(0 + .05, -.5);
542  glVertex2d(ml - .05, -.5);
543  glVertex2d(ml, -.45);
544  glVertex2d(ml, .45);
545  glVertex2d(ml - .05, .5);
546  glVertex2d(0 + .05, .5);
547  glVertex2d(0, .45);
548  glVertex2d(0, 0);
549  glEnd();
550  glTranslated(0, 0, -.04);
551 
552  glTranslated(0, 0, .045);
553  glColor3d(0, 0, 0);
554  glBegin(GL_QUADS);
555  glVertex2d(0 + .05, .48);
556  glVertex2d(0 + .05, -.48);
557  glVertex2d(0 + .15, -.48);
558  glVertex2d(0 + .15, .48);
559 
560  glVertex2d(ml - .1, .45);
561  glVertex2d(ml - .1, -.45);
562  glVertex2d(ml - .05, -.45);
563  glVertex2d(ml - .05, .45);
564 
565  glVertex2d(0 + .20, .49);
566  glVertex2d(0 + .20, .45);
567  glVertex2d(ml - .20, .45);
568  glVertex2d(ml - .20, .49);
569 
570  glVertex2d(0 + .20, -.49);
571  glVertex2d(0 + .20, -.45);
572  glVertex2d(ml - .20, -.45);
573  glVertex2d(ml - .20, -.49);
574 
575  glEnd();
576  glTranslated(0, 0, -.045);
577  }
578  break;
579  case SVS_BUS_OVERLAND:
580  case SVS_RAIL:
581  drawAction_drawRailCarriages(s, 25.0, 1);
582  break;
583  case SVS_RAIL_LIGHT:
585  break;
586  case SVS_RAIL_CITY:
588  break;
589  case SVS_RAIL_SLOW:
590  drawAction_drawRailCarriages(s, 15.0, 1);
591  break;
592  case SVS_RAIL_FAST:
593  drawAction_drawRailCarriages(s, 40.0, 1);
594  break;
595  case SVS_RAIL_CARGO:
597  break;
598  case SVS_E_VEHICLE:
599  drawPoly(vehiclePoly_EVehicleBody, 4);
600  glColor3d(0, 0, 0);
601  drawPoly(vehiclePoly_EVehicleFrontGlass, 4.5);
602  glTranslated(0, 0, .048);
603  GLHelper::setColor(current);
604  glBegin(GL_QUADS);
605  glVertex2d(.3, .5);
606  glVertex2d(.35, .5);
607  glVertex2d(.35, -.5);
608  glVertex2d(.3, -.5);
609 
610  glVertex2d(.3, -.05);
611  glVertex2d(.7, -.05);
612  glVertex2d(.7, .05);
613  glVertex2d(.3, .05);
614 
615  glVertex2d(.7, .5);
616  glVertex2d(.65, .5);
617  glVertex2d(.65, -.5);
618  glVertex2d(.7, -.5);
619  glEnd();
620  glTranslated(0, 0, -.048);
621  //drawPoly(vehiclePoly_EVehicleBackGlass, 4.5);
622  break;
623  case SVS_ANT:
624  glPushMatrix();
625  // ant is stretched via vehicle length
626  GLHelper::setColor(darker);
627  // draw left side
628  GLHelper::drawBoxLine(Position(-0.2, -.10), 350, 0.5, .02);
629  GLHelper::drawBoxLine(Position(-0.3, -.50), 240, 0.4, .03);
630  GLHelper::drawBoxLine(Position(0.3, -.10), 340, 0.8, .03);
631  GLHelper::drawBoxLine(Position(0.05, -.80), 290, 0.6, .04);
632  GLHelper::drawBoxLine(Position(0.4, -.10), 20, 0.8, .03);
633  GLHelper::drawBoxLine(Position(0.65, -.80), 75, 0.6, .04);
634  GLHelper::drawBoxLine(Position(0.5, -.10), 55, 0.8, .04);
635  GLHelper::drawBoxLine(Position(1.1, -.55), 90, 0.6, .04);
636  // draw right side
637  GLHelper::drawBoxLine(Position(-0.2, .10), 190, 0.5, .02);
638  GLHelper::drawBoxLine(Position(-0.3, .50), 300, 0.4, .03);
639  GLHelper::drawBoxLine(Position(0.3, .10), 200, 0.8, .03);
640  GLHelper::drawBoxLine(Position(0.05, .80), 250, 0.6, .04);
641  GLHelper::drawBoxLine(Position(0.4, .10), 160, 0.8, .03);
642  GLHelper::drawBoxLine(Position(0.65, .80), 105, 0.6, .04);
643  GLHelper::drawBoxLine(Position(0.5, .10), 125, 0.8, .04);
644  GLHelper::drawBoxLine(Position(1.1, .55), 90, 0.6, .04);
645  // draw body
646  GLHelper::setColor(current);
647  glTranslated(0, 0, 0.1);
649  glTranslated(.4, 0, 0);
651  glTranslated(.4, 0, 0);
653  glPopMatrix();
654  break;
655  default: // same as passenger
657  glColor3d(1, 1, 1);
658  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
659  glColor3d(0, 0, 0);
660  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
661  break;
662  }
663 
664  // draw decorations
665  switch (shape) {
666  case SVS_PEDESTRIAN:
667  break;
668  case SVS_BICYCLE:
669  //glScaled(length, 1, 1.);
670  glBegin(GL_TRIANGLE_FAN);
671  glVertex2d(1 / 2., 0);
672  glVertex2d(0, 0);
673  glVertex2d(0, -.03);
674  glVertex2d(0 + .05, -.05);
675  glVertex2d(1 - .05, -.05);
676  glVertex2d(1, -.03);
677  glVertex2d(1, .03);
678  glVertex2d(1 - .05, .05);
679  glVertex2d(0 + .05, .05);
680  glVertex2d(0, .03);
681  glVertex2d(0, 0);
682  glEnd();
683  break;
684  case SVS_MOTORCYCLE:
685  //glScaled(length, 1, 1.);
686  glBegin(GL_TRIANGLE_FAN);
687  glVertex2d(1 / 2., 0);
688  glVertex2d(0, 0);
689  glVertex2d(0, -.03);
690  glVertex2d(0 + .05, -.2);
691  glVertex2d(1 - .05, -.2);
692  glVertex2d(1, -.03);
693  glVertex2d(1, .03);
694  glVertex2d(1 - .05, .2);
695  glVertex2d(0 + .05, .2);
696  glVertex2d(0, .03);
697  glVertex2d(0, 0);
698  glEnd();
699  break;
700  case SVS_PASSENGER:
701  case SVS_PASSENGER_SEDAN:
702  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
703  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
704  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
705  break;
707  drawPoly(vehiclePoly_PassengerHatchbackRightGlass, 4.5);
708  drawPoly(vehiclePoly_PassengerHatchbackLeftGlass, 4.5);
709  drawPoly(vehiclePoly_PassengerHatchbackBackGlass, 4.5);
710  break;
711  case SVS_PASSENGER_WAGON:
712  drawPoly(vehiclePoly_PassengerWagonRightGlass, 4.5);
713  drawPoly(vehiclePoly_PassengerWagonLeftGlass, 4.5);
714  drawPoly(vehiclePoly_PassengerWagonBackGlass, 4.5);
715  break;
716  case SVS_PASSENGER_VAN:
717  case SVS_DELIVERY:
718  break;
719  case SVS_TRANSPORT:
720  GLHelper::setColor(current);
721  GLHelper::drawBoxLine(Position(2.3, 0), 90., length - 2.3, .5);
722  break;
724  GLHelper::setColor(current);
725  GLHelper::drawBoxLine(Position(2.8, 0), 90., length - 2.8, .5);
726  break;
727  case SVS_TRANSPORT_1TRAILER: {
728  GLHelper::setColor(current);
729  SUMOReal l = length - 2.3;
730  l = l / 2.;
731  GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
732  GLHelper::drawBoxLine(Position(2.3 + l + .5, 0), 90., l - .5, .5);
733  break;
734  }
735  case SVS_BUS_TROLLEY:
736  glPushMatrix();
737  glTranslated(0, 0, .1);
738  GLHelper::setColor(darker);
739  GLHelper::drawBoxLine(Position(3.8, 0), 90., 1, .3);
740  glTranslated(0, 0, .1);
741  glColor3d(0, 0, 0);
742  GLHelper::drawBoxLine(Position(4.3, .2), 90., 1, .06);
743  GLHelper::drawBoxLine(Position(4.3, -.2), 90., 1, .06);
744  GLHelper::drawBoxLine(Position(5.3, .2), 90., 3, .03);
745  GLHelper::drawBoxLine(Position(5.3, -.2), 90., 3, .03);
746  glPopMatrix();
747  break;
748  case SVS_BUS:
749  case SVS_BUS_CITY:
751  case SVS_BUS_OVERLAND:
752  case SVS_RAIL:
753  case SVS_RAIL_LIGHT:
754  case SVS_RAIL_CITY:
755  case SVS_RAIL_SLOW:
756  case SVS_RAIL_FAST:
757  case SVS_RAIL_CARGO:
758  case SVS_E_VEHICLE:
759  case SVS_ANT:
760  break;
761  default: // same as passenger/sedan
762  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
763  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
764  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
765  break;
766  }
767  /*
768  glBegin(GL_TRIANGLE_FAN);
769  glVertex2d(.5,.5); // center - strip begin
770  glVertex2d(0, .5); // center, front
771  glVertex2d(0, .8); // ... clockwise ... (vehicle right side)
772  glVertex2d(0.08, .94);
773  glVertex2d(0.25, 1.);
774  glVertex2d(0.95, 1.);
775  glVertex2d(1., .9);
776  glVertex2d(1., .1); // (vehicle left side)
777  glVertex2d(0.95, 0.);
778  glVertex2d(0.25, 0.);
779  glVertex2d(0.08, .06);
780  glVertex2d(0, .2); //
781  glVertex2d(0, .5); // center, front (close)
782  glEnd();
783 
784  glPolygonOffset(0, -4.5);
785  glColor3d(1, 1, 1); // front
786  glBegin(GL_TRIANGLE_FAN);
787  glVertex2d(0.1,0.5);
788  glVertex2d(0.025,0.5);
789  glVertex2d(0.025,0.75);
790  glVertex2d(0.27,0.9);
791  glVertex2d(0.27,0.1);
792  glVertex2d(0.025,0.25);
793  glVertex2d(0.025,0.5);
794  glEnd();
795 
796  glColor3d(0, 0, 0); // front glass
797  glBegin(GL_TRIANGLE_FAN);
798  glVertex2d(0.35,0.5);
799  glVertex2d(0.3,0.5);
800  glVertex2d(0.3,0.9);
801  glVertex2d(0.43,0.8);
802  glVertex2d(0.43,0.2);
803  glVertex2d(0.3,0.1);
804  glVertex2d(0.3,0.5);
805  glEnd();
806 
807  glBegin(GL_TRIANGLE_FAN); // back glass
808  glVertex2d(0.92,0.5);
809  glVertex2d(0.90,0.5);
810  glVertex2d(0.90,0.8);
811  glVertex2d(0.95,0.9);
812  glVertex2d(0.95,0.1);
813  glVertex2d(0.90,0.2);
814  glVertex2d(0.90,0.5);
815  glEnd();
816 
817  glBegin(GL_TRIANGLE_FAN); // right glass
818  glVertex2d(0.36,0.07);
819  glVertex2d(0.34,0.03);
820  glVertex2d(0.94,0.03);
821  glVertex2d(0.87,0.13);
822  glVertex2d(0.45,0.13);
823  glVertex2d(0.34,0.03);
824  glEnd();
825 
826  glBegin(GL_TRIANGLE_FAN); // left glass
827  glVertex2d(0.36,1.-0.07);
828  glVertex2d(0.34,1.-0.03);
829  glVertex2d(0.94,1.-0.03);
830  glVertex2d(0.87,1.-0.13);
831  glVertex2d(0.45,1.-0.13);
832  glVertex2d(0.34,1.-0.03);
833  glEnd();
834  */
835 
836  glPopMatrix();
837 }
838 
839 
840 bool
842  const std::string& file = getVehicleType().getImgFile();
843  if (file != "") {
844  int textureID = GUITexturesHelper::getTextureID(file);
845  if (textureID > 0) {
846  if (length < 0) {
848  }
849  const SUMOReal halfWidth = getVehicleType().getWidth() / 2.0 * s.vehicleExaggeration;
850  GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, 0, halfWidth, length);
851  return true;
852  }
853  }
854  return false;
855 }
856 
857 
858 #define BLINKER_POS_FRONT .5
859 #define BLINKER_POS_BACK .5
860 
861 inline void
862 drawAction_drawBlinker(const GUIVehicle& veh, double dir) {
863  glColor3d(1.f, .8f, 0);
864  glPushMatrix();
865  glTranslated(dir, BLINKER_POS_FRONT, -0.1);
867  glPopMatrix();
868  glPushMatrix();
869  glTranslated(dir, veh.getVehicleType().getLength() - BLINKER_POS_BACK, -0.1);
871  glPopMatrix();
872 }
873 
874 
875 inline void
878  return;
879  }
880  const double offset = MAX2(.5 * veh.getVehicleType().getWidth(), .4);
882  drawAction_drawBlinker(veh, -offset);
883  }
885  drawAction_drawBlinker(veh, offset);;
886  }
888  drawAction_drawBlinker(veh, -offset);
889  drawAction_drawBlinker(veh, offset);
890  }
891 }
892 
893 
894 inline void
897  return;
898  }
899  glColor3f(1.f, .2f, 0);
900  glPushMatrix();
901  glTranslated(-veh.getVehicleType().getWidth() * 0.5, veh.getVehicleType().getLength(), -0.1);
903  glPopMatrix();
904  glPushMatrix();
905  glTranslated(veh.getVehicleType().getWidth() * 0.5, veh.getVehicleType().getLength(), -0.1);
907  glPopMatrix();
908 }
909 
910 
911 void
913  glPushName(getGlID());
914  glPushMatrix();
915  Position p1 = getPosition();
916  // one seat in the center of the vehicle by default
918  glTranslated(p1.x(), p1.y(), getType());
919  glRotated(getAngle(), 0, 0, 1);
920  // set lane color
921  setColor(s);
922  // scale
923  SUMOReal upscale = s.vehicleExaggeration;
924  glScaled(upscale, upscale, 1);
925  /*
926  MSLCM_DK2004 &m2 = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
927  if((m2.getState()&LCA_URGENT)!=0) {
928  glColor3d(1, .4, .4);
929  } else if((m2.getState()&LCA_SPEEDGAIN)!=0) {
930  glColor3d(.4, .4, 1);
931  } else {
932  glColor3d(.4, 1, .4);
933  }
934  */
935  // draw the vehicle
936  switch (s.vehicleQuality) {
937  case 0:
939  break;
940  case 1:
942  break;
943  case 2:
945  break;
946  case 3:
947  default:
948  // draw as image but take special care for drawing trains
949  // XXX handle default carriage lenghts someplace else
950  switch (getVehicleType().getGuiShape()) {
951  case SVS_RAIL:
952  drawAction_drawRailCarriages(s, 25.0, 1, true);
953  break;
954  case SVS_RAIL_LIGHT:
955  drawAction_drawRailCarriages(s, 38.0, true);
956  break;
957  case SVS_RAIL_CITY:
958  drawAction_drawRailCarriages(s, 25.0, true);
959  break;
960  case SVS_RAIL_SLOW:
961  drawAction_drawRailCarriages(s, 15.0, 1, true);
962  break;
963  case SVS_RAIL_FAST:
964  drawAction_drawRailCarriages(s, 40.0, 1, true);
965  break;
966  case SVS_RAIL_CARGO:
967  drawAction_drawRailCarriages(s, 20.0, true);
968  break;
969  default:
970  // draw normal vehicle
973  };
974  };
975  break;
976  }
977  if (s.drawMinGap) {
978  SUMOReal minGap = -getVehicleType().getMinGap();
979  glColor3d(0., 1., 0.);
980  glBegin(GL_LINES);
981  glVertex2d(0., 0);
982  glVertex2d(0., minGap);
983  glVertex2d(-.5, minGap);
984  glVertex2d(.5, minGap);
985  glEnd();
986  }
987  // draw the blinker and brakelights if wished
988  if (s.showBlinker) {
989  glTranslated(0, 0, .1);
990  switch (getVehicleType().getGuiShape()) {
991  case SVS_PEDESTRIAN:
992  case SVS_BICYCLE:
993  case SVS_ANT:
994  case SVS_RAIL:
995  case SVS_RAIL_LIGHT:
996  case SVS_RAIL_SLOW:
997  case SVS_RAIL_FAST:
998  case SVS_RAIL_CARGO:
999  // only SVS_RAIL_CITY has blinkers and brake lights
1000  break;
1001  default:
1004  break;
1005  }
1006  }
1007  // draw the wish to change the lane
1008  if (s.drawLaneChangePreference) {
1009  /*
1010  if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
1011  MSLCM_DK2004 &m = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
1012  glColor3d(.5, .5, 1);
1013  glBegin(GL_LINES);
1014  glVertex2f(0, 0);
1015  glVertex2f(m.getChangeProbability(), .5);
1016  glEnd();
1017 
1018  glColor3d(1, 0, 0);
1019  glBegin(GL_LINES);
1020  glVertex2f(0.1, 0);
1021  glVertex2f(0.1, m.myMaxJam1);
1022  glEnd();
1023 
1024  glColor3d(0, 1, 0);
1025  glBegin(GL_LINES);
1026  glVertex2f(-0.1, 0);
1027  glVertex2f(-0.1, m.myTDist);
1028  glEnd();
1029  }
1030  */
1031  }
1032  // draw best lanes
1033  /*
1034  if (true) {
1035  const MSLane &l = veh->getLane();
1036  SUMOReal r1 = veh->allowedContinuationsLength(&l, 0);
1037  SUMOReal r2 = l.getLeftLane()!=0 ? veh->allowedContinuationsLength(l.getLeftLane(), 0) : 0;
1038  SUMOReal r3 = l.getRightLane()!=0 ? veh->allowedContinuationsLength(l.getRightLane(), 0) : 0;
1039  SUMOReal mmax = MAX3(r1, r2, r3);
1040  glBegin(GL_LINES);
1041  glVertex2f(0, 0);
1042  glVertex2f(0, r1/mmax/2.);
1043  glEnd();
1044  glBegin(GL_LINES);
1045  glVertex2f(.4, 0);
1046  glVertex2f(.4, r2/mmax/2.);
1047  glEnd();
1048  glBegin(GL_LINES);
1049  glVertex2f(-.4, 0);
1050  glVertex2f(-.4, r3/mmax/2.);
1051  glEnd();
1052  }
1053  */
1054  glPopMatrix();
1055  drawName(getPosition(-MIN2(getVehicleType().getLength() / 2, SUMOReal(5))),
1056  s.scale,
1057  getVehicleType().getGuiShape() == SVS_PEDESTRIAN ? s.personName : s.vehicleName);
1058  glPopName();
1059  if (myPersonDevice != 0) {
1060  const std::vector<MSPerson*>& ps = myPersonDevice->getPersons();
1061  size_t personIndex = 0;
1062  for (std::vector<MSPerson*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
1063  GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
1064  assert(person != 0);
1065  person->setPositionInVehicle(getSeatPosition(personIndex++));
1066  person->drawGL(s);
1067  }
1068  }
1069 }
1070 
1071 
1072 void
1074  glPushName(getGlID());
1075  glPushMatrix();
1076  glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
1078  drawBestLanes();
1079  }
1081  drawRoute(s, 0, 0.25);
1082  }
1084  if (getNumberReroutes() > 0) {
1085  const int noReroutePlus1 = getNumberReroutes() + 1;
1086  for (int i = noReroutePlus1 - 1; i >= 0; i--) {
1087  SUMOReal darken = SUMOReal(0.4) / SUMOReal(noReroutePlus1) * SUMOReal(i);
1088  drawRoute(s, i, darken);
1089  }
1090  } else {
1091  drawRoute(s, 0, 0.25);
1092  }
1093  }
1095  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
1096  if ((*i).myLink == 0) {
1097  continue;
1098  }
1099  MSLink* link = (*i).myLink;
1100  MSLane* via = link->getViaLaneOrLane();
1101  if (via != 0) {
1102  Position p = via->getShape()[0];
1103  if ((*i).mySetRequest) {
1104  glColor3d(0, .8, 0);
1105  } else {
1106  glColor3d(.8, 0, 0);
1107  }
1108  const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
1109  (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(), getVehicleType().getLengthWithGap());
1110  drawLinkItem(p, (*i).myArrivalTime, leaveTime, s.addExaggeration);
1111  // the time slot that ego vehicle uses when checking opened may
1112  // differ from the one it requests in setApproaching
1113  MSLink::ApproachingVehicleInformation avi = (*i).myLink->getApproaching(this);
1114  assert(avi.arrivalTime == (*i).myArrivalTime && avi.leavingTime == leaveTime);
1115  }
1116  }
1117  }
1118  glPopMatrix();
1119  glPopName();
1120 }
1121 
1122 
1123 void
1124 GUIVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate) {
1125  glTranslated(pos.x(), pos.y(), -.1);
1127  std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
1128  GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
1129  glTranslated(-pos.x(), -pos.y(), .1);
1130 }
1131 
1132 const std::vector<MSVehicle::LaneQ>&
1134  myLock.lock();
1135  const std::vector<MSVehicle::LaneQ>& ret = MSVehicle::getBestLanes();
1136  myLock.unlock();
1137  return ret;
1138 }
1139 
1140 
1141 void
1143  const GUIColorer& c = s.vehicleColorer;
1144  if (!setFunctionalColor(c.getActive())) {
1146  }
1147 }
1148 
1149 
1150 bool
1151 GUIVehicle::setFunctionalColor(size_t activeScheme) const {
1152  switch (activeScheme) {
1153  case 0: {
1154  if (getParameter().wasSet(VEHPARS_COLOR_SET)) {
1156  return true;
1157  }
1158  if (getVehicleType().wasSet(VTYPEPARS_COLOR_SET)) {
1159  GLHelper::setColor(getVehicleType().getColor());
1160  return true;
1161  }
1162  if (&getRoute().getColor() != &RGBColor::DEFAULT_COLOR) {
1163  GLHelper::setColor(getRoute().getColor());
1164  return true;
1165  }
1166  return false;
1167  }
1168  case 2: {
1169  if (getParameter().wasSet(VEHPARS_COLOR_SET)) {
1171  return true;
1172  }
1173  return false;
1174  }
1175  case 3: {
1176  if (getVehicleType().wasSet(VTYPEPARS_COLOR_SET)) {
1177  GLHelper::setColor(getVehicleType().getColor());
1178  return true;
1179  }
1180  return false;
1181  }
1182  case 4: {
1183  if (&getRoute().getColor() != &RGBColor::DEFAULT_COLOR) {
1184  GLHelper::setColor(getRoute().getColor());
1185  return true;
1186  }
1187  return false;
1188  }
1189  case 5: {
1190  Position p = getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1191  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1192  Position center = b.getCenter();
1193  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1194  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1195  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1196  return true;
1197  }
1198  case 6: {
1199  Position p = getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1200  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1201  Position center = b.getCenter();
1202  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1203  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1204  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1205  return true;
1206  }
1207  case 7: {
1208  Position pb = getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1209  Position pe = getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1210  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1211  SUMOReal hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / PI;
1212  Position minp(b.xmin(), b.ymin());
1213  Position maxp(b.xmax(), b.ymax());
1214  SUMOReal sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1215  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1216  return true;
1217  }
1218  }
1219  return false;
1220 }
1221 
1222 
1223 SUMOReal
1224 GUIVehicle::getColorValue(size_t activeScheme) const {
1225  switch (activeScheme) {
1226  case 8:
1227  return getSpeed();
1228  case 9:
1229  return getWaitingSeconds();
1230  case 10:
1231  return getLastLaneChangeOffset();
1232  case 11:
1233  return getMaxSpeed();
1234  case 12:
1235  return getHBEFA_CO2Emissions();
1236  case 13:
1237  return getHBEFA_COEmissions();
1238  case 14:
1239  return getHBEFA_PMxEmissions();
1240  case 15:
1241  return getHBEFA_NOxEmissions();
1242  case 16:
1243  return getHBEFA_HCEmissions();
1244  case 17:
1245  return getHBEFA_FuelConsumption();
1246  case 18:
1248  case 19:
1249  if (getNumberReroutes() == 0) {
1250  return -1;
1251  }
1252  return getNumberReroutes();
1253  case 20:
1255  case 21:
1256  return getBestLaneOffset();
1257  case 22:
1258  return getAcceleration();
1259  }
1260  return 0;
1261 }
1262 
1263 
1264 // ------------ Additional visualisations
1265 bool
1267  return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
1268 }
1269 
1270 
1271 void
1273  if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
1274  myAdditionalVisualizations[parent] = 0;
1275  }
1276  myAdditionalVisualizations[parent] |= which;
1277  parent->addAdditionalGLVisualisation(this);
1278 }
1279 
1280 
1281 void
1283  myAdditionalVisualizations[parent] &= ~which;
1284  parent->removeAdditionalGLVisualisation(this);
1285 }
1286 
1287 
1288 void
1289 GUIVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const {
1290  setColor(s);
1291  GLdouble colors[4];
1292  glGetDoublev(GL_CURRENT_COLOR, colors);
1293  colors[0] -= darken;
1294  if (colors[0] < 0) {
1295  colors[0] = 0;
1296  }
1297  colors[1] -= darken;
1298  if (colors[1] < 0) {
1299  colors[1] = 0;
1300  }
1301  colors[2] -= darken;
1302  if (colors[2] < 0) {
1303  colors[2] = 0;
1304  }
1305  colors[3] -= darken;
1306  if (colors[3] < 0) {
1307  colors[3] = 0;
1308  }
1309  glColor3dv(colors);
1310  if (routeNo == 0) {
1312  return;
1313  }
1314  --routeNo; // only prior routes are stored
1316 }
1317 
1318 
1319 void
1321  myLock.lock();
1322  std::vector<std::vector<MSVehicle::LaneQ> > bestLanes = myBestLanes;
1323  myLock.unlock();
1324  SUMOReal width = 0.5;
1325  for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
1326  std::vector<MSVehicle::LaneQ>& lanes = *j;
1327  SUMOReal gmax = -1;
1328  SUMOReal rmax = -1;
1329  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1330  gmax = MAX2((*i).length, gmax);
1331  rmax = MAX2((*i).occupation, rmax);
1332  }
1333  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1334  const PositionVector& shape = (*i).lane->getShape();
1335  SUMOReal g = (*i).length / gmax;
1336  SUMOReal r = (*i).occupation / rmax;
1337  glColor3d(r, g, 0);
1338  GLHelper::drawBoxLines(shape, width);
1339 
1340  PositionVector s1 = shape;
1341  s1.move2side((SUMOReal) .1);
1342  glColor3d(r, 0, 0);
1343  GLHelper::drawLine(s1);
1344  s1.move2side((SUMOReal) - .2);
1345  glColor3d(0, g, 0);
1346  GLHelper::drawLine(s1);
1347 
1348  glColor3d(r, g, 0);
1349  Position lastPos = shape[-1];
1350  }
1351  width = .2;
1352  }
1353 }
1354 
1355 
1356 void
1357 GUIVehicle::drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const {
1358  MSRouteIterator i = r.begin();
1359  const std::vector<MSLane*>& bestLaneConts = getBestLanesContinuation();
1360  // draw continuation lanes when drawing the current route where available
1361  size_t bestLaneIndex = (&r == myRoute ? 0 : bestLaneConts.size());
1362  for (; i != r.end(); ++i) {
1363  const GUILane* lane;
1364  if (bestLaneIndex < bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) {
1365  lane = static_cast<GUILane*>(bestLaneConts[bestLaneIndex]);
1366  ++bestLaneIndex;
1367  } else {
1368  lane = static_cast<GUILane*>((*i)->getLanes()[0]);
1369  }
1370  GLHelper::drawBoxLines(lane->getShape(), lane->getShapeRotations(), lane->getShapeLengths(), exaggeration);
1371  }
1372 }
1373 
1374 
1375 MSLane*
1376 GUIVehicle::getPreviousLane(MSLane* current, int& routeIndex) const {
1377  const bool isInternal = current->getEdge().getPurpose() == MSEdge::EDGEFUNCTION_INTERNAL;
1378  if (isInternal) {
1379  // route pointer still points to the previous lane
1380  return myRoute->getEdges()[routeIndex]->getLanes()[0];
1381  } else if (routeIndex == 0) {
1382  // there is no previous lane because the route has just begun
1383  return current;
1384  } else {
1385  // retrieve the previous internal edge
1386  routeIndex -= 1;
1387  const MSEdge* previous = myRoute->getEdges()[routeIndex];
1388 #ifdef HAVE_INTERNAL_LANES
1389  const MSEdge* previousInternal = previous->getInternalFollowingEdge(&current->getEdge());
1390 #else
1391  const MSEdge* previousInternal = 0;
1392 #endif
1393  if (previousInternal != 0) {
1394  return previousInternal->getLanes()[0];
1395  } else {
1396  // network without internal links, use previous edge instead
1397  return previous->getLanes()[0];
1398  }
1399  }
1400 }
1401 
1402 
1403 void
1404 GUIVehicle::drawAction_drawRailCarriages(const GUIVisualizationSettings& s, SUMOReal defaultLength, int firstPassengerCarriage, bool asImage) const {
1405  RGBColor current = GLHelper::getColor();
1406  RGBColor darker = current.changedBrightness(-51);
1407  const SUMOReal length = getVehicleType().getLength() * s.vehicleExaggeration;
1408  const SUMOReal halfWidth = getVehicleType().getWidth() / 2.0 * s.vehicleExaggeration;
1409  glPopMatrix(); // undo scaling and 90 degree rotation
1410  glPopMatrix(); // undo initial translation and rotation
1411  glPushMatrix();
1412  glPushMatrix();
1413  GLHelper::setColor(darker);
1414  const SUMOReal carriageGap = 1;
1415  const SUMOReal xCornerCut = 0.3;
1416  const SUMOReal yCornerCut = 0.4;
1417  // round to closest integer
1418  const int numCarriages = floor(length / (defaultLength + carriageGap) + 0.5);
1419  assert(numCarriages > 0);
1420  const SUMOReal carriageLengthWithGap = length / numCarriages;
1421  const SUMOReal carriageLength = carriageLengthWithGap - carriageGap;
1422  // lane on which the carriage front is situated
1423  MSLane* lane = myLane;
1424  int routeIndex = myCurrEdge - myRoute->begin();
1425  // lane on which the carriage back is situated
1426  MSLane* backLane = myLane;
1427  int backRouteIndex = routeIndex;
1428  // offsets of front and back
1429  SUMOReal carriageOffset = myState.pos();
1430  SUMOReal carriageBackOffset = myState.pos() - carriageLength;
1431  // handle seats
1432  int requiredSeats = getNumPassengers();
1433  if (requiredSeats > 0) {
1434  mySeatPositions.clear();
1435  }
1436  // draw individual carriages
1437  for (int i = 0; i < numCarriages; ++i) {
1438  while (carriageOffset < 0) {
1439  lane = getPreviousLane(lane, routeIndex);
1440  carriageOffset += lane->getLength();
1441  }
1442  while (carriageBackOffset < 0) {
1443  backLane = getPreviousLane(backLane, backRouteIndex);
1444  carriageBackOffset += backLane->getLength();
1445  }
1446  const Position front = lane->getShape().positionAtOffset2D(carriageOffset);
1447  const Position back = backLane->getShape().positionAtOffset2D(carriageBackOffset);
1448  const SUMOReal angle = atan2((front.x() - back.x()), (back.y() - front.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
1449  if (i >= firstPassengerCarriage) {
1450  computeSeats(front, back, requiredSeats);
1451  }
1452  glPushMatrix();
1453  glTranslated(front.x(), front.y(), getType());
1454  glRotated(angle, 0, 0, 1);
1455  if (!asImage || !drawAction_drawVehicleAsImage(s, carriageLength)) {
1456  glBegin(GL_TRIANGLE_FAN);
1457  glVertex2d(-halfWidth + xCornerCut, 0);
1458  glVertex2d(-halfWidth, yCornerCut);
1459  glVertex2d(-halfWidth, carriageLength - yCornerCut);
1460  glVertex2d(-halfWidth + xCornerCut, carriageLength);
1461  glVertex2d(halfWidth - xCornerCut, carriageLength);
1462  glVertex2d(halfWidth, carriageLength - yCornerCut);
1463  glVertex2d(halfWidth, yCornerCut);
1464  glVertex2d(halfWidth - xCornerCut, 0);
1465  glEnd();
1466  }
1467  glPopMatrix();
1468  carriageOffset -= carriageLengthWithGap;
1469  carriageBackOffset -= carriageLengthWithGap;
1470  GLHelper::setColor(current);
1471  }
1472 }
1473 
1474 
1475 const Position&
1476 GUIVehicle::getSeatPosition(size_t personIndex) const {
1478  return mySeatPositions[(int)MIN2(personIndex, mySeatPositions.size() - 1)];
1479 }
1480 
1481 
1482 int
1484  if (myPersonDevice != 0) {
1485  return (int)myPersonDevice->getPersons().size();
1486  }
1487  return 0;
1488 }
1489 
1490 
1491 void
1492 GUIVehicle::computeSeats(const Position& front, const Position& back, int& requiredSeats) const {
1493  if (requiredSeats <= 0) {
1494  return; // save some work
1495  }
1496  const Line l(front, back);
1497  const SUMOReal length = l.length2D();
1498  if (length < 4) {
1499  // small vehicle, sit at the center
1501  requiredSeats--;
1502  } else {
1503  for (SUMOReal p = 2; p <= length - 1; p += 1) {
1505  requiredSeats--;
1506  }
1507  }
1508 }
1509 
1510 
1511 SUMOReal
1514 }
1515 
1516 
1517 std::string
1519  std::string result = "";
1520  if (isParking()) {
1521  result += "parking";
1522  } else if (isStopped()) {
1523  result += "stopped";
1524  } else {
1525  return "";
1526  }
1527  if (myStops.front().triggered) {
1528  result += ", triggered";
1529  } else {
1530  result += ", duration=" + time2string(myStops.front().duration);
1531  }
1532  return result;
1533 }
1534 
1535 
1536 void
1538  if (myLFLinkLanes.size() == 0) {
1539  return;
1540  }
1541  const DriveProcessItem& dpi = myLFLinkLanes[0];
1542  if (dpi.myLink == 0) {
1543  return;
1544  }
1545  std::vector<const SUMOVehicle*> blockingFoes;
1547  getImpatience(), getCarFollowModel().getMaxDecel(), getWaitingTime(), &blockingFoes);
1548  for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
1549  gSelected.select(static_cast<const GUIVehicle*>(*it)->getGlID());
1550  }
1551 #ifdef HAVE_INTERNAL_LANES
1552  const MSLink::LinkLeaders linkLeaders = (dpi.myLink)->getLeaderInfo(myLane->getLength() - getPositionOnLane(), getVehicleType().getMinGap());
1553  for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1554  // the vehicle to enter the junction first has priority
1555  const MSVehicle* leader = it->first;
1556  if ((static_cast<const GUIVehicle*>(leader))->myLinkLeaders.count(getID()) == 0) {
1557  // leader isn't already following us, now we follow it
1558  gSelected.select(static_cast<const GUIVehicle*>(leader)->getGlID());
1559  }
1560  }
1561 #endif
1562 }
1563 
1564 
1565 #ifdef HAVE_OSG
1566 void
1567 GUIVehicle::updateColor(GUIOSGView* view) {
1568  const GUIVisualizationSettings* s = view->getVisualisationSettings();
1570  myGeom[view]->setColor(osg::Vec4(col.red() / 255., col.green() / 255., col.blue() / 255., col.alpha() / 255.));
1571 }
1572 #endif
1573 
1574 /****************************************************************************/
1575 
float vehicleExaggeration
The vehicle exaggeration (upscale)
SUMOReal length2D() const
Definition: Line.cpp:177
bool signalSet(int which) const
Returns whether the given signal is on.
Definition: MSVehicle.h:765
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIVehicle.cpp:323
render as a light rail
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
virtual const std::vector< LaneQ > & getBestLanes(bool forceRebuild=false, MSLane *startLane=0) const
Returns the description of best lanes to use in order to continue the route.
Definition: MSVehicle.cpp:1673
void selectBlockingFoes() const
adds the blocking foes to the current selection
const MSVehicleType * myType
This Vehicle&#39;s type.
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
const std::vector< SUMOReal > & getShapeRotations() const
Definition: GUILane.cpp:668
render as a rail
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:447
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
unsigned int getNumberReroutes() const
Returns the number of new routes this vehicle got.
double vehiclePoly_TransportFrontGlass[]
Definition: GUIVehicle.cpp:125
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIVehicle.cpp:277
MoveReminderCont myMoveReminders
Current lane&#39;s move reminder.
const RGBColor getColor(const SUMOReal value) const
SUMOReal getHBEFA_HCEmissions() const
Returns HC emission of the current state.
Definition: MSVehicle.cpp:2028
static RGBColor fromHSV(SUMOReal h, SUMOReal s, SUMOReal v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:273
bool showBlinker
Information whether vehicle blinkers shall be drawn.
SUMOReal getImpatience() const
Returns this vehicles impatience.
Definition: MSVehicle.cpp:2134
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
std::vector< std::vector< LaneQ > > myBestLanes
Definition: MSVehicle.h:1032
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:106
const MSCFModel & getCarFollowModel() const
Returns the vehicle&#39;s car following model definition.
Definition: MSVehicle.h:510
State myState
This Vehicles driving state (pos and speed)
Definition: MSVehicle.h:1022
a vehicles
GUIVisualizationTextSettings personName
const Position geometryPositionAtOffset(SUMOReal offset) const
Definition: MSLane.h:335
SUMOReal getMaxSpeed() const
Returns the maximum speed.
DriveItemVector myLFLinkLanes
Container for used Links/visited Lanes during lookForward.
Definition: MSVehicle.h:1116
SUMOReal pos() const
Position of this state.
Definition: MSVehicle.cpp:133
render as a slow (passenger) train
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:168
MSLane * getPreviousLane(MSLane *current, int &routeIndex) const
void drawAction_drawVehicleBlinker(const GUIVehicle &veh)
Definition: GUIVehicle.cpp:876
SUMOReal getLengthWithGap() const
Get vehicle&#39;s length including the minimum gap [m].
render as a motorcycle
SUMOReal getHBEFA_NOxEmissions() const
Returns NOx emission of the current state.
Definition: MSVehicle.cpp:2034
void drawBestLanes() const
Draws the vehicle&#39;s best lanes.
SUMOReal getLeaveSpeed() const
Definition: MSVehicle.h:1108
MSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:59
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:341
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
Stores the information about how to visualize structures.
SUMOReal getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:365
Position getPosition(const SUMOReal offset=0) const
Return current position (x/y, cartesian)
Definition: MSVehicle.cpp:577
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
Position getPositionAtDistance2D(SUMOReal offset) const
Definition: Line.cpp:105
track vehicle
Definition: GUIVehicle.h:256
bool drawLaneChangePreference
Information whether the lane change preference shall be drawn.
render as a city bus
double vehiclePoly_EVehicleBody[]
Definition: GUIVehicle.cpp:129
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:112
bool hasActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) const
Returns whether the named feature is enabled in the given view.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:61
GUIVisualizationTextSettings vehicleName
SUMOReal getLength() const
Get vehicle&#39;s length [m].
const MSEdgeVector & getEdges() const
Definition: MSRoute.h:122
SUMOReal getLastLaneChangeOffset() const
Returns the time since the last lane change in seconds.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
double vehiclePoly_TransportBody[]
Definition: GUIVehicle.cpp:124
render as a fast (passenger) train
bool addAdditionalGLVisualisation(GUIGlObject *const which)
Adds an object to call its additional visualisation method.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:150
T MAX2(T a, T b)
Definition: StdDefs.h:63
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:386
const MSRoute & getRoute() const
Returns the current route.
Definition: MSBaseVehicle.h:86
render as a delivery vehicle
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
const MSRoute * myRoute
This Vehicle&#39;s route.
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
render as a sedan passenger vehicle (&quot;Stufenheck&quot;)
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
const std::vector< SUMOReal > & getShapeLengths() const
Definition: GUILane.cpp:674
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:208
SUMOReal getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MSVehicle.h:283
static void drawText(const std::string &text, const Position &pos, const SUMOReal layer, const SUMOReal size, const RGBColor &col=RGBColor::BLACK, const SUMOReal angle=0)
draw Text with given parameters
Definition: GLHelper.cpp:318
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
Show vehicle&#39;s current route.
Definition: GUIAppEnum.h:235
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, SUMOReal length=-1) const
Definition: GUIVehicle.cpp:841
double vehiclePoly_PassengerWagonRightGlass[]
Definition: GUIVehicle.cpp:110
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
long onCmdHideAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:161
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:115
double vehiclePoly_PassengerVanRightGlass[]
Definition: GUIVehicle.cpp:117
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:118
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
double vehiclePoly_PassengerHatchbackRightGlass[]
Definition: GUIVehicle.cpp:107
bool setFunctionalColor(size_t activeScheme) const
sets the color according to the current scheme index and some vehicle function
FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[]
The car-following model and parameter.
Definition: MSVehicleType.h:74
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:1661
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
double vehiclePoly_PassengerCarBody[]
Definition: GUIVehicle.cpp:101
size_t getActive() const
Definition: GUIColorer.h:72
std::string getStopInfo() const
retrieve information about the current stop state
Right blinker lights are switched on.
Definition: MSVehicle.h:687
render as a semi-trailer transport vehicle (&quot;Sattelschlepper&quot;)
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:70
double vehiclePoly_PassengerFrontGlass[]
Definition: GUIVehicle.cpp:103
long onCmdHideCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:178
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:91
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:231
GUIColorer vehicleColorer
The vehicle colorer.
virtual int getTrackedID() const
select foes of a vehicle
Definition: GUIAppEnum.h:251
static void drawFilledCircle(SUMOReal width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:196
const std::string & getID() const
Returns the id.
Definition: Named.h:60
A road/street connecting two junctions.
Definition: MSEdge.h:73
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:159
double vehiclePoly_PassengerCarBodyFront[]
Definition: GUIVehicle.cpp:102
void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
Definition: GUIVehicle.cpp:444
bool removeAdditionalGLVisualisation(GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
long onCmdShowCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
Definition: GUIVehicle.cpp:169
static const RGBColor GREEN
Definition: RGBColor.h:189
Left blinker lights are switched on.
Definition: MSVehicle.h:689
SUMOReal getHBEFA_COEmissions() const
Returns CO emission of the current state.
Definition: MSVehicle.cpp:2022
void drawAction_drawVehicleAsTrianglePlus() const
Definition: GUIVehicle.cpp:410
#define PI
Definition: polyfonts.c:57
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2)
float addExaggeration
The additional structures exaggeration (upscale)
const SUMOVTypeParameter & getParameter() const
static void drawTexturedBox(unsigned int which, SUMOReal size)
Draws a named texture as a box with the given size.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:301
render as a hatchback passenger vehicle (&quot;Fliessheck&quot;)
double vehiclePoly_EVehicleBackGlass[]
Definition: GUIVehicle.cpp:132
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
StringBijection< SUMOEmissionClass > SumoEmissionClassStrings(SumoEmissionClassStringInitializer, SVE_P_LDV_A0_14_14)
render as a bus
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the subpart of best lanes that describes the vehicle&#39;s current lane and their successors...
Definition: MSVehicle.cpp:1946
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
bool drawMinGap
Information whether the minimum gap shall be drawn.
GUIVehiclePopupMenu()
default constructor needed by FOX
Definition: GUIVehicle.h:238
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:198
not defined
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:99
render as a bicycle
double vehiclePoly_EVehicleFrontGlass[]
Definition: GUIVehicle.cpp:130
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
Definition: GUIVehicle.h:262
std::list< Stop > myStops
The vehicle&#39;s list of stops.
Definition: MSVehicle.h:1037
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
bool isStopped() const
Returns whether the vehicle is at a stop.
Definition: MSVehicle.cpp:701
double vehiclePoly_TransportLeftGlass[]
Definition: GUIVehicle.cpp:127
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
MSLane * myLane
The lane the vehicle is on.
Definition: MSVehicle.h:1025
Blinker lights on both sides are switched on.
Definition: MSVehicle.h:691
~GUIVehicle()
destructor
Definition: GUIVehicle.cpp:260
void setPositionInVehicle(const Position &pos)
Definition: GUIPerson.h:120
Definition: Line.h:51
double vehiclePoly_DeliveryMediumLeftGlass[]
Definition: GUIVehicle.cpp:122
T MIN2(T a, T b)
Definition: StdDefs.h:57
double vehiclePoly_PassengerWagonBackGlass[]
Definition: GUIVehicle.cpp:112
SUMOReal getHBEFA_PMxEmissions() const
Returns PMx emission of the current state.
Definition: MSVehicle.cpp:2040
static void drawPoly(double *poses, SUMOReal offset)
Definition: GUIVehicle.cpp:428
The brake lights are on.
Definition: MSVehicle.h:693
GUIVehicle(SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, SUMOReal speedFactor)
Constructor.
Definition: GUIVehicle.cpp:248
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
void drawAction_drawVehicleBrakeLight(const GUIVehicle &veh)
Definition: GUIVehicle.cpp:895
int getNumPassengers() const
return the number of passengers
Show all vehicle&#39;s routes.
Definition: GUIAppEnum.h:243
const std::vector< MSPerson * > & getPersons() const
Returns the list of persons using this vehicle.
render as a van
SUMOReal getMaxDecel() const
Get the vehicle type&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:165
#define BLINKER_POS_BACK
Definition: GUIVehicle.cpp:859
Stop to track a vehicle.
Definition: GUIAppEnum.h:249
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width)
Draws thick lines.
Definition: GLHelper.cpp:106
render as a passenger vehicle
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:51
const int VEHPARS_COLOR_SET
bool isParking() const
Returns whether the vehicle is parking.
Definition: MSVehicle.cpp:707
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
Definition: GUIVehicle.h:353
SUMOReal getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
Definition: MSVehicle.cpp:2052
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIPerson.cpp:159
SUMOVehicleShape getGuiShape() const
Get this vehicle type&#39;s shape.
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUIVehicle.h:348
Show vehicle&#39;s best lanes.
Definition: GUIAppEnum.h:239
SUMOReal getHBEFA_FuelConsumption() const
Returns fuel consumption of the current state.
Definition: MSVehicle.cpp:2046
static void removeObject(GUIGlObject &o)
Removes all instances that pass values from the object with the given id.
render as a cargo train
render as a flexible city bus
void computeSeats(const Position &front, const Position &back, int &requiredSeats) const
add seats to mySeatPositions and update requiredSeats
void unlock()
release mutex lock
Definition: MFXMutex.cpp:93
Hide all vehicle&#39;s routes.
Definition: GUIAppEnum.h:245
Hide vehicle&#39;s best lanes.
Definition: GUIAppEnum.h:241
SUMOReal getWidth() const
Get the width which vehicles of this class shall have when being drawn.
Hide vehicle&#39;s current route.
Definition: GUIAppEnum.h:237
void push_back(const PositionVector &p)
Appends all positions from the given vector.
render as a giant ant
static void drawBoxLine(const Position &beg, SUMOReal rot, SUMOReal visLength, SUMOReal width)
Draws a thick line.
Definition: GLHelper.cpp:73
render as a pedestrian
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:200
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
Definition: MSEdge.h:204
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:912
Structure representing possible vehicle parameter.
double vehiclePoly_PassengerVanLeftGlass[]
Definition: GUIVehicle.cpp:118
void drawAction_drawVehicleAsBoxPlus() const
Definition: GUIVehicle.cpp:395
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:80
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:90
GUIColorScheme & getScheme()
Definition: GUIColorer.h:76
void drawRoute(const GUIVisualizationSettings &s, int routeNo, SUMOReal darken) const
Chooses the route to draw and draws it, darkening it as given.
Position positionAtOffset2D(SUMOReal pos) const
Returns the position at the given length.
SUMOReal getAcceleration() const
Returns the vehicle&#39;s acceleration in m/s.
Definition: MSVehicle.h:299
RGBColor changedBrightness(const char change)
Returns a new color with altered brightness.
Definition: RGBColor.cpp:145
double vehiclePoly_PassengerVanBodyFront[]
Definition: GUIVehicle.cpp:115
void drawAction_drawBlinker(const GUIVehicle &veh, double dir)
Definition: GUIVehicle.cpp:862
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:94
The popup menu of a globject.
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into, unsigned int maxRoutes=INT_MAX)
Build devices for the given vehicle, if needed.
SUMOReal getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
const std::string & getID() const
Returns the name of the vehicle type.
SUMOReal getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:291
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
void lock()
lock mutex
Definition: MFXMutex.cpp:83
Base class for coloring. Allows changing the used colors and sets the used color in dependence to a v...
Definition: GUIColorer.h:50
render as a transport vehicle with one trailer
long onCmdShowFoes(FXObject *, FXSelector, void *)
Called when show a vehicles foes.
Definition: GUIVehicle.cpp:238
SUMOReal getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:352
double vehiclePoly_PassengerSedanBackGlass[]
Definition: GUIVehicle.cpp:106
double vehiclePoly_PassengerHatchbackBackGlass[]
Definition: GUIVehicle.cpp:109
unsigned size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:86
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:323
render as a (futuristic) e-vehicle
static void drawLine(const Position &beg, SUMOReal rot, SUMOReal visLength)
Draws a thin line.
Definition: GLHelper.cpp:145
void move2side(SUMOReal amount)
#define BLINKER_POS_FRONT
Definition: GUIVehicle.cpp:858
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:83
#define SUMOReal
Definition: config.h:215
std::string getImgFile() const
Get this vehicle type&#39;s raster model file name.
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
double vehiclePoly_PassengerVanFrontGlass[]
Definition: GUIVehicle.cpp:116
MSRouteIterator myCurrEdge
Iterator to current route-edge.
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.
int vehicleQuality
The quality of vehicle drawing.
double vehiclePoly_TransportRightGlass[]
Definition: GUIVehicle.cpp:126
double vehiclePoly_DeliveryMediumRightGlass[]
Definition: GUIVehicle.cpp:121
double vehiclePoly_PassengerVanBody[]
Definition: GUIVehicle.cpp:114
SUMOEmissionClass getEmissionClass() const
Get this vehicle type&#39;s emission class.
The edge is an internal edge.
Definition: MSEdge.h:90
render as a wagon passenger vehicle (&quot;Combi&quot;)
render as a overland bus
double vehiclePoly_PassengerVanBackGlass[]
Definition: GUIVehicle.cpp:119
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:75
SUMOReal getHBEFA_CO2Emissions() const
Returns CO2 emission of the current state.
Definition: MSVehicle.cpp:2016
double vehiclePoly_PassengerWagonLeftGlass[]
Definition: GUIVehicle.cpp:111
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
GUISelectedStorage gSelected
A global holder of selected objects.
void closeBuilding()
Closes the building of the table.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
std::vector< MSDevice * > myDevices
The devices this vehicle has.
A window containing a gl-object&#39;s parameter.
const int VTYPEPARS_COLOR_SET
double vehiclePoly_PassengerHatchbackLeftGlass[]
Definition: GUIVehicle.cpp:108
double vehiclePoly_PassengerSedanRightGlass[]
Definition: GUIVehicle.cpp:104
MSDevice_Person * myPersonDevice
The passengers this vehicle may have.
Definition: MSVehicle.h:1040
double vehiclePoly_PassengerSedanLeftGlass[]
Definition: GUIVehicle.cpp:105
render as a city rail
Start to track a vehicle.
Definition: GUIAppEnum.h:247
int getBestLaneOffset() const
returns the current offset from the best lane
Definition: MSVehicle.cpp:1974
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:74
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
render as a trolley bus
SUMOReal getAngle() const
Returns the vehicle&#39;s direction in degrees.
Definition: MSVehicle.cpp:604
render as a transport vehicle
const std::string & getID() const
Returns the name of the vehicle.
const PositionVector & getShape() const
Definition: GUILane.cpp:662
const MSRoute * getRoute(int index) const
Called on route retrieval.
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:307
static int getTextureID(const std::string &filename)
return texture id for the given filename (initialize on first use)
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