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, int vehicleIndex) :
251  MSVehicle(pars, route, type, speedFactor, vehicleIndex),
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, 21);
327  // add items
328  ret->mkItem("type [NAME]", false, myType->getID());
329  if (getParameter().repetitionNumber > 0) {
330  ret->mkItem("left same route [#]", false, (unsigned int) getParameter().repetitionNumber);
331  }
332  if (getParameter().repetitionOffset > 0) {
333  ret->mkItem("insertion period [s]", false, time2string(getParameter().repetitionOffset));
334  }
335  if (getChosenSpeedFactor() != 1) {
336  ret->mkItem("speed factor", false, getChosenSpeedFactor());
337  }
338  ret->mkItem("insertion period [s]", false, time2string(getParameter().repetitionOffset));
339  ret->mkItem("waiting time [s]", true,
341  ret->mkItem("last lane change [s]", true,
343  ret->mkItem("desired depart [s]", false, time2string(getParameter().depart));
344  ret->mkItem("position [m]", true,
346  ret->mkItem("speed [m/s]", true,
348  ret->mkItem("angle", true,
350  ret->mkItem("stop info", false, getStopInfo());
351  ret->mkItem("CO2 (HBEFA) [mg/s]", true,
353  ret->mkItem("CO (HBEFA) [mg/s]", true,
355  ret->mkItem("HC (HBEFA) [mg/s]", true,
357  ret->mkItem("NOx (HBEFA) [mg/s]", true,
359  ret->mkItem("PMx (HBEFA) [mg/s]", true,
361  ret->mkItem("fuel (HBEFA) [ml/s]", true,
363  ret->mkItem("noise (Harmonoise) [dB]", true,
365  // close building
366  ret->closeBuilding();
367  return ret;
368 }
369 
370 
371 Boundary
373  Boundary b;
374  b.add(getPosition());
375  b.grow(20);
376  return b;
377 }
378 
379 
380 void
382  glPushMatrix();
383  glScaled(getVehicleType().getWidth(), getVehicleType().getLength(), 1.);
384  glBegin(GL_TRIANGLE_STRIP);
385  glVertex2d(0., 0.);
386  glVertex2d(-.5, .15);
387  glVertex2d(.5, .15);
388  glVertex2d(-.5, 1.);
389  glVertex2d(.5, 1.);
390  glEnd();
391  glPopMatrix();
392 }
393 
394 
395 void
397  const SUMOReal length = getVehicleType().getLength();
398  if (length >= 8.) {
400  return;
401  }
402  glPushMatrix();
403  glScaled(getVehicleType().getWidth(), length, 1.);
404  glBegin(GL_TRIANGLES);
405  glVertex2d(0., 0.);
406  glVertex2d(-.5, 1.);
407  glVertex2d(.5, 1.);
408  glEnd();
409  glPopMatrix();
410 }
411 
412 
413 void
414 GUIVehicle::drawPoly(double* poses, SUMOReal offset) {
415  glPushMatrix();
416  glTranslated(0, 0, offset * .1);
417  glPolygonOffset(0, offset * -1);
418  glBegin(GL_TRIANGLE_FAN);
419  int i = 0;
420  while (poses[i] > -999) {
421  glVertex2d(poses[i], poses[i + 1]);
422  i = i + 2;
423  }
424  glEnd();
425  glPopMatrix();
426 }
427 
428 
429 void
431  RGBColor current = GLHelper::getColor();
432  RGBColor lighter = current.changedBrightness(51);
433  RGBColor darker = current.changedBrightness(-51);
434 
435  const SUMOReal length = getVehicleType().getLength();
436  const SUMOReal width = getVehicleType().getWidth();
437  glPushMatrix();
438  glRotated(90, 0, 0, 1);
439  glScaled(length, width, 1.);
441 
442  // draw main body
443  switch (shape) {
444  case SVS_UNKNOWN:
446  GLHelper::setColor(lighter);
447  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
448  glColor3d(0, 0, 0);
449  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
450  break;
451  case SVS_PEDESTRIAN:
452  glTranslated(0, 0, .045);
454  glTranslated(0, 0, -.045);
455  glScaled(.7, 2, 1);
456  glTranslated(0, 0, .04);
457  GLHelper::setColor(lighter);
459  glTranslated(0, 0, -.04);
460  break;
461  case SVS_BICYCLE:
462  case SVS_MOTORCYCLE: {
463  glPushMatrix();
464  glTranslated(.5, 0, 0);
465  glScaled(.25 / (length), 1, 1.);
466  glTranslated(0, 0, .045);
468  glScaled(.7, 2, 1);
469  glTranslated(0, 0, -.045);
470  glTranslated(0, 0, .04);
471  GLHelper::setColor(lighter);
473  glTranslated(0, 0, -.04);
474  glPopMatrix();
475  }
476  break;
477  case SVS_PASSENGER:
478  case SVS_PASSENGER_SEDAN:
480  case SVS_PASSENGER_WAGON:
482  GLHelper::setColor(lighter);
483  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
484  glColor3d(0, 0, 0);
485  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
486  break;
487  case SVS_PASSENGER_VAN:
488  drawPoly(vehiclePoly_PassengerVanBody, 4);
489  GLHelper::setColor(lighter);
490  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
491  glColor3d(0, 0, 0);
492  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
493  drawPoly(vehiclePoly_PassengerVanRightGlass, 4.5);
494  drawPoly(vehiclePoly_PassengerVanLeftGlass, 4.5);
495  drawPoly(vehiclePoly_PassengerVanBackGlass, 4.5);
496  break;
497  case SVS_DELIVERY:
498  drawPoly(vehiclePoly_PassengerVanBody, 4);
499  GLHelper::setColor(lighter);
500  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
501  glColor3d(0, 0, 0);
502  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
503  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
504  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
505  break;
506  case SVS_TRANSPORT:
509  glScaled(1. / (length), 1, 1.);
510  drawPoly(vehiclePoly_TransportBody, 4);
511  glColor3d(0, 0, 0);
512  drawPoly(vehiclePoly_TransportFrontGlass, 4.5);
513  drawPoly(vehiclePoly_TransportRightGlass, 4.5);
514  drawPoly(vehiclePoly_TransportLeftGlass, 4.5);
515  break;
516  case SVS_BUS:
517  case SVS_BUS_TROLLEY:
519  case SVS_BUS_CITY: {
520  SUMOReal ml = length;
521  glScaled(1. / (length), 1, 1.);
522  glTranslated(0, 0, .04);
523  glBegin(GL_TRIANGLE_FAN);
524  glVertex2d(ml / 2., 0);
525  glVertex2d(0, 0);
526  glVertex2d(0, -.45);
527  glVertex2d(0 + .05, -.5);
528  glVertex2d(ml - .05, -.5);
529  glVertex2d(ml, -.45);
530  glVertex2d(ml, .45);
531  glVertex2d(ml - .05, .5);
532  glVertex2d(0 + .05, .5);
533  glVertex2d(0, .45);
534  glVertex2d(0, 0);
535  glEnd();
536  glTranslated(0, 0, -.04);
537 
538  glTranslated(0, 0, .045);
539  glColor3d(0, 0, 0);
540  glBegin(GL_QUADS);
541  glVertex2d(0 + .05, .48);
542  glVertex2d(0 + .05, -.48);
543  glVertex2d(0 + .15, -.48);
544  glVertex2d(0 + .15, .48);
545 
546  glVertex2d(ml - .1, .45);
547  glVertex2d(ml - .1, -.45);
548  glVertex2d(ml - .05, -.45);
549  glVertex2d(ml - .05, .45);
550 
551  glVertex2d(0 + .20, .49);
552  glVertex2d(0 + .20, .45);
553  glVertex2d(ml - .20, .45);
554  glVertex2d(ml - .20, .49);
555 
556  glVertex2d(0 + .20, -.49);
557  glVertex2d(0 + .20, -.45);
558  glVertex2d(ml - .20, -.45);
559  glVertex2d(ml - .20, -.49);
560 
561  glEnd();
562  glTranslated(0, 0, -.045);
563  }
564  break;
565  case SVS_BUS_OVERLAND:
566  case SVS_RAIL:
567  drawAction_drawRailCarriages(s, 25.0, 1);
568  break;
569  case SVS_RAIL_LIGHT:
571  break;
572  case SVS_RAIL_CITY:
574  break;
575  case SVS_RAIL_SLOW:
576  drawAction_drawRailCarriages(s, 15.0, 1);
577  break;
578  case SVS_RAIL_FAST:
579  drawAction_drawRailCarriages(s, 40.0, 1);
580  break;
581  case SVS_RAIL_CARGO:
583  break;
584  case SVS_E_VEHICLE:
585  drawPoly(vehiclePoly_EVehicleBody, 4);
586  glColor3d(0, 0, 0);
587  drawPoly(vehiclePoly_EVehicleFrontGlass, 4.5);
588  glTranslated(0, 0, .048);
589  GLHelper::setColor(current);
590  glBegin(GL_QUADS);
591  glVertex2d(.3, .5);
592  glVertex2d(.35, .5);
593  glVertex2d(.35, -.5);
594  glVertex2d(.3, -.5);
595 
596  glVertex2d(.3, -.05);
597  glVertex2d(.7, -.05);
598  glVertex2d(.7, .05);
599  glVertex2d(.3, .05);
600 
601  glVertex2d(.7, .5);
602  glVertex2d(.65, .5);
603  glVertex2d(.65, -.5);
604  glVertex2d(.7, -.5);
605  glEnd();
606  glTranslated(0, 0, -.048);
607  //drawPoly(vehiclePoly_EVehicleBackGlass, 4.5);
608  break;
609  case SVS_ANT:
610  glPushMatrix();
611  // ant is stretched via vehicle length
612  GLHelper::setColor(darker);
613  // draw left side
614  GLHelper::drawBoxLine(Position(-0.2, -.10), 350, 0.5, .02);
615  GLHelper::drawBoxLine(Position(-0.3, -.50), 240, 0.4, .03);
616  GLHelper::drawBoxLine(Position(0.3, -.10), 340, 0.8, .03);
617  GLHelper::drawBoxLine(Position(0.05, -.80), 290, 0.6, .04);
618  GLHelper::drawBoxLine(Position(0.4, -.10), 20, 0.8, .03);
619  GLHelper::drawBoxLine(Position(0.65, -.80), 75, 0.6, .04);
620  GLHelper::drawBoxLine(Position(0.5, -.10), 55, 0.8, .04);
621  GLHelper::drawBoxLine(Position(1.1, -.55), 90, 0.6, .04);
622  // draw right side
623  GLHelper::drawBoxLine(Position(-0.2, .10), 190, 0.5, .02);
624  GLHelper::drawBoxLine(Position(-0.3, .50), 300, 0.4, .03);
625  GLHelper::drawBoxLine(Position(0.3, .10), 200, 0.8, .03);
626  GLHelper::drawBoxLine(Position(0.05, .80), 250, 0.6, .04);
627  GLHelper::drawBoxLine(Position(0.4, .10), 160, 0.8, .03);
628  GLHelper::drawBoxLine(Position(0.65, .80), 105, 0.6, .04);
629  GLHelper::drawBoxLine(Position(0.5, .10), 125, 0.8, .04);
630  GLHelper::drawBoxLine(Position(1.1, .55), 90, 0.6, .04);
631  // draw body
632  GLHelper::setColor(current);
633  glTranslated(0, 0, 0.1);
635  glTranslated(.4, 0, 0);
637  glTranslated(.4, 0, 0);
639  glPopMatrix();
640  break;
641  default: // same as passenger
643  glColor3d(1, 1, 1);
644  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
645  glColor3d(0, 0, 0);
646  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
647  break;
648  }
649 
650  // draw decorations
651  switch (shape) {
652  case SVS_PEDESTRIAN:
653  break;
654  case SVS_BICYCLE:
655  //glScaled(length, 1, 1.);
656  glBegin(GL_TRIANGLE_FAN);
657  glVertex2d(1 / 2., 0);
658  glVertex2d(0, 0);
659  glVertex2d(0, -.03);
660  glVertex2d(0 + .05, -.05);
661  glVertex2d(1 - .05, -.05);
662  glVertex2d(1, -.03);
663  glVertex2d(1, .03);
664  glVertex2d(1 - .05, .05);
665  glVertex2d(0 + .05, .05);
666  glVertex2d(0, .03);
667  glVertex2d(0, 0);
668  glEnd();
669  break;
670  case SVS_MOTORCYCLE:
671  //glScaled(length, 1, 1.);
672  glBegin(GL_TRIANGLE_FAN);
673  glVertex2d(1 / 2., 0);
674  glVertex2d(0, 0);
675  glVertex2d(0, -.03);
676  glVertex2d(0 + .05, -.2);
677  glVertex2d(1 - .05, -.2);
678  glVertex2d(1, -.03);
679  glVertex2d(1, .03);
680  glVertex2d(1 - .05, .2);
681  glVertex2d(0 + .05, .2);
682  glVertex2d(0, .03);
683  glVertex2d(0, 0);
684  glEnd();
685  break;
686  case SVS_PASSENGER:
687  case SVS_PASSENGER_SEDAN:
688  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
689  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
690  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
691  break;
693  drawPoly(vehiclePoly_PassengerHatchbackRightGlass, 4.5);
694  drawPoly(vehiclePoly_PassengerHatchbackLeftGlass, 4.5);
695  drawPoly(vehiclePoly_PassengerHatchbackBackGlass, 4.5);
696  break;
697  case SVS_PASSENGER_WAGON:
698  drawPoly(vehiclePoly_PassengerWagonRightGlass, 4.5);
699  drawPoly(vehiclePoly_PassengerWagonLeftGlass, 4.5);
700  drawPoly(vehiclePoly_PassengerWagonBackGlass, 4.5);
701  break;
702  case SVS_PASSENGER_VAN:
703  case SVS_DELIVERY:
704  break;
705  case SVS_TRANSPORT:
706  GLHelper::setColor(current);
707  GLHelper::drawBoxLine(Position(2.3, 0), 90., length - 2.3, .5);
708  break;
710  GLHelper::setColor(current);
711  GLHelper::drawBoxLine(Position(2.8, 0), 90., length - 2.8, .5);
712  break;
713  case SVS_TRANSPORT_1TRAILER: {
714  GLHelper::setColor(current);
715  SUMOReal l = length - 2.3;
716  l = l / 2.;
717  GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
718  GLHelper::drawBoxLine(Position(2.3 + l + .5, 0), 90., l - .5, .5);
719  break;
720  }
721  case SVS_BUS_TROLLEY:
722  glPushMatrix();
723  glTranslated(0, 0, .1);
724  GLHelper::setColor(darker);
725  GLHelper::drawBoxLine(Position(3.8, 0), 90., 1, .3);
726  glTranslated(0, 0, .1);
727  glColor3d(0, 0, 0);
728  GLHelper::drawBoxLine(Position(4.3, .2), 90., 1, .06);
729  GLHelper::drawBoxLine(Position(4.3, -.2), 90., 1, .06);
730  GLHelper::drawBoxLine(Position(5.3, .2), 90., 3, .03);
731  GLHelper::drawBoxLine(Position(5.3, -.2), 90., 3, .03);
732  glPopMatrix();
733  break;
734  case SVS_BUS:
735  case SVS_BUS_CITY:
737  case SVS_BUS_OVERLAND:
738  case SVS_RAIL:
739  case SVS_RAIL_LIGHT:
740  case SVS_RAIL_CITY:
741  case SVS_RAIL_SLOW:
742  case SVS_RAIL_FAST:
743  case SVS_RAIL_CARGO:
744  case SVS_E_VEHICLE:
745  case SVS_ANT:
746  break;
747  default: // same as passenger/sedan
748  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
749  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
750  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
751  break;
752  }
753  /*
754  glBegin(GL_TRIANGLE_FAN);
755  glVertex2d(.5,.5); // center - strip begin
756  glVertex2d(0, .5); // center, front
757  glVertex2d(0, .8); // ... clockwise ... (vehicle right side)
758  glVertex2d(0.08, .94);
759  glVertex2d(0.25, 1.);
760  glVertex2d(0.95, 1.);
761  glVertex2d(1., .9);
762  glVertex2d(1., .1); // (vehicle left side)
763  glVertex2d(0.95, 0.);
764  glVertex2d(0.25, 0.);
765  glVertex2d(0.08, .06);
766  glVertex2d(0, .2); //
767  glVertex2d(0, .5); // center, front (close)
768  glEnd();
769 
770  glPolygonOffset(0, -4.5);
771  glColor3d(1, 1, 1); // front
772  glBegin(GL_TRIANGLE_FAN);
773  glVertex2d(0.1,0.5);
774  glVertex2d(0.025,0.5);
775  glVertex2d(0.025,0.75);
776  glVertex2d(0.27,0.9);
777  glVertex2d(0.27,0.1);
778  glVertex2d(0.025,0.25);
779  glVertex2d(0.025,0.5);
780  glEnd();
781 
782  glColor3d(0, 0, 0); // front glass
783  glBegin(GL_TRIANGLE_FAN);
784  glVertex2d(0.35,0.5);
785  glVertex2d(0.3,0.5);
786  glVertex2d(0.3,0.9);
787  glVertex2d(0.43,0.8);
788  glVertex2d(0.43,0.2);
789  glVertex2d(0.3,0.1);
790  glVertex2d(0.3,0.5);
791  glEnd();
792 
793  glBegin(GL_TRIANGLE_FAN); // back glass
794  glVertex2d(0.92,0.5);
795  glVertex2d(0.90,0.5);
796  glVertex2d(0.90,0.8);
797  glVertex2d(0.95,0.9);
798  glVertex2d(0.95,0.1);
799  glVertex2d(0.90,0.2);
800  glVertex2d(0.90,0.5);
801  glEnd();
802 
803  glBegin(GL_TRIANGLE_FAN); // right glass
804  glVertex2d(0.36,0.07);
805  glVertex2d(0.34,0.03);
806  glVertex2d(0.94,0.03);
807  glVertex2d(0.87,0.13);
808  glVertex2d(0.45,0.13);
809  glVertex2d(0.34,0.03);
810  glEnd();
811 
812  glBegin(GL_TRIANGLE_FAN); // left glass
813  glVertex2d(0.36,1.-0.07);
814  glVertex2d(0.34,1.-0.03);
815  glVertex2d(0.94,1.-0.03);
816  glVertex2d(0.87,1.-0.13);
817  glVertex2d(0.45,1.-0.13);
818  glVertex2d(0.34,1.-0.03);
819  glEnd();
820  */
821 
822  glPopMatrix();
823 }
824 
825 
826 bool
828  const std::string& file = getVehicleType().getImgFile();
829  if (file != "") {
830  int textureID = GUITexturesHelper::getTextureID(file);
831  if (textureID > 0) {
832  if (length < 0) {
834  }
835  const SUMOReal halfWidth = getVehicleType().getWidth() / 2.0 * s.vehicleExaggeration;
836  GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, 0, halfWidth, length);
837  return true;
838  }
839  }
840  return false;
841 }
842 
843 
844 #define BLINKER_POS_FRONT .5
845 #define BLINKER_POS_BACK .5
846 
847 inline void
848 drawAction_drawBlinker(const GUIVehicle& veh, double dir) {
849  glColor3d(1.f, .8f, 0);
850  glPushMatrix();
851  glTranslated(dir, BLINKER_POS_FRONT, -0.1);
853  glPopMatrix();
854  glPushMatrix();
855  glTranslated(dir, veh.getVehicleType().getLength() - BLINKER_POS_BACK, -0.1);
857  glPopMatrix();
858 }
859 
860 
861 inline void
864  return;
865  }
866  const double offset = MAX2(.5 * veh.getVehicleType().getWidth(), .4);
868  drawAction_drawBlinker(veh, -offset);
869  }
871  drawAction_drawBlinker(veh, offset);;
872  }
874  drawAction_drawBlinker(veh, -offset);
875  drawAction_drawBlinker(veh, offset);
876  }
877 }
878 
879 
880 inline void
883  return;
884  }
885  glColor3f(1.f, .2f, 0);
886  glPushMatrix();
887  glTranslated(-veh.getVehicleType().getWidth() * 0.5, veh.getVehicleType().getLength(), -0.1);
889  glPopMatrix();
890  glPushMatrix();
891  glTranslated(veh.getVehicleType().getWidth() * 0.5, veh.getVehicleType().getLength(), -0.1);
893  glPopMatrix();
894 }
895 
896 
897 void
899  glPushName(getGlID());
900  glPushMatrix();
901  Position p1 = getPosition();
902  // one seat in the center of the vehicle by default
904  glTranslated(p1.x(), p1.y(), getType());
905  glRotated(getAngle(), 0, 0, 1);
906  // set lane color
907  setColor(s);
908  // scale
909  SUMOReal upscale = s.vehicleExaggeration;
910  glScaled(upscale, upscale, 1);
911  /*
912  MSLCM_DK2004 &m2 = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
913  if((m2.getState()&LCA_URGENT)!=0) {
914  glColor3d(1, .4, .4);
915  } else if((m2.getState()&LCA_SPEEDGAIN)!=0) {
916  glColor3d(.4, .4, 1);
917  } else {
918  glColor3d(.4, 1, .4);
919  }
920  */
921  // draw the vehicle
922  switch (s.vehicleQuality) {
923  case 0:
925  break;
926  case 1:
928  break;
929  case 2:
931  break;
932  case 3:
933  default:
934  // draw as image but take special care for drawing trains
935  // XXX handle default carriage lenghts someplace else
936  switch (getVehicleType().getGuiShape()) {
937  case SVS_RAIL:
938  drawAction_drawRailCarriages(s, 25.0, 1, true);
939  break;
940  case SVS_RAIL_LIGHT:
941  drawAction_drawRailCarriages(s, 38.0, true);
942  break;
943  case SVS_RAIL_CITY:
944  drawAction_drawRailCarriages(s, 25.0, true);
945  break;
946  case SVS_RAIL_SLOW:
947  drawAction_drawRailCarriages(s, 15.0, 1, true);
948  break;
949  case SVS_RAIL_FAST:
950  drawAction_drawRailCarriages(s, 40.0, 1, true);
951  break;
952  case SVS_RAIL_CARGO:
953  drawAction_drawRailCarriages(s, 20.0, true);
954  break;
955  default:
956  // draw normal vehicle
959  };
960  };
961  break;
962  }
963  if (s.drawMinGap) {
964  SUMOReal minGap = -getVehicleType().getMinGap();
965  glColor3d(0., 1., 0.);
966  glBegin(GL_LINES);
967  glVertex2d(0., 0);
968  glVertex2d(0., minGap);
969  glVertex2d(-.5, minGap);
970  glVertex2d(.5, minGap);
971  glEnd();
972  }
973  // draw the blinker and brakelights if wished
974  if (s.showBlinker) {
975  glTranslated(0, 0, .1);
976  switch (getVehicleType().getGuiShape()) {
977  case SVS_PEDESTRIAN:
978  case SVS_BICYCLE:
979  case SVS_ANT:
980  case SVS_RAIL:
981  case SVS_RAIL_LIGHT:
982  case SVS_RAIL_SLOW:
983  case SVS_RAIL_FAST:
984  case SVS_RAIL_CARGO:
985  // only SVS_RAIL_CITY has blinkers and brake lights
986  break;
987  default:
990  break;
991  }
992  }
993  // draw the wish to change the lane
994  if (s.drawLaneChangePreference) {
995  /*
996  if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
997  MSLCM_DK2004 &m = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
998  glColor3d(.5, .5, 1);
999  glBegin(GL_LINES);
1000  glVertex2f(0, 0);
1001  glVertex2f(m.getChangeProbability(), .5);
1002  glEnd();
1003 
1004  glColor3d(1, 0, 0);
1005  glBegin(GL_LINES);
1006  glVertex2f(0.1, 0);
1007  glVertex2f(0.1, m.myMaxJam1);
1008  glEnd();
1009 
1010  glColor3d(0, 1, 0);
1011  glBegin(GL_LINES);
1012  glVertex2f(-0.1, 0);
1013  glVertex2f(-0.1, m.myTDist);
1014  glEnd();
1015  }
1016  */
1017  }
1018  // draw best lanes
1019  /*
1020  if (true) {
1021  const MSLane &l = veh->getLane();
1022  SUMOReal r1 = veh->allowedContinuationsLength(&l, 0);
1023  SUMOReal r2 = l.getLeftLane()!=0 ? veh->allowedContinuationsLength(l.getLeftLane(), 0) : 0;
1024  SUMOReal r3 = l.getRightLane()!=0 ? veh->allowedContinuationsLength(l.getRightLane(), 0) : 0;
1025  SUMOReal mmax = MAX3(r1, r2, r3);
1026  glBegin(GL_LINES);
1027  glVertex2f(0, 0);
1028  glVertex2f(0, r1/mmax/2.);
1029  glEnd();
1030  glBegin(GL_LINES);
1031  glVertex2f(.4, 0);
1032  glVertex2f(.4, r2/mmax/2.);
1033  glEnd();
1034  glBegin(GL_LINES);
1035  glVertex2f(-.4, 0);
1036  glVertex2f(-.4, r3/mmax/2.);
1037  glEnd();
1038  }
1039  */
1040  glPopMatrix();
1041  drawName(getPosition(-MIN2(getVehicleType().getLength() / 2, SUMOReal(5))),
1042  s.scale,
1043  getVehicleType().getGuiShape() == SVS_PEDESTRIAN ? s.personName : s.vehicleName);
1044  glPopName();
1045  if (myPersonDevice != 0) {
1046  const std::vector<MSPerson*>& ps = myPersonDevice->getPersons();
1047  size_t personIndex = 0;
1048  for (std::vector<MSPerson*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
1049  GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
1050  assert(person != 0);
1051  person->setPositionInVehicle(getSeatPosition(personIndex++));
1052  person->drawGL(s);
1053  }
1054  }
1055 }
1056 
1057 
1058 void
1060  glPushName(getGlID());
1061  glPushMatrix();
1062  glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
1064  drawBestLanes();
1065  }
1067  drawRoute(s, 0, 0.25);
1068  }
1070  if (getNumberReroutes() > 0) {
1071  const int noReroutePlus1 = getNumberReroutes() + 1;
1072  for (int i = noReroutePlus1 - 1; i >= 0; i--) {
1073  SUMOReal darken = SUMOReal(0.4) / SUMOReal(noReroutePlus1) * SUMOReal(i);
1074  drawRoute(s, i, darken);
1075  }
1076  } else {
1077  drawRoute(s, 0, 0.25);
1078  }
1079  }
1081  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
1082  if ((*i).myLink == 0) {
1083  continue;
1084  }
1085  MSLink* link = (*i).myLink;
1086  MSLane* via = link->getViaLaneOrLane();
1087  if (via != 0) {
1088  Position p = via->getShape()[0];
1089  if ((*i).mySetRequest) {
1090  glColor3d(0, .8, 0);
1091  } else {
1092  glColor3d(.8, 0, 0);
1093  }
1094  const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
1095  (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(), getVehicleType().getLengthWithGap());
1096  drawLinkItem(p, (*i).myArrivalTime, leaveTime, s.addExaggeration);
1097  // the time slot that ego vehicle uses when checking opened may
1098  // differ from the one it requests in setApproaching
1099  MSLink::ApproachingVehicleInformation avi = (*i).myLink->getApproaching(this);
1100  assert(avi.arrivalTime == (*i).myArrivalTime && avi.leavingTime == leaveTime);
1101  }
1102  }
1103  }
1104  glPopMatrix();
1105  glPopName();
1106 }
1107 
1108 
1109 void
1110 GUIVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate) {
1111  glTranslated(pos.x(), pos.y(), -.1);
1113  std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
1114  GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
1115  glTranslated(-pos.x(), -pos.y(), .1);
1116 }
1117 
1118 const std::vector<MSVehicle::LaneQ>&
1120  myLock.lock();
1121  const std::vector<MSVehicle::LaneQ>& ret = MSVehicle::getBestLanes();
1122  myLock.unlock();
1123  return ret;
1124 }
1125 
1126 
1127 void
1129  const GUIColorer& c = s.vehicleColorer;
1130  if (!setFunctionalColor(c.getActive())) {
1132  }
1133 }
1134 
1135 
1136 bool
1137 GUIVehicle::setFunctionalColor(size_t activeScheme) const {
1138  switch (activeScheme) {
1139  case 0: {
1140  if (getParameter().wasSet(VEHPARS_COLOR_SET)) {
1142  return true;
1143  }
1144  if (getVehicleType().wasSet(VTYPEPARS_COLOR_SET)) {
1145  GLHelper::setColor(getVehicleType().getColor());
1146  return true;
1147  }
1148  if (&getRoute().getColor() != &RGBColor::DEFAULT_COLOR) {
1149  GLHelper::setColor(getRoute().getColor());
1150  return true;
1151  }
1152  return false;
1153  }
1154  case 2: {
1155  if (getParameter().wasSet(VEHPARS_COLOR_SET)) {
1157  return true;
1158  }
1159  return false;
1160  }
1161  case 3: {
1162  if (getVehicleType().wasSet(VTYPEPARS_COLOR_SET)) {
1163  GLHelper::setColor(getVehicleType().getColor());
1164  return true;
1165  }
1166  return false;
1167  }
1168  case 4: {
1169  if (&getRoute().getColor() != &RGBColor::DEFAULT_COLOR) {
1170  GLHelper::setColor(getRoute().getColor());
1171  return true;
1172  }
1173  return false;
1174  }
1175  case 5: {
1176  Position p = getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1177  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1178  Position center = b.getCenter();
1179  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1180  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1181  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1182  return true;
1183  }
1184  case 6: {
1185  Position p = getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1186  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1187  Position center = b.getCenter();
1188  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1189  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1190  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1191  return true;
1192  }
1193  case 7: {
1194  Position pb = getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1195  Position pe = getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1196  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1197  SUMOReal hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / PI;
1198  Position minp(b.xmin(), b.ymin());
1199  Position maxp(b.xmax(), b.ymax());
1200  SUMOReal sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1201  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1202  return true;
1203  }
1204  }
1205  return false;
1206 }
1207 
1208 
1209 SUMOReal
1210 GUIVehicle::getColorValue(size_t activeScheme) const {
1211  switch (activeScheme) {
1212  case 8:
1213  return getSpeed();
1214  case 9:
1215  return getWaitingSeconds();
1216  case 10:
1217  return getLastLaneChangeOffset();
1218  case 11:
1219  return getMaxSpeed();
1220  case 12:
1221  return getHBEFA_CO2Emissions();
1222  case 13:
1223  return getHBEFA_COEmissions();
1224  case 14:
1225  return getHBEFA_PMxEmissions();
1226  case 15:
1227  return getHBEFA_NOxEmissions();
1228  case 16:
1229  return getHBEFA_HCEmissions();
1230  case 17:
1231  return getHBEFA_FuelConsumption();
1232  case 18:
1234  case 19:
1235  if (getNumberReroutes() == 0) {
1236  return -1;
1237  }
1238  return getNumberReroutes();
1239  case 20:
1241  }
1242  return 0;
1243 }
1244 
1245 
1246 // ------------ Additional visualisations
1247 bool
1249  return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
1250 }
1251 
1252 
1253 void
1255  if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
1256  myAdditionalVisualizations[parent] = 0;
1257  }
1258  myAdditionalVisualizations[parent] |= which;
1259  parent->addAdditionalGLVisualisation(this);
1260 }
1261 
1262 
1263 void
1265  myAdditionalVisualizations[parent] &= ~which;
1266  parent->removeAdditionalGLVisualisation(this);
1267 }
1268 
1269 
1270 void
1271 GUIVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const {
1272  setColor(s);
1273  GLdouble colors[4];
1274  glGetDoublev(GL_CURRENT_COLOR, colors);
1275  colors[0] -= darken;
1276  if (colors[0] < 0) {
1277  colors[0] = 0;
1278  }
1279  colors[1] -= darken;
1280  if (colors[1] < 0) {
1281  colors[1] = 0;
1282  }
1283  colors[2] -= darken;
1284  if (colors[2] < 0) {
1285  colors[2] = 0;
1286  }
1287  colors[3] -= darken;
1288  if (colors[3] < 0) {
1289  colors[3] = 0;
1290  }
1291  glColor3dv(colors);
1292  if (routeNo == 0) {
1294  return;
1295  }
1296  --routeNo; // only prior routes are stored
1298 }
1299 
1300 
1301 void
1303  myLock.lock();
1304  std::vector<std::vector<MSVehicle::LaneQ> > bestLanes = myBestLanes;
1305  myLock.unlock();
1306  SUMOReal width = 0.5;
1307  for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
1308  std::vector<MSVehicle::LaneQ>& lanes = *j;
1309  SUMOReal gmax = -1;
1310  SUMOReal rmax = -1;
1311  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1312  gmax = MAX2((*i).length, gmax);
1313  rmax = MAX2((*i).occupation, rmax);
1314  }
1315  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1316  const PositionVector& shape = (*i).lane->getShape();
1317  SUMOReal g = (*i).length / gmax;
1318  SUMOReal r = (*i).occupation / rmax;
1319  glColor3d(r, g, 0);
1320  GLHelper::drawBoxLines(shape, width);
1321 
1322  PositionVector s1 = shape;
1323  s1.move2side((SUMOReal) .1);
1324  glColor3d(r, 0, 0);
1325  GLHelper::drawLine(s1);
1326  s1.move2side((SUMOReal) - .2);
1327  glColor3d(0, g, 0);
1328  GLHelper::drawLine(s1);
1329 
1330  glColor3d(r, g, 0);
1331  Position lastPos = shape[-1];
1332  }
1333  width = .2;
1334  }
1335 }
1336 
1337 
1338 void
1339 GUIVehicle::drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const {
1340  MSRouteIterator i = r.begin();
1341  for (; i != r.end(); ++i) {
1342  const GUILane* lane = static_cast<GUILane*>((*i)->getLanes()[0]);
1343  GLHelper::drawBoxLines(lane->getShape(), lane->getShapeRotations(), lane->getShapeLengths(), exaggeration);
1344  }
1345 }
1346 
1347 
1348 MSLane*
1349 GUIVehicle::getPreviousLane(MSLane* current, int& routeIndex) const {
1350  const bool isInternal = current->getEdge().getPurpose() == MSEdge::EDGEFUNCTION_INTERNAL;
1351  if (isInternal) {
1352  // route pointer still points to the previous lane
1353  return myRoute->getEdges()[routeIndex]->getLanes()[0];
1354  } else if (routeIndex == 0) {
1355  // there is no previous lane because the route has just begun
1356  return current;
1357  } else {
1358  // retrieve the previous internal edge
1359  routeIndex -= 1;
1360  const MSEdge* previous = myRoute->getEdges()[routeIndex];
1361 #ifdef HAVE_INTERNAL_LANES
1362  const MSEdge* previousInternal = previous->getInternalFollowingEdge(&current->getEdge());
1363 #else
1364  const MSEdge* previousInternal = 0;
1365 #endif
1366  if (previousInternal != 0) {
1367  return previousInternal->getLanes()[0];
1368  } else {
1369  // network without internal links, use previous edge instead
1370  return previous->getLanes()[0];
1371  }
1372  }
1373 }
1374 
1375 
1376 void
1377 GUIVehicle::drawAction_drawRailCarriages(const GUIVisualizationSettings& s, SUMOReal defaultLength, int firstPassengerCarriage, bool asImage) const {
1378  RGBColor current = GLHelper::getColor();
1379  RGBColor darker = current.changedBrightness(-51);
1380  const SUMOReal length = getVehicleType().getLength() * s.vehicleExaggeration;
1381  const SUMOReal halfWidth = getVehicleType().getWidth() / 2.0 * s.vehicleExaggeration;
1382  glPopMatrix(); // undo scaling and 90 degree rotation
1383  glPopMatrix(); // undo initial translation and rotation
1384  glPushMatrix();
1385  glPushMatrix();
1386  GLHelper::setColor(darker);
1387  const SUMOReal carriageGap = 1;
1388  const SUMOReal xCornerCut = 0.3;
1389  const SUMOReal yCornerCut = 0.4;
1390  // round to closest integer
1391  const int numCarriages = floor(length / (defaultLength + carriageGap) + 0.5);
1392  assert(numCarriages > 0);
1393  const SUMOReal carriageLengthWithGap = length / numCarriages;
1394  const SUMOReal carriageLength = carriageLengthWithGap - carriageGap;
1395  // lane on which the carriage front is situated
1396  MSLane* lane = myLane;
1397  int routeIndex = myCurrEdge - myRoute->begin();
1398  // lane on which the carriage back is situated
1399  MSLane* backLane = myLane;
1400  int backRouteIndex = routeIndex;
1401  // offsets of front and back
1402  SUMOReal carriageOffset = myState.pos();
1403  SUMOReal carriageBackOffset = myState.pos() - carriageLength;
1404  // handle seats
1405  int requiredSeats = getNumPassengers();
1406  if (requiredSeats > 0) {
1407  mySeatPositions.clear();
1408  }
1409  // draw individual carriages
1410  for (int i = 0; i < numCarriages; ++i) {
1411  while (carriageOffset < 0) {
1412  lane = getPreviousLane(lane, routeIndex);
1413  carriageOffset += lane->getLength();
1414  }
1415  while (carriageBackOffset < 0) {
1416  backLane = getPreviousLane(backLane, backRouteIndex);
1417  carriageBackOffset += backLane->getLength();
1418  }
1419  const Position front = lane->getShape().positionAtOffset2D(carriageOffset);
1420  const Position back = backLane->getShape().positionAtOffset2D(carriageBackOffset);
1421  const SUMOReal angle = atan2((front.x() - back.x()), (back.y() - front.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
1422  if (i >= firstPassengerCarriage) {
1423  computeSeats(front, back, requiredSeats);
1424  }
1425  glPushMatrix();
1426  glTranslated(front.x(), front.y(), getType());
1427  glRotated(angle, 0, 0, 1);
1428  if (!asImage || !drawAction_drawVehicleAsImage(s, carriageLength)) {
1429  glBegin(GL_TRIANGLE_FAN);
1430  glVertex2d(-halfWidth + xCornerCut, 0);
1431  glVertex2d(-halfWidth, yCornerCut);
1432  glVertex2d(-halfWidth, carriageLength - yCornerCut);
1433  glVertex2d(-halfWidth + xCornerCut, carriageLength);
1434  glVertex2d(halfWidth - xCornerCut, carriageLength);
1435  glVertex2d(halfWidth, carriageLength - yCornerCut);
1436  glVertex2d(halfWidth, yCornerCut);
1437  glVertex2d(halfWidth - xCornerCut, 0);
1438  glEnd();
1439  }
1440  glPopMatrix();
1441  carriageOffset -= carriageLengthWithGap;
1442  carriageBackOffset -= carriageLengthWithGap;
1443  GLHelper::setColor(current);
1444  }
1445 }
1446 
1447 
1448 const Position&
1449 GUIVehicle::getSeatPosition(size_t personIndex) const {
1451  return mySeatPositions[(int)MIN2(personIndex, mySeatPositions.size() - 1)];
1452 }
1453 
1454 
1455 int
1457  if (myPersonDevice != 0) {
1458  return (int)myPersonDevice->getPersons().size();
1459  }
1460  return 0;
1461 }
1462 
1463 
1464 void
1465 GUIVehicle::computeSeats(const Position& front, const Position& back, int& requiredSeats) const {
1466  if (requiredSeats <= 0) {
1467  return; // save some work
1468  }
1469  const Line l(front, back);
1470  const SUMOReal length = l.length2D();
1471  if (length < 4) {
1472  // small vehicle, sit at the center
1474  requiredSeats--;
1475  } else {
1476  for (SUMOReal p = 2; p <= length - 1; p += 1) {
1478  requiredSeats--;
1479  }
1480  }
1481 }
1482 
1483 
1484 SUMOReal
1487 }
1488 
1489 
1490 std::string
1492  std::string result = "";
1493  if (isParking()) {
1494  result += "parking";
1495  } else if (isStopped()) {
1496  result += "stopped";
1497  } else {
1498  return "";
1499  }
1500  if (myStops.front().triggered) {
1501  result += ", triggered";
1502  } else {
1503  result += ", duration=" + time2string(myStops.front().duration);
1504  }
1505  return result;
1506 }
1507 
1508 
1509 void
1511  if (myLFLinkLanes.size() == 0) {
1512  return;
1513  }
1514  const DriveProcessItem& dpi = myLFLinkLanes[0];
1515  if (dpi.myLink == 0) {
1516  return;
1517  }
1518  std::vector<const SUMOVehicle*> blockingFoes;
1520  getImpatience(), getCarFollowModel().getMaxDecel(), getWaitingTime(), &blockingFoes);
1521  for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
1522  gSelected.select(static_cast<const GUIVehicle*>(*it)->getGlID());
1523  }
1524 #ifdef HAVE_INTERNAL_LANES
1525  const MSLink::LinkLeaders linkLeaders = (dpi.myLink)->getLeaderInfo(myLane->getLength() - getPositionOnLane() - getVehicleType().getMinGap());
1526  for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1527  // the vehicle to enter the junction first has priority
1528  const MSVehicle* leader = it->first;
1529  if ((static_cast<const GUIVehicle*>(leader))->myLinkLeaders.count(getID()) == 0) {
1530  // leader isn't already following us, now we follow it
1531  gSelected.select(static_cast<const GUIVehicle*>(leader)->getGlID());
1532  }
1533  }
1534 #endif
1535 }
1536 
1537 
1538 #ifdef HAVE_OSG
1539 void
1540 GUIVehicle::updateColor(GUIOSGView* view) {
1541  const GUIVisualizationSettings* s = view->getVisualisationSettings();
1543  myGeom[view]->setColor(osg::Vec4(col.red() / 255., col.green() / 255., col.blue() / 255., col.alpha() / 255.));
1544 }
1545 #endif
1546 
1547 /****************************************************************************/
1548 
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:748
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:1539
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:442
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
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:1844
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
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:1950
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:975
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:513
State myState
This Vehicles driving state (pos and speed)
Definition: MSVehicle.h:967
a vehicles
GUIVisualizationTextSettings personName
const Position geometryPositionAtOffset(SUMOReal offset) const
Definition: MSLane.h:330
SUMOReal getMaxSpeed() const
Returns the maximum speed.
DriveItemVector myLFLinkLanes
Container for used Links/visited Lanes during lookForward.
Definition: MSVehicle.h:1052
SUMOReal pos() const
Position of this state.
Definition: MSVehicle.cpp:131
render as a slow (passenger) train
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:167
MSLane * getPreviousLane(MSLane *current, int &routeIndex) const
void drawAction_drawVehicleBlinker(const GUIVehicle &veh)
Definition: GUIVehicle.cpp:862
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:1850
void drawBestLanes() const
Draws the vehicle&#39;s best lanes.
SUMOReal getLeaveSpeed() const
Definition: MSVehicle.h:1044
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:342
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:360
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:372
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::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
Position getPosition(SUMOReal offset=0) const
Return current position (x/y, cartesian)
Definition: MSVehicle.cpp:484
SUMOReal getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MSVehicle.h:284
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:827
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:1527
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:690
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
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:430
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:692
SUMOReal getHBEFA_COEmissions() const
Returns CO emission of the current state.
Definition: MSVehicle.cpp:1838
void drawAction_drawVehicleAsTrianglePlus() const
Definition: GUIVehicle.cpp:396
#define PI
Definition: polyfonts.c:57
float addExaggeration
The additional structures exaggeration (upscale)
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.
render as a bus
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:980
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:586
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:970
Blinker lights on both sides are switched on.
Definition: MSVehicle.h:694
~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:1856
static void drawPoly(double *poses, SUMOReal offset)
Definition: GUIVehicle.cpp:414
The brake lights are on.
Definition: MSVehicle.h:696
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:881
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:845
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:592
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:1868
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:1862
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
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
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:203
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.
double vehiclePoly_PassengerVanLeftGlass[]
Definition: GUIVehicle.cpp:118
void drawAction_drawVehicleAsBoxPlus() const
Definition: GUIVehicle.cpp:381
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:81
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.
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:848
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:292
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:353
double vehiclePoly_PassengerSedanBackGlass[]
Definition: GUIVehicle.cpp:106
double vehiclePoly_PassengerHatchbackBackGlass[]
Definition: GUIVehicle.cpp:109
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:318
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:844
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:83
#define SUMOReal
Definition: config.h:221
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
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:1832
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:73
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:983
double vehiclePoly_PassengerSedanLeftGlass[]
Definition: GUIVehicle.cpp:105
render as a city rail
Start to track a vehicle.
Definition: GUIAppEnum.h:247
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:75
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:504
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