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