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