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-2014 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>
46 #include <utils/gui/div/GLHelper.h>
49 #include <microsim/MSVehicle.h>
50 #include <microsim/MSLane.h>
58 #include <gui/GUIGlobals.h>
59 #include "GUIVehicle.h"
60 #include "GUIPerson.h"
61 #include "GUINet.h"
62 #include "GUIEdge.h"
63 #include "GUILane.h"
64 
65 #ifdef CHECK_MEMORY_LEAKS
66 #include <foreign/nvwa/debug_new.h>
67 #endif // CHECK_MEMORY_LEAKS
68 
69 
70 // ===========================================================================
71 // FOX callback mapping
72 // ===========================================================================
73 FXDEFMAP(GUIVehicle::GUIVehiclePopupMenu) GUIVehiclePopupMenuMap[] = {
85 };
86 
87 // Object implementation
88 FXIMPLEMENT(GUIVehicle::GUIVehiclePopupMenu, GUIGLObjectPopupMenu, GUIVehiclePopupMenuMap, ARRAYNUMBER(GUIVehiclePopupMenuMap))
89 
90 
91 
92 // ===========================================================================
93 // data definitions
94 // ===========================================================================
95 /* -------------------------------------------------------------------------
96  * drawed shapes
97  * ----------------------------------------------------------------------- */
98 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 };
99 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 };
100 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 };
101 double vehiclePoly_PassengerSedanRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.77, -.47, 0.67, -.37, 0.45, -.37, 0.34, -.47, -10000 };
102 double vehiclePoly_PassengerSedanLeftGlass[] = { 0.36, .43, 0.34, .47, 0.77, .47, 0.67, .37, 0.45, .37, 0.34, .47, -10000 };
103 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 };
104 double vehiclePoly_PassengerHatchbackRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.80, -.37, 0.45, -.37, 0.34, -.47, -10000 };
105 double vehiclePoly_PassengerHatchbackLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.80, .37, 0.45, .37, 0.34, .47, -10000 };
106 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 };
107 double vehiclePoly_PassengerWagonRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.87, -.37, 0.45, -.37, 0.34, -.47, -10000 };
108 double vehiclePoly_PassengerWagonLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.87, .37, 0.45, .37, 0.34, .47, -10000 };
109 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 };
110 
111 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 };
112 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 };
113 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 };
114 double vehiclePoly_PassengerVanRightGlass[] = { 0.36, -.43, 0.20, -.47, 0.98, -.47, 0.91, -.37, 0.31, -.37, 0.20, -.47, -10000 };
115 double vehiclePoly_PassengerVanLeftGlass[] = { 0.36, .43, 0.20, .47, 0.98, .47, 0.91, .37, 0.31, .37, 0.20, .47, -10000 };
116 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 };
117 
118 double vehiclePoly_DeliveryMediumRightGlass[] = { 0.21, -.43, 0.20, -.47, 0.38, -.47, 0.38, -.37, 0.31, -.37, 0.20, -.47, -10000 };
119 double vehiclePoly_DeliveryMediumLeftGlass[] = { 0.21, .43, 0.20, .47, 0.38, .47, 0.38, .37, 0.31, .37, 0.20, .47, -10000 };
120 
121 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 };
122 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 };
123 double vehiclePoly_TransportRightGlass[] = { 0.36, -.47, 0.10, -.48, 1.25, -.48, 1.25, -.4, 0.3, -.4, 0.10, -.48, -10000 };
124 double vehiclePoly_TransportLeftGlass[] = { 0.36, .47, 0.10, .48, 1.25, .48, 1.25, .4, 0.3, .4, 0.10, .48, -10000 };
125 
126 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 };
127 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 };
128 //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 };
129 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 };
130 
131 
132 // ===========================================================================
133 // method definitions
134 // ===========================================================================
135 /* -------------------------------------------------------------------------
136  * GUIVehicle::GUIVehiclePopupMenu - methods
137  * ----------------------------------------------------------------------- */
139  GUIMainWindow& app, GUISUMOAbstractView& parent,
140  GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations)
141  : GUIGLObjectPopupMenu(app, parent, o), myVehiclesAdditionalVisualizations(additionalVisualizations) {
142 }
143 
144 
146 
147 
148 long
150  assert(myObject->getType() == GLO_VEHICLE);
151  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES)) {
152  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES);
153  }
154  return 1;
155 }
156 
157 long
159  assert(myObject->getType() == GLO_VEHICLE);
160  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES);
161  return 1;
162 }
163 
164 
165 long
167  assert(myObject->getType() == GLO_VEHICLE);
168  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ROUTE)) {
169  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_ROUTE);
170  }
171  return 1;
172 }
173 
174 long
176  assert(myObject->getType() == GLO_VEHICLE);
177  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_ROUTE);
178  return 1;
179 }
180 
181 
182 long
184  assert(myObject->getType() == GLO_VEHICLE);
185  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES)) {
186  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES);
187  }
188  return 1;
189 }
190 
191 long
193  assert(myObject->getType() == GLO_VEHICLE);
194  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES);
195  return 1;
196 }
197 
198 
199 long
201  assert(myObject->getType() == GLO_VEHICLE);
202  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_TRACKED)) {
203  myParent->startTrack(static_cast<GUIVehicle*>(myObject)->getGlID());
204  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_TRACKED);
205  }
206  return 1;
207 }
208 
209 long
211  assert(myObject->getType() == GLO_VEHICLE);
212  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_TRACKED);
213  myParent->stopTrack();
214  return 1;
215 }
216 
217 
218 long
220  assert(myObject->getType() == GLO_VEHICLE);
221  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS)) {
222  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS);
223  }
224  return 1;
225 }
226 
227 long
229  assert(myObject->getType() == GLO_VEHICLE);
230  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS);
231  return 1;
232 }
233 
234 long
236  assert(myObject->getType() == GLO_VEHICLE);
237  static_cast<GUIVehicle*>(myObject)->selectBlockingFoes();
238  return 1;
239 }
240 
241 
242 /* -------------------------------------------------------------------------
243  * GUIVehicle - methods
244  * ----------------------------------------------------------------------- */
246  const MSVehicleType* type,
247  SUMOReal speedFactor) :
248  MSVehicle(pars, route, type, speedFactor),
249  GUIGlObject(GLO_VEHICLE, pars->id) {
250  // as it is possible to show all vehicle routes, we have to store them... (bug [ 2519761 ])
252  myMoveReminders.push_back(std::make_pair(myRoutes, 0.));
253  mySeatPositions.push_back(Position(0, 0)); // ensure length 1
254 }
255 
256 
258  myLock.lock();
259  for (std::map<GUISUMOAbstractView*, int>::iterator i = myAdditionalVisualizations.begin(); i != myAdditionalVisualizations.end(); ++i) {
260  while (i->first->removeAdditionalGLVisualisation(this));
261  }
262  myLock.unlock();
264  delete myRoutes;
265 }
266 
267 
270  GUISUMOAbstractView& parent) {
272  buildPopupHeader(ret, app);
276  //
278  new FXMenuCommand(ret, "Hide Current Route", 0, ret, MID_HIDE_CURRENTROUTE);
279  } else {
280  new FXMenuCommand(ret, "Show Current Route", 0, ret, MID_SHOW_CURRENTROUTE);
281  }
283  new FXMenuCommand(ret, "Hide All Routes", 0, ret, MID_HIDE_ALLROUTES);
284  } else {
285  new FXMenuCommand(ret, "Show All Routes", 0, ret, MID_SHOW_ALLROUTES);
286  }
288  new FXMenuCommand(ret, "Hide Best Lanes", 0, ret, MID_HIDE_BEST_LANES);
289  } else {
290  new FXMenuCommand(ret, "Show Best Lanes", 0, ret, MID_SHOW_BEST_LANES);
291  }
293  new FXMenuCommand(ret, "Hide Link Items", 0, ret, MID_HIDE_LFLINKITEMS);
294  } else {
295  new FXMenuCommand(ret, "Show Link Items", 0, ret, MID_SHOW_LFLINKITEMS);
296  }
297  new FXMenuSeparator(ret);
298  int trackedID = parent.getTrackedID();
299  if (trackedID < 0 || (size_t)trackedID != getGlID()) {
300  new FXMenuCommand(ret, "Start Tracking", 0, ret, MID_START_TRACK);
301  } else {
302  new FXMenuCommand(ret, "Stop Tracking", 0, ret, MID_STOP_TRACK);
303  }
304  new FXMenuCommand(ret, "Select Foes", 0, ret, MID_SHOW_FOES);
305 
306  new FXMenuSeparator(ret);
307  //
309  buildPositionCopyEntry(ret, false);
310  return ret;
311 }
312 
313 
318  new GUIParameterTableWindow(app, *this, 34);
319  // add items
320  ret->mkItem("lane [id]", false, myLane->getID());
321  ret->mkItem("position [m]", true,
323  ret->mkItem("speed [m/s]", true,
325  ret->mkItem("angle [degree]", true,
327  if (getChosenSpeedFactor() != 1) {
328  ret->mkItem("speed factor", false, getChosenSpeedFactor());
329  }
330  ret->mkItem("time gap [s]", true,
332  ret->mkItem("waiting time [s]", true,
334  ret->mkItem("impatience", true,
336  ret->mkItem("last lane change [s]", true,
338  ret->mkItem("desired depart [s]", false, time2string(getParameter().depart));
339  if (getParameter().repetitionNumber < INT_MAX) {
340  ret->mkItem("remaining [#]", false, (unsigned int) getParameter().repetitionNumber - getParameter().repetitionsDone);
341  }
342  if (getParameter().repetitionOffset > 0) {
343  ret->mkItem("insertion period [s]", false, time2string(getParameter().repetitionOffset));
344  }
345  if (getParameter().repetitionProbability > 0) {
346  ret->mkItem("insertion probability", false, getParameter().repetitionProbability);
347  }
348  ret->mkItem("stop info", false, getStopInfo());
349  ret->mkItem("CO2 [mg/s]", true,
351  ret->mkItem("CO [mg/s]", true,
353  ret->mkItem("HC [mg/s]", true,
355  ret->mkItem("NOx [mg/s]", true,
357  ret->mkItem("PMx [mg/s]", true,
359  ret->mkItem("fuel [ml/s]", true,
361  ret->mkItem("noise (Harmonoise) [dB]", true,
363  ret->mkItem("parameters [key:val]", false, toString(getParameter().getMap()));
364  ret->mkItem("", false, "");
365  ret->mkItem("Type Information:", false, "");
366  ret->mkItem("type [id]", false, myType->getID());
367  ret->mkItem("length", false, myType->getLength());
368  ret->mkItem("minGap", false, myType->getMinGap());
369  ret->mkItem("vehicle class", false, SumoVehicleClassStrings.getString(myType->getVehicleClass()));
370  ret->mkItem("emission class", false, PollutantsInterface::getName(myType->getEmissionClass()));
371  ret->mkItem("maximum speed [m/s]", false, getMaxSpeed());
372  ret->mkItem("maximum acceleration [m/s^2]", false, getCarFollowModel().getMaxAccel());
373  ret->mkItem("maximum deceleration [m/s^2]", false, getCarFollowModel().getMaxDecel());
374  ret->mkItem("imperfection (sigma)", false, getCarFollowModel().getImperfection());
375  ret->mkItem("reaction time (tau)", false, getCarFollowModel().getHeadwayTime());
376  ret->mkItem("type parameters [key:val]", false, toString(myType->getParameter().getMap()));
377  // close building
378  ret->closeBuilding();
379  return ret;
380 }
381 
382 
383 Boundary
385  Boundary b;
386  b.add(getPosition());
387  b.grow(20);
388  return b;
389 }
390 
391 
392 void
394  glPushMatrix();
395  glScaled(getVehicleType().getWidth(), getVehicleType().getLength(), 1.);
396  glBegin(GL_TRIANGLE_STRIP);
397  glVertex2d(0., 0.);
398  glVertex2d(-.5, .15);
399  glVertex2d(.5, .15);
400  glVertex2d(-.5, 1.);
401  glVertex2d(.5, 1.);
402  glEnd();
403  glPopMatrix();
404 }
405 
406 
407 void
409  const SUMOReal length = getVehicleType().getLength();
410  if (length >= 8.) {
412  return;
413  }
414  glPushMatrix();
415  glScaled(getVehicleType().getWidth(), length, 1.);
416  glBegin(GL_TRIANGLES);
417  glVertex2d(0., 0.);
418  glVertex2d(-.5, 1.);
419  glVertex2d(.5, 1.);
420  glEnd();
421  glPopMatrix();
422 }
423 
424 
425 void
426 GUIVehicle::drawPoly(double* poses, SUMOReal offset) {
427  glPushMatrix();
428  glTranslated(0, 0, offset * .1);
429  glPolygonOffset(0, offset * -1);
430  glBegin(GL_TRIANGLE_FAN);
431  int i = 0;
432  while (poses[i] > -999) {
433  glVertex2d(poses[i], poses[i + 1]);
434  i = i + 2;
435  }
436  glEnd();
437  glPopMatrix();
438 }
439 
440 
441 void
443  RGBColor current = GLHelper::getColor();
444  RGBColor lighter = current.changedBrightness(51);
445  RGBColor darker = current.changedBrightness(-51);
446 
447  const SUMOReal length = getVehicleType().getLength();
448  const SUMOReal width = getVehicleType().getWidth();
449  glPushMatrix();
450  glRotated(90, 0, 0, 1);
451  glScaled(length, width, 1.);
453 
454  // draw main body
455  switch (shape) {
456  case SVS_UNKNOWN:
458  GLHelper::setColor(lighter);
459  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
460  glColor3d(0, 0, 0);
461  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
462  break;
463  case SVS_PEDESTRIAN:
464  glTranslated(0, 0, .045);
466  glTranslated(0, 0, -.045);
467  glScaled(.7, 2, 1);
468  glTranslated(0, 0, .04);
469  GLHelper::setColor(lighter);
471  glTranslated(0, 0, -.04);
472  break;
473  case SVS_BICYCLE:
474  case SVS_MOPED:
475  case SVS_MOTORCYCLE: {
476  glPushMatrix();
477  glTranslated(.5, 0, 0);
478  glScaled(.25 / (length), 1, 1.);
479  glTranslated(0, 0, .045);
481  glScaled(.7, 2, 1);
482  glTranslated(0, 0, -.045);
483  glTranslated(0, 0, .04);
484  GLHelper::setColor(lighter);
486  glTranslated(0, 0, -.04);
487  glPopMatrix();
488  }
489  break;
490  case SVS_PASSENGER:
491  case SVS_PASSENGER_SEDAN:
493  case SVS_PASSENGER_WAGON:
495  GLHelper::setColor(lighter);
496  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
497  glColor3d(0, 0, 0);
498  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
499  break;
500  case SVS_PASSENGER_VAN:
501  drawPoly(vehiclePoly_PassengerVanBody, 4);
502  GLHelper::setColor(lighter);
503  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
504  glColor3d(0, 0, 0);
505  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
506  drawPoly(vehiclePoly_PassengerVanRightGlass, 4.5);
507  drawPoly(vehiclePoly_PassengerVanLeftGlass, 4.5);
508  drawPoly(vehiclePoly_PassengerVanBackGlass, 4.5);
509  break;
510  case SVS_DELIVERY:
511  drawPoly(vehiclePoly_PassengerVanBody, 4);
512  GLHelper::setColor(lighter);
513  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
514  glColor3d(0, 0, 0);
515  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
516  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
517  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
518  break;
519  case SVS_TRUCK:
521  case SVS_TRUCK_1TRAILER:
522  glScaled(1. / (length), 1, 1.);
523  drawPoly(vehiclePoly_TransportBody, 4);
524  glColor3d(0, 0, 0);
525  drawPoly(vehiclePoly_TransportFrontGlass, 4.5);
526  drawPoly(vehiclePoly_TransportRightGlass, 4.5);
527  drawPoly(vehiclePoly_TransportLeftGlass, 4.5);
528  break;
529  case SVS_BUS:
530  case SVS_BUS_COACH:
531  case SVS_BUS_TROLLEY: {
532  SUMOReal ml = length;
533  glScaled(1. / (length), 1, 1.);
534  glTranslated(0, 0, .04);
535  glBegin(GL_TRIANGLE_FAN);
536  glVertex2d(ml / 2., 0);
537  glVertex2d(0, 0);
538  glVertex2d(0, -.45);
539  glVertex2d(0 + .05, -.5);
540  glVertex2d(ml - .05, -.5);
541  glVertex2d(ml, -.45);
542  glVertex2d(ml, .45);
543  glVertex2d(ml - .05, .5);
544  glVertex2d(0 + .05, .5);
545  glVertex2d(0, .45);
546  glVertex2d(0, 0);
547  glEnd();
548  glTranslated(0, 0, -.04);
549 
550  glTranslated(0, 0, .045);
551  glColor3d(0, 0, 0);
552  glBegin(GL_QUADS);
553  glVertex2d(0 + .05, .48);
554  glVertex2d(0 + .05, -.48);
555  glVertex2d(0 + .15, -.48);
556  glVertex2d(0 + .15, .48);
557 
558  glVertex2d(ml - .1, .45);
559  glVertex2d(ml - .1, -.45);
560  glVertex2d(ml - .05, -.45);
561  glVertex2d(ml - .05, .45);
562 
563  glVertex2d(0 + .20, .49);
564  glVertex2d(0 + .20, .45);
565  glVertex2d(ml - .20, .45);
566  glVertex2d(ml - .20, .49);
567 
568  glVertex2d(0 + .20, -.49);
569  glVertex2d(0 + .20, -.45);
570  glVertex2d(ml - .20, -.45);
571  glVertex2d(ml - .20, -.49);
572 
573  glEnd();
574  glTranslated(0, 0, -.045);
575  }
576  break;
577  case SVS_BUS_FLEXIBLE:
578  case SVS_RAIL:
579  case SVS_RAIL_CAR:
580  case SVS_RAIL_CARGO:
581  drawAction_drawCarriageClass(s, shape, false);
582  break;
583  case SVS_E_VEHICLE:
584  drawPoly(vehiclePoly_EVehicleBody, 4);
585  glColor3d(0, 0, 0);
586  drawPoly(vehiclePoly_EVehicleFrontGlass, 4.5);
587  glTranslated(0, 0, .048);
588  GLHelper::setColor(current);
589  glBegin(GL_QUADS);
590  glVertex2d(.3, .5);
591  glVertex2d(.35, .5);
592  glVertex2d(.35, -.5);
593  glVertex2d(.3, -.5);
594 
595  glVertex2d(.3, -.05);
596  glVertex2d(.7, -.05);
597  glVertex2d(.7, .05);
598  glVertex2d(.3, .05);
599 
600  glVertex2d(.7, .5);
601  glVertex2d(.65, .5);
602  glVertex2d(.65, -.5);
603  glVertex2d(.7, -.5);
604  glEnd();
605  glTranslated(0, 0, -.048);
606  //drawPoly(vehiclePoly_EVehicleBackGlass, 4.5);
607  break;
608  case SVS_ANT:
609  glPushMatrix();
610  // ant is stretched via vehicle length
611  GLHelper::setColor(darker);
612  // draw left side
613  GLHelper::drawBoxLine(Position(-0.2, -.10), 350, 0.5, .02);
614  GLHelper::drawBoxLine(Position(-0.3, -.50), 240, 0.4, .03);
615  GLHelper::drawBoxLine(Position(0.3, -.10), 340, 0.8, .03);
616  GLHelper::drawBoxLine(Position(0.05, -.80), 290, 0.6, .04);
617  GLHelper::drawBoxLine(Position(0.4, -.10), 20, 0.8, .03);
618  GLHelper::drawBoxLine(Position(0.65, -.80), 75, 0.6, .04);
619  GLHelper::drawBoxLine(Position(0.5, -.10), 55, 0.8, .04);
620  GLHelper::drawBoxLine(Position(1.1, -.55), 90, 0.6, .04);
621  // draw right side
622  GLHelper::drawBoxLine(Position(-0.2, .10), 190, 0.5, .02);
623  GLHelper::drawBoxLine(Position(-0.3, .50), 300, 0.4, .03);
624  GLHelper::drawBoxLine(Position(0.3, .10), 200, 0.8, .03);
625  GLHelper::drawBoxLine(Position(0.05, .80), 250, 0.6, .04);
626  GLHelper::drawBoxLine(Position(0.4, .10), 160, 0.8, .03);
627  GLHelper::drawBoxLine(Position(0.65, .80), 105, 0.6, .04);
628  GLHelper::drawBoxLine(Position(0.5, .10), 125, 0.8, .04);
629  GLHelper::drawBoxLine(Position(1.1, .55), 90, 0.6, .04);
630  // draw body
631  GLHelper::setColor(current);
632  glTranslated(0, 0, 0.1);
634  glTranslated(.4, 0, 0);
636  glTranslated(.4, 0, 0);
638  glPopMatrix();
639  break;
640  default: // same as passenger
642  glColor3d(1, 1, 1);
643  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
644  glColor3d(0, 0, 0);
645  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
646  break;
647  }
648 
649  // draw decorations
650  switch (shape) {
651  case SVS_PEDESTRIAN:
652  break;
653  case SVS_BICYCLE:
654  //glScaled(length, 1, 1.);
655  glBegin(GL_TRIANGLE_FAN);
656  glVertex2d(1 / 2., 0);
657  glVertex2d(0, 0);
658  glVertex2d(0, -.03);
659  glVertex2d(0 + .05, -.05);
660  glVertex2d(1 - .05, -.05);
661  glVertex2d(1, -.03);
662  glVertex2d(1, .03);
663  glVertex2d(1 - .05, .05);
664  glVertex2d(0 + .05, .05);
665  glVertex2d(0, .03);
666  glVertex2d(0, 0);
667  glEnd();
668  break;
669  case SVS_MOPED:
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_TRUCK:
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_TRUCK_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_COACH:
736  case SVS_BUS_FLEXIBLE:
737  case SVS_RAIL:
738  case SVS_RAIL_CAR:
739  case SVS_RAIL_CARGO:
740  case SVS_E_VEHICLE:
741  case SVS_ANT:
742  break;
743  default: // same as passenger/sedan
744  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
745  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
746  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
747  break;
748  }
749  /*
750  glBegin(GL_TRIANGLE_FAN);
751  glVertex2d(.5,.5); // center - strip begin
752  glVertex2d(0, .5); // center, front
753  glVertex2d(0, .8); // ... clockwise ... (vehicle right side)
754  glVertex2d(0.08, .94);
755  glVertex2d(0.25, 1.);
756  glVertex2d(0.95, 1.);
757  glVertex2d(1., .9);
758  glVertex2d(1., .1); // (vehicle left side)
759  glVertex2d(0.95, 0.);
760  glVertex2d(0.25, 0.);
761  glVertex2d(0.08, .06);
762  glVertex2d(0, .2); //
763  glVertex2d(0, .5); // center, front (close)
764  glEnd();
765 
766  glPolygonOffset(0, -4.5);
767  glColor3d(1, 1, 1); // front
768  glBegin(GL_TRIANGLE_FAN);
769  glVertex2d(0.1,0.5);
770  glVertex2d(0.025,0.5);
771  glVertex2d(0.025,0.75);
772  glVertex2d(0.27,0.9);
773  glVertex2d(0.27,0.1);
774  glVertex2d(0.025,0.25);
775  glVertex2d(0.025,0.5);
776  glEnd();
777 
778  glColor3d(0, 0, 0); // front glass
779  glBegin(GL_TRIANGLE_FAN);
780  glVertex2d(0.35,0.5);
781  glVertex2d(0.3,0.5);
782  glVertex2d(0.3,0.9);
783  glVertex2d(0.43,0.8);
784  glVertex2d(0.43,0.2);
785  glVertex2d(0.3,0.1);
786  glVertex2d(0.3,0.5);
787  glEnd();
788 
789  glBegin(GL_TRIANGLE_FAN); // back glass
790  glVertex2d(0.92,0.5);
791  glVertex2d(0.90,0.5);
792  glVertex2d(0.90,0.8);
793  glVertex2d(0.95,0.9);
794  glVertex2d(0.95,0.1);
795  glVertex2d(0.90,0.2);
796  glVertex2d(0.90,0.5);
797  glEnd();
798 
799  glBegin(GL_TRIANGLE_FAN); // right glass
800  glVertex2d(0.36,0.07);
801  glVertex2d(0.34,0.03);
802  glVertex2d(0.94,0.03);
803  glVertex2d(0.87,0.13);
804  glVertex2d(0.45,0.13);
805  glVertex2d(0.34,0.03);
806  glEnd();
807 
808  glBegin(GL_TRIANGLE_FAN); // left glass
809  glVertex2d(0.36,1.-0.07);
810  glVertex2d(0.34,1.-0.03);
811  glVertex2d(0.94,1.-0.03);
812  glVertex2d(0.87,1.-0.13);
813  glVertex2d(0.45,1.-0.13);
814  glVertex2d(0.34,1.-0.03);
815  glEnd();
816  */
817 
818  glPopMatrix();
819 }
820 
821 
822 bool
824  const std::string& file = getVehicleType().getImgFile();
825  if (file != "") {
826  int textureID = GUITexturesHelper::getTextureID(file);
827  if (textureID > 0) {
828  if (length < 0) {
830  }
831  const SUMOReal halfWidth = getVehicleType().getWidth() / 2.0 * s.vehicleExaggeration;
832  GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, 0, halfWidth, length);
833  return true;
834  }
835  }
836  return false;
837 }
838 
839 
840 bool
842  switch (guiShape) {
843  case SVS_BUS_FLEXIBLE:
844  drawAction_drawRailCarriages(s, 8.25, 0, 0, asImage); // 16.5 overall, 2 modules http://de.wikipedia.org/wiki/Ikarus_180
845  break;
846  case SVS_RAIL:
847  drawAction_drawRailCarriages(s, 24.5, 1, 1, asImage); // http://de.wikipedia.org/wiki/UIC-Y-Wagen_%28DR%29
848  break;
849  case SVS_RAIL_CAR:
850  drawAction_drawRailCarriages(s, 16.85, 1, 0, asImage); // 67.4m overall, 4 carriages http://de.wikipedia.org/wiki/DB-Baureihe_423
851 // drawAction_drawRailCarriages(s, 5.71, 0, 0, asImage); // 40.0m overall, 7 modules http://de.wikipedia.org/wiki/Bombardier_Flexity_Berlin
852 // drawAction_drawRailCarriages(s, 9.44, 1, 1, asImage); // actually length of the locomotive http://de.wikipedia.org/wiki/KJI_Nr._20_und_21
853 // drawAction_drawRailCarriages(s, 24.775, 0, 0, asImage); // http://de.wikipedia.org/wiki/ICE_3
854  break;
855  case SVS_RAIL_CARGO:
856  drawAction_drawRailCarriages(s, 13.86, 1, 0, asImage); // UIC 571-1 http://de.wikipedia.org/wiki/Flachwagen
857  break;
858  default:
859  return false;
860  }
861  return true;
862 }
863 
864 #define BLINKER_POS_FRONT .5
865 #define BLINKER_POS_BACK .5
866 
867 inline void
868 drawAction_drawBlinker(double dir, SUMOReal length) {
869  glColor3d(1.f, .8f, 0);
870  glPushMatrix();
871  glTranslated(dir, BLINKER_POS_FRONT, -0.1);
873  glPopMatrix();
874  glPushMatrix();
875  glTranslated(dir, length - BLINKER_POS_BACK, -0.1);
877  glPopMatrix();
878 }
879 
880 
881 inline void
884  return;
885  }
886  const double offset = MAX2(.5 * veh.getVehicleType().getWidth(), .4);
888  drawAction_drawBlinker(-offset, length);
889  }
891  drawAction_drawBlinker(offset, length);;
892  }
894  drawAction_drawBlinker(-offset, length);
895  drawAction_drawBlinker(offset, length);
896  }
897 }
898 
899 
900 inline void
903  return;
904  }
905  glColor3f(1.f, .2f, 0);
906  glPushMatrix();
907  glTranslated(-veh.getVehicleType().getWidth() * 0.5, length, -0.1);
909  glPopMatrix();
910  glPushMatrix();
911  glTranslated(veh.getVehicleType().getWidth() * 0.5, length, -0.1);
913  glPopMatrix();
914 }
915 
916 
917 void
919  glPushName(getGlID());
920  glPushMatrix();
921  Position p1 = getPosition();
922  // one seat in the center of the vehicle by default
924  glTranslated(p1.x(), p1.y(), getType());
925  glRotated(getAngle(), 0, 0, 1);
926  // set lane color
927  setColor(s);
928  // scale
929  SUMOReal upscale = s.vehicleExaggeration;
930  glScaled(upscale, upscale, 1);
931  /*
932  MSLCM_DK2004 &m2 = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
933  if((m2.getState()&LCA_URGENT)!=0) {
934  glColor3d(1, .4, .4);
935  } else if((m2.getState()&LCA_SPEEDGAIN)!=0) {
936  glColor3d(.4, .4, 1);
937  } else {
938  glColor3d(.4, 1, .4);
939  }
940  */
941  // draw the vehicle
943  switch (s.vehicleQuality) {
944  case 0:
946  break;
947  case 1:
949  break;
950  case 2:
952  break;
953  case 3:
954  default:
955  // draw as image but take special care for drawing trains
956  // fallback to simple shapes
957  if (!drawAction_drawCarriageClass(s, getVehicleType().getGuiShape(), true)) {
960  };
961  }
962  break;
963  }
964  if (s.drawMinGap) {
965  SUMOReal minGap = -getVehicleType().getMinGap();
966  glColor3d(0., 1., 0.);
967  glBegin(GL_LINES);
968  glVertex2d(0., 0);
969  glVertex2d(0., minGap);
970  glVertex2d(-.5, minGap);
971  glVertex2d(.5, minGap);
972  glEnd();
973  }
974  // draw the blinker and brakelights if wished
975  if (s.showBlinker) {
976  glTranslated(0, 0, .1);
977  switch (getVehicleType().getGuiShape()) {
978  case SVS_PEDESTRIAN:
979  case SVS_BICYCLE:
980  case SVS_ANT:
981  case SVS_RAIL:
982  case SVS_RAIL_CARGO:
983  // only SVS_RAIL_CAR has blinkers and brake lights
984  break;
985  default:
988  break;
989  }
990  }
991  // draw the wish to change the lane
992  if (s.drawLaneChangePreference) {
993  /*
994  if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
995  MSLCM_DK2004 &m = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
996  glColor3d(.5, .5, 1);
997  glBegin(GL_LINES);
998  glVertex2f(0, 0);
999  glVertex2f(m.getChangeProbability(), .5);
1000  glEnd();
1001 
1002  glColor3d(1, 0, 0);
1003  glBegin(GL_LINES);
1004  glVertex2f(0.1, 0);
1005  glVertex2f(0.1, m.myMaxJam1);
1006  glEnd();
1007 
1008  glColor3d(0, 1, 0);
1009  glBegin(GL_LINES);
1010  glVertex2f(-0.1, 0);
1011  glVertex2f(-0.1, m.myTDist);
1012  glEnd();
1013  }
1014  */
1015  }
1016  // draw best lanes
1017  /*
1018  if (true) {
1019  const MSLane &l = veh->getLane();
1020  SUMOReal r1 = veh->allowedContinuationsLength(&l, 0);
1021  SUMOReal r2 = l.getLeftLane()!=0 ? veh->allowedContinuationsLength(l.getLeftLane(), 0) : 0;
1022  SUMOReal r3 = l.getRightLane()!=0 ? veh->allowedContinuationsLength(l.getRightLane(), 0) : 0;
1023  SUMOReal mmax = MAX3(r1, r2, r3);
1024  glBegin(GL_LINES);
1025  glVertex2f(0, 0);
1026  glVertex2f(0, r1/mmax/2.);
1027  glEnd();
1028  glBegin(GL_LINES);
1029  glVertex2f(.4, 0);
1030  glVertex2f(.4, r2/mmax/2.);
1031  glEnd();
1032  glBegin(GL_LINES);
1033  glVertex2f(-.4, 0);
1034  glVertex2f(-.4, r3/mmax/2.);
1035  glEnd();
1036  }
1037  */
1038  glPopMatrix();
1039  drawName(getPosition(-MIN2(getVehicleType().getLength() / 2, SUMOReal(5))),
1040  s.scale,
1041  getVehicleType().getGuiShape() == SVS_PEDESTRIAN ? s.personName : s.vehicleName);
1042  glPopName();
1043  if (myPersonDevice != 0) {
1044  const std::vector<MSPerson*>& ps = myPersonDevice->getPersons();
1045  size_t personIndex = 0;
1046  for (std::vector<MSPerson*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
1047  GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
1048  assert(person != 0);
1049  person->setPositionInVehicle(getSeatPosition(personIndex++));
1050  person->drawGL(s);
1051  }
1052  }
1053 }
1054 
1055 
1056 void
1058  glPushName(getGlID());
1059  glPushMatrix();
1060  glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
1062  drawBestLanes();
1063  }
1065  drawRoute(s, 0, 0.25);
1066  }
1068  if (getNumberReroutes() > 0) {
1069  const int noReroutePlus1 = getNumberReroutes() + 1;
1070  for (int i = noReroutePlus1 - 1; i >= 0; i--) {
1071  SUMOReal darken = SUMOReal(0.4) / SUMOReal(noReroutePlus1) * SUMOReal(i);
1072  drawRoute(s, i, darken);
1073  }
1074  } else {
1075  drawRoute(s, 0, 0.25);
1076  }
1077  }
1079  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
1080  if ((*i).myLink == 0) {
1081  continue;
1082  }
1083  MSLink* link = (*i).myLink;
1084  MSLane* via = link->getViaLaneOrLane();
1085  if (via != 0) {
1086  Position p = via->getShape()[0];
1087  if ((*i).mySetRequest) {
1088  glColor3d(0, .8, 0);
1089  } else {
1090  glColor3d(.8, 0, 0);
1091  }
1092  const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
1093  (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(), getVehicleType().getLengthWithGap());
1094  drawLinkItem(p, (*i).myArrivalTime, leaveTime, s.addExaggeration);
1095  // the time slot that ego vehicle uses when checking opened may
1096  // differ from the one it requests in setApproaching
1097  MSLink::ApproachingVehicleInformation avi = (*i).myLink->getApproaching(this);
1098  assert(avi.arrivalTime == (*i).myArrivalTime && avi.leavingTime == leaveTime);
1099  UNUSED_PARAMETER(avi); // only used for assertion
1100  }
1101  }
1102  }
1103  glPopMatrix();
1104  glPopName();
1105 }
1106 
1107 
1108 void
1109 GUIVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate) {
1110  glTranslated(pos.x(), pos.y(), -.1);
1112  std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
1113  GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
1114  glTranslated(-pos.x(), -pos.y(), .1);
1115 }
1116 
1117 
1118 void
1120  const GUIColorer& c = s.vehicleColorer;
1121  if (!setFunctionalColor(c.getActive())) {
1123  }
1124 }
1125 
1126 
1127 bool
1128 GUIVehicle::setFunctionalColor(size_t activeScheme) const {
1129  switch (activeScheme) {
1130  case 0: {
1131  if (getParameter().wasSet(VEHPARS_COLOR_SET)) {
1133  return true;
1134  }
1135  if (getVehicleType().wasSet(VTYPEPARS_COLOR_SET)) {
1136  GLHelper::setColor(getVehicleType().getColor());
1137  return true;
1138  }
1139  if (&getRoute().getColor() != &RGBColor::DEFAULT_COLOR) {
1140  GLHelper::setColor(getRoute().getColor());
1141  return true;
1142  }
1143  return false;
1144  }
1145  case 2: {
1146  if (getParameter().wasSet(VEHPARS_COLOR_SET)) {
1148  return true;
1149  }
1150  return false;
1151  }
1152  case 3: {
1153  if (getVehicleType().wasSet(VTYPEPARS_COLOR_SET)) {
1154  GLHelper::setColor(getVehicleType().getColor());
1155  return true;
1156  }
1157  return false;
1158  }
1159  case 4: {
1160  if (&getRoute().getColor() != &RGBColor::DEFAULT_COLOR) {
1161  GLHelper::setColor(getRoute().getColor());
1162  return true;
1163  }
1164  return false;
1165  }
1166  case 5: {
1167  Position p = getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1168  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1169  Position center = b.getCenter();
1170  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1171  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1172  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1173  return true;
1174  }
1175  case 6: {
1176  Position p = getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
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 7: {
1185  Position pb = getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1186  Position pe = getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1187  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1188  SUMOReal hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / PI;
1189  Position minp(b.xmin(), b.ymin());
1190  Position maxp(b.xmax(), b.ymax());
1191  SUMOReal sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1192  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1193  return true;
1194  }
1195  }
1196  return false;
1197 }
1198 
1199 
1200 SUMOReal
1201 GUIVehicle::getColorValue(size_t activeScheme) const {
1202  switch (activeScheme) {
1203  case 8:
1204  return getSpeed();
1205  case 9:
1206  return getWaitingSeconds();
1207  case 10:
1208  return getLastLaneChangeOffset();
1209  case 11:
1210  return MIN2(getMaxSpeed(), getLane()->getVehicleMaxSpeed(this));
1211  case 12:
1212  return getCO2Emissions();
1213  case 13:
1214  return getCOEmissions();
1215  case 14:
1216  return getPMxEmissions();
1217  case 15:
1218  return getNOxEmissions();
1219  case 16:
1220  return getHCEmissions();
1221  case 17:
1222  return getFuelConsumption();
1223  case 18:
1225  case 19: // !!! unused!?
1226  if (getNumberReroutes() == 0) {
1227  return -1;
1228  }
1229  return getNumberReroutes();
1230  case 20:
1232  case 21:
1233  return getBestLaneOffset();
1234  case 22:
1235  return getAcceleration();
1236  case 23:
1237  return getTimeGap();
1238  }
1239  return 0;
1240 }
1241 
1242 
1243 // ------------ Additional visualisations
1244 bool
1246  return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
1247 }
1248 
1249 
1250 void
1252  if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
1253  myAdditionalVisualizations[parent] = 0;
1254  }
1255  myAdditionalVisualizations[parent] |= which;
1256  parent->addAdditionalGLVisualisation(this);
1257 }
1258 
1259 
1260 void
1262  myAdditionalVisualizations[parent] &= ~which;
1263  parent->removeAdditionalGLVisualisation(this);
1264 }
1265 
1266 
1267 void
1268 GUIVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const {
1269  setColor(s);
1270  GLdouble colors[4];
1271  glGetDoublev(GL_CURRENT_COLOR, colors);
1272  colors[0] -= darken;
1273  if (colors[0] < 0) {
1274  colors[0] = 0;
1275  }
1276  colors[1] -= darken;
1277  if (colors[1] < 0) {
1278  colors[1] = 0;
1279  }
1280  colors[2] -= darken;
1281  if (colors[2] < 0) {
1282  colors[2] = 0;
1283  }
1284  colors[3] -= darken;
1285  if (colors[3] < 0) {
1286  colors[3] = 0;
1287  }
1288  glColor3dv(colors);
1289  if (routeNo == 0) {
1291  return;
1292  }
1293  --routeNo; // only prior routes are stored
1295 }
1296 
1297 
1298 void
1300  myLock.lock();
1301  std::vector<std::vector<MSVehicle::LaneQ> > bestLanes = myBestLanes;
1302  myLock.unlock();
1303  SUMOReal width = 0.5;
1304  for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
1305  std::vector<MSVehicle::LaneQ>& lanes = *j;
1306  SUMOReal gmax = -1;
1307  SUMOReal rmax = -1;
1308  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1309  gmax = MAX2((*i).length, gmax);
1310  rmax = MAX2((*i).occupation, rmax);
1311  }
1312  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1313  const PositionVector& shape = (*i).lane->getShape();
1314  SUMOReal g = (*i).length / gmax;
1315  SUMOReal r = (*i).occupation / rmax;
1316  glColor3d(r, g, 0);
1317  GLHelper::drawBoxLines(shape, width);
1318 
1319  PositionVector s1 = shape;
1320  s1.move2side((SUMOReal) .1);
1321  glColor3d(r, 0, 0);
1322  GLHelper::drawLine(s1);
1323  s1.move2side((SUMOReal) - .2);
1324  glColor3d(0, g, 0);
1325  GLHelper::drawLine(s1);
1326 
1327  glColor3d(r, g, 0);
1328  Position lastPos = shape[-1];
1329  }
1330  width = .2;
1331  }
1332 }
1333 
1334 
1335 void
1336 GUIVehicle::drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const {
1337  MSRouteIterator i = r.begin();
1338  const std::vector<MSLane*>& bestLaneConts = getBestLanesContinuation();
1339  // draw continuation lanes when drawing the current route where available
1340  size_t bestLaneIndex = (&r == myRoute ? 0 : bestLaneConts.size());
1341  for (; i != r.end(); ++i) {
1342  const GUILane* lane;
1343  if (bestLaneIndex < bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) {
1344  lane = static_cast<GUILane*>(bestLaneConts[bestLaneIndex]);
1345  ++bestLaneIndex;
1346  } else {
1347  lane = static_cast<GUILane*>((*i)->getLanes()[0]);
1348  }
1349  GLHelper::drawBoxLines(lane->getShape(), lane->getShapeRotations(), lane->getShapeLengths(), exaggeration);
1350  }
1351 }
1352 
1353 
1354 MSLane*
1355 GUIVehicle::getPreviousLane(MSLane* current, int& furtherIndex) const {
1356  if (furtherIndex < (int)myFurtherLanes.size()) {
1357  return myFurtherLanes[furtherIndex++];
1358  } else {
1359  return current;
1360  }
1361 }
1362 
1363 
1364 void
1365 GUIVehicle::drawAction_drawRailCarriages(const GUIVisualizationSettings& s, SUMOReal defaultLength, SUMOReal carriageGap, int firstPassengerCarriage, bool asImage) const {
1366  RGBColor current = GLHelper::getColor();
1367  RGBColor darker = current.changedBrightness(-51);
1368  const SUMOReal length = getVehicleType().getLength() * s.vehicleExaggeration;
1369  const SUMOReal halfWidth = getVehicleType().getWidth() / 2.0 * s.vehicleExaggeration;
1370  glPopMatrix(); // undo scaling and 90 degree rotation
1371  glPopMatrix(); // undo initial translation and rotation
1372  GLHelper::setColor(darker);
1373  const SUMOReal xCornerCut = 0.3;
1374  const SUMOReal yCornerCut = 0.4;
1375  // round to closest integer
1376  const int numCarriages = floor(length / (defaultLength + carriageGap) + 0.5);
1377  assert(numCarriages > 0);
1378  const SUMOReal carriageLengthWithGap = length / numCarriages;
1379  const SUMOReal carriageLength = carriageLengthWithGap - carriageGap;
1380  // lane on which the carriage front is situated
1381  MSLane* lane = myLane;
1382  int furtherIndex = 0;
1383  // lane on which the carriage back is situated
1384  MSLane* backLane = myLane;
1385  int backFurtherIndex = furtherIndex;
1386  // offsets of front and back
1387  SUMOReal carriageOffset = myState.pos();
1388  SUMOReal carriageBackOffset = myState.pos() - carriageLength;
1389  // handle seats
1390  int requiredSeats = getNumPassengers();
1391  if (requiredSeats > 0) {
1392  mySeatPositions.clear();
1393  }
1394  Position front, back;
1395  SUMOReal angle = 0.;
1396  // draw individual carriages
1397  for (int i = 0; i < numCarriages; ++i) {
1398  while (carriageOffset < 0) {
1399  MSLane* prev = getPreviousLane(lane, furtherIndex);
1400  if (prev != lane) {
1401  carriageOffset += lane->getLength();
1402  } else {
1403  // no lane available for drawing.
1404  carriageOffset = 0;
1405  }
1406  lane = prev;
1407  }
1408  while (carriageBackOffset < 0) {
1409  backLane = getPreviousLane(backLane, backFurtherIndex);
1410  carriageBackOffset += backLane->getLength();
1411  }
1412  front = lane->getShape().positionAtOffset2D(carriageOffset);
1413  back = backLane->getShape().positionAtOffset2D(carriageBackOffset);
1414  angle = atan2((front.x() - back.x()), (back.y() - front.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
1415  if (i >= firstPassengerCarriage) {
1416  computeSeats(front, back, requiredSeats);
1417  }
1418  glPushMatrix();
1419  glTranslated(front.x(), front.y(), getType());
1420  glRotated(angle, 0, 0, 1);
1421  if (!asImage || !drawAction_drawVehicleAsImage(s, carriageLength)) {
1422  glBegin(GL_TRIANGLE_FAN);
1423  glVertex2d(-halfWidth + xCornerCut, 0);
1424  glVertex2d(-halfWidth, yCornerCut);
1425  glVertex2d(-halfWidth, carriageLength - yCornerCut);
1426  glVertex2d(-halfWidth + xCornerCut, carriageLength);
1427  glVertex2d(halfWidth - xCornerCut, carriageLength);
1428  glVertex2d(halfWidth, carriageLength - yCornerCut);
1429  glVertex2d(halfWidth, yCornerCut);
1430  glVertex2d(halfWidth - xCornerCut, 0);
1431  glEnd();
1432  }
1433  glPopMatrix();
1434  carriageOffset -= carriageLengthWithGap;
1435  carriageBackOffset -= carriageLengthWithGap;
1436  GLHelper::setColor(current);
1437  }
1438  myCarriageLength = front.distanceTo2D(back);
1439  // restore matrices
1440  glPushMatrix();
1441  glTranslated(front.x(), front.y(), getType());
1442  glRotated(angle, 0, 0, 1);
1443  glPushMatrix();
1444 }
1445 
1446 
1447 const Position&
1448 GUIVehicle::getSeatPosition(size_t personIndex) const {
1450  return mySeatPositions[(int)MIN2(personIndex, mySeatPositions.size() - 1)];
1451 }
1452 
1453 
1454 int
1456  if (myPersonDevice != 0) {
1457  return (int)myPersonDevice->getPersons().size();
1458  }
1459  return 0;
1460 }
1461 
1462 
1463 void
1464 GUIVehicle::computeSeats(const Position& front, const Position& back, int& requiredSeats) const {
1465  if (requiredSeats <= 0) {
1466  return; // save some work
1467  }
1468  const Line l(front, back);
1469  const SUMOReal length = l.length2D();
1470  if (length < 4) {
1471  // small vehicle, sit at the center
1473  requiredSeats--;
1474  } else {
1475  for (SUMOReal p = 2; p <= length - 1; p += 1) {
1477  requiredSeats--;
1478  }
1479  }
1480 }
1481 
1482 
1483 SUMOReal
1486 }
1487 
1488 
1489 std::string
1491  std::string result = "";
1492  if (isParking()) {
1493  result += "parking";
1494  } else if (isStopped()) {
1495  result += "stopped";
1496  } else {
1497  return "";
1498  }
1499  if (myStops.front().triggered) {
1500  result += ", triggered";
1501  } else {
1502  result += ", duration=" + time2string(myStops.front().duration);
1503  }
1504  return result;
1505 }
1506 
1507 
1508 void
1511  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
1512  const DriveProcessItem& dpi = *i;
1513  if (dpi.myLink == 0) {
1514  continue;
1515  }
1516  std::vector<const SUMOVehicle*> blockingFoes;
1517  std::vector<const MSPerson*> blockingPersons;
1519  getImpatience(), getCarFollowModel().getMaxDecel(), getWaitingTime(), &blockingFoes);
1520  for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
1521  gSelected.select(static_cast<const GUIVehicle*>(*it)->getGlID());
1522  }
1523 #ifdef HAVE_INTERNAL_LANES
1524  const MSLink::LinkLeaders linkLeaders = (dpi.myLink)->getLeaderInfo(dist, getVehicleType().getMinGap(), &blockingPersons);
1525  for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1526  // the vehicle to enter the junction first has priority
1527  const GUIVehicle* leader = dynamic_cast<const GUIVehicle*>(it->vehAndGap.first);
1528  if (leader != 0) {
1529  if (leader->myLinkLeaders.count(getID()) == 0) {
1530  // leader isn't already following us, now we follow it
1531  gSelected.select(leader->getGlID());
1532  }
1533  } else {
1534  for (std::vector<const MSPerson*>::iterator it_p = blockingPersons.begin(); it_p != blockingPersons.end(); ++it_p) {
1535  const GUIPerson* foe = dynamic_cast<const GUIPerson*>(*it_p);
1536  if (foe != 0) {
1537  gSelected.select(foe->getGlID());
1538  //std::cout << SIMTIME << " veh=" << getID() << " is blocked on link " << dpi.myLink->getRespondIndex() << " to " << dpi.myLink->getViaLaneOrLane()->getID() << " by pedestrian. dist=" << it->second << "\n";
1539  }
1540  }
1541  }
1542  }
1543 #endif
1544  dist += dpi.myLink->getViaLaneOrLane()->getLength();
1545  }
1546 }
1547 
1548 /****************************************************************************/
1549 
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:807
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIVehicle.cpp:315
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
void selectBlockingFoes() const
adds the blocking foes to the current selection
const MSVehicleType * myType
This Vehicle'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:701
render as a rail
bool drawAction_drawCarriageClass(const GUIVisualizationSettings &s, SUMOVehicleShape guiShape, bool asImage) const
draws the given guiShape if it has distinc carriages/modules and eturns true if so ...
Definition: GUIVehicle.cpp:841
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be shown.
Definition: GUIVehicle.cpp:183
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
long onCmdStartTrack(FXObject *, FXSelector, void *)
Called if the vehicle shall be tracked.
Definition: GUIVehicle.cpp:200
unsigned int getNumberReroutes() const
Returns the number of new routes this vehicle got.
double vehiclePoly_TransportFrontGlass[]
Definition: GUIVehicle.cpp:122
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIVehicle.cpp:269
MoveReminderCont myMoveReminders
Current lane's move reminder.
const RGBColor getColor(const SUMOReal value) const
static RGBColor fromHSV(SUMOReal h, SUMOReal s, SUMOReal v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:287
bool showBlinker
Information whether vehicle blinkers shall be drawn.
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:1111
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:106
void drawAction_drawVehicleBlinker(const GUIVehicle &veh, SUMOReal length)
Definition: GUIVehicle.cpp:882
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:538
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
Definition: MSVehicle.h:1125
State myState
This Vehicles driving state (pos and speed)
Definition: MSVehicle.h:1101
a vehicles
GUIVisualizationTextSettings personName
const Position geometryPositionAtOffset(SUMOReal offset) const
Definition: MSLane.h:340
SUMOReal getMaxSpeed() const
Returns the maximum speed.
DriveItemVector myLFLinkLanes
Container for used Links/visited Lanes during lookForward.
Definition: MSVehicle.h:1195
SUMOReal pos() const
Position of this state.
Definition: MSVehicle.cpp:137
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
SUMOReal getImpatience() const
Returns this vehicles impatience.
render as a motorcycle
void drawBestLanes() const
Draws the vehicle's best lanes.
SUMOReal getLeaveSpeed() const
Definition: MSVehicle.h:1187
MSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:60
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:362
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's length.
Definition: MSLane.h:370
Position getPosition(const SUMOReal offset=0) const
Return current position (x/y, cartesian)
Definition: MSVehicle.cpp:616
render as a transport vehicle
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
render as a flexible city bus
Position getPositionAtDistance2D(SUMOReal offset) const
Definition: Line.cpp:105
track vehicle
Definition: GUIVehicle.h:240
bool drawLaneChangePreference
Information whether the lane change preference shall be drawn.
double vehiclePoly_EVehicleBody[]
Definition: GUIVehicle.cpp:126
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's length [m].
const MSEdgeVector & getEdges() const
Definition: MSRoute.h:123
SUMOReal getLastLaneChangeOffset() const
Returns the time since the last lane change in seconds.
SUMOReal getHCEmissions() const
Returns HC emission of the current state.
Definition: MSVehicle.cpp:2159
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
double vehiclePoly_TransportBody[]
Definition: GUIVehicle.cpp:121
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:159
T MAX2(T a, T b)
Definition: StdDefs.h:72
show all vehicle's routes
Definition: GUIVehicle.h:238
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIVehicle.cpp:384
const MSRoute & getRoute() const
Returns the current route.
Definition: MSBaseVehicle.h:87
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's route.
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
render as a sedan passenger vehicle ("Stufenheck")
SUMOReal getCO2Emissions() const
Returns CO2 emission of the current state.
Definition: MSVehicle.cpp:2147
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
const std::vector< SUMOReal > & getShapeLengths() const
Definition: GUILane.cpp:707
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:229
SUMOReal getPositionOnLane() const
Get the vehicle'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:378
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
Show vehicle's current route.
Definition: GUIAppEnum.h:235
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, SUMOReal length=-1) const
Definition: GUIVehicle.cpp:823
double vehiclePoly_PassengerWagonRightGlass[]
Definition: GUIVehicle.cpp:107
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:158
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.
Position positionAtOffset2D(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:115
double vehiclePoly_PassengerVanRightGlass[]
Definition: GUIVehicle.cpp:114
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:118
long onCmdHideBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be hidden.
Definition: GUIVehicle.cpp:192
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
double vehiclePoly_PassengerHatchbackRightGlass[]
Definition: GUIVehicle.cpp:104
bool setFunctionalColor(size_t activeScheme) const
sets the color according to the current scheme index and some vehicle function
The car-following model and parameter.
Definition: MSVehicleType.h:74
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:1750
SUMOReal scale
information about a lane's width (temporary, used for a single view)
double vehiclePoly_PassengerCarBody[]
Definition: GUIVehicle.cpp:98
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:729
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:70
double vehiclePoly_PassengerFrontGlass[]
Definition: GUIVehicle.cpp:100
long onCmdHideCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:175
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:228
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:256
const std::string & getID() const
Returns the id.
Definition: Named.h:60
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:159
double vehiclePoly_PassengerCarBodyFront[]
Definition: GUIVehicle.cpp:99
void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
Definition: GUIVehicle.cpp:442
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:166
static const RGBColor GREEN
Definition: RGBColor.h:190
Left blinker lights are switched on.
Definition: MSVehicle.h:731
void drawAction_drawVehicleAsTrianglePlus() const
Definition: GUIVehicle.cpp:408
#define PI
Definition: polyfonts.c:61
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:361
render as a hatchback passenger vehicle ("Fliessheck")
double vehiclePoly_EVehicleBackGlass[]
Definition: GUIVehicle.cpp:129
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
render as a bus
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the subpart of best lanes that describes the vehicle's current lane and their successors...
Definition: MSVehicle.cpp:2035
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:222
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:199
not defined
render as a bicycle
double vehiclePoly_EVehicleFrontGlass[]
Definition: GUIVehicle.cpp:127
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
Definition: GUIVehicle.h:246
std::list< Stop > myStops
The vehicle's list of stops.
Definition: MSVehicle.h:1116
long onCmdShowLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
Definition: GUIVehicle.cpp:219
show vehicle's current route
Definition: GUIVehicle.h:236
MSLane * getPreviousLane(MSLane *current, int &furtherIndex) const
bool isStopped() const
Returns whether the vehicle is at a stop.
Definition: MSVehicle.cpp:755
double vehiclePoly_TransportLeftGlass[]
Definition: GUIVehicle.cpp:124
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
MSLane * myLane
The lane the vehicle is on.
Definition: MSVehicle.h:1104
Blinker lights on both sides are switched on.
Definition: MSVehicle.h:733
~GUIVehicle()
destructor
Definition: GUIVehicle.cpp:257
void setPositionInVehicle(const Position &pos)
Definition: GUIPerson.h:120
Definition: Line.h:51
double vehiclePoly_DeliveryMediumLeftGlass[]
Definition: GUIVehicle.cpp:119
render as a (city) rail without locomotive
T MIN2(T a, T b)
Definition: StdDefs.h:66
double vehiclePoly_PassengerWagonBackGlass[]
Definition: GUIVehicle.cpp:109
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:146
static void drawPoly(double *poses, SUMOReal offset)
Definition: GUIVehicle.cpp:426
The brake lights are on.
Definition: MSVehicle.h:735
GUIVehicle(SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, SUMOReal speedFactor)
Constructor.
Definition: GUIVehicle.cpp:245
long onCmdStopTrack(FXObject *, FXSelector, void *)
Called if the current shall not be tracked any longer.
Definition: GUIVehicle.cpp:210
MSDevice_Vehroutes * myRoutes
Definition: GUIVehicle.h:333
int getNumPassengers() const
return the number of passengers
Show all vehicle's routes.
Definition: GUIAppEnum.h:243
const std::vector< MSPerson * > & getPersons() const
Returns the list of persons using this vehicle.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
render as a van
SUMOReal getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
Definition: MSCFModel.h:165
#define BLINKER_POS_BACK
Definition: GUIVehicle.cpp:865
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
Stop to track a vehicle.
Definition: GUIAppEnum.h:249
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:53
const int VEHPARS_COLOR_SET
bool isParking() const
Returns whether the vehicle is parking.
Definition: MSVehicle.cpp:761
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
Definition: GUIVehicle.h:336
SUMOReal getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
Definition: MSVehicle.cpp:2183
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIPerson.cpp:167
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUIVehicle.h:328
SUMOReal getNOxEmissions() const
Returns NOx emission of the current state.
Definition: MSVehicle.cpp:2165
Show vehicle's best lanes.
Definition: GUIAppEnum.h:239
static void removeObject(GUIGlObject &o)
Removes all instances that pass values from the object with the given id.
render as a cargo train
SUMOReal getPMxEmissions() const
Returns PMx emission of the current state.
Definition: MSVehicle.cpp:2171
SUMOReal getCOEmissions() const
Returns CO emission of the current state.
Definition: MSVehicle.cpp:2153
void computeSeats(const Position &front, const Position &back, int &requiredSeats) const
add seats to mySeatPositions and update requiredSeats
void drawAction_drawVehicleBrakeLight(const GUIVehicle &veh, SUMOReal length)
Definition: GUIVehicle.cpp:901
void unlock()
release mutex lock
Definition: MFXMutex.cpp:96
FXDEFMAP(GUIVehicle::GUIVehiclePopupMenu) GUIVehiclePopupMenuMap[]
Hide all vehicle's routes.
Definition: GUIAppEnum.h:245
Hide vehicle'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'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:124
render as a pedestrian
render as a moped
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
const Position & getSeatPosition(size_t personIndex) const
returns the seat position for the person with the given index
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIVehicle.cpp:918
Structure representing possible vehicle parameter.
double vehiclePoly_PassengerVanLeftGlass[]
Definition: GUIVehicle.cpp:115
void drawAction_drawVehicleAsBoxPlus() const
Definition: GUIVehicle.cpp:393
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.
SUMOReal getAcceleration() const
Returns the vehicle's acceleration in m/s.
Definition: MSVehicle.h:299
double vehiclePoly_PassengerVanBodyFront[]
Definition: GUIVehicle.cpp:112
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
SUMOReal getFuelConsumption() const
Returns fuel consumption of the current state.
Definition: MSVehicle.cpp:2177
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
Definition: MSBaseVehicle.h:95
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.
void drawAction_drawBlinker(double dir, SUMOReal length)
Definition: GUIVehicle.cpp:868
SUMOReal getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:291
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
void lock()
lock mutex
Definition: MFXMutex.cpp:86
Base class for coloring. Allows changing the used colors and sets the used color in dependence to a v...
Definition: GUIColorer.h:50
long onCmdShowFoes(FXObject *, FXSelector, void *)
Called when show a vehicles foes.
Definition: GUIVehicle.cpp:235
SUMOReal getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:373
double vehiclePoly_PassengerSedanBackGlass[]
Definition: GUIVehicle.cpp:103
double vehiclePoly_PassengerHatchbackBackGlass[]
Definition: GUIVehicle.cpp:106
unsigned size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:87
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:323
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:240
render as a (futuristic) e-vehicle
static void drawLine(const Position &beg, SUMOReal rot, SUMOReal visLength)
Draws a thin line.
Definition: GLHelper.cpp:205
void drawAction_drawRailCarriages(const GUIVisualizationSettings &s, SUMOReal defaultLength, SUMOReal carriageGap, int firstPassengerCarriage, bool asImage) const
void move2side(SUMOReal amount)
#define BLINKER_POS_FRONT
Definition: GUIVehicle.cpp:864
#define SUMOReal
Definition: config.h:215
std::string getImgFile() const
Get this vehicle type's raster model file name.
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
double vehiclePoly_PassengerVanFrontGlass[]
Definition: GUIVehicle.cpp:113
show vehicle's best lanes
Definition: GUIVehicle.h:234
void drawRouteHelper(const MSRoute &r, SUMOReal exaggeration) const
Draws the route.
int vehicleQuality
The quality of vehicle drawing.
double vehiclePoly_TransportRightGlass[]
Definition: GUIVehicle.cpp:123
double vehiclePoly_DeliveryMediumRightGlass[]
Definition: GUIVehicle.cpp:118
double vehiclePoly_PassengerVanBody[]
Definition: GUIVehicle.cpp:111
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:328
render as a transport vehicle with one trailer
render as a wagon passenger vehicle ("Combi")
SUMOReal getTimeGap() const
Returns the time gap in seconds to the leader of the vehicle looking for a fixed distance.
Definition: MSVehicle.cpp:2137
double vehiclePoly_PassengerVanBackGlass[]
Definition: GUIVehicle.cpp:116
double vehiclePoly_PassengerWagonLeftGlass[]
Definition: GUIVehicle.cpp:108
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.
render as a coach
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's parameter.
const int VTYPEPARS_COLOR_SET
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width, int cornerDetail=0)
Draws thick lines.
Definition: GLHelper.cpp:157
render as a semi-trailer transport vehicle ("Sattelschlepper")
double vehiclePoly_PassengerHatchbackLeftGlass[]
Definition: GUIVehicle.cpp:105
double vehiclePoly_PassengerSedanRightGlass[]
Definition: GUIVehicle.cpp:101
MSDevice_Person * myPersonDevice
The passengers this vehicle may have.
Definition: MSVehicle.h:1119
double vehiclePoly_PassengerSedanLeftGlass[]
Definition: GUIVehicle.cpp:102
Start to track a vehicle.
Definition: GUIAppEnum.h:247
int getBestLaneOffset() const
returns the current offset from the best lane
Definition: MSVehicle.cpp:2063
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's direction in degrees.
Definition: MSVehicle.cpp:643
SUMOReal myCarriageLength
Variable to set with the length of the last drawn carriage or the vehicle length. ...
Definition: GUIVehicle.h:331
const std::string & getID() const
Returns the name of the vehicle.
const PositionVector & getShape() const
Definition: GUILane.cpp:695
const MSRoute * getRoute(int index) const
Called on route retrieval.
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:367
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:149
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:68