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.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, 40);
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("persons", true,
381  ret->mkItem("containers", true,
383 
384  ret->mkItem("parameters [key:val]", false, toString(getParameter().getMap()));
385  ret->mkItem("", false, "");
386  ret->mkItem("Type Information:", false, "");
387  ret->mkItem("type [id]", false, myType->getID());
388  ret->mkItem("length", false, myType->getLength());
389  ret->mkItem("minGap", false, myType->getMinGap());
390  ret->mkItem("vehicle class", false, SumoVehicleClassStrings.getString(myType->getVehicleClass()));
391  ret->mkItem("emission class", false, PollutantsInterface::getName(myType->getEmissionClass()));
392  ret->mkItem("maximum speed [m/s]", false, getMaxSpeed());
393  ret->mkItem("maximum acceleration [m/s^2]", false, getCarFollowModel().getMaxAccel());
394  ret->mkItem("maximum deceleration [m/s^2]", false, getCarFollowModel().getMaxDecel());
395  ret->mkItem("imperfection (sigma)", false, getCarFollowModel().getImperfection());
396  ret->mkItem("reaction time (tau)", false, getCarFollowModel().getHeadwayTime());
397  ret->mkItem("person capacity", false, myType->getPersonCapacity());
398  ret->mkItem("container capacity", false, myType->getContainerCapacity());
399 
400  ret->mkItem("type parameters [key:val]", false, toString(myType->getParameter().getMap()));
401  // close building
402  ret->closeBuilding();
403  return ret;
404 }
405 
406 
407 Boundary
409  Boundary b;
410  b.add(getPosition());
411  b.grow(20);
412  return b;
413 }
414 
415 
416 void
418  glPushMatrix();
419  glScaled(getVehicleType().getWidth(), getVehicleType().getLength(), 1.);
420  glBegin(GL_TRIANGLE_STRIP);
421  glVertex2d(0., 0.);
422  glVertex2d(-.5, .15);
423  glVertex2d(.5, .15);
424  glVertex2d(-.5, 1.);
425  glVertex2d(.5, 1.);
426  glEnd();
427  glPopMatrix();
428 }
429 
430 
431 void
433  const SUMOReal length = getVehicleType().getLength();
434  if (length >= 8.) {
436  return;
437  }
438  glPushMatrix();
439  glScaled(getVehicleType().getWidth(), length, 1.);
440  glBegin(GL_TRIANGLES);
441  glVertex2d(0., 0.);
442  glVertex2d(-.5, 1.);
443  glVertex2d(.5, 1.);
444  glEnd();
445  glPopMatrix();
446 }
447 
448 
449 void
450 GUIVehicle::drawPoly(double* poses, SUMOReal offset) {
451  glPushMatrix();
452  glTranslated(0, 0, offset * .1);
453  glPolygonOffset(0, offset * -1);
454  glBegin(GL_TRIANGLE_FAN);
455  int i = 0;
456  while (poses[i] > -999) {
457  glVertex2d(poses[i], poses[i + 1]);
458  i = i + 2;
459  }
460  glEnd();
461  glPopMatrix();
462 }
463 
464 
465 void
467  RGBColor current = GLHelper::getColor();
468  RGBColor lighter = current.changedBrightness(51);
469  RGBColor darker = current.changedBrightness(-51);
470 
471  const SUMOReal length = getVehicleType().getLength();
472  const SUMOReal width = getVehicleType().getWidth();
473  glPushMatrix();
474  glRotated(90, 0, 0, 1);
475  glScaled(length, width, 1.);
477 
478  // draw main body
479  switch (shape) {
480  case SVS_UNKNOWN:
482  GLHelper::setColor(lighter);
483  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
484  glColor3d(0, 0, 0);
485  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
486  break;
487  case SVS_PEDESTRIAN:
488  glTranslated(0, 0, .045);
490  glTranslated(0, 0, -.045);
491  glScaled(.7, 2, 1);
492  glTranslated(0, 0, .04);
493  GLHelper::setColor(lighter);
495  glTranslated(0, 0, -.04);
496  break;
497  case SVS_BICYCLE:
498  case SVS_MOPED:
499  case SVS_MOTORCYCLE: {
500  RGBColor darker = current.changedBrightness(-50);
501  // body
502  drawPoly(vehiclePoly_Cyclist, 4);
503  // head
504  glPushMatrix();
505  glTranslated(0.4, 0, .5);
506  glScaled(0.1, 0.2, 1);
507  GLHelper::setColor(darker);
509  glPopMatrix();
510  // bike frame
512  glPushMatrix();
513  glTranslated(0.5, 0, .3);
514  glScaled(0.5, 0.05, 1);
516  glPopMatrix();
517  // handle bar
518  glPushMatrix();
519  glTranslated(0.25, 0, .3);
520  glScaled(0.02, 0.5, 1);
522  glPopMatrix();
523  }
524  break;
525  case SVS_PASSENGER:
526  case SVS_PASSENGER_SEDAN:
528  case SVS_PASSENGER_WAGON:
530  GLHelper::setColor(lighter);
531  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
532  glColor3d(0, 0, 0);
533  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
534  break;
535  case SVS_PASSENGER_VAN:
536  drawPoly(vehiclePoly_PassengerVanBody, 4);
537  GLHelper::setColor(lighter);
538  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
539  glColor3d(0, 0, 0);
540  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
541  drawPoly(vehiclePoly_PassengerVanRightGlass, 4.5);
542  drawPoly(vehiclePoly_PassengerVanLeftGlass, 4.5);
543  drawPoly(vehiclePoly_PassengerVanBackGlass, 4.5);
544  break;
545  case SVS_DELIVERY:
546  drawPoly(vehiclePoly_PassengerVanBody, 4);
547  GLHelper::setColor(lighter);
548  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
549  glColor3d(0, 0, 0);
550  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
551  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
552  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
553  break;
554  case SVS_TRUCK:
556  case SVS_TRUCK_1TRAILER:
557  glScaled(1. / (length), 1, 1.);
558  drawPoly(vehiclePoly_TransportBody, 4);
559  glColor3d(0, 0, 0);
560  drawPoly(vehiclePoly_TransportFrontGlass, 4.5);
561  drawPoly(vehiclePoly_TransportRightGlass, 4.5);
562  drawPoly(vehiclePoly_TransportLeftGlass, 4.5);
563  break;
564  case SVS_BUS:
565  case SVS_BUS_COACH:
566  case SVS_BUS_TROLLEY: {
567  SUMOReal ml = length;
568  glScaled(1. / (length), 1, 1.);
569  glTranslated(0, 0, .04);
570  glBegin(GL_TRIANGLE_FAN);
571  glVertex2d(ml / 2., 0);
572  glVertex2d(0, 0);
573  glVertex2d(0, -.45);
574  glVertex2d(0 + .05, -.5);
575  glVertex2d(ml - .05, -.5);
576  glVertex2d(ml, -.45);
577  glVertex2d(ml, .45);
578  glVertex2d(ml - .05, .5);
579  glVertex2d(0 + .05, .5);
580  glVertex2d(0, .45);
581  glVertex2d(0, 0);
582  glEnd();
583  glTranslated(0, 0, -.04);
584 
585  glTranslated(0, 0, .045);
586  glColor3d(0, 0, 0);
587  glBegin(GL_QUADS);
588  glVertex2d(0 + .05, .48);
589  glVertex2d(0 + .05, -.48);
590  glVertex2d(0 + .15, -.48);
591  glVertex2d(0 + .15, .48);
592 
593  glVertex2d(ml - .1, .45);
594  glVertex2d(ml - .1, -.45);
595  glVertex2d(ml - .05, -.45);
596  glVertex2d(ml - .05, .45);
597 
598  glVertex2d(0 + .20, .49);
599  glVertex2d(0 + .20, .45);
600  glVertex2d(ml - .20, .45);
601  glVertex2d(ml - .20, .49);
602 
603  glVertex2d(0 + .20, -.49);
604  glVertex2d(0 + .20, -.45);
605  glVertex2d(ml - .20, -.45);
606  glVertex2d(ml - .20, -.49);
607 
608  glEnd();
609  glTranslated(0, 0, -.045);
610  }
611  break;
612  case SVS_BUS_FLEXIBLE:
613  case SVS_RAIL:
614  case SVS_RAIL_CAR:
615  case SVS_RAIL_CARGO:
616  drawAction_drawCarriageClass(s, shape, false);
617  break;
618  case SVS_E_VEHICLE:
619  drawPoly(vehiclePoly_EVehicleBody, 4);
620  glColor3d(0, 0, 0);
621  drawPoly(vehiclePoly_EVehicleFrontGlass, 4.5);
622  glTranslated(0, 0, .048);
623  GLHelper::setColor(current);
624  glBegin(GL_QUADS);
625  glVertex2d(.3, .5);
626  glVertex2d(.35, .5);
627  glVertex2d(.35, -.5);
628  glVertex2d(.3, -.5);
629 
630  glVertex2d(.3, -.05);
631  glVertex2d(.7, -.05);
632  glVertex2d(.7, .05);
633  glVertex2d(.3, .05);
634 
635  glVertex2d(.7, .5);
636  glVertex2d(.65, .5);
637  glVertex2d(.65, -.5);
638  glVertex2d(.7, -.5);
639  glEnd();
640  glTranslated(0, 0, -.048);
641  //drawPoly(vehiclePoly_EVehicleBackGlass, 4.5);
642  break;
643  case SVS_ANT:
644  glPushMatrix();
645  // ant is stretched via vehicle length
646  GLHelper::setColor(darker);
647  // draw left side
648  GLHelper::drawBoxLine(Position(-0.2, -.10), 350, 0.5, .02);
649  GLHelper::drawBoxLine(Position(-0.3, -.50), 240, 0.4, .03);
650  GLHelper::drawBoxLine(Position(0.3, -.10), 340, 0.8, .03);
651  GLHelper::drawBoxLine(Position(0.05, -.80), 290, 0.6, .04);
652  GLHelper::drawBoxLine(Position(0.4, -.10), 20, 0.8, .03);
653  GLHelper::drawBoxLine(Position(0.65, -.80), 75, 0.6, .04);
654  GLHelper::drawBoxLine(Position(0.5, -.10), 55, 0.8, .04);
655  GLHelper::drawBoxLine(Position(1.1, -.55), 90, 0.6, .04);
656  // draw right side
657  GLHelper::drawBoxLine(Position(-0.2, .10), 190, 0.5, .02);
658  GLHelper::drawBoxLine(Position(-0.3, .50), 300, 0.4, .03);
659  GLHelper::drawBoxLine(Position(0.3, .10), 200, 0.8, .03);
660  GLHelper::drawBoxLine(Position(0.05, .80), 250, 0.6, .04);
661  GLHelper::drawBoxLine(Position(0.4, .10), 160, 0.8, .03);
662  GLHelper::drawBoxLine(Position(0.65, .80), 105, 0.6, .04);
663  GLHelper::drawBoxLine(Position(0.5, .10), 125, 0.8, .04);
664  GLHelper::drawBoxLine(Position(1.1, .55), 90, 0.6, .04);
665  // draw body
666  GLHelper::setColor(current);
667  glTranslated(0, 0, 0.1);
669  glTranslated(.4, 0, 0);
671  glTranslated(.4, 0, 0);
673  glPopMatrix();
674  break;
675  case SVS_SHIP: {
676  RGBColor darker = current.changedBrightness(-30);
677  RGBColor darker2 = current.changedBrightness(-70);
678  drawPoly(vehiclePoly_Ship, 4);
679  GLHelper::setColor(darker);
680  drawPoly(vehiclePoly_ShipDeck, 5);
681  GLHelper::setColor(darker2);
682  drawPoly(vehiclePoly_ShipSuperStructure, 6);
683  break;
684  }
685  default: // same as passenger
687  glColor3d(1, 1, 1);
688  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
689  glColor3d(0, 0, 0);
690  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
691  break;
692  }
693 
694  // draw decorations
695  switch (shape) {
696  case SVS_PEDESTRIAN:
697  break;
698  case SVS_BICYCLE:
699  //glScaled(length, 1, 1.);
700  glBegin(GL_TRIANGLE_FAN);
701  glVertex2d(1 / 2., 0);
702  glVertex2d(0, 0);
703  glVertex2d(0, -.03);
704  glVertex2d(0 + .05, -.05);
705  glVertex2d(1 - .05, -.05);
706  glVertex2d(1, -.03);
707  glVertex2d(1, .03);
708  glVertex2d(1 - .05, .05);
709  glVertex2d(0 + .05, .05);
710  glVertex2d(0, .03);
711  glVertex2d(0, 0);
712  glEnd();
713  break;
714  case SVS_MOPED:
715  case SVS_MOTORCYCLE:
716  //glScaled(length, 1, 1.);
717  glBegin(GL_TRIANGLE_FAN);
718  glVertex2d(1 / 2., 0);
719  glVertex2d(0, 0);
720  glVertex2d(0, -.03);
721  glVertex2d(0 + .05, -.2);
722  glVertex2d(1 - .05, -.2);
723  glVertex2d(1, -.03);
724  glVertex2d(1, .03);
725  glVertex2d(1 - .05, .2);
726  glVertex2d(0 + .05, .2);
727  glVertex2d(0, .03);
728  glVertex2d(0, 0);
729  glEnd();
730  break;
731  case SVS_PASSENGER:
732  case SVS_PASSENGER_SEDAN:
733  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
734  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
735  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
736  break;
738  drawPoly(vehiclePoly_PassengerHatchbackRightGlass, 4.5);
739  drawPoly(vehiclePoly_PassengerHatchbackLeftGlass, 4.5);
740  drawPoly(vehiclePoly_PassengerHatchbackBackGlass, 4.5);
741  break;
742  case SVS_PASSENGER_WAGON:
743  drawPoly(vehiclePoly_PassengerWagonRightGlass, 4.5);
744  drawPoly(vehiclePoly_PassengerWagonLeftGlass, 4.5);
745  drawPoly(vehiclePoly_PassengerWagonBackGlass, 4.5);
746  break;
747  case SVS_PASSENGER_VAN:
748  case SVS_DELIVERY:
749  break;
750  case SVS_TRUCK:
751  GLHelper::setColor(current);
752  GLHelper::drawBoxLine(Position(2.3, 0), 90., length - 2.3, .5);
753  break;
755  GLHelper::setColor(current);
756  GLHelper::drawBoxLine(Position(2.8, 0), 90., length - 2.8, .5);
757  break;
758  case SVS_TRUCK_1TRAILER: {
759  GLHelper::setColor(current);
760  SUMOReal l = length - 2.3;
761  l = l / 2.;
762  GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
763  GLHelper::drawBoxLine(Position(2.3 + l + .5, 0), 90., l - .5, .5);
764  break;
765  }
766  case SVS_BUS_TROLLEY:
767  glPushMatrix();
768  glTranslated(0, 0, .1);
769  GLHelper::setColor(darker);
770  GLHelper::drawBoxLine(Position(3.8, 0), 90., 1, .3);
771  glTranslated(0, 0, .1);
772  glColor3d(0, 0, 0);
773  GLHelper::drawBoxLine(Position(4.3, .2), 90., 1, .06);
774  GLHelper::drawBoxLine(Position(4.3, -.2), 90., 1, .06);
775  GLHelper::drawBoxLine(Position(5.3, .2), 90., 3, .03);
776  GLHelper::drawBoxLine(Position(5.3, -.2), 90., 3, .03);
777  glPopMatrix();
778  break;
779  case SVS_BUS:
780  case SVS_BUS_COACH:
781  case SVS_BUS_FLEXIBLE:
782  case SVS_RAIL:
783  case SVS_RAIL_CAR:
784  case SVS_RAIL_CARGO:
785  case SVS_E_VEHICLE:
786  case SVS_ANT:
787  case SVS_SHIP:
788  break;
789  default: // same as passenger/sedan
790  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
791  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
792  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
793  break;
794  }
795  /*
796  glBegin(GL_TRIANGLE_FAN);
797  glVertex2d(.5,.5); // center - strip begin
798  glVertex2d(0, .5); // center, front
799  glVertex2d(0, .8); // ... clockwise ... (vehicle right side)
800  glVertex2d(0.08, .94);
801  glVertex2d(0.25, 1.);
802  glVertex2d(0.95, 1.);
803  glVertex2d(1., .9);
804  glVertex2d(1., .1); // (vehicle left side)
805  glVertex2d(0.95, 0.);
806  glVertex2d(0.25, 0.);
807  glVertex2d(0.08, .06);
808  glVertex2d(0, .2); //
809  glVertex2d(0, .5); // center, front (close)
810  glEnd();
811 
812  glPolygonOffset(0, -4.5);
813  glColor3d(1, 1, 1); // front
814  glBegin(GL_TRIANGLE_FAN);
815  glVertex2d(0.1,0.5);
816  glVertex2d(0.025,0.5);
817  glVertex2d(0.025,0.75);
818  glVertex2d(0.27,0.9);
819  glVertex2d(0.27,0.1);
820  glVertex2d(0.025,0.25);
821  glVertex2d(0.025,0.5);
822  glEnd();
823 
824  glColor3d(0, 0, 0); // front glass
825  glBegin(GL_TRIANGLE_FAN);
826  glVertex2d(0.35,0.5);
827  glVertex2d(0.3,0.5);
828  glVertex2d(0.3,0.9);
829  glVertex2d(0.43,0.8);
830  glVertex2d(0.43,0.2);
831  glVertex2d(0.3,0.1);
832  glVertex2d(0.3,0.5);
833  glEnd();
834 
835  glBegin(GL_TRIANGLE_FAN); // back glass
836  glVertex2d(0.92,0.5);
837  glVertex2d(0.90,0.5);
838  glVertex2d(0.90,0.8);
839  glVertex2d(0.95,0.9);
840  glVertex2d(0.95,0.1);
841  glVertex2d(0.90,0.2);
842  glVertex2d(0.90,0.5);
843  glEnd();
844 
845  glBegin(GL_TRIANGLE_FAN); // right glass
846  glVertex2d(0.36,0.07);
847  glVertex2d(0.34,0.03);
848  glVertex2d(0.94,0.03);
849  glVertex2d(0.87,0.13);
850  glVertex2d(0.45,0.13);
851  glVertex2d(0.34,0.03);
852  glEnd();
853 
854  glBegin(GL_TRIANGLE_FAN); // left glass
855  glVertex2d(0.36,1.-0.07);
856  glVertex2d(0.34,1.-0.03);
857  glVertex2d(0.94,1.-0.03);
858  glVertex2d(0.87,1.-0.13);
859  glVertex2d(0.45,1.-0.13);
860  glVertex2d(0.34,1.-0.03);
861  glEnd();
862  */
863 
864  glPopMatrix();
865 }
866 
867 
868 bool
870  const std::string& file = getVehicleType().getImgFile();
871  if (file != "") {
872  int textureID = GUITexturesHelper::getTextureID(file);
873  if (textureID > 0) {
874  const SUMOReal exaggeration = s.vehicleSize.getExaggeration(s);
875  if (length < 0) {
876  length = getVehicleType().getLength() * exaggeration;
877  }
878  const SUMOReal halfWidth = getVehicleType().getWidth() / 2.0 * exaggeration;
879  GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, 0, halfWidth, length);
880  return true;
881  }
882  }
883  return false;
884 }
885 
886 
887 bool
889  switch (guiShape) {
890  case SVS_BUS_FLEXIBLE:
891  drawAction_drawRailCarriages(s, 8.25, 0, 0, asImage); // 16.5 overall, 2 modules http://de.wikipedia.org/wiki/Ikarus_180
892  break;
893  case SVS_RAIL:
894  drawAction_drawRailCarriages(s, 24.5, 1, 1, asImage); // http://de.wikipedia.org/wiki/UIC-Y-Wagen_%28DR%29
895  break;
896  case SVS_RAIL_CAR:
897  drawAction_drawRailCarriages(s, 16.85, 1, 0, asImage); // 67.4m overall, 4 carriages http://de.wikipedia.org/wiki/DB-Baureihe_423
898 // drawAction_drawRailCarriages(s, 5.71, 0, 0, asImage); // 40.0m overall, 7 modules http://de.wikipedia.org/wiki/Bombardier_Flexity_Berlin
899 // drawAction_drawRailCarriages(s, 9.44, 1, 1, asImage); // actually length of the locomotive http://de.wikipedia.org/wiki/KJI_Nr._20_und_21
900 // drawAction_drawRailCarriages(s, 24.775, 0, 0, asImage); // http://de.wikipedia.org/wiki/ICE_3
901  break;
902  case SVS_RAIL_CARGO:
903  drawAction_drawRailCarriages(s, 13.86, 1, 0, asImage); // UIC 571-1 http://de.wikipedia.org/wiki/Flachwagen
904  break;
905  default:
906  return false;
907  }
908  return true;
909 }
910 
911 #define BLINKER_POS_FRONT .5
912 #define BLINKER_POS_BACK .5
913 
914 inline void
915 drawAction_drawBlinker(double dir, SUMOReal length) {
916  glColor3d(1.f, .8f, 0);
917  glPushMatrix();
918  glTranslated(dir, BLINKER_POS_FRONT, -0.1);
920  glPopMatrix();
921  glPushMatrix();
922  glTranslated(dir, length - BLINKER_POS_BACK, -0.1);
924  glPopMatrix();
925 }
926 
927 
928 inline void
931  return;
932  }
933  const double offset = MAX2(.5 * veh.getVehicleType().getWidth(), .4);
935  drawAction_drawBlinker(-offset, length);
936  }
938  drawAction_drawBlinker(offset, length);;
939  }
941  drawAction_drawBlinker(-offset, length);
942  drawAction_drawBlinker(offset, length);
943  }
944 }
945 
946 
947 inline void
950  return;
951  }
952  glColor3f(1.f, .2f, 0);
953  glPushMatrix();
954  glTranslated(-veh.getVehicleType().getWidth() * 0.5, length, -0.1);
956  glPopMatrix();
957  glPushMatrix();
958  glTranslated(veh.getVehicleType().getWidth() * 0.5, length, -0.1);
960  glPopMatrix();
961 }
962 
963 
964 void
966  glPushName(getGlID());
967  glPushMatrix();
968  Position p1 = getPosition();
969  // one seat in the center of the vehicle by default
971  glTranslated(p1.x(), p1.y(), getType());
972  glRotated(getAngle(), 0, 0, 1);
973  // set lane color
974  setColor(s);
975  // scale
976  const SUMOReal upscale = s.vehicleSize.getExaggeration(s);
977  glScaled(upscale, upscale, 1);
978  /*
979  MSLCM_DK2004 &m2 = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
980  if((m2.getState()&LCA_URGENT)!=0) {
981  glColor3d(1, .4, .4);
982  } else if((m2.getState()&LCA_SPEEDGAIN)!=0) {
983  glColor3d(.4, .4, 1);
984  } else {
985  glColor3d(.4, 1, .4);
986  }
987  */
988  // draw the vehicle
990  switch (s.vehicleQuality) {
991  case 0:
993  break;
994  case 1:
996  break;
997  case 2:
999  break;
1000  case 3:
1001  default:
1002  // draw as image but take special care for drawing trains
1003  // fallback to simple shapes
1004  if (!drawAction_drawCarriageClass(s, getVehicleType().getGuiShape(), true)) {
1007  };
1008  }
1009  break;
1010  }
1011  if (s.drawMinGap) {
1012  const SUMOReal minGap = -getVehicleType().getMinGap();
1013  glColor3d(0., 1., 0.);
1014  glBegin(GL_LINES);
1015  glVertex2d(0., 0);
1016  glVertex2d(0., minGap);
1017  glVertex2d(-.5, minGap);
1018  glVertex2d(.5, minGap);
1019  glEnd();
1020  }
1022  if (dev != 0 && s.showBTRange) {
1023  glColor3d(1., 0., 0.);
1024  GLHelper::drawOutlineCircle(dev->getRange(), dev->getRange() - .2, 32);
1025  }
1026  // draw the blinker and brakelights if wished
1027  if (s.showBlinker) {
1028  glTranslated(0, 0, .1);
1029  switch (getVehicleType().getGuiShape()) {
1030  case SVS_PEDESTRIAN:
1031  case SVS_BICYCLE:
1032  case SVS_ANT:
1033  case SVS_SHIP:
1034  case SVS_RAIL:
1035  case SVS_RAIL_CARGO:
1036  // only SVS_RAIL_CAR has blinkers and brake lights
1037  break;
1038  default:
1041  break;
1042  }
1043  }
1044  // draw the wish to change the lane
1045  if (s.drawLaneChangePreference) {
1046  /*
1047  if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
1048  MSLCM_DK2004 &m = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
1049  glColor3d(.5, .5, 1);
1050  glBegin(GL_LINES);
1051  glVertex2f(0, 0);
1052  glVertex2f(m.getChangeProbability(), .5);
1053  glEnd();
1054 
1055  glColor3d(1, 0, 0);
1056  glBegin(GL_LINES);
1057  glVertex2f(0.1, 0);
1058  glVertex2f(0.1, m.myMaxJam1);
1059  glEnd();
1060 
1061  glColor3d(0, 1, 0);
1062  glBegin(GL_LINES);
1063  glVertex2f(-0.1, 0);
1064  glVertex2f(-0.1, m.myTDist);
1065  glEnd();
1066  }
1067  */
1068  }
1069  // draw best lanes
1070  /*
1071  if (true) {
1072  const MSLane &l = veh->getLane();
1073  SUMOReal r1 = veh->allowedContinuationsLength(&l, 0);
1074  SUMOReal r2 = l.getLeftLane()!=0 ? veh->allowedContinuationsLength(l.getLeftLane(), 0) : 0;
1075  SUMOReal r3 = l.getRightLane()!=0 ? veh->allowedContinuationsLength(l.getRightLane(), 0) : 0;
1076  SUMOReal mmax = MAX3(r1, r2, r3);
1077  glBegin(GL_LINES);
1078  glVertex2f(0, 0);
1079  glVertex2f(0, r1/mmax/2.);
1080  glEnd();
1081  glBegin(GL_LINES);
1082  glVertex2f(.4, 0);
1083  glVertex2f(.4, r2/mmax/2.);
1084  glEnd();
1085  glBegin(GL_LINES);
1086  glVertex2f(-.4, 0);
1087  glVertex2f(-.4, r3/mmax/2.);
1088  glEnd();
1089  }
1090  */
1091  glPopMatrix();
1092  const Position namePos = getPosition(-MIN2(getVehicleType().getLength() / 2, SUMOReal(5)));
1093  drawName(namePos, s.scale,
1094  getVehicleType().getGuiShape() == SVS_PEDESTRIAN ? s.personName : s.vehicleName);
1095  if (s.vehicleName.show && myParameter->line != "") {
1096  GLHelper::drawText("line:" + myParameter->line, namePos + Position(0, -0.6 * s.vehicleName.size / s.scale),
1098  }
1099  glPopName();
1100  if (myPersonDevice != 0) {
1101  const std::vector<MSTransportable*>& ps = myPersonDevice->getPersons();
1102  size_t personIndex = 0;
1103  for (std::vector<MSTransportable*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
1104  GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
1105  assert(person != 0);
1106  person->setPositionInVehicle(getSeatPosition(personIndex++));
1107  person->drawGL(s);
1108  }
1109  }
1110  if (myContainerDevice != 0) {
1111  const std::vector<MSTransportable*>& cs = myContainerDevice->getContainers();
1112  size_t containerIndex = 0;
1113  for (std::vector<MSTransportable*>::const_iterator i = cs.begin(); i != cs.end(); ++i) {
1114  GUIContainer* container = dynamic_cast<GUIContainer*>(*i);
1115  assert(container != 0);
1116  container->setPositionInVehicle(getSeatPosition(containerIndex++));
1117  container->drawGL(s);
1118  }
1119  }
1120 }
1121 
1122 
1123 void
1125  glPushName(getGlID());
1126  glPushMatrix();
1127  glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
1129  drawBestLanes();
1130  }
1132  drawRoute(s, 0, 0.25);
1133  }
1135  if (getNumberReroutes() > 0) {
1136  const int noReroutePlus1 = getNumberReroutes() + 1;
1137  for (int i = noReroutePlus1 - 1; i >= 0; i--) {
1138  SUMOReal darken = SUMOReal(0.4) / SUMOReal(noReroutePlus1) * SUMOReal(i);
1139  drawRoute(s, i, darken);
1140  }
1141  } else {
1142  drawRoute(s, 0, 0.25);
1143  }
1144  }
1146  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
1147  if ((*i).myLink == 0) {
1148  continue;
1149  }
1150  MSLink* link = (*i).myLink;
1151  MSLane* via = link->getViaLaneOrLane();
1152  if (via != 0) {
1153  Position p = via->getShape()[0];
1154  if ((*i).mySetRequest) {
1155  glColor3d(0, .8, 0);
1156  } else {
1157  glColor3d(.8, 0, 0);
1158  }
1159  const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
1160  (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(), getVehicleType().getLengthWithGap());
1161  drawLinkItem(p, (*i).myArrivalTime, leaveTime, s.vehicleSize.getExaggeration(s));
1162  // the time slot that ego vehicle uses when checking opened may
1163  // differ from the one it requests in setApproaching
1164  MSLink::ApproachingVehicleInformation avi = (*i).myLink->getApproaching(this);
1165  assert(avi.arrivalTime == (*i).myArrivalTime && avi.leavingTime == leaveTime);
1166  UNUSED_PARAMETER(avi); // only used for assertion
1167  }
1168  }
1169  }
1170  glPopMatrix();
1171  glPopName();
1172 }
1173 
1174 
1175 void
1176 GUIVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate) {
1177  glTranslated(pos.x(), pos.y(), -.1);
1179  std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
1180  GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
1181  glTranslated(-pos.x(), -pos.y(), .1);
1182 }
1183 
1184 
1185 void
1187  const GUIColorer& c = s.vehicleColorer;
1188  if (!setFunctionalColor(c.getActive(), this)) {
1190  }
1191 }
1192 
1193 
1194 bool
1195 GUIVehicle::setFunctionalColor(size_t activeScheme, const MSBaseVehicle* veh) {
1196  switch (activeScheme) {
1197  case 0: {
1198  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1200  return true;
1201  }
1204  return true;
1205  }
1206  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1208  return true;
1209  }
1210  return false;
1211  }
1212  case 2: {
1213  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1215  return true;
1216  }
1217  return false;
1218  }
1219  case 3: {
1222  return true;
1223  }
1224  return false;
1225  }
1226  case 4: {
1227  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1229  return true;
1230  }
1231  return false;
1232  }
1233  case 5: {
1234  Position p = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1235  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1236  Position center = b.getCenter();
1237  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1238  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1239  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1240  return true;
1241  }
1242  case 6: {
1243  Position p = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1244  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1245  Position center = b.getCenter();
1246  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1247  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1248  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1249  return true;
1250  }
1251  case 7: {
1252  Position pb = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1253  Position pe = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1254  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1255  SUMOReal hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / PI;
1256  Position minp(b.xmin(), b.ymin());
1257  Position maxp(b.xmax(), b.ymax());
1258  SUMOReal sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1259  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1260  return true;
1261  }
1262  case 24: { // color randomly (by pointer)
1263  const SUMOReal hue = (long)veh % 360; // [0-360]
1264  const SUMOReal sat = (((long)veh / 360) % 67) / 100.0 + 0.33; // [0.33-1]
1265  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1266  return true;
1267  }
1268  }
1269  return false;
1270 }
1271 
1272 
1273 SUMOReal
1274 GUIVehicle::getColorValue(size_t activeScheme) const {
1275  switch (activeScheme) {
1276  case 8:
1277  return getSpeed();
1278  case 9:
1279  return getWaitingSeconds();
1280  case 10:
1281  return getLastLaneChangeOffset();
1282  case 11:
1283  return getLane()->getVehicleMaxSpeed(this);
1284  case 12:
1285  return getCO2Emissions();
1286  case 13:
1287  return getCOEmissions();
1288  case 14:
1289  return getPMxEmissions();
1290  case 15:
1291  return getNOxEmissions();
1292  case 16:
1293  return getHCEmissions();
1294  case 17:
1295  return getFuelConsumption();
1296  case 18:
1298  case 19: // !!! unused!?
1299  if (getNumberReroutes() == 0) {
1300  return -1;
1301  }
1302  return getNumberReroutes();
1303  case 20:
1305  case 21:
1306  return getBestLaneOffset();
1307  case 22:
1308  return getAcceleration();
1309  case 23:
1310  return getTimeGap();
1311  }
1312  return 0;
1313 }
1314 
1315 
1316 // ------------ Additional visualisations
1317 bool
1319  return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
1320 }
1321 
1322 
1323 void
1325  if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
1326  myAdditionalVisualizations[parent] = 0;
1327  }
1328  myAdditionalVisualizations[parent] |= which;
1329  parent->addAdditionalGLVisualisation(this);
1330 }
1331 
1332 
1333 void
1335  myAdditionalVisualizations[parent] &= ~which;
1336  parent->removeAdditionalGLVisualisation(this);
1337 }
1338 
1339 
1340 void
1341 GUIVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const {
1342  setColor(s);
1343  GLdouble colors[4];
1344  glGetDoublev(GL_CURRENT_COLOR, colors);
1345  colors[0] -= darken;
1346  if (colors[0] < 0) {
1347  colors[0] = 0;
1348  }
1349  colors[1] -= darken;
1350  if (colors[1] < 0) {
1351  colors[1] = 0;
1352  }
1353  colors[2] -= darken;
1354  if (colors[2] < 0) {
1355  colors[2] = 0;
1356  }
1357  colors[3] -= darken;
1358  if (colors[3] < 0) {
1359  colors[3] = 0;
1360  }
1361  glColor3dv(colors);
1362  const SUMOReal exaggeration = s.vehicleSize.getExaggeration(s);
1363  if (routeNo == 0) {
1364  drawRouteHelper(*myRoute, exaggeration);
1365  return;
1366  }
1367  --routeNo; // only prior routes are stored
1368  drawRouteHelper(*myRoutes->getRoute(routeNo), exaggeration);
1369 }
1370 
1371 
1372 void
1374  myLock.lock();
1375  std::vector<std::vector<MSVehicle::LaneQ> > bestLanes = myBestLanes;
1376  myLock.unlock();
1377  SUMOReal width = 0.5;
1378  for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
1379  std::vector<MSVehicle::LaneQ>& lanes = *j;
1380  SUMOReal gmax = -1;
1381  SUMOReal rmax = -1;
1382  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1383  gmax = MAX2((*i).length, gmax);
1384  rmax = MAX2((*i).occupation, rmax);
1385  }
1386  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1387  const PositionVector& shape = (*i).lane->getShape();
1388  SUMOReal g = (*i).length / gmax;
1389  SUMOReal r = (*i).occupation / rmax;
1390  glColor3d(r, g, 0);
1391  GLHelper::drawBoxLines(shape, width);
1392 
1393  PositionVector s1 = shape;
1394  s1.move2side((SUMOReal) .1);
1395  glColor3d(r, 0, 0);
1396  GLHelper::drawLine(s1);
1397  s1.move2side((SUMOReal) - .2);
1398  glColor3d(0, g, 0);
1399  GLHelper::drawLine(s1);
1400 
1401  glColor3d(r, g, 0);
1402  Position lastPos = shape[-1];
1403  }
1404  width = .2;
1405  }
1406 }
1407 
1408 
1409 void
1410 GUIVehicle::drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const {
1411  MSRouteIterator i = r.begin();
1412  const std::vector<MSLane*>& bestLaneConts = getBestLanesContinuation();
1413  // draw continuation lanes when drawing the current route where available
1414  size_t bestLaneIndex = (&r == myRoute ? 0 : bestLaneConts.size());
1415  for (; i != r.end(); ++i) {
1416  const GUILane* lane;
1417  if (bestLaneIndex < bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) {
1418  lane = static_cast<GUILane*>(bestLaneConts[bestLaneIndex]);
1419  ++bestLaneIndex;
1420  } else {
1421  lane = static_cast<GUILane*>((*i)->getLanes()[0]);
1422  }
1423  GLHelper::drawBoxLines(lane->getShape(), lane->getShapeRotations(), lane->getShapeLengths(), exaggeration);
1424  }
1425 }
1426 
1427 
1428 MSLane*
1429 GUIVehicle::getPreviousLane(MSLane* current, int& furtherIndex) const {
1430  if (furtherIndex < (int)myFurtherLanes.size()) {
1431  return myFurtherLanes[furtherIndex++];
1432  } else {
1433  return current;
1434  }
1435 }
1436 
1437 
1438 void
1439 GUIVehicle::drawAction_drawRailCarriages(const GUIVisualizationSettings& s, SUMOReal defaultLength, SUMOReal carriageGap, int firstPassengerCarriage, bool asImage) const {
1440  RGBColor current = GLHelper::getColor();
1441  RGBColor darker = current.changedBrightness(-51);
1442  const SUMOReal exaggeration = s.vehicleSize.getExaggeration(s);
1443  defaultLength *= exaggeration;
1444  if (exaggeration == 0) {
1445  return;
1446  }
1447  carriageGap *= exaggeration;
1448  const SUMOReal length = getVehicleType().getLength() * exaggeration;
1449  const SUMOReal halfWidth = getVehicleType().getWidth() / 2.0 * exaggeration;
1450  glPopMatrix(); // undo scaling and 90 degree rotation
1451  glPopMatrix(); // undo initial translation and rotation
1452  GLHelper::setColor(darker);
1453  const SUMOReal xCornerCut = 0.3 * exaggeration;
1454  const SUMOReal yCornerCut = 0.4 * exaggeration;
1455  // round to closest integer
1456  const int numCarriages = floor(length / (defaultLength + carriageGap) + 0.5);
1457  assert(numCarriages > 0);
1458  const SUMOReal carriageLengthWithGap = length / numCarriages;
1459  const SUMOReal carriageLength = carriageLengthWithGap - carriageGap;
1460  // lane on which the carriage front is situated
1461  MSLane* lane = myLane;
1462  int furtherIndex = 0;
1463  // lane on which the carriage back is situated
1464  MSLane* backLane = myLane;
1465  int backFurtherIndex = furtherIndex;
1466  // offsets of front and back
1467  SUMOReal carriageOffset = myState.pos();
1468  SUMOReal carriageBackOffset = myState.pos() - carriageLength;
1469  // handle seats
1470  int requiredSeats = getNumPassengers();
1471  if (requiredSeats > 0) {
1472  mySeatPositions.clear();
1473  }
1474  Position front, back;
1475  SUMOReal angle = 0.;
1476  // draw individual carriages
1477  for (int i = 0; i < numCarriages; ++i) {
1478  while (carriageOffset < 0) {
1479  MSLane* prev = getPreviousLane(lane, furtherIndex);
1480  if (prev != lane) {
1481  carriageOffset += prev->getLength();
1482  } else {
1483  // no lane available for drawing.
1484  carriageOffset = 0;
1485  }
1486  lane = prev;
1487  }
1488  while (carriageBackOffset < 0) {
1489  MSLane* prev = getPreviousLane(backLane, backFurtherIndex);
1490  if (prev != backLane) {
1491  carriageBackOffset += prev->getLength();
1492  } else {
1493  // no lane available for drawing.
1494  carriageBackOffset = 0;
1495  }
1496  backLane = prev;
1497  }
1498  front = lane->getShape().positionAtOffset2D(carriageOffset);
1499  back = backLane->getShape().positionAtOffset2D(carriageBackOffset);
1500  if (front == back) {
1501  // no place for drawing available
1502  continue;
1503  }
1504  angle = atan2((front.x() - back.x()), (back.y() - front.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
1505  if (i >= firstPassengerCarriage) {
1506  computeSeats(front, back, requiredSeats);
1507  }
1508  glPushMatrix();
1509  glTranslated(front.x(), front.y(), getType());
1510  glRotated(angle, 0, 0, 1);
1511  if (!asImage || !drawAction_drawVehicleAsImage(s, carriageLength)) {
1512  glBegin(GL_TRIANGLE_FAN);
1513  glVertex2d(-halfWidth + xCornerCut, 0);
1514  glVertex2d(-halfWidth, yCornerCut);
1515  glVertex2d(-halfWidth, carriageLength - yCornerCut);
1516  glVertex2d(-halfWidth + xCornerCut, carriageLength);
1517  glVertex2d(halfWidth - xCornerCut, carriageLength);
1518  glVertex2d(halfWidth, carriageLength - yCornerCut);
1519  glVertex2d(halfWidth, yCornerCut);
1520  glVertex2d(halfWidth - xCornerCut, 0);
1521  glEnd();
1522  }
1523  glPopMatrix();
1524  carriageOffset -= carriageLengthWithGap;
1525  carriageBackOffset -= carriageLengthWithGap;
1526  GLHelper::setColor(current);
1527  }
1528  myCarriageLength = front.distanceTo2D(back);
1529  // restore matrices
1530  glPushMatrix();
1531  glTranslated(front.x(), front.y(), getType());
1532  glRotated(angle, 0, 0, 1);
1533  glPushMatrix();
1534 }
1535 
1536 
1537 const Position&
1538 GUIVehicle::getSeatPosition(size_t personIndex) const {
1540  return mySeatPositions[(int)MIN2(personIndex, mySeatPositions.size() - 1)];
1541 }
1542 
1543 
1544 int
1546  if (myPersonDevice != 0) {
1547  return (int)myPersonDevice->getPersons().size();
1548  }
1549  return 0;
1550 }
1551 
1552 
1553 void
1554 GUIVehicle::computeSeats(const Position& front, const Position& back, int& requiredSeats) const {
1555  if (requiredSeats <= 0) {
1556  return; // save some work
1557  }
1558  const Line l(front, back);
1559  const SUMOReal length = l.length2D();
1560  if (length < 4) {
1561  // small vehicle, sit at the center
1563  requiredSeats--;
1564  } else {
1565  for (SUMOReal p = 2; p <= length - 1; p += 1) {
1567  requiredSeats--;
1568  }
1569  }
1570 }
1571 
1572 
1573 SUMOReal
1576 }
1577 
1578 
1579 std::string
1581  std::string result = "";
1582  if (isParking()) {
1583  result += "parking";
1584  } else if (isStopped()) {
1585  result += "stopped";
1586  } else {
1587  return "";
1588  }
1589  if (myStops.front().triggered) {
1590  result += ", triggered";
1591  } else if (myStops.front().containerTriggered) {
1592  result += ", containerTriggered";
1593  } else {
1594  result += ", duration=" + time2string(myStops.front().duration);
1595  }
1596  return result;
1597 }
1598 
1599 
1600 void
1603  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
1604  const DriveProcessItem& dpi = *i;
1605  if (dpi.myLink == 0) {
1606  continue;
1607  }
1608  std::vector<const SUMOVehicle*> blockingFoes;
1609  std::vector<const MSPerson*> blockingPersons;
1611  getImpatience(), getCarFollowModel().getMaxDecel(), getWaitingTime(), &blockingFoes);
1612  for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
1613  gSelected.select(static_cast<const GUIVehicle*>(*it)->getGlID());
1614  }
1615 #ifdef HAVE_INTERNAL_LANES
1616  const MSLink::LinkLeaders linkLeaders = (dpi.myLink)->getLeaderInfo(dist, getVehicleType().getMinGap(), &blockingPersons);
1617  for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1618  // the vehicle to enter the junction first has priority
1619  const GUIVehicle* leader = dynamic_cast<const GUIVehicle*>(it->vehAndGap.first);
1620  if (leader != 0) {
1621  if (leader->myLinkLeaders[dpi.myLink->getJunction()].count(getID()) == 0) {
1622  // leader isn't already following us, now we follow it
1623  gSelected.select(leader->getGlID());
1624  }
1625  } else {
1626  for (std::vector<const MSPerson*>::iterator it_p = blockingPersons.begin(); it_p != blockingPersons.end(); ++it_p) {
1627  const GUIPerson* foe = dynamic_cast<const GUIPerson*>(*it_p);
1628  if (foe != 0) {
1629  gSelected.select(foe->getGlID());
1630  //std::cout << SIMTIME << " veh=" << getID() << " is blocked on link " << dpi.myLink->getRespondIndex() << " to " << dpi.myLink->getViaLaneOrLane()->getID() << " by pedestrian. dist=" << it->second << "\n";
1631  }
1632  }
1633  }
1634  }
1635 #endif
1636  dist += dpi.myLink->getViaLaneOrLane()->getLength();
1637  }
1638 }
1639 
1640 /****************************************************************************/
1641 
SUMOReal length2D() const
Definition: Line.cpp:186
bool signalSet(int which) const
Returns whether the given signal is on.
Definition: MSVehicle.h:844
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&#39;s type.
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
SUMOReal getColorValue(size_t activeScheme) const
gets the color value according to the current scheme index
const std::vector< SUMOReal > & getShapeRotations() const
Definition: GUILane.cpp:711
render as a rail
RGBColor color
The vehicle&#39;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:888
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle&#39;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&#39;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&#39;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:1183
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:106
void drawAction_drawVehicleBlinker(const GUIVehicle &veh, SUMOReal length)
Definition: GUIVehicle.cpp:929
const MSCFModel & getCarFollowModel() const
Returns the vehicle&#39;s car following model definition.
Definition: MSVehicle.h:544
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
Definition: MSVehicle.h:1200
State myState
This Vehicles driving state (pos and speed)
Definition: MSVehicle.h:1173
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:1273
SUMOReal pos() const
Position of this state.
Definition: MSVehicle.cpp:134
SUMOReal getLengthWithGap() const
Get vehicle&#39;s length including the minimum gap [m].
SUMOReal getImpatience() const
Returns this vehicles impatience.
render as a motorcycle
void drawBestLanes() const
Draws the vehicle&#39;s best lanes.
bool showBTRange
Information whether the communication range shall be drawn.
SUMOReal getLeaveSpeed() const
Definition: MSVehicle.h:1265
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&#39;s length.
Definition: MSLane.h:376
Position getPosition(const SUMOReal offset=0) const
Return current position (x/y, cartesian)
Definition: MSVehicle.cpp:597
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
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&#39;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:2284
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:162
T MAX2(T a, T b)
Definition: StdDefs.h:74
show all vehicle&#39;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:408
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
unsigned int getPersonNumber() const
Returns the number of persons.
Definition: MSVehicle.cpp:2356
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
const MSRoute * myRoute
This Vehicle&#39;s route.
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
render as a sedan passenger vehicle (&quot;Stufenheck&quot;)
SUMOReal getCO2Emissions() const
Returns CO2 emission of the current state.
Definition: MSVehicle.cpp:2272
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:717
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:229
SUMOReal getPositionOnLane() const
Get the vehicle&#39;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&#39;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
Show vehicle&#39;s current route.
Definition: GUIAppEnum.h:241
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, SUMOReal length=-1) const
Definition: GUIVehicle.cpp:869
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&#39;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
FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[]
The car-following model and parameter.
Definition: MSVehicleType.h:74
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:1876
SUMOReal scale
information about a lane&#39;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:766
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
const std::vector< MSTransportable * > & getPersons() const
Returns the list of persons using this vehicle.
select foes of a vehicle
Definition: GUIAppEnum.h:257
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:466
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:768
static const RGBColor GREY
Definition: RGBColor.h:198
void drawAction_drawVehicleAsTrianglePlus() const
Definition: GUIVehicle.cpp:432
unsigned int getContainerNumber() const
Returns the number of containers.
Definition: MSVehicle.cpp:2362
#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 (&quot;Fliessheck&quot;)
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&#39;s current lane and their successors...
Definition: MSVehicle.cpp:2160
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
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&#39;s list of stops.
Definition: MSVehicle.h:1188
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&#39;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:805
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:1176
Blinker lights on both sides are switched on.
Definition: MSVehicle.h:770
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:450
The brake lights are on.
Definition: MSVehicle.h:772
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
Show all vehicle&#39;s routes.
Definition: GUIAppEnum.h:249
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&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:184
#define BLINKER_POS_BACK
Definition: GUIVehicle.cpp:912
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
Stop to track a vehicle.
Definition: GUIAppEnum.h:255
const std::vector< MSTransportable * > & getContainers() const
Returns the list of containers using this vehicle.
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
unsigned int getPersonCapacity() const
Get this vehicle type&#39;s person capacity.
const int VEHPARS_COLOR_SET
bool isParking() const
Returns whether the vehicle is parking.
Definition: MSVehicle.cpp:811
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:2308
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate)
std::string line
The vehicle&#39;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&#39;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:2290
Show vehicle&#39;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:2296
SUMOReal getCOEmissions() const
Returns CO emission of the current state.
Definition: MSVehicle.cpp:2278
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:948
void unlock()
release mutex lock
Definition: MFXMutex.cpp:96
Hide all vehicle&#39;s routes.
Definition: GUIAppEnum.h:251
Hide vehicle&#39;s best lanes.
Definition: GUIAppEnum.h:247
SUMOReal getWidth() const
Get the width which vehicles of this class shall have when being drawn.
Hide vehicle&#39;s current route.
Definition: GUIAppEnum.h:243
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
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:965
Structure representing possible vehicle parameter.
double vehiclePoly_PassengerVanLeftGlass[]
Definition: GUIVehicle.cpp:118
void drawAction_drawVehicleAsBoxPlus() const
Definition: GUIVehicle.cpp:417
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
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&#39;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:2302
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;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...
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:915
SUMOReal getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:294
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
void lock()
lock mutex
Definition: MFXMutex.cpp:86
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&#39;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&#39;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:911
unsigned int getContainerCapacity() const
Get this vehicle type&#39;s container capacity.
const RGBColor & getColor() const
Returns the color.
Definition: MSRoute.cpp:328
#define SUMOReal
Definition: config.h:215
std::string getImgFile() const
Get this vehicle type&#39;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&#39;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
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: MSLane.h:354
SUMOEmissionClass getEmissionClass() const
Get this vehicle type&#39;s emission class.
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:331
render as a transport vehicle with one trailer
render as a wagon passenger vehicle (&quot;Combi&quot;)
SUMOReal getTimeGap() const
Returns the time gap in seconds to the leader of the vehicle looking for a fixed distance.
Definition: MSVehicle.cpp:2262
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:1194
std::vector< MSDevice * > myDevices
The devices this vehicle has.
A window containing a gl-object&#39;s parameter.
const int VTYPEPARS_COLOR_SET
render as a semi-trailer transport vehicle (&quot;Sattelschlepper&quot;)
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:1191
double vehiclePoly_PassengerSedanLeftGlass[]
Definition: GUIVehicle.cpp:105
Start to track a vehicle.
Definition: GUIAppEnum.h:253
int getBestLaneOffset() const
returns the current offset from the best lane
Definition: MSVehicle.cpp:2188
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:75
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
render as a trolley bus
SUMOReal getAngle() const
Returns the vehicle&#39;s direction in degrees.
Definition: MSVehicle.cpp:640
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:705
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