SUMO - Simulation of Urban MObility
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.dlr.de/
12 // Copyright (C) 2001-2015 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>
60 #include <gui/GUIGlobals.h>
61 #include "GUIVehicle.h"
62 #include "GUIPerson.h"
63 #include "GUIContainer.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 double vehiclePoly_Ship[] = { 0.25, 0, 0, 0, 0.1, 0.25, 0.2, 0.45, 0.25, 0.5, 0.95, 0.5, 1.0, 0.45, 1.0, -0.45, 0.95, -0.5, 0.25, -0.5, 0.2, -0.45, 0.1, -0.25, 0, 0, -10000 };
135 double vehiclePoly_ShipDeck[] = { 0.5, 0, 0.25, 0.4, 0.95, 0.4, 0.95, -0.4, 0.25, -0.4, 0.25, 0.4, -10000 };
136 double vehiclePoly_ShipSuperStructure[] = { 0.8, 0, 0.5, 0.3, 0.85, 0.3, 0.85, -0.3, 0.5, -0.3, 0.5, 0.3, -10000 };
137 
138 double vehiclePoly_Cyclist[] = { 0.5, 0, 0.25, 0.45, 0.25, 0.5, 0.8, 0.15, 0.8, -0.15, 0.25, -0.5, 0.25, -0.45, -10000 };
139 
140 // ===========================================================================
141 // method definitions
142 // ===========================================================================
143 /* -------------------------------------------------------------------------
144  * GUIVehicle::GUIVehiclePopupMenu - methods
145  * ----------------------------------------------------------------------- */
147  GUIMainWindow& app, GUISUMOAbstractView& parent,
148  GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations)
149  : GUIGLObjectPopupMenu(app, parent, o), myVehiclesAdditionalVisualizations(additionalVisualizations) {
150 }
151 
152 
154 
155 
156 long
158  assert(myObject->getType() == GLO_VEHICLE);
159  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES)) {
160  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES);
161  }
162  return 1;
163 }
164 
165 long
167  assert(myObject->getType() == GLO_VEHICLE);
168  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES);
169  return 1;
170 }
171 
172 
173 long
175  assert(myObject->getType() == GLO_VEHICLE);
176  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ROUTE)) {
177  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_ROUTE);
178  }
179  return 1;
180 }
181 
182 long
184  assert(myObject->getType() == GLO_VEHICLE);
185  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_ROUTE);
186  return 1;
187 }
188 
189 
190 long
192  assert(myObject->getType() == GLO_VEHICLE);
193  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES)) {
194  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES);
195  }
196  return 1;
197 }
198 
199 long
201  assert(myObject->getType() == GLO_VEHICLE);
202  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES);
203  return 1;
204 }
205 
206 
207 long
209  assert(myObject->getType() == GLO_VEHICLE);
210  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_TRACKED)) {
211  myParent->startTrack(static_cast<GUIVehicle*>(myObject)->getGlID());
212  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_TRACKED);
213  }
214  return 1;
215 }
216 
217 long
219  assert(myObject->getType() == GLO_VEHICLE);
220  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_TRACKED);
221  myParent->stopTrack();
222  return 1;
223 }
224 
225 
226 long
228  assert(myObject->getType() == GLO_VEHICLE);
229  if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS)) {
230  static_cast<GUIVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS);
231  }
232  return 1;
233 }
234 
235 long
237  assert(myObject->getType() == GLO_VEHICLE);
238  static_cast<GUIVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS);
239  return 1;
240 }
241 
242 long
244  assert(myObject->getType() == GLO_VEHICLE);
245  static_cast<GUIVehicle*>(myObject)->selectBlockingFoes();
246  return 1;
247 }
248 
249 
250 /* -------------------------------------------------------------------------
251  * GUIVehicle - methods
252  * ----------------------------------------------------------------------- */
254  const MSVehicleType* type, const SUMOReal speedFactor) :
255  MSVehicle(pars, route, type, speedFactor),
256  GUIGlObject(GLO_VEHICLE, pars->id) {
257  // as it is possible to show all vehicle routes, we have to store them... (bug [ 2519761 ])
259  myMoveReminders.push_back(std::make_pair(myRoutes, 0.));
260  mySeatPositions.push_back(Position(0, 0)); // ensure length 1
261 }
262 
263 
265  myLock.lock();
266  for (std::map<GUISUMOAbstractView*, int>::iterator i = myAdditionalVisualizations.begin(); i != myAdditionalVisualizations.end(); ++i) {
267  while (i->first->removeAdditionalGLVisualisation(this));
268  }
269  myLock.unlock();
271  delete myRoutes;
272 }
273 
274 
277  GUISUMOAbstractView& parent) {
279  buildPopupHeader(ret, app);
283  //
285  new FXMenuCommand(ret, "Hide Current Route", 0, ret, MID_HIDE_CURRENTROUTE);
286  } else {
287  new FXMenuCommand(ret, "Show Current Route", 0, ret, MID_SHOW_CURRENTROUTE);
288  }
290  new FXMenuCommand(ret, "Hide All Routes", 0, ret, MID_HIDE_ALLROUTES);
291  } else {
292  new FXMenuCommand(ret, "Show All Routes", 0, ret, MID_SHOW_ALLROUTES);
293  }
295  new FXMenuCommand(ret, "Hide Best Lanes", 0, ret, MID_HIDE_BEST_LANES);
296  } else {
297  new FXMenuCommand(ret, "Show Best Lanes", 0, ret, MID_SHOW_BEST_LANES);
298  }
300  new FXMenuCommand(ret, "Hide Link Items", 0, ret, MID_HIDE_LFLINKITEMS);
301  } else {
302  new FXMenuCommand(ret, "Show Link Items", 0, ret, MID_SHOW_LFLINKITEMS);
303  }
304  new FXMenuSeparator(ret);
305  int trackedID = parent.getTrackedID();
306  if (trackedID < 0 || (size_t)trackedID != getGlID()) {
307  new FXMenuCommand(ret, "Start Tracking", 0, ret, MID_START_TRACK);
308  } else {
309  new FXMenuCommand(ret, "Stop Tracking", 0, ret, MID_STOP_TRACK);
310  }
311  new FXMenuCommand(ret, "Select Foes", 0, ret, MID_SHOW_FOES);
312 
313  new FXMenuSeparator(ret);
314  //
316  buildPositionCopyEntry(ret, false);
317  return ret;
318 }
319 
320 
325  new GUIParameterTableWindow(app, *this, 36);
326  // add items
327  ret->mkItem("lane [id]", false, myLane->getID());
328  ret->mkItem("position [m]", true,
330  ret->mkItem("speed [m/s]", true,
332  ret->mkItem("angle [degree]", true,
334  if (getChosenSpeedFactor() != 1) {
335  ret->mkItem("speed factor", false, getChosenSpeedFactor());
336  }
337  ret->mkItem("time gap [s]", true,
339  ret->mkItem("waiting time [s]", true,
341  ret->mkItem("impatience", true,
343  ret->mkItem("last lane change [s]", true,
345  ret->mkItem("desired depart [s]", false, time2string(getParameter().depart));
346  if (getParameter().repetitionNumber < INT_MAX) {
347  ret->mkItem("remaining [#]", false, (unsigned int) getParameter().repetitionNumber - getParameter().repetitionsDone);
348  }
349  if (getParameter().repetitionOffset > 0) {
350  ret->mkItem("insertion period [s]", false, time2string(getParameter().repetitionOffset));
351  }
352  if (getParameter().repetitionProbability > 0) {
353  ret->mkItem("insertion probability", false, getParameter().repetitionProbability);
354  }
355  ret->mkItem("stop info", false, getStopInfo());
356  ret->mkItem("line", false, myParameter->line);
357  ret->mkItem("CO2 [mg/s]", true,
359  ret->mkItem("CO [mg/s]", true,
361  ret->mkItem("HC [mg/s]", true,
363  ret->mkItem("NOx [mg/s]", true,
365  ret->mkItem("PMx [mg/s]", true,
367  ret->mkItem("fuel [ml/s]", true,
369  ret->mkItem("noise (Harmonoise) [dB]", true,
371  std::ostringstream str;
372  for (std::vector<MSDevice*>::const_iterator i = myDevices.begin(); i != myDevices.end(); ++i) {
373  if (i != myDevices.begin()) {
374  str << ' ';
375  }
376  str << (*i)->getID().substr(0, (*i)->getID().find(getID()));
377  }
378  ret->mkItem("devices", false, str.str());
379  ret->mkItem("parameters [key:val]", false, toString(getParameter().getMap()));
380  ret->mkItem("", false, "");
381  ret->mkItem("Type Information:", false, "");
382  ret->mkItem("type [id]", false, myType->getID());
383  ret->mkItem("length", false, myType->getLength());
384  ret->mkItem("minGap", false, myType->getMinGap());
385  ret->mkItem("vehicle class", false, SumoVehicleClassStrings.getString(myType->getVehicleClass()));
386  ret->mkItem("emission class", false, PollutantsInterface::getName(myType->getEmissionClass()));
387  ret->mkItem("maximum speed [m/s]", false, getMaxSpeed());
388  ret->mkItem("maximum acceleration [m/s^2]", false, getCarFollowModel().getMaxAccel());
389  ret->mkItem("maximum deceleration [m/s^2]", false, getCarFollowModel().getMaxDecel());
390  ret->mkItem("imperfection (sigma)", false, getCarFollowModel().getImperfection());
391  ret->mkItem("reaction time (tau)", false, getCarFollowModel().getHeadwayTime());
392  ret->mkItem("type parameters [key:val]", false, toString(myType->getParameter().getMap()));
393  // close building
394  ret->closeBuilding();
395  return ret;
396 }
397 
398 
399 Boundary
401  Boundary b;
402  b.add(getPosition());
403  b.grow(20);
404  return b;
405 }
406 
407 
408 void
410  glPushMatrix();
411  glScaled(getVehicleType().getWidth(), getVehicleType().getLength(), 1.);
412  glBegin(GL_TRIANGLE_STRIP);
413  glVertex2d(0., 0.);
414  glVertex2d(-.5, .15);
415  glVertex2d(.5, .15);
416  glVertex2d(-.5, 1.);
417  glVertex2d(.5, 1.);
418  glEnd();
419  glPopMatrix();
420 }
421 
422 
423 void
425  const SUMOReal length = getVehicleType().getLength();
426  if (length >= 8.) {
428  return;
429  }
430  glPushMatrix();
431  glScaled(getVehicleType().getWidth(), length, 1.);
432  glBegin(GL_TRIANGLES);
433  glVertex2d(0., 0.);
434  glVertex2d(-.5, 1.);
435  glVertex2d(.5, 1.);
436  glEnd();
437  glPopMatrix();
438 }
439 
440 
441 void
442 GUIVehicle::drawPoly(double* poses, SUMOReal offset) {
443  glPushMatrix();
444  glTranslated(0, 0, offset * .1);
445  glPolygonOffset(0, offset * -1);
446  glBegin(GL_TRIANGLE_FAN);
447  int i = 0;
448  while (poses[i] > -999) {
449  glVertex2d(poses[i], poses[i + 1]);
450  i = i + 2;
451  }
452  glEnd();
453  glPopMatrix();
454 }
455 
456 
457 void
459  RGBColor current = GLHelper::getColor();
460  RGBColor lighter = current.changedBrightness(51);
461  RGBColor darker = current.changedBrightness(-51);
462 
463  const SUMOReal length = getVehicleType().getLength();
464  const SUMOReal width = getVehicleType().getWidth();
465  glPushMatrix();
466  glRotated(90, 0, 0, 1);
467  glScaled(length, width, 1.);
469 
470  // draw main body
471  switch (shape) {
472  case SVS_UNKNOWN:
474  GLHelper::setColor(lighter);
475  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
476  glColor3d(0, 0, 0);
477  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
478  break;
479  case SVS_PEDESTRIAN:
480  glTranslated(0, 0, .045);
482  glTranslated(0, 0, -.045);
483  glScaled(.7, 2, 1);
484  glTranslated(0, 0, .04);
485  GLHelper::setColor(lighter);
487  glTranslated(0, 0, -.04);
488  break;
489  case SVS_BICYCLE:
490  case SVS_MOPED:
491  case SVS_MOTORCYCLE: {
492  RGBColor darker = current.changedBrightness(-50);
493  // body
494  drawPoly(vehiclePoly_Cyclist, 4);
495  // head
496  glPushMatrix();
497  glTranslated(0.4, 0, .5);
498  glScaled(0.1, 0.2, 1);
499  GLHelper::setColor(darker);
501  glPopMatrix();
502  // bike frame
504  glPushMatrix();
505  glTranslated(0.5, 0, .3);
506  glScaled(0.5, 0.05, 1);
508  glPopMatrix();
509  // handle bar
510  glPushMatrix();
511  glTranslated(0.25, 0, .3);
512  glScaled(0.02, 0.5, 1);
514  glPopMatrix();
515  }
516  break;
517  case SVS_PASSENGER:
518  case SVS_PASSENGER_SEDAN:
520  case SVS_PASSENGER_WAGON:
522  GLHelper::setColor(lighter);
523  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
524  glColor3d(0, 0, 0);
525  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
526  break;
527  case SVS_PASSENGER_VAN:
528  drawPoly(vehiclePoly_PassengerVanBody, 4);
529  GLHelper::setColor(lighter);
530  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
531  glColor3d(0, 0, 0);
532  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
533  drawPoly(vehiclePoly_PassengerVanRightGlass, 4.5);
534  drawPoly(vehiclePoly_PassengerVanLeftGlass, 4.5);
535  drawPoly(vehiclePoly_PassengerVanBackGlass, 4.5);
536  break;
537  case SVS_DELIVERY:
538  drawPoly(vehiclePoly_PassengerVanBody, 4);
539  GLHelper::setColor(lighter);
540  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
541  glColor3d(0, 0, 0);
542  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
543  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
544  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
545  break;
546  case SVS_TRUCK:
548  case SVS_TRUCK_1TRAILER:
549  glScaled(1. / (length), 1, 1.);
550  drawPoly(vehiclePoly_TransportBody, 4);
551  glColor3d(0, 0, 0);
552  drawPoly(vehiclePoly_TransportFrontGlass, 4.5);
553  drawPoly(vehiclePoly_TransportRightGlass, 4.5);
554  drawPoly(vehiclePoly_TransportLeftGlass, 4.5);
555  break;
556  case SVS_BUS:
557  case SVS_BUS_COACH:
558  case SVS_BUS_TROLLEY: {
559  SUMOReal ml = length;
560  glScaled(1. / (length), 1, 1.);
561  glTranslated(0, 0, .04);
562  glBegin(GL_TRIANGLE_FAN);
563  glVertex2d(ml / 2., 0);
564  glVertex2d(0, 0);
565  glVertex2d(0, -.45);
566  glVertex2d(0 + .05, -.5);
567  glVertex2d(ml - .05, -.5);
568  glVertex2d(ml, -.45);
569  glVertex2d(ml, .45);
570  glVertex2d(ml - .05, .5);
571  glVertex2d(0 + .05, .5);
572  glVertex2d(0, .45);
573  glVertex2d(0, 0);
574  glEnd();
575  glTranslated(0, 0, -.04);
576 
577  glTranslated(0, 0, .045);
578  glColor3d(0, 0, 0);
579  glBegin(GL_QUADS);
580  glVertex2d(0 + .05, .48);
581  glVertex2d(0 + .05, -.48);
582  glVertex2d(0 + .15, -.48);
583  glVertex2d(0 + .15, .48);
584 
585  glVertex2d(ml - .1, .45);
586  glVertex2d(ml - .1, -.45);
587  glVertex2d(ml - .05, -.45);
588  glVertex2d(ml - .05, .45);
589 
590  glVertex2d(0 + .20, .49);
591  glVertex2d(0 + .20, .45);
592  glVertex2d(ml - .20, .45);
593  glVertex2d(ml - .20, .49);
594 
595  glVertex2d(0 + .20, -.49);
596  glVertex2d(0 + .20, -.45);
597  glVertex2d(ml - .20, -.45);
598  glVertex2d(ml - .20, -.49);
599 
600  glEnd();
601  glTranslated(0, 0, -.045);
602  }
603  break;
604  case SVS_BUS_FLEXIBLE:
605  case SVS_RAIL:
606  case SVS_RAIL_CAR:
607  case SVS_RAIL_CARGO:
608  drawAction_drawCarriageClass(s, shape, false);
609  break;
610  case SVS_E_VEHICLE:
611  drawPoly(vehiclePoly_EVehicleBody, 4);
612  glColor3d(0, 0, 0);
613  drawPoly(vehiclePoly_EVehicleFrontGlass, 4.5);
614  glTranslated(0, 0, .048);
615  GLHelper::setColor(current);
616  glBegin(GL_QUADS);
617  glVertex2d(.3, .5);
618  glVertex2d(.35, .5);
619  glVertex2d(.35, -.5);
620  glVertex2d(.3, -.5);
621 
622  glVertex2d(.3, -.05);
623  glVertex2d(.7, -.05);
624  glVertex2d(.7, .05);
625  glVertex2d(.3, .05);
626 
627  glVertex2d(.7, .5);
628  glVertex2d(.65, .5);
629  glVertex2d(.65, -.5);
630  glVertex2d(.7, -.5);
631  glEnd();
632  glTranslated(0, 0, -.048);
633  //drawPoly(vehiclePoly_EVehicleBackGlass, 4.5);
634  break;
635  case SVS_ANT:
636  glPushMatrix();
637  // ant is stretched via vehicle length
638  GLHelper::setColor(darker);
639  // draw left side
640  GLHelper::drawBoxLine(Position(-0.2, -.10), 350, 0.5, .02);
641  GLHelper::drawBoxLine(Position(-0.3, -.50), 240, 0.4, .03);
642  GLHelper::drawBoxLine(Position(0.3, -.10), 340, 0.8, .03);
643  GLHelper::drawBoxLine(Position(0.05, -.80), 290, 0.6, .04);
644  GLHelper::drawBoxLine(Position(0.4, -.10), 20, 0.8, .03);
645  GLHelper::drawBoxLine(Position(0.65, -.80), 75, 0.6, .04);
646  GLHelper::drawBoxLine(Position(0.5, -.10), 55, 0.8, .04);
647  GLHelper::drawBoxLine(Position(1.1, -.55), 90, 0.6, .04);
648  // draw right side
649  GLHelper::drawBoxLine(Position(-0.2, .10), 190, 0.5, .02);
650  GLHelper::drawBoxLine(Position(-0.3, .50), 300, 0.4, .03);
651  GLHelper::drawBoxLine(Position(0.3, .10), 200, 0.8, .03);
652  GLHelper::drawBoxLine(Position(0.05, .80), 250, 0.6, .04);
653  GLHelper::drawBoxLine(Position(0.4, .10), 160, 0.8, .03);
654  GLHelper::drawBoxLine(Position(0.65, .80), 105, 0.6, .04);
655  GLHelper::drawBoxLine(Position(0.5, .10), 125, 0.8, .04);
656  GLHelper::drawBoxLine(Position(1.1, .55), 90, 0.6, .04);
657  // draw body
658  GLHelper::setColor(current);
659  glTranslated(0, 0, 0.1);
661  glTranslated(.4, 0, 0);
663  glTranslated(.4, 0, 0);
665  glPopMatrix();
666  break;
667  case SVS_SHIP: {
668  RGBColor darker = current.changedBrightness(-30);
669  RGBColor darker2 = current.changedBrightness(-70);
670  drawPoly(vehiclePoly_Ship, 4);
671  GLHelper::setColor(darker);
672  drawPoly(vehiclePoly_ShipDeck, 5);
673  GLHelper::setColor(darker2);
674  drawPoly(vehiclePoly_ShipSuperStructure, 6);
675  break;
676  }
677  default: // same as passenger
679  glColor3d(1, 1, 1);
680  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
681  glColor3d(0, 0, 0);
682  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
683  break;
684  }
685 
686  // draw decorations
687  switch (shape) {
688  case SVS_PEDESTRIAN:
689  break;
690  case SVS_BICYCLE:
691  //glScaled(length, 1, 1.);
692  glBegin(GL_TRIANGLE_FAN);
693  glVertex2d(1 / 2., 0);
694  glVertex2d(0, 0);
695  glVertex2d(0, -.03);
696  glVertex2d(0 + .05, -.05);
697  glVertex2d(1 - .05, -.05);
698  glVertex2d(1, -.03);
699  glVertex2d(1, .03);
700  glVertex2d(1 - .05, .05);
701  glVertex2d(0 + .05, .05);
702  glVertex2d(0, .03);
703  glVertex2d(0, 0);
704  glEnd();
705  break;
706  case SVS_MOPED:
707  case SVS_MOTORCYCLE:
708  //glScaled(length, 1, 1.);
709  glBegin(GL_TRIANGLE_FAN);
710  glVertex2d(1 / 2., 0);
711  glVertex2d(0, 0);
712  glVertex2d(0, -.03);
713  glVertex2d(0 + .05, -.2);
714  glVertex2d(1 - .05, -.2);
715  glVertex2d(1, -.03);
716  glVertex2d(1, .03);
717  glVertex2d(1 - .05, .2);
718  glVertex2d(0 + .05, .2);
719  glVertex2d(0, .03);
720  glVertex2d(0, 0);
721  glEnd();
722  break;
723  case SVS_PASSENGER:
724  case SVS_PASSENGER_SEDAN:
725  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
726  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
727  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
728  break;
730  drawPoly(vehiclePoly_PassengerHatchbackRightGlass, 4.5);
731  drawPoly(vehiclePoly_PassengerHatchbackLeftGlass, 4.5);
732  drawPoly(vehiclePoly_PassengerHatchbackBackGlass, 4.5);
733  break;
734  case SVS_PASSENGER_WAGON:
735  drawPoly(vehiclePoly_PassengerWagonRightGlass, 4.5);
736  drawPoly(vehiclePoly_PassengerWagonLeftGlass, 4.5);
737  drawPoly(vehiclePoly_PassengerWagonBackGlass, 4.5);
738  break;
739  case SVS_PASSENGER_VAN:
740  case SVS_DELIVERY:
741  break;
742  case SVS_TRUCK:
743  GLHelper::setColor(current);
744  GLHelper::drawBoxLine(Position(2.3, 0), 90., length - 2.3, .5);
745  break;
747  GLHelper::setColor(current);
748  GLHelper::drawBoxLine(Position(2.8, 0), 90., length - 2.8, .5);
749  break;
750  case SVS_TRUCK_1TRAILER: {
751  GLHelper::setColor(current);
752  SUMOReal l = length - 2.3;
753  l = l / 2.;
754  GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
755  GLHelper::drawBoxLine(Position(2.3 + l + .5, 0), 90., l - .5, .5);
756  break;
757  }
758  case SVS_BUS_TROLLEY:
759  glPushMatrix();
760  glTranslated(0, 0, .1);
761  GLHelper::setColor(darker);
762  GLHelper::drawBoxLine(Position(3.8, 0), 90., 1, .3);
763  glTranslated(0, 0, .1);
764  glColor3d(0, 0, 0);
765  GLHelper::drawBoxLine(Position(4.3, .2), 90., 1, .06);
766  GLHelper::drawBoxLine(Position(4.3, -.2), 90., 1, .06);
767  GLHelper::drawBoxLine(Position(5.3, .2), 90., 3, .03);
768  GLHelper::drawBoxLine(Position(5.3, -.2), 90., 3, .03);
769  glPopMatrix();
770  break;
771  case SVS_BUS:
772  case SVS_BUS_COACH:
773  case SVS_BUS_FLEXIBLE:
774  case SVS_RAIL:
775  case SVS_RAIL_CAR:
776  case SVS_RAIL_CARGO:
777  case SVS_E_VEHICLE:
778  case SVS_ANT:
779  case SVS_SHIP:
780  break;
781  default: // same as passenger/sedan
782  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
783  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
784  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
785  break;
786  }
787  /*
788  glBegin(GL_TRIANGLE_FAN);
789  glVertex2d(.5,.5); // center - strip begin
790  glVertex2d(0, .5); // center, front
791  glVertex2d(0, .8); // ... clockwise ... (vehicle right side)
792  glVertex2d(0.08, .94);
793  glVertex2d(0.25, 1.);
794  glVertex2d(0.95, 1.);
795  glVertex2d(1., .9);
796  glVertex2d(1., .1); // (vehicle left side)
797  glVertex2d(0.95, 0.);
798  glVertex2d(0.25, 0.);
799  glVertex2d(0.08, .06);
800  glVertex2d(0, .2); //
801  glVertex2d(0, .5); // center, front (close)
802  glEnd();
803 
804  glPolygonOffset(0, -4.5);
805  glColor3d(1, 1, 1); // front
806  glBegin(GL_TRIANGLE_FAN);
807  glVertex2d(0.1,0.5);
808  glVertex2d(0.025,0.5);
809  glVertex2d(0.025,0.75);
810  glVertex2d(0.27,0.9);
811  glVertex2d(0.27,0.1);
812  glVertex2d(0.025,0.25);
813  glVertex2d(0.025,0.5);
814  glEnd();
815 
816  glColor3d(0, 0, 0); // front glass
817  glBegin(GL_TRIANGLE_FAN);
818  glVertex2d(0.35,0.5);
819  glVertex2d(0.3,0.5);
820  glVertex2d(0.3,0.9);
821  glVertex2d(0.43,0.8);
822  glVertex2d(0.43,0.2);
823  glVertex2d(0.3,0.1);
824  glVertex2d(0.3,0.5);
825  glEnd();
826 
827  glBegin(GL_TRIANGLE_FAN); // back glass
828  glVertex2d(0.92,0.5);
829  glVertex2d(0.90,0.5);
830  glVertex2d(0.90,0.8);
831  glVertex2d(0.95,0.9);
832  glVertex2d(0.95,0.1);
833  glVertex2d(0.90,0.2);
834  glVertex2d(0.90,0.5);
835  glEnd();
836 
837  glBegin(GL_TRIANGLE_FAN); // right glass
838  glVertex2d(0.36,0.07);
839  glVertex2d(0.34,0.03);
840  glVertex2d(0.94,0.03);
841  glVertex2d(0.87,0.13);
842  glVertex2d(0.45,0.13);
843  glVertex2d(0.34,0.03);
844  glEnd();
845 
846  glBegin(GL_TRIANGLE_FAN); // left glass
847  glVertex2d(0.36,1.-0.07);
848  glVertex2d(0.34,1.-0.03);
849  glVertex2d(0.94,1.-0.03);
850  glVertex2d(0.87,1.-0.13);
851  glVertex2d(0.45,1.-0.13);
852  glVertex2d(0.34,1.-0.03);
853  glEnd();
854  */
855 
856  glPopMatrix();
857 }
858 
859 
860 bool
862  const std::string& file = getVehicleType().getImgFile();
863  if (file != "") {
864  int textureID = GUITexturesHelper::getTextureID(file);
865  if (textureID > 0) {
866  const SUMOReal exaggeration = s.vehicleSize.getExaggeration(s);
867  if (length < 0) {
868  length = getVehicleType().getLength() * exaggeration;
869  }
870  const SUMOReal halfWidth = getVehicleType().getWidth() / 2.0 * exaggeration;
871  GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, 0, halfWidth, length);
872  return true;
873  }
874  }
875  return false;
876 }
877 
878 
879 bool
881  switch (guiShape) {
882  case SVS_BUS_FLEXIBLE:
883  drawAction_drawRailCarriages(s, 8.25, 0, 0, asImage); // 16.5 overall, 2 modules http://de.wikipedia.org/wiki/Ikarus_180
884  break;
885  case SVS_RAIL:
886  drawAction_drawRailCarriages(s, 24.5, 1, 1, asImage); // http://de.wikipedia.org/wiki/UIC-Y-Wagen_%28DR%29
887  break;
888  case SVS_RAIL_CAR:
889  drawAction_drawRailCarriages(s, 16.85, 1, 0, asImage); // 67.4m overall, 4 carriages http://de.wikipedia.org/wiki/DB-Baureihe_423
890 // drawAction_drawRailCarriages(s, 5.71, 0, 0, asImage); // 40.0m overall, 7 modules http://de.wikipedia.org/wiki/Bombardier_Flexity_Berlin
891 // drawAction_drawRailCarriages(s, 9.44, 1, 1, asImage); // actually length of the locomotive http://de.wikipedia.org/wiki/KJI_Nr._20_und_21
892 // drawAction_drawRailCarriages(s, 24.775, 0, 0, asImage); // http://de.wikipedia.org/wiki/ICE_3
893  break;
894  case SVS_RAIL_CARGO:
895  drawAction_drawRailCarriages(s, 13.86, 1, 0, asImage); // UIC 571-1 http://de.wikipedia.org/wiki/Flachwagen
896  break;
897  default:
898  return false;
899  }
900  return true;
901 }
902 
903 #define BLINKER_POS_FRONT .5
904 #define BLINKER_POS_BACK .5
905 
906 inline void
907 drawAction_drawBlinker(double dir, SUMOReal length) {
908  glColor3d(1.f, .8f, 0);
909  glPushMatrix();
910  glTranslated(dir, BLINKER_POS_FRONT, -0.1);
912  glPopMatrix();
913  glPushMatrix();
914  glTranslated(dir, length - BLINKER_POS_BACK, -0.1);
916  glPopMatrix();
917 }
918 
919 
920 inline void
923  return;
924  }
925  const double offset = MAX2(.5 * veh.getVehicleType().getWidth(), .4);
927  drawAction_drawBlinker(-offset, length);
928  }
930  drawAction_drawBlinker(offset, length);;
931  }
933  drawAction_drawBlinker(-offset, length);
934  drawAction_drawBlinker(offset, length);
935  }
936 }
937 
938 
939 inline void
942  return;
943  }
944  glColor3f(1.f, .2f, 0);
945  glPushMatrix();
946  glTranslated(-veh.getVehicleType().getWidth() * 0.5, length, -0.1);
948  glPopMatrix();
949  glPushMatrix();
950  glTranslated(veh.getVehicleType().getWidth() * 0.5, length, -0.1);
952  glPopMatrix();
953 }
954 
955 
956 void
958  glPushName(getGlID());
959  glPushMatrix();
960  Position p1 = getPosition();
961  // one seat in the center of the vehicle by default
963  glTranslated(p1.x(), p1.y(), getType());
964  glRotated(getAngle(), 0, 0, 1);
965  // set lane color
966  setColor(s);
967  // scale
968  const SUMOReal upscale = s.vehicleSize.getExaggeration(s);
969  glScaled(upscale, upscale, 1);
970  /*
971  MSLCM_DK2004 &m2 = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
972  if((m2.getState()&LCA_URGENT)!=0) {
973  glColor3d(1, .4, .4);
974  } else if((m2.getState()&LCA_SPEEDGAIN)!=0) {
975  glColor3d(.4, .4, 1);
976  } else {
977  glColor3d(.4, 1, .4);
978  }
979  */
980  // draw the vehicle
982  switch (s.vehicleQuality) {
983  case 0:
985  break;
986  case 1:
988  break;
989  case 2:
991  break;
992  case 3:
993  default:
994  // draw as image but take special care for drawing trains
995  // fallback to simple shapes
996  if (!drawAction_drawCarriageClass(s, getVehicleType().getGuiShape(), true)) {
999  };
1000  }
1001  break;
1002  }
1003  if (s.drawMinGap) {
1004  const SUMOReal minGap = -getVehicleType().getMinGap();
1005  glColor3d(0., 1., 0.);
1006  glBegin(GL_LINES);
1007  glVertex2d(0., 0);
1008  glVertex2d(0., minGap);
1009  glVertex2d(-.5, minGap);
1010  glVertex2d(.5, minGap);
1011  glEnd();
1012  }
1014  if (dev != 0 && s.showBTRange) {
1015  glColor3d(1., 0., 0.);
1016  GLHelper::drawOutlineCircle(dev->getRange(), dev->getRange() - .2, 32);
1017  }
1018  // draw the blinker and brakelights if wished
1019  if (s.showBlinker) {
1020  glTranslated(0, 0, .1);
1021  switch (getVehicleType().getGuiShape()) {
1022  case SVS_PEDESTRIAN:
1023  case SVS_BICYCLE:
1024  case SVS_ANT:
1025  case SVS_SHIP:
1026  case SVS_RAIL:
1027  case SVS_RAIL_CARGO:
1028  // only SVS_RAIL_CAR has blinkers and brake lights
1029  break;
1030  default:
1033  break;
1034  }
1035  }
1036  // draw the wish to change the lane
1037  if (s.drawLaneChangePreference) {
1038  /*
1039  if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
1040  MSLCM_DK2004 &m = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
1041  glColor3d(.5, .5, 1);
1042  glBegin(GL_LINES);
1043  glVertex2f(0, 0);
1044  glVertex2f(m.getChangeProbability(), .5);
1045  glEnd();
1046 
1047  glColor3d(1, 0, 0);
1048  glBegin(GL_LINES);
1049  glVertex2f(0.1, 0);
1050  glVertex2f(0.1, m.myMaxJam1);
1051  glEnd();
1052 
1053  glColor3d(0, 1, 0);
1054  glBegin(GL_LINES);
1055  glVertex2f(-0.1, 0);
1056  glVertex2f(-0.1, m.myTDist);
1057  glEnd();
1058  }
1059  */
1060  }
1061  // draw best lanes
1062  /*
1063  if (true) {
1064  const MSLane &l = veh->getLane();
1065  SUMOReal r1 = veh->allowedContinuationsLength(&l, 0);
1066  SUMOReal r2 = l.getLeftLane()!=0 ? veh->allowedContinuationsLength(l.getLeftLane(), 0) : 0;
1067  SUMOReal r3 = l.getRightLane()!=0 ? veh->allowedContinuationsLength(l.getRightLane(), 0) : 0;
1068  SUMOReal mmax = MAX3(r1, r2, r3);
1069  glBegin(GL_LINES);
1070  glVertex2f(0, 0);
1071  glVertex2f(0, r1/mmax/2.);
1072  glEnd();
1073  glBegin(GL_LINES);
1074  glVertex2f(.4, 0);
1075  glVertex2f(.4, r2/mmax/2.);
1076  glEnd();
1077  glBegin(GL_LINES);
1078  glVertex2f(-.4, 0);
1079  glVertex2f(-.4, r3/mmax/2.);
1080  glEnd();
1081  }
1082  */
1083  glPopMatrix();
1084  const Position namePos = getPosition(-MIN2(getVehicleType().getLength() / 2, SUMOReal(5)));
1085  drawName(namePos, s.scale,
1086  getVehicleType().getGuiShape() == SVS_PEDESTRIAN ? s.personName : s.vehicleName);
1087  if (s.vehicleName.show && myParameter->line != "") {
1088  GLHelper::drawText("line:" + myParameter->line, namePos + Position(0, -0.6 * s.vehicleName.size / s.scale),
1090  }
1091  glPopName();
1092  if (myPersonDevice != 0) {
1093  const std::vector<MSPerson*>& ps = myPersonDevice->getPersons();
1094  size_t personIndex = 0;
1095  for (std::vector<MSPerson*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
1096  GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
1097  assert(person != 0);
1098  person->setPositionInVehicle(getSeatPosition(personIndex++));
1099  person->drawGL(s);
1100  }
1101  }
1102  if (myContainerDevice != 0) {
1103  const std::vector<MSContainer*>& cs = myContainerDevice->getContainers();
1104  size_t containerIndex = 0;
1105  for (std::vector<MSContainer*>::const_iterator i = cs.begin(); i != cs.end(); ++i) {
1106  GUIContainer* container = dynamic_cast<GUIContainer*>(*i);
1107  assert(container != 0);
1108  container->setPositionInVehicle(getSeatPosition(containerIndex++));
1109  container->drawGL(s);
1110  }
1111  }
1112 }
1113 
1114 
1115 void
1117  glPushName(getGlID());
1118  glPushMatrix();
1119  glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
1121  drawBestLanes();
1122  }
1124  drawRoute(s, 0, 0.25);
1125  }
1127  if (getNumberReroutes() > 0) {
1128  const int noReroutePlus1 = getNumberReroutes() + 1;
1129  for (int i = noReroutePlus1 - 1; i >= 0; i--) {
1130  SUMOReal darken = SUMOReal(0.4) / SUMOReal(noReroutePlus1) * SUMOReal(i);
1131  drawRoute(s, i, darken);
1132  }
1133  } else {
1134  drawRoute(s, 0, 0.25);
1135  }
1136  }
1138  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
1139  if ((*i).myLink == 0) {
1140  continue;
1141  }
1142  MSLink* link = (*i).myLink;
1143  MSLane* via = link->getViaLaneOrLane();
1144  if (via != 0) {
1145  Position p = via->getShape()[0];
1146  if ((*i).mySetRequest) {
1147  glColor3d(0, .8, 0);
1148  } else {
1149  glColor3d(.8, 0, 0);
1150  }
1151  const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
1152  (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(), getVehicleType().getLengthWithGap());
1153  drawLinkItem(p, (*i).myArrivalTime, leaveTime, s.vehicleSize.getExaggeration(s));
1154  // the time slot that ego vehicle uses when checking opened may
1155  // differ from the one it requests in setApproaching
1156  MSLink::ApproachingVehicleInformation avi = (*i).myLink->getApproaching(this);
1157  assert(avi.arrivalTime == (*i).myArrivalTime && avi.leavingTime == leaveTime);
1158  UNUSED_PARAMETER(avi); // only used for assertion
1159  }
1160  }
1161  }
1162  glPopMatrix();
1163  glPopName();
1164 }
1165 
1166 
1167 void
1168 GUIVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate) {
1169  glTranslated(pos.x(), pos.y(), -.1);
1171  std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
1172  GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
1173  glTranslated(-pos.x(), -pos.y(), .1);
1174 }
1175 
1176 
1177 void
1179  const GUIColorer& c = s.vehicleColorer;
1180  if (!setFunctionalColor(c.getActive(), this)) {
1182  }
1183 }
1184 
1185 
1186 bool
1187 GUIVehicle::setFunctionalColor(size_t activeScheme, const MSBaseVehicle* veh) {
1188  switch (activeScheme) {
1189  case 0: {
1190  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1192  return true;
1193  }
1196  return true;
1197  }
1198  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1200  return true;
1201  }
1202  return false;
1203  }
1204  case 2: {
1205  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1207  return true;
1208  }
1209  return false;
1210  }
1211  case 3: {
1214  return true;
1215  }
1216  return false;
1217  }
1218  case 4: {
1219  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1221  return true;
1222  }
1223  return false;
1224  }
1225  case 5: {
1226  Position p = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1227  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1228  Position center = b.getCenter();
1229  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1230  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1231  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1232  return true;
1233  }
1234  case 6: {
1235  Position p = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1236  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1237  Position center = b.getCenter();
1238  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1239  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1240  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1241  return true;
1242  }
1243  case 7: {
1244  Position pb = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1245  Position pe = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1246  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1247  SUMOReal hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / PI;
1248  Position minp(b.xmin(), b.ymin());
1249  Position maxp(b.xmax(), b.ymax());
1250  SUMOReal sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1251  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1252  return true;
1253  }
1254  case 24: { // color randomly (by pointer)
1255  const SUMOReal hue = (long)veh % 360; // [0-360]
1256  const SUMOReal sat = (((long)veh / 360) % 67) / 100.0 + 0.33; // [0.33-1]
1257  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1258  return true;
1259  }
1260  }
1261  return false;
1262 }
1263 
1264 
1265 SUMOReal
1266 GUIVehicle::getColorValue(size_t activeScheme) const {
1267  switch (activeScheme) {
1268  case 8:
1269  return getSpeed();
1270  case 9:
1271  return getWaitingSeconds();
1272  case 10:
1273  return getLastLaneChangeOffset();
1274  case 11:
1275  return MIN2(getMaxSpeed(), getLane()->getVehicleMaxSpeed(this));
1276  case 12:
1277  return getCO2Emissions();
1278  case 13:
1279  return getCOEmissions();
1280  case 14:
1281  return getPMxEmissions();
1282  case 15:
1283  return getNOxEmissions();
1284  case 16:
1285  return getHCEmissions();
1286  case 17:
1287  return getFuelConsumption();
1288  case 18:
1290  case 19: // !!! unused!?
1291  if (getNumberReroutes() == 0) {
1292  return -1;
1293  }
1294  return getNumberReroutes();
1295  case 20:
1297  case 21:
1298  return getBestLaneOffset();
1299  case 22:
1300  return getAcceleration();
1301  case 23:
1302  return getTimeGap();
1303  }
1304  return 0;
1305 }
1306 
1307 
1308 // ------------ Additional visualisations
1309 bool
1311  return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
1312 }
1313 
1314 
1315 void
1317  if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
1318  myAdditionalVisualizations[parent] = 0;
1319  }
1320  myAdditionalVisualizations[parent] |= which;
1321  parent->addAdditionalGLVisualisation(this);
1322 }
1323 
1324 
1325 void
1327  myAdditionalVisualizations[parent] &= ~which;
1328  parent->removeAdditionalGLVisualisation(this);
1329 }
1330 
1331 
1332 void
1333 GUIVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const {
1334  setColor(s);
1335  GLdouble colors[4];
1336  glGetDoublev(GL_CURRENT_COLOR, colors);
1337  colors[0] -= darken;
1338  if (colors[0] < 0) {
1339  colors[0] = 0;
1340  }
1341  colors[1] -= darken;
1342  if (colors[1] < 0) {
1343  colors[1] = 0;
1344  }
1345  colors[2] -= darken;
1346  if (colors[2] < 0) {
1347  colors[2] = 0;
1348  }
1349  colors[3] -= darken;
1350  if (colors[3] < 0) {
1351  colors[3] = 0;
1352  }
1353  glColor3dv(colors);
1354  const SUMOReal exaggeration = s.vehicleSize.getExaggeration(s);
1355  if (routeNo == 0) {
1356  drawRouteHelper(*myRoute, exaggeration);
1357  return;
1358  }
1359  --routeNo; // only prior routes are stored
1360  drawRouteHelper(*myRoutes->getRoute(routeNo), exaggeration);
1361 }
1362 
1363 
1364 void
1366  myLock.lock();
1367  std::vector<std::vector<MSVehicle::LaneQ> > bestLanes = myBestLanes;
1368  myLock.unlock();
1369  SUMOReal width = 0.5;
1370  for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
1371  std::vector<MSVehicle::LaneQ>& lanes = *j;
1372  SUMOReal gmax = -1;
1373  SUMOReal rmax = -1;
1374  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1375  gmax = MAX2((*i).length, gmax);
1376  rmax = MAX2((*i).occupation, rmax);
1377  }
1378  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1379  const PositionVector& shape = (*i).lane->getShape();
1380  SUMOReal g = (*i).length / gmax;
1381  SUMOReal r = (*i).occupation / rmax;
1382  glColor3d(r, g, 0);
1383  GLHelper::drawBoxLines(shape, width);
1384 
1385  PositionVector s1 = shape;
1386  s1.move2side((SUMOReal) .1);
1387  glColor3d(r, 0, 0);
1388  GLHelper::drawLine(s1);
1389  s1.move2side((SUMOReal) - .2);
1390  glColor3d(0, g, 0);
1391  GLHelper::drawLine(s1);
1392 
1393  glColor3d(r, g, 0);
1394  Position lastPos = shape[-1];
1395  }
1396  width = .2;
1397  }
1398 }
1399 
1400 
1401 void
1402 GUIVehicle::drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const {
1403  MSRouteIterator i = r.begin();
1404  const std::vector<MSLane*>& bestLaneConts = getBestLanesContinuation();
1405  // draw continuation lanes when drawing the current route where available
1406  size_t bestLaneIndex = (&r == myRoute ? 0 : bestLaneConts.size());
1407  for (; i != r.end(); ++i) {
1408  const GUILane* lane;
1409  if (bestLaneIndex < bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) {
1410  lane = static_cast<GUILane*>(bestLaneConts[bestLaneIndex]);
1411  ++bestLaneIndex;
1412  } else {
1413  lane = static_cast<GUILane*>((*i)->getLanes()[0]);
1414  }
1415  GLHelper::drawBoxLines(lane->getShape(), lane->getShapeRotations(), lane->getShapeLengths(), exaggeration);
1416  }
1417 }
1418 
1419 
1420 MSLane*
1421 GUIVehicle::getPreviousLane(MSLane* current, int& furtherIndex) const {
1422  if (furtherIndex < (int)myFurtherLanes.size()) {
1423  return myFurtherLanes[furtherIndex++];
1424  } else {
1425  return current;
1426  }
1427 }
1428 
1429 
1430 void
1431 GUIVehicle::drawAction_drawRailCarriages(const GUIVisualizationSettings& s, SUMOReal defaultLength, SUMOReal carriageGap, int firstPassengerCarriage, bool asImage) const {
1432  RGBColor current = GLHelper::getColor();
1433  RGBColor darker = current.changedBrightness(-51);
1434  const SUMOReal exaggeration = s.vehicleSize.getExaggeration(s);
1435  defaultLength *= exaggeration;
1436  if (exaggeration == 0) {
1437  return;
1438  }
1439  carriageGap *= exaggeration;
1440  const SUMOReal length = getVehicleType().getLength() * exaggeration;
1441  const SUMOReal halfWidth = getVehicleType().getWidth() / 2.0 * exaggeration;
1442  glPopMatrix(); // undo scaling and 90 degree rotation
1443  glPopMatrix(); // undo initial translation and rotation
1444  GLHelper::setColor(darker);
1445  const SUMOReal xCornerCut = 0.3 * exaggeration;
1446  const SUMOReal yCornerCut = 0.4 * exaggeration;
1447  // round to closest integer
1448  const int numCarriages = floor(length / (defaultLength + carriageGap) + 0.5);
1449  assert(numCarriages > 0);
1450  const SUMOReal carriageLengthWithGap = length / numCarriages;
1451  const SUMOReal carriageLength = carriageLengthWithGap - carriageGap;
1452  // lane on which the carriage front is situated
1453  MSLane* lane = myLane;
1454  int furtherIndex = 0;
1455  // lane on which the carriage back is situated
1456  MSLane* backLane = myLane;
1457  int backFurtherIndex = furtherIndex;
1458  // offsets of front and back
1459  SUMOReal carriageOffset = myState.pos();
1460  SUMOReal carriageBackOffset = myState.pos() - carriageLength;
1461  // handle seats
1462  int requiredSeats = getNumPassengers();
1463  if (requiredSeats > 0) {
1464  mySeatPositions.clear();
1465  }
1466  Position front, back;
1467  SUMOReal angle = 0.;
1468  // draw individual carriages
1469  for (int i = 0; i < numCarriages; ++i) {
1470  while (carriageOffset < 0) {
1471  MSLane* prev = getPreviousLane(lane, furtherIndex);
1472  if (prev != lane) {
1473  carriageOffset += prev->getLength();
1474  } else {
1475  // no lane available for drawing.
1476  carriageOffset = 0;
1477  }
1478  lane = prev;
1479  }
1480  while (carriageBackOffset < 0) {
1481  MSLane* prev = getPreviousLane(backLane, backFurtherIndex);
1482  if (prev != backLane) {
1483  carriageBackOffset += prev->getLength();
1484  } else {
1485  // no lane available for drawing.
1486  carriageBackOffset = 0;
1487  }
1488  backLane = prev;
1489  }
1490  front = lane->getShape().positionAtOffset2D(carriageOffset);
1491  back = backLane->getShape().positionAtOffset2D(carriageBackOffset);
1492  if (front == back) {
1493  // no place for drawing available
1494  continue;
1495  }
1496  angle = atan2((front.x() - back.x()), (back.y() - front.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
1497  if (i >= firstPassengerCarriage) {
1498  computeSeats(front, back, requiredSeats);
1499  }
1500  glPushMatrix();
1501  glTranslated(front.x(), front.y(), getType());
1502  glRotated(angle, 0, 0, 1);
1503  if (!asImage || !drawAction_drawVehicleAsImage(s, carriageLength)) {
1504  glBegin(GL_TRIANGLE_FAN);
1505  glVertex2d(-halfWidth + xCornerCut, 0);
1506  glVertex2d(-halfWidth, yCornerCut);
1507  glVertex2d(-halfWidth, carriageLength - yCornerCut);
1508  glVertex2d(-halfWidth + xCornerCut, carriageLength);
1509  glVertex2d(halfWidth - xCornerCut, carriageLength);
1510  glVertex2d(halfWidth, carriageLength - yCornerCut);
1511  glVertex2d(halfWidth, yCornerCut);
1512  glVertex2d(halfWidth - xCornerCut, 0);
1513  glEnd();
1514  }
1515  glPopMatrix();
1516  carriageOffset -= carriageLengthWithGap;
1517  carriageBackOffset -= carriageLengthWithGap;
1518  GLHelper::setColor(current);
1519  }
1520  myCarriageLength = front.distanceTo2D(back);
1521  // restore matrices
1522  glPushMatrix();
1523  glTranslated(front.x(), front.y(), getType());
1524  glRotated(angle, 0, 0, 1);
1525  glPushMatrix();
1526 }
1527 
1528 
1529 const Position&
1530 GUIVehicle::getSeatPosition(size_t personIndex) const {
1532  return mySeatPositions[(int)MIN2(personIndex, mySeatPositions.size() - 1)];
1533 }
1534 
1535 
1536 int
1538  if (myPersonDevice != 0) {
1539  return (int)myPersonDevice->getPersons().size();
1540  }
1541  return 0;
1542 }
1543 
1544 
1545 void
1546 GUIVehicle::computeSeats(const Position& front, const Position& back, int& requiredSeats) const {
1547  if (requiredSeats <= 0) {
1548  return; // save some work
1549  }
1550  const Line l(front, back);
1551  const SUMOReal length = l.length2D();
1552  if (length < 4) {
1553  // small vehicle, sit at the center
1555  requiredSeats--;
1556  } else {
1557  for (SUMOReal p = 2; p <= length - 1; p += 1) {
1559  requiredSeats--;
1560  }
1561  }
1562 }
1563 
1564 
1565 SUMOReal
1568 }
1569 
1570 
1571 std::string
1573  std::string result = "";
1574  if (isParking()) {
1575  result += "parking";
1576  } else if (isStopped()) {
1577  result += "stopped";
1578  } else {
1579  return "";
1580  }
1581  if (myStops.front().triggered) {
1582  result += ", triggered";
1583  } else if (myStops.front().containerTriggered) {
1584  result += ", containerTriggered";
1585  } else {
1586  result += ", duration=" + time2string(myStops.front().duration);
1587  }
1588  return result;
1589 }
1590 
1591 
1592 void
1595  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
1596  const DriveProcessItem& dpi = *i;
1597  if (dpi.myLink == 0) {
1598  continue;
1599  }
1600  std::vector<const SUMOVehicle*> blockingFoes;
1601  std::vector<const MSPerson*> blockingPersons;
1603  getImpatience(), getCarFollowModel().getMaxDecel(), getWaitingTime(), &blockingFoes);
1604  for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
1605  gSelected.select(static_cast<const GUIVehicle*>(*it)->getGlID());
1606  }
1607 #ifdef HAVE_INTERNAL_LANES
1608  const MSLink::LinkLeaders linkLeaders = (dpi.myLink)->getLeaderInfo(dist, getVehicleType().getMinGap(), &blockingPersons);
1609  for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1610  // the vehicle to enter the junction first has priority
1611  const GUIVehicle* leader = dynamic_cast<const GUIVehicle*>(it->vehAndGap.first);
1612  if (leader != 0) {
1613  if (leader->myLinkLeaders[dpi.myLink->getJunction()].count(getID()) == 0) {
1614  // leader isn't already following us, now we follow it
1615  gSelected.select(leader->getGlID());
1616  }
1617  } else {
1618  for (std::vector<const MSPerson*>::iterator it_p = blockingPersons.begin(); it_p != blockingPersons.end(); ++it_p) {
1619  const GUIPerson* foe = dynamic_cast<const GUIPerson*>(*it_p);
1620  if (foe != 0) {
1621  gSelected.select(foe->getGlID());
1622  //std::cout << SIMTIME << " veh=" << getID() << " is blocked on link " << dpi.myLink->getRespondIndex() << " to " << dpi.myLink->getViaLaneOrLane()->getID() << " by pedestrian. dist=" << it->second << "\n";
1623  }
1624  }
1625  }
1626  }
1627 #endif
1628  dist += dpi.myLink->getViaLaneOrLane()->getLength();
1629  }
1630 }
1631 
1632 /****************************************************************************/
1633 
SUMOReal length2D() const
Definition: Line.cpp:186
bool signalSet(int which) const
Returns whether the given signal is on.
Definition: MSVehicle.h:838
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIVehicle.cpp:322
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:91
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:705
render as a rail
RGBColor color
The vehicle's color.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
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:880
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be shown.
Definition: GUIVehicle.cpp:191
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
long onCmdStartTrack(FXObject *, FXSelector, void *)
Called if the vehicle shall be tracked.
Definition: GUIVehicle.cpp:208
double vehiclePoly_Ship[]
Definition: GUIVehicle.cpp:134
unsigned int getNumberReroutes() const
Returns the number of new routes this vehicle got.
double vehiclePoly_TransportFrontGlass[]
Definition: GUIVehicle.cpp:125
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIVehicle.cpp:276
static bool setFunctionalColor(size_t activeScheme, const MSBaseVehicle *veh)
sets the color according to the current scheme index and some vehicle function
MoveReminderCont myMoveReminders
Current lane's move reminder.
static RGBColor fromHSV(SUMOReal h, SUMOReal s, SUMOReal v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:294
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:1162
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:106
void drawAction_drawVehicleBlinker(const GUIVehicle &veh, SUMOReal length)
Definition: GUIVehicle.cpp:921
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:540
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
Definition: MSVehicle.h:1179
State myState
This Vehicles driving state (pos and speed)
Definition: MSVehicle.h:1152
a vehicles
GUIVisualizationTextSettings personName
Show all vehicle's routes.
Definition: GUIAppEnum.h:249
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:1252
SUMOReal pos() const
Position of this state.
Definition: MSVehicle.cpp:139
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.
bool showBTRange
Information whether the communication range shall be drawn.
SUMOReal getLeaveSpeed() const
Definition: MSVehicle.h:1244
double vehiclePoly_ShipDeck[]
Definition: GUIVehicle.cpp:135
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:359
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:603
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:114
track vehicle
Definition: GUIVehicle.h:239
Start to track a vehicle.
Definition: GUIAppEnum.h:253
static void drawOutlineCircle(SUMOReal width, SUMOReal iwidth, int steps=8)
Draws an unfilled circle around (0,0)
Definition: GLHelper.cpp:375
bool drawLaneChangePreference
Information whether the lane change preference shall be drawn.
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's length [m].
SUMOReal getLastLaneChangeOffset() const
Returns the time since the last lane change in seconds.
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width, int cornerDetail=0, SUMOReal offset=0)
Draws thick lines.
Definition: GLHelper.cpp:176
SUMOReal getHCEmissions() const
Returns HC emission of the current state.
Definition: MSVehicle.cpp:2292
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
double vehiclePoly_TransportBody[]
Definition: GUIVehicle.cpp:124
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:74
show all vehicle's routes
Definition: GUIVehicle.h:237
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIVehicle.cpp:400
const MSRoute & getRoute() const
Returns the current route.
Definition: MSBaseVehicle.h:82
render as a delivery vehicle
double vehiclePoly_ShipSuperStructure[]
Definition: GUIVehicle.cpp:136
static void drawBoxLine(const Position &beg, SUMOReal rot, SUMOReal visLength, SUMOReal width, SUMOReal offset=0)
Draws a thick line.
Definition: GLHelper.cpp:130
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:2280
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
double vehiclePoly_Cyclist[]
Definition: GUIVehicle.cpp:138
const std::vector< SUMOReal > & getShapeLengths() const
Definition: GUILane.cpp:711
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:286
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:459
const SUMOVehicleParameter * myParameter
This Vehicle's parameter.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:52
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, SUMOReal length=-1) const
Definition: GUIVehicle.cpp:861
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:166
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:117
#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:200
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
double vehiclePoly_PassengerHatchbackRightGlass[]
Definition: GUIVehicle.cpp:107
The car-following model and parameter.
Definition: MSVehicleType.h:74
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:1884
SUMOReal scale
information about a lane's width (temporary, used for a single view)
double vehiclePoly_PassengerCarBody[]
Definition: GUIVehicle.cpp:101
std::string getStopInfo() const
retrieve information about the current stop state
Right blinker lights are switched on.
Definition: MSVehicle.h:760
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:183
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
Definition: GUIVehicle.cpp:236
GUIColorer vehicleColorer
The vehicle colorer.
virtual int getTrackedID() const
static void drawFilledCircle(SUMOReal width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:344
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:102
void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
Definition: GUIVehicle.cpp:458
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:174
static const RGBColor GREEN
Definition: RGBColor.h:190
Left blinker lights are switched on.
Definition: MSVehicle.h:762
static const RGBColor GREY
Definition: RGBColor.h:198
void drawAction_drawVehicleAsTrianglePlus() const
Definition: GUIVehicle.cpp:424
#define PI
Definition: polyfonts.c:61
GUIVehicle(SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, const SUMOReal speedFactor)
Constructor.
Definition: GUIVehicle.cpp:253
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:442
render as a hatchback passenger vehicle ("Fliessheck")
double vehiclePoly_EVehicleBackGlass[]
Definition: GUIVehicle.cpp:132
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
bool wasSet(int what) const
Returns whether the given parameter was set.
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:2168
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:221
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:200
not defined
render as a bicycle
Hide all vehicle's routes.
Definition: GUIAppEnum.h:251
double vehiclePoly_EVehicleFrontGlass[]
Definition: GUIVehicle.cpp:130
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
Definition: GUIVehicle.h:245
std::list< Stop > myStops
The vehicle's list of stops.
Definition: MSVehicle.h:1167
long onCmdShowLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
Definition: GUIVehicle.cpp:227
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:61
show vehicle's current route
Definition: GUIVehicle.h:235
MSLane * getPreviousLane(MSLane *current, int &furtherIndex) const
bool isStopped() const
Returns whether the vehicle is at a stop.
Definition: MSVehicle.cpp:807
double vehiclePoly_TransportLeftGlass[]
Definition: GUIVehicle.cpp:127
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
MSLane * myLane
The lane the vehicle is on.
Definition: MSVehicle.h:1155
Blinker lights on both sides are switched on.
Definition: MSVehicle.h:764
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:124
~GUIVehicle()
destructor
Definition: GUIVehicle.cpp:264
const T getColor(const SUMOReal value) const
void setPositionInVehicle(const Position &pos)
Definition: GUIPerson.h:120
Definition: Line.h:51
double vehiclePoly_DeliveryMediumLeftGlass[]
Definition: GUIVehicle.cpp:122
render as a (city) rail without locomotive
T MIN2(T a, T b)
Definition: StdDefs.h:68
double vehiclePoly_PassengerWagonBackGlass[]
Definition: GUIVehicle.cpp:112
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:150
static void drawPoly(double *poses, SUMOReal offset)
Definition: GUIVehicle.cpp:442
The brake lights are on.
Definition: MSVehicle.h:766
long onCmdStopTrack(FXObject *, FXSelector, void *)
Called if the current shall not be tracked any longer.
Definition: GUIVehicle.cpp:218
MSDevice_Vehroutes * myRoutes
Definition: GUIVehicle.h:332
int getNumPassengers() const
return the number of passengers
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:184
#define BLINKER_POS_BACK
Definition: GUIVehicle.cpp:904
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
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:813
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
Definition: GUIVehicle.h:335
SUMOReal getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
Definition: MSVehicle.cpp:2316
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate)
std::string line
The vehicle's line (mainly for public transport)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIPerson.cpp:179
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:327
SUMOReal getNOxEmissions() const
Returns NOx emission of the current state.
Definition: MSVehicle.cpp:2298
Show vehicle's best lanes.
Definition: GUIAppEnum.h:245
static void removeObject(GUIGlObject &o)
Removes all instances that pass values from the object with the given id.
void setPositionInVehicle(const Position &pos)
Definition: GUIContainer.h:118
render as a cargo train
SUMOReal getPMxEmissions() const
Returns PMx emission of the current state.
Definition: MSVehicle.cpp:2304
SUMOReal getCOEmissions() const
Returns CO emission of the current state.
Definition: MSVehicle.cpp:2286
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:940
void unlock()
release mutex lock
Definition: MFXMutex.cpp:96
FXDEFMAP(GUIVehicle::GUIVehiclePopupMenu) GUIVehiclePopupMenuMap[]
SUMOReal getWidth() const
Get the width which vehicles of this class shall have when being drawn.
void push_back(const PositionVector &p)
Appends all positions from the given vector.
render as a giant ant
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
Stop to track a vehicle.
Definition: GUIAppEnum.h:255
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:957
Structure representing possible vehicle parameter.
double vehiclePoly_PassengerVanLeftGlass[]
Definition: GUIVehicle.cpp:118
void drawAction_drawVehicleAsBoxPlus() const
Definition: GUIVehicle.cpp:409
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.
render as a arbitrary ship
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:90
Hide vehicle's current route.
Definition: GUIAppEnum.h:243
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:302
double vehiclePoly_PassengerVanBodyFront[]
Definition: GUIVehicle.cpp:115
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
SUMOReal getFuelConsumption() const
Returns fuel consumption of the current state.
Definition: MSVehicle.cpp:2310
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
Definition: MSBaseVehicle.h:90
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...
const std::vector< MSContainer * > & getContainers() const
Returns the list of containers using this vehicle.
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:907
SUMOReal getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:294
int SUMOTime
Definition: SUMOTime.h:43
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
void lock()
lock mutex
Definition: MFXMutex.cpp:86
Show vehicle's current route.
Definition: GUIAppEnum.h:241
long onCmdShowFoes(FXObject *, FXSelector, void *)
Called when show a vehicles foes.
Definition: GUIVehicle.cpp:243
SUMOReal getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:370
const RGBColor & getColor() const
Returns this type's color.
double vehiclePoly_PassengerSedanBackGlass[]
Definition: GUIVehicle.cpp:106
double vehiclePoly_PassengerHatchbackBackGlass[]
Definition: GUIVehicle.cpp:109
unsigned size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp: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:269
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:903
const RGBColor & getColor() const
Returns the color.
Definition: MSRoute.cpp:328
#define SUMOReal
Definition: config.h:218
std::string getImgFile() const
Get this vehicle type's raster model file name.
GUIVisualizationSizeSettings vehicleSize
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
double vehiclePoly_PassengerVanFrontGlass[]
Definition: GUIVehicle.cpp:116
show vehicle's best lanes
Definition: GUIVehicle.h:233
empty max
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
static SUMOReal getRange()
Returns the configured range.
double vehiclePoly_PassengerVanBody[]
Definition: GUIVehicle.cpp:114
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:331
Hide vehicle's best lanes.
Definition: GUIAppEnum.h:247
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:2270
select foes of a vehicle
Definition: GUIAppEnum.h:257
double vehiclePoly_PassengerVanBackGlass[]
Definition: GUIVehicle.cpp:119
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.
render as a coach
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
MSDevice_Container * myContainerDevice
The containers this vehicle may have.
Definition: MSVehicle.h:1173
std::vector< MSDevice * > myDevices
The devices this vehicle has.
A window containing a gl-object's parameter.
const int VTYPEPARS_COLOR_SET
render as a semi-trailer transport vehicle ("Sattelschlepper")
double vehiclePoly_PassengerHatchbackLeftGlass[]
Definition: GUIVehicle.cpp:108
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double vehiclePoly_PassengerSedanRightGlass[]
Definition: GUIVehicle.cpp:104
SUMOReal getExaggeration(const GUIVisualizationSettings &s) const
return the drawing size including exaggeration and constantSize values
MSDevice_Person * myPersonDevice
The passengers this vehicle may have.
Definition: MSVehicle.h:1170
double vehiclePoly_PassengerSedanLeftGlass[]
Definition: GUIVehicle.cpp:105
int getBestLaneOffset() const
returns the current offset from the best lane
Definition: MSVehicle.cpp:2196
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:646
SUMOReal myCarriageLength
Variable to set with the length of the last drawn carriage or the vehicle length. ...
Definition: GUIVehicle.h:330
const std::string & getID() const
Returns the name of the vehicle.
const PositionVector & getShape() const
Definition: GUILane.cpp:699
const MSRoute * getRoute(int index) const
Called on route retrieval.
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:448
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:157
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:68