SUMO - Simulation of Urban MObility
GUIBaseVehicle.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-2016 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>
38 #include <utils/geom/GeomHelper.h>
46 #include <utils/gui/div/GLHelper.h>
49 #include <microsim/MSVehicle.h>
50 #include <microsim/MSLane.h>
58 #include <gui/GUIGlobals.h>
59 #include "GUIBaseVehicle.h"
60 #include "GUIPerson.h"
61 #include "GUIContainer.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(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[] = {
86 };
87 
88 // Object implementation
89 FXIMPLEMENT(GUIBaseVehicle::GUIBaseVehiclePopupMenu, GUIGLObjectPopupMenu, GUIBaseVehiclePopupMenuMap, ARRAYNUMBER(GUIBaseVehiclePopupMenuMap))
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 double vehiclePoly_Ship[] = { 0.25, 0, 0, 0, 0.1, 0.25, 0.2, 0.45, 0.25, 0.5, 0.95, 0.5, 1.0, 0.45, 1.0, -0.45, 0.95, -0.5, 0.25, -0.5, 0.2, -0.45, 0.1, -0.25, 0, 0, -10000 };
133 double vehiclePoly_ShipDeck[] = { 0.5, 0, 0.25, 0.4, 0.95, 0.4, 0.95, -0.4, 0.25, -0.4, 0.25, 0.4, -10000 };
134 double vehiclePoly_ShipSuperStructure[] = { 0.8, 0, 0.5, 0.3, 0.85, 0.3, 0.85, -0.3, 0.5, -0.3, 0.5, 0.3, -10000 };
135 
136 double vehiclePoly_Cyclist[] = { 0.5, 0, 0.25, 0.45, 0.25, 0.5, 0.8, 0.15, 0.8, -0.15, 0.25, -0.5, 0.25, -0.45, -10000 };
137 
138 double vehiclePoly_EmergencySign[] = { .2, .5, -.2, .5, -.2, -.5, .2, -.5, -10000 };
139 double vehiclePoly_Emergency[] = { .1, .1, -.1, .1, -.1, -.1, .1, -.1, -10000 };
140 double vehiclePoly_Emergency2[] = { .04, .3, -.04, .3, -.04, -.3, .04, -.3, -10000 };
141 
142 // ===========================================================================
143 // method definitions
144 // ===========================================================================
145 /* -------------------------------------------------------------------------
146  * GUIBaseVehicle::GUIBaseVehiclePopupMenu - methods
147  * ----------------------------------------------------------------------- */
149  GUIMainWindow& app, GUISUMOAbstractView& parent,
150  GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations)
151  : GUIGLObjectPopupMenu(app, parent, o), myVehiclesAdditionalVisualizations(additionalVisualizations) {
152 }
153 
154 
156 
157 
158 long
160  assert(myObject->getType() == GLO_VEHICLE);
161  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES)) {
163  }
164  return 1;
165 }
166 
167 long
169  assert(myObject->getType() == GLO_VEHICLE);
171  return 1;
172 }
173 
174 
175 long
177  assert(myObject->getType() == GLO_VEHICLE);
178  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ROUTE)) {
180  }
181  return 1;
182 }
183 
184 long
186  assert(myObject->getType() == GLO_VEHICLE);
188  return 1;
189 }
190 
191 
192 long
194  assert(myObject->getType() == GLO_VEHICLE);
195  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES)) {
197  }
198  return 1;
199 }
200 
201 long
203  assert(myObject->getType() == GLO_VEHICLE);
205  return 1;
206 }
207 
208 
209 long
211  assert(myObject->getType() == GLO_VEHICLE);
212  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_TRACKED)) {
213  myParent->startTrack(static_cast<GUIBaseVehicle*>(myObject)->getGlID());
215  }
216  return 1;
217 }
218 
219 long
221  assert(myObject->getType() == GLO_VEHICLE);
223  myParent->stopTrack();
224  return 1;
225 }
226 
227 
228 long
230  assert(myObject->getType() == GLO_VEHICLE);
231  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS)) {
233  }
234  return 1;
235 }
236 
237 long
239  assert(myObject->getType() == GLO_VEHICLE);
241  return 1;
242 }
243 
244 long
246  assert(myObject->getType() == GLO_VEHICLE);
247  static_cast<GUIBaseVehicle*>(myObject)->selectBlockingFoes();
248  myParent->update();
249  return 1;
250 }
251 
252 
253 /* -------------------------------------------------------------------------
254  * GUIBaseVehicle - methods
255  * ----------------------------------------------------------------------- */
256 
258  GUIGlObject(GLO_VEHICLE, vehicle.getID()),
259  myVehicle(vehicle),
260  myVType(vehicle.getVehicleType()) {
261  // as it is possible to show all vehicle routes, we have to store them... (bug [ 2519761 ])
263  myVehicle.myMoveReminders.push_back(std::make_pair(myRoutes, 0.));
264  mySeatPositions.push_back(Position(0, 0)); // ensure length 1
265 }
266 
267 
269  myLock.lock();
270  for (std::map<GUISUMOAbstractView*, int>::iterator i = myAdditionalVisualizations.begin(); i != myAdditionalVisualizations.end(); ++i) {
271  while (i->first->removeAdditionalGLVisualisation(this));
272  }
273  myLock.unlock();
275  delete myRoutes;
276 }
277 
278 
281  GUISUMOAbstractView& parent) {
283  buildPopupHeader(ret, app);
287  //
289  new FXMenuCommand(ret, "Hide Current Route", 0, ret, MID_HIDE_CURRENTROUTE);
290  } else {
291  new FXMenuCommand(ret, "Show Current Route", 0, ret, MID_SHOW_CURRENTROUTE);
292  }
294  new FXMenuCommand(ret, "Hide All Routes", 0, ret, MID_HIDE_ALLROUTES);
295  } else {
296  new FXMenuCommand(ret, "Show All Routes", 0, ret, MID_SHOW_ALLROUTES);
297  }
299  new FXMenuCommand(ret, "Hide Best Lanes", 0, ret, MID_HIDE_BEST_LANES);
300  } else {
301  new FXMenuCommand(ret, "Show Best Lanes", 0, ret, MID_SHOW_BEST_LANES);
302  }
304  new FXMenuCommand(ret, "Hide Link Items", 0, ret, MID_HIDE_LFLINKITEMS);
305  } else {
306  new FXMenuCommand(ret, "Show Link Items", 0, ret, MID_SHOW_LFLINKITEMS);
307  }
308  new FXMenuSeparator(ret);
309  int trackedID = parent.getTrackedID();
310  if (trackedID < 0 || (size_t)trackedID != getGlID()) {
311  new FXMenuCommand(ret, "Start Tracking", 0, ret, MID_START_TRACK);
312  } else {
313  new FXMenuCommand(ret, "Stop Tracking", 0, ret, MID_STOP_TRACK);
314  }
315  new FXMenuCommand(ret, "Select Foes", 0, ret, MID_SHOW_FOES);
316 
317  new FXMenuSeparator(ret);
318  //
319  buildShowParamsPopupEntry(ret, false);
321  buildPositionCopyEntry(ret, false);
322  return ret;
323 }
324 
325 
326 Boundary
328  Boundary b;
329  b.add(getPosition());
331  return b;
332 }
333 
334 
335 void
337  glPushMatrix();
338  glScaled(myVType.getWidth(), myVType.getLength(), 1.);
339  glBegin(GL_TRIANGLE_STRIP);
340  glVertex2d(0., 0.);
341  glVertex2d(-.5, .15);
342  glVertex2d(.5, .15);
343  glVertex2d(-.5, 1.);
344  glVertex2d(.5, 1.);
345  glEnd();
346  glPopMatrix();
347 }
348 
349 
350 void
352  const SUMOReal length = myVType.getLength();
353  if (length >= 8.) {
355  return;
356  }
357  glPushMatrix();
358  glScaled(myVType.getWidth(), length, 1.);
359  glBegin(GL_TRIANGLES);
360  glVertex2d(0., 0.);
361  glVertex2d(-.5, 1.);
362  glVertex2d(.5, 1.);
363  glEnd();
364  glPopMatrix();
365 }
366 
367 
368 void
369 GUIBaseVehicle::drawPoly(double* poses, SUMOReal offset) {
370  glPushMatrix();
371  glTranslated(0, 0, offset * .1);
372  glPolygonOffset(0, offset * -1);
373  glBegin(GL_TRIANGLE_FAN);
374  int i = 0;
375  while (poses[i] > -999) {
376  glVertex2d(poses[i], poses[i + 1]);
377  i = i + 2;
378  }
379  glEnd();
380  glPopMatrix();
381 }
382 
383 
384 void
386  RGBColor current = GLHelper::getColor();
387  RGBColor lighter = current.changedBrightness(51);
388  RGBColor darker = current.changedBrightness(-51);
389 
390  const SUMOReal length = myVType.getLength();
391  const SUMOReal width = myVType.getWidth();
392  glPushMatrix();
393  glRotated(90, 0, 0, 1);
394  glScaled(length, width, 1.);
396 
397  // draw main body
398  switch (shape) {
399  case SVS_UNKNOWN:
401  GLHelper::setColor(lighter);
402  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
403  glColor3d(0, 0, 0);
404  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
405  break;
406  case SVS_PEDESTRIAN:
407  glTranslated(0, 0, .045);
409  glTranslated(0, 0, -.045);
410  glScaled(.7, 2, 1);
411  glTranslated(0, 0, .04);
412  GLHelper::setColor(lighter);
414  glTranslated(0, 0, -.04);
415  break;
416  case SVS_BICYCLE:
417  case SVS_MOPED:
418  case SVS_MOTORCYCLE: {
419  RGBColor darker = current.changedBrightness(-50);
420  // body
421  drawPoly(vehiclePoly_Cyclist, 4);
422  // head
423  glPushMatrix();
424  glTranslated(0.4, 0, .5);
425  glScaled(0.1, 0.2, 1);
426  GLHelper::setColor(darker);
428  glPopMatrix();
429  // bike frame
431  glPushMatrix();
432  glTranslated(0.5, 0, .3);
433  glScaled(0.5, 0.05, 1);
435  glPopMatrix();
436  // handle bar
437  glPushMatrix();
438  glTranslated(0.25, 0, .3);
439  glScaled(0.02, 0.5, 1);
441  glPopMatrix();
442  }
443  break;
444  case SVS_PASSENGER:
445  case SVS_PASSENGER_SEDAN:
447  case SVS_PASSENGER_WAGON:
449  GLHelper::setColor(lighter);
450  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
451  glColor3d(0, 0, 0);
452  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
453  break;
454  case SVS_PASSENGER_VAN:
455  drawPoly(vehiclePoly_PassengerVanBody, 4);
456  GLHelper::setColor(lighter);
457  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
458  glColor3d(0, 0, 0);
459  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
460  drawPoly(vehiclePoly_PassengerVanRightGlass, 4.5);
461  drawPoly(vehiclePoly_PassengerVanLeftGlass, 4.5);
462  drawPoly(vehiclePoly_PassengerVanBackGlass, 4.5);
463  break;
464  case SVS_DELIVERY:
465  drawPoly(vehiclePoly_PassengerVanBody, 4);
466  GLHelper::setColor(lighter);
467  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
468  glColor3d(0, 0, 0);
469  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
470  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
471  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
472  break;
473  case SVS_TRUCK:
475  case SVS_TRUCK_1TRAILER:
476  glScaled(1. / (length), 1, 1.);
477  drawPoly(vehiclePoly_TransportBody, 4);
478  glColor3d(0, 0, 0);
479  drawPoly(vehiclePoly_TransportFrontGlass, 4.5);
480  drawPoly(vehiclePoly_TransportRightGlass, 4.5);
481  drawPoly(vehiclePoly_TransportLeftGlass, 4.5);
482  break;
483  case SVS_BUS:
484  case SVS_BUS_COACH:
485  case SVS_BUS_TROLLEY: {
486  SUMOReal ml = length;
487  glScaled(1. / (length), 1, 1.);
488  glTranslated(0, 0, .04);
489  glBegin(GL_TRIANGLE_FAN);
490  glVertex2d(ml / 2., 0);
491  glVertex2d(0, 0);
492  glVertex2d(0, -.45);
493  glVertex2d(0 + .05, -.5);
494  glVertex2d(ml - .05, -.5);
495  glVertex2d(ml, -.45);
496  glVertex2d(ml, .45);
497  glVertex2d(ml - .05, .5);
498  glVertex2d(0 + .05, .5);
499  glVertex2d(0, .45);
500  glVertex2d(0, 0);
501  glEnd();
502  glTranslated(0, 0, -.04);
503 
504  glTranslated(0, 0, .045);
505  glColor3d(0, 0, 0);
506  glBegin(GL_QUADS);
507  glVertex2d(0 + .05, .48);
508  glVertex2d(0 + .05, -.48);
509  glVertex2d(0 + .15, -.48);
510  glVertex2d(0 + .15, .48);
511 
512  glVertex2d(ml - .1, .45);
513  glVertex2d(ml - .1, -.45);
514  glVertex2d(ml - .05, -.45);
515  glVertex2d(ml - .05, .45);
516 
517  glVertex2d(0 + .20, .49);
518  glVertex2d(0 + .20, .45);
519  glVertex2d(ml - .20, .45);
520  glVertex2d(ml - .20, .49);
521 
522  glVertex2d(0 + .20, -.49);
523  glVertex2d(0 + .20, -.45);
524  glVertex2d(ml - .20, -.45);
525  glVertex2d(ml - .20, -.49);
526 
527  glEnd();
528  glTranslated(0, 0, -.045);
529  }
530  break;
531  case SVS_BUS_FLEXIBLE:
532  case SVS_RAIL:
533  case SVS_RAIL_CAR:
534  case SVS_RAIL_CARGO:
535  drawAction_drawCarriageClass(s, shape, false);
536  break;
537  case SVS_E_VEHICLE:
538  drawPoly(vehiclePoly_EVehicleBody, 4);
539  glColor3d(0, 0, 0);
540  drawPoly(vehiclePoly_EVehicleFrontGlass, 4.5);
541  glTranslated(0, 0, .048);
542  GLHelper::setColor(current);
543  glBegin(GL_QUADS);
544  glVertex2d(.3, .5);
545  glVertex2d(.35, .5);
546  glVertex2d(.35, -.5);
547  glVertex2d(.3, -.5);
548 
549  glVertex2d(.3, -.05);
550  glVertex2d(.7, -.05);
551  glVertex2d(.7, .05);
552  glVertex2d(.3, .05);
553 
554  glVertex2d(.7, .5);
555  glVertex2d(.65, .5);
556  glVertex2d(.65, -.5);
557  glVertex2d(.7, -.5);
558  glEnd();
559  glTranslated(0, 0, -.048);
560  //drawPoly(vehiclePoly_EVehicleBackGlass, 4.5);
561  break;
562  case SVS_ANT:
563  glPushMatrix();
564  // ant is stretched via vehicle length
565  GLHelper::setColor(darker);
566  // draw left side
567  GLHelper::drawBoxLine(Position(-0.2, -.10), 350, 0.5, .02);
568  GLHelper::drawBoxLine(Position(-0.3, -.50), 240, 0.4, .03);
569  GLHelper::drawBoxLine(Position(0.3, -.10), 340, 0.8, .03);
570  GLHelper::drawBoxLine(Position(0.05, -.80), 290, 0.6, .04);
571  GLHelper::drawBoxLine(Position(0.4, -.10), 20, 0.8, .03);
572  GLHelper::drawBoxLine(Position(0.65, -.80), 75, 0.6, .04);
573  GLHelper::drawBoxLine(Position(0.5, -.10), 55, 0.8, .04);
574  GLHelper::drawBoxLine(Position(1.1, -.55), 90, 0.6, .04);
575  // draw right side
576  GLHelper::drawBoxLine(Position(-0.2, .10), 190, 0.5, .02);
577  GLHelper::drawBoxLine(Position(-0.3, .50), 300, 0.4, .03);
578  GLHelper::drawBoxLine(Position(0.3, .10), 200, 0.8, .03);
579  GLHelper::drawBoxLine(Position(0.05, .80), 250, 0.6, .04);
580  GLHelper::drawBoxLine(Position(0.4, .10), 160, 0.8, .03);
581  GLHelper::drawBoxLine(Position(0.65, .80), 105, 0.6, .04);
582  GLHelper::drawBoxLine(Position(0.5, .10), 125, 0.8, .04);
583  GLHelper::drawBoxLine(Position(1.1, .55), 90, 0.6, .04);
584  // draw body
585  GLHelper::setColor(current);
586  glTranslated(0, 0, 0.1);
588  glTranslated(.4, 0, 0);
590  glTranslated(.4, 0, 0);
592  glPopMatrix();
593  break;
594  case SVS_SHIP: {
595  RGBColor darker = current.changedBrightness(-30);
596  RGBColor darker2 = current.changedBrightness(-70);
597  drawPoly(vehiclePoly_Ship, 4);
598  GLHelper::setColor(darker);
599  drawPoly(vehiclePoly_ShipDeck, 5);
600  GLHelper::setColor(darker2);
601  drawPoly(vehiclePoly_ShipSuperStructure, 6);
602  break;
603  }
604  case SVS_EMERGENCY: // similar to delivery
605  glColor3d(1, 1, 1);
606  drawPoly(vehiclePoly_PassengerVanBody, 4);
607  glColor3d(1, 0, 0);
608  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
609  glColor3d(0, 0, 0);
610  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
611  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
612  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
613  // first aid sign
614  glTranslated(0.7, 0, 0);
615  glColor3d(.18, .55, .34);
616  drawPoly(vehiclePoly_EmergencySign, 4.5);
617  glColor3d(1, 1, 1);
618  drawPoly(vehiclePoly_Emergency, 5);
619  drawPoly(vehiclePoly_Emergency2, 5);
620  break;
621  default: // same as passenger
623  glColor3d(1, 1, 1);
624  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
625  glColor3d(0, 0, 0);
626  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
627  break;
628  }
629 
630  // draw decorations
631  switch (shape) {
632  case SVS_PEDESTRIAN:
633  break;
634  case SVS_BICYCLE:
635  //glScaled(length, 1, 1.);
636  glBegin(GL_TRIANGLE_FAN);
637  glVertex2d(1 / 2., 0);
638  glVertex2d(0, 0);
639  glVertex2d(0, -.03);
640  glVertex2d(0 + .05, -.05);
641  glVertex2d(1 - .05, -.05);
642  glVertex2d(1, -.03);
643  glVertex2d(1, .03);
644  glVertex2d(1 - .05, .05);
645  glVertex2d(0 + .05, .05);
646  glVertex2d(0, .03);
647  glVertex2d(0, 0);
648  glEnd();
649  break;
650  case SVS_MOPED:
651  case SVS_MOTORCYCLE:
652  //glScaled(length, 1, 1.);
653  glBegin(GL_TRIANGLE_FAN);
654  glVertex2d(1 / 2., 0);
655  glVertex2d(0, 0);
656  glVertex2d(0, -.03);
657  glVertex2d(0 + .05, -.2);
658  glVertex2d(1 - .05, -.2);
659  glVertex2d(1, -.03);
660  glVertex2d(1, .03);
661  glVertex2d(1 - .05, .2);
662  glVertex2d(0 + .05, .2);
663  glVertex2d(0, .03);
664  glVertex2d(0, 0);
665  glEnd();
666  break;
667  case SVS_PASSENGER:
668  case SVS_PASSENGER_SEDAN:
669  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
670  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
671  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
672  break;
674  drawPoly(vehiclePoly_PassengerHatchbackRightGlass, 4.5);
675  drawPoly(vehiclePoly_PassengerHatchbackLeftGlass, 4.5);
676  drawPoly(vehiclePoly_PassengerHatchbackBackGlass, 4.5);
677  break;
678  case SVS_PASSENGER_WAGON:
679  drawPoly(vehiclePoly_PassengerWagonRightGlass, 4.5);
680  drawPoly(vehiclePoly_PassengerWagonLeftGlass, 4.5);
681  drawPoly(vehiclePoly_PassengerWagonBackGlass, 4.5);
682  break;
683  case SVS_PASSENGER_VAN:
684  case SVS_DELIVERY:
685  break;
686  case SVS_TRUCK:
687  GLHelper::setColor(current);
688  GLHelper::drawBoxLine(Position(2.3, 0), 90., length - 2.3, .5);
689  break;
691  GLHelper::setColor(current);
692  GLHelper::drawBoxLine(Position(2.8, 0), 90., length - 2.8, .5);
693  break;
694  case SVS_TRUCK_1TRAILER: {
695  GLHelper::setColor(current);
696  SUMOReal l = length - 2.3;
697  l = l / 2.;
698  GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
699  GLHelper::drawBoxLine(Position(2.3 + l + .5, 0), 90., l - .5, .5);
700  break;
701  }
702  case SVS_BUS_TROLLEY:
703  glPushMatrix();
704  glTranslated(0, 0, .1);
705  GLHelper::setColor(darker);
706  GLHelper::drawBoxLine(Position(3.8, 0), 90., 1, .3);
707  glTranslated(0, 0, .1);
708  glColor3d(0, 0, 0);
709  GLHelper::drawBoxLine(Position(4.3, .2), 90., 1, .06);
710  GLHelper::drawBoxLine(Position(4.3, -.2), 90., 1, .06);
711  GLHelper::drawBoxLine(Position(5.3, .2), 90., 3, .03);
712  GLHelper::drawBoxLine(Position(5.3, -.2), 90., 3, .03);
713  glPopMatrix();
714  break;
715  case SVS_BUS:
716  case SVS_BUS_COACH:
717  case SVS_BUS_FLEXIBLE:
718  case SVS_RAIL:
719  case SVS_RAIL_CAR:
720  case SVS_RAIL_CARGO:
721  case SVS_E_VEHICLE:
722  case SVS_ANT:
723  case SVS_SHIP:
724  case SVS_EMERGENCY:
725  break;
726  default: // same as passenger/sedan
727  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
728  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
729  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
730  break;
731  }
732  /*
733  glBegin(GL_TRIANGLE_FAN);
734  glVertex2d(.5,.5); // center - strip begin
735  glVertex2d(0, .5); // center, front
736  glVertex2d(0, .8); // ... clockwise ... (vehicle right side)
737  glVertex2d(0.08, .94);
738  glVertex2d(0.25, 1.);
739  glVertex2d(0.95, 1.);
740  glVertex2d(1., .9);
741  glVertex2d(1., .1); // (vehicle left side)
742  glVertex2d(0.95, 0.);
743  glVertex2d(0.25, 0.);
744  glVertex2d(0.08, .06);
745  glVertex2d(0, .2); //
746  glVertex2d(0, .5); // center, front (close)
747  glEnd();
748 
749  glPolygonOffset(0, -4.5);
750  glColor3d(1, 1, 1); // front
751  glBegin(GL_TRIANGLE_FAN);
752  glVertex2d(0.1,0.5);
753  glVertex2d(0.025,0.5);
754  glVertex2d(0.025,0.75);
755  glVertex2d(0.27,0.9);
756  glVertex2d(0.27,0.1);
757  glVertex2d(0.025,0.25);
758  glVertex2d(0.025,0.5);
759  glEnd();
760 
761  glColor3d(0, 0, 0); // front glass
762  glBegin(GL_TRIANGLE_FAN);
763  glVertex2d(0.35,0.5);
764  glVertex2d(0.3,0.5);
765  glVertex2d(0.3,0.9);
766  glVertex2d(0.43,0.8);
767  glVertex2d(0.43,0.2);
768  glVertex2d(0.3,0.1);
769  glVertex2d(0.3,0.5);
770  glEnd();
771 
772  glBegin(GL_TRIANGLE_FAN); // back glass
773  glVertex2d(0.92,0.5);
774  glVertex2d(0.90,0.5);
775  glVertex2d(0.90,0.8);
776  glVertex2d(0.95,0.9);
777  glVertex2d(0.95,0.1);
778  glVertex2d(0.90,0.2);
779  glVertex2d(0.90,0.5);
780  glEnd();
781 
782  glBegin(GL_TRIANGLE_FAN); // right glass
783  glVertex2d(0.36,0.07);
784  glVertex2d(0.34,0.03);
785  glVertex2d(0.94,0.03);
786  glVertex2d(0.87,0.13);
787  glVertex2d(0.45,0.13);
788  glVertex2d(0.34,0.03);
789  glEnd();
790 
791  glBegin(GL_TRIANGLE_FAN); // left glass
792  glVertex2d(0.36,1.-0.07);
793  glVertex2d(0.34,1.-0.03);
794  glVertex2d(0.94,1.-0.03);
795  glVertex2d(0.87,1.-0.13);
796  glVertex2d(0.45,1.-0.13);
797  glVertex2d(0.34,1.-0.03);
798  glEnd();
799  */
800 
801  glPopMatrix();
802 }
803 
804 
805 bool
807  const std::string& file = myVType.getImgFile();
808  if (file != "") {
809  int textureID = GUITexturesHelper::getTextureID(file);
810  if (textureID > 0) {
811  const SUMOReal exaggeration = s.vehicleSize.getExaggeration(s);
812  if (length < 0) {
813  length = myVType.getLength() * exaggeration;
814  }
815  const SUMOReal halfWidth = myVType.getWidth() / 2.0 * exaggeration;
816  GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, 0, halfWidth, length);
817  return true;
818  }
819  }
820  return false;
821 }
822 
823 
824 void
825 GUIBaseVehicle::drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const SUMOReal angle) const {
826  glPushName(getGlID());
827  glPushMatrix();
828  Position p1 = pos;
829  const SUMOReal degAngle = RAD2DEG(angle + PI / 2.);
830  // one seat in the center of the vehicle by default
831  if (myVehicle.getLane() != 0) {
833  } else {
834  mySeatPositions[0] = p1;
835  }
836  glTranslated(p1.x(), p1.y(), getType());
837  glRotated(degAngle, 0, 0, 1);
838  // set lane color
839  setColor(s);
840  // scale
841  const SUMOReal upscale = s.vehicleSize.getExaggeration(s);
842  glScaled(upscale, upscale, 1);
843  /*
844  MSLCM_DK2004 &m2 = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
845  if((m2.getState()&LCA_URGENT)!=0) {
846  glColor3d(1, .4, .4);
847  } else if((m2.getState()&LCA_SPEEDGAIN)!=0) {
848  glColor3d(.4, .4, 1);
849  } else {
850  glColor3d(.4, 1, .4);
851  }
852  */
853  // draw the vehicle
855  switch (s.vehicleQuality) {
856  case 0:
858  break;
859  case 1:
861  break;
862  case 2:
864  // draw flashing blue light for emergency vehicles
865  if (myVType.getGuiShape() == SVS_EMERGENCY) {
866  glTranslated(0, 0, .1);
868  }
869  break;
870  case 3:
871  default:
872  // draw as image but take special care for drawing trains
873  // fallback to simple shapes
877  };
878  }
879  break;
880  }
881  if (s.drawMinGap) {
882  const SUMOReal minGap = -myVType.getMinGap();
883  glColor3d(0., 1., 0.);
884  glBegin(GL_LINES);
885  glVertex2d(0., 0);
886  glVertex2d(0., minGap);
887  glVertex2d(-.5, minGap);
888  glVertex2d(.5, minGap);
889  glEnd();
890  }
892  if (dev != 0 && s.showBTRange) {
893  glColor3d(1., 0., 0.);
894  GLHelper::drawOutlineCircle(dev->getRange(), dev->getRange() - .2, 32);
895  }
896  // draw the blinker and brakelights if wished
897  if (s.showBlinker) {
898  glTranslated(0, 0, .1);
899  switch (myVType.getGuiShape()) {
900  case SVS_PEDESTRIAN:
901  case SVS_BICYCLE:
902  case SVS_ANT:
903  case SVS_SHIP:
904  case SVS_RAIL:
905  case SVS_RAIL_CARGO:
906  // only SVS_RAIL_CAR has blinkers and brake lights
907  break;
908  case SVS_MOTORCYCLE:
909  case SVS_MOPED:
912  break;
913  default:
916  break;
917  }
918  }
919  // draw the wish to change the lane
920  if (s.drawLaneChangePreference) {
921  /*
922  if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
923  MSLCM_DK2004 &m = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
924  glColor3d(.5, .5, 1);
925  glBegin(GL_LINES);
926  glVertex2f(0, 0);
927  glVertex2f(m.getChangeProbability(), .5);
928  glEnd();
929 
930  glColor3d(1, 0, 0);
931  glBegin(GL_LINES);
932  glVertex2f(0.1, 0);
933  glVertex2f(0.1, m.myMaxJam1);
934  glEnd();
935 
936  glColor3d(0, 1, 0);
937  glBegin(GL_LINES);
938  glVertex2f(-0.1, 0);
939  glVertex2f(-0.1, m.myTDist);
940  glEnd();
941  }
942  */
943  }
944  // draw best lanes
945  /*
946  if (true) {
947  const MSLane &l = veh->getLane();
948  SUMOReal r1 = veh->allowedContinuationsLength(&l, 0);
949  SUMOReal r2 = l.getLeftLane()!=0 ? veh->allowedContinuationsLength(l.getLeftLane(), 0) : 0;
950  SUMOReal r3 = l.getRightLane()!=0 ? veh->allowedContinuationsLength(l.getRightLane(), 0) : 0;
951  SUMOReal mmax = MAX3(r1, r2, r3);
952  glBegin(GL_LINES);
953  glVertex2f(0, 0);
954  glVertex2f(0, r1/mmax/2.);
955  glEnd();
956  glBegin(GL_LINES);
957  glVertex2f(.4, 0);
958  glVertex2f(.4, r2/mmax/2.);
959  glEnd();
960  glBegin(GL_LINES);
961  glVertex2f(-.4, 0);
962  glVertex2f(-.4, r3/mmax/2.);
963  glEnd();
964  }
965  */
966  glTranslated(0, MIN2(myVType.getLength() / 2, SUMOReal(5)), -getType()); // drawing name at GLO_MAX fails unless translating z
967  glRotated(-degAngle, 0, 0, 1);
968  glScaled(1 / upscale, 1 / upscale, 1);
969  drawName(Position(0, 0), s.scale,
971  if (s.vehicleName.show && myVehicle.getParameter().line != "") {
972  glTranslated(0, 0.6 * s.vehicleName.size / s.scale, 0);
975  }
976  glPopMatrix();
977  glPopName();
979 }
980 
981 
982 void
984  drawOnPos(s, getPosition(), getAngle());
985 }
986 
987 
988 void
990  if (!myVehicle.isOnRoad()) {
991  drawGL(s);
992  }
993  glPushName(getGlID());
994  glPushMatrix();
995  glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
997  drawBestLanes();
998  }
1000  drawRoute(s, 0, 0.25);
1001  }
1003  if (myVehicle.getNumberReroutes() > 0) {
1004  const int noReroutePlus1 = myVehicle.getNumberReroutes() + 1;
1005  for (int i = noReroutePlus1 - 1; i >= 0; i--) {
1006  SUMOReal darken = SUMOReal(0.4) / SUMOReal(noReroutePlus1) * SUMOReal(i);
1007  drawRoute(s, i, darken);
1008  }
1009  } else {
1010  drawRoute(s, 0, 0.25);
1011  }
1012  }
1015  }
1016  glPopMatrix();
1017  glPopName();
1018 }
1019 
1020 
1021 void
1022 GUIBaseVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate) {
1023  glTranslated(pos.x(), pos.y(), -.1);
1025  std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
1026  GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
1027  glTranslated(-pos.x(), -pos.y(), .1);
1028 }
1029 
1030 
1031 void
1033  const GUIColorer& c = s.vehicleColorer;
1034  if (!setFunctionalColor(c.getActive(), &myVehicle)) {
1036  }
1037 }
1038 
1039 
1040 bool
1041 GUIBaseVehicle::setFunctionalColor(size_t activeScheme, const MSBaseVehicle* veh) {
1042  switch (activeScheme) {
1043  case 0: {
1044  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1046  return true;
1047  }
1050  return true;
1051  }
1052  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1054  return true;
1055  }
1056  return false;
1057  }
1058  case 2: {
1059  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1061  return true;
1062  }
1063  return false;
1064  }
1065  case 3: {
1068  return true;
1069  }
1070  return false;
1071  }
1072  case 4: {
1073  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1075  return true;
1076  }
1077  return false;
1078  }
1079  case 5: {
1080  Position p = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1081  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1082  Position center = b.getCenter();
1083  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1084  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1085  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1086  return true;
1087  }
1088  case 6: {
1089  Position p = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1090  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1091  Position center = b.getCenter();
1092  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1093  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1094  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1095  return true;
1096  }
1097  case 7: {
1098  Position pb = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1099  Position pe = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1100  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1101  SUMOReal hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / PI;
1102  Position minp(b.xmin(), b.ymin());
1103  Position maxp(b.xmax(), b.ymax());
1104  SUMOReal sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1105  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1106  return true;
1107  }
1108  case 27: { // color randomly (by pointer)
1109  const SUMOReal hue = (long)veh % 360; // [0-360]
1110  const SUMOReal sat = (((long)veh / 360) % 67) / 100.0 + 0.33; // [0.33-1]
1111  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1112  return true;
1113  }
1114  }
1115  return false;
1116 }
1117 
1118 
1119 // ------------ Additional visualisations
1120 bool
1122  return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
1123 }
1124 
1125 
1126 void
1128  if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
1129  myAdditionalVisualizations[parent] = 0;
1130  }
1131  myAdditionalVisualizations[parent] |= which;
1132  parent->addAdditionalGLVisualisation(this);
1133 }
1134 
1135 
1136 void
1138  myAdditionalVisualizations[parent] &= ~which;
1139  parent->removeAdditionalGLVisualisation(this);
1140 }
1141 
1142 
1143 void
1144 GUIBaseVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const {
1145  setColor(s);
1146  GLdouble colors[4];
1147  glGetDoublev(GL_CURRENT_COLOR, colors);
1148  colors[0] -= darken;
1149  if (colors[0] < 0) {
1150  colors[0] = 0;
1151  }
1152  colors[1] -= darken;
1153  if (colors[1] < 0) {
1154  colors[1] = 0;
1155  }
1156  colors[2] -= darken;
1157  if (colors[2] < 0) {
1158  colors[2] = 0;
1159  }
1160  colors[3] -= darken;
1161  if (colors[3] < 0) {
1162  colors[3] = 0;
1163  }
1164  glColor3dv(colors);
1165  const SUMOReal exaggeration = s.vehicleSize.getExaggeration(s);
1166  if (routeNo == 0) {
1167  drawRouteHelper(myVehicle.getRoute(), exaggeration);
1168  return;
1169  }
1170  --routeNo; // only prior routes are stored
1171  const MSRoute* route = myRoutes->getRoute(routeNo);
1172  if (route != 0) {
1173  drawRouteHelper(*route, exaggeration);
1174  }
1175 }
1176 
1177 
1178 const Position&
1179 GUIBaseVehicle::getSeatPosition(size_t personIndex) const {
1181  return mySeatPositions[(int)MIN2(personIndex, mySeatPositions.size() - 1)];
1182 }
1183 
1184 
1185 /****************************************************************************/
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
SUMOReal getExaggeration(const GUIVisualizationSettings &s, SUMOReal factor=20) const
return the drawing size including exaggeration and constantSize values
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
void drawAction_drawVehicleAsBoxPlus() const
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:91
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
long onCmdStopTrack(FXObject *, FXSelector, void *)
Called if the current shall not be tracked any longer.
long onCmdHideCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
double vehiclePoly_PassengerVanBody[]
render as a rail
double vehiclePoly_Emergency2[]
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.
long long int SUMOTime
Definition: SUMOTime.h:43
unsigned int getNumberReroutes() const
Returns the number of new routes this vehicle got.
double vehiclePoly_PassengerVanRightGlass[]
MoveReminderCont myMoveReminders
Current lane&#39;s move reminder.
static RGBColor fromHSV(SUMOReal h, SUMOReal s, SUMOReal v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:294
bool showBlinker
Information whether vehicle blinkers shall be drawn.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:106
virtual void drawAction_drawLinkItems(const GUIVisualizationSettings &) const
double vehiclePoly_PassengerWagonLeftGlass[]
a vehicles
GUIVisualizationTextSettings personName
virtual void selectBlockingFoes() const =0
adds the blocking foes to the current selection
double vehiclePoly_EVehicleFrontGlass[]
virtual bool drawAction_drawCarriageClass(const GUIVisualizationSettings &s, SUMOVehicleShape guiShape, bool asImage) const =0
draws the given guiShape if it has distinc carriages/modules and eturns true if so ...
double vehiclePoly_PassengerSedanRightGlass[]
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
render as a motorcycle
double vehiclePoly_PassengerVanFrontGlass[]
long onCmdStartTrack(FXObject *, FXSelector, void *)
Called if the vehicle shall be tracked.
double vehiclePoly_TransportLeftGlass[]
bool showBTRange
Information whether the communication range shall be drawn.
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
Stores the information about how to visualize structures.
render as a transport vehicle
render as a flexible city bus
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
static void drawOutlineCircle(SUMOReal width, SUMOReal iwidth, int steps=8)
Draws an unfilled circle around (0,0)
Definition: GLHelper.cpp:375
bool drawLaneChangePreference
Information whether the lane change preference shall be drawn.
show vehicle&#39;s best lanes
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:112
MSDevice_Vehroutes * myRoutes
GUIVisualizationTextSettings vehicleName
SUMOReal getLength() const
Get vehicle&#39;s length [m].
double vehiclePoly_EVehicleBody[]
double vehiclePoly_PassengerFrontGlass[]
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:159
const MSRoute & getRoute() const
Returns the current route.
Definition: MSBaseVehicle.h:89
render as a delivery vehicle
static void drawBoxLine(const Position &beg, SUMOReal rot, SUMOReal visLength, SUMOReal width, SUMOReal offset=0)
Draws a thick line.
Definition: GLHelper.cpp:130
double vehiclePoly_Emergency[]
double vehiclePoly_PassengerHatchbackLeftGlass[]
double vehiclePoly_PassengerVanBackGlass[]
GUISUMOAbstractView * myParent
The parent window.
render as a sedan passenger vehicle ("Stufenheck")
bool addAdditionalGLVisualisation(const GUIGlObject *const which)
Adds an object to call its additional visualisation method.
#define RAD2DEG(x)
Definition: GeomHelper.h:46
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:221
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:460
double vehiclePoly_PassengerSedanBackGlass[]
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:56
Show vehicle&#39;s current route.
Definition: GUIAppEnum.h:259
double vehiclePoly_PassengerVanLeftGlass[]
void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
virtual void stopTrack()
stop track
const Position geometryPositionAtOffset(SUMOReal offset, SUMOReal lateralOffset=0) const
Definition: MSLane.h:439
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
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.
void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the type parameter window.
GUIGlID getGlID() const
Returns the numerical id of the object.
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:118
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
bool removeAdditionalGLVisualisation(const GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
long onCmdHideAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
GUIColorer vehicleColorer
The vehicle colorer.
double vehiclePoly_ShipDeck[]
select foes of a vehicle
Definition: GUIAppEnum.h:275
static void drawFilledCircle(SUMOReal width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:344
static void drawPoly(double *poses, SUMOReal offset)
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
double vehiclePoly_PassengerCarBody[]
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, SUMOReal length=-1) const
virtual void startTrack(int)
star track
static const RGBColor GREEN
Definition: RGBColor.h:190
static const RGBColor GREY
Definition: RGBColor.h:198
#define PI
Definition: polyfonts.c:61
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle&#39;s best lanes shall be shown.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
static void drawTexturedBox(unsigned int which, SUMOReal size)
Draws a named texture as a box with the given size.
long onCmdShowAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:443
render as a hatchback passenger vehicle ("Fliessheck")
virtual void drawBestLanes() const
Draws the vehicle&#39;s best lanes.
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
double vehiclePoly_PassengerWagonRightGlass[]
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
double vehiclePoly_ShipSuperStructure[]
bool drawMinGap
Information whether the minimum gap shall be drawn.
virtual void drawAction_drawVehicleBrakeLight(SUMOReal length, bool onlyOne=false) const
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:200
not defined
render as a bicycle
long onCmdHideBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle&#39;s best lanes shall be hidden.
double vehiclePoly_Ship[]
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:128
const T getColor(const SUMOReal value) const
render as a (city) rail without locomotive
T MIN2(T a, T b)
Definition: StdDefs.h:69
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:150
A MSVehicle extended by some values for usage within the gui.
Show all vehicle&#39;s routes.
Definition: GUIAppEnum.h:267
render as a van
double vehiclePoly_PassengerHatchbackRightGlass[]
SUMOReal myCarriageLength
Variable to set with the length of the last drawn carriage or the vehicle length. ...
Stop to track a vehicle.
Definition: GUIAppEnum.h:273
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
render as a passenger vehicle
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
draw name of item
double vehiclePoly_TransportBody[]
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
const int VEHPARS_COLOR_SET
virtual Position getPosition(const SUMOReal offset=0) const =0
Return current position (x/y, cartesian)
void drawRoute(const GUIVisualizationSettings &s, int routeNo, SUMOReal darken) const
Chooses the route to draw and draws it, darkening it as given.
std::string line
The vehicle&#39;s line (mainly for public transport)
SUMOVehicleShape getGuiShape() const
Get this vehicle type&#39;s shape.
virtual SUMOReal getColorValue(size_t activeScheme) const =0
gets the color value according to the current scheme index
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
Show vehicle&#39;s best lanes.
Definition: GUIAppEnum.h:263
static void removeObject(GUIGlObject &o)
Removes all instances that pass values from the object with the given id.
double vehiclePoly_PassengerSedanLeftGlass[]
render as a cargo train
void drawOnPos(const GUIVisualizationSettings &s, const Position &pos, const SUMOReal angle) const
Draws the object on the specified position with the specified angle.
void unlock()
release mutex lock
Definition: MFXMutex.cpp:96
double vehiclePoly_PassengerHatchbackBackGlass[]
Hide all vehicle&#39;s routes.
Definition: GUIAppEnum.h:269
Hide vehicle&#39;s best lanes.
Definition: GUIAppEnum.h:265
GUIBaseVehicle(MSBaseVehicle &vehicle)
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:261
virtual void drawAction_drawVehicleBlinker(SUMOReal) const
render as a giant ant
render as a pedestrian
render as a moped
double vehiclePoly_PassengerCarBodyFront[]
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:201
GUIBaseVehiclePopupMenu()
default constructor needed by FOX
bool hasActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) const
Returns whether the named feature is enabled in the given view.
~GUIBaseVehicle()
destructor
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
render as a arbitrary ship
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:89
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &) const
static bool setFunctionalColor(size_t activeScheme, const MSBaseVehicle *veh)
sets the color according to the current scheme index and some vehicle function
double vehiclePoly_EVehicleBackGlass[]
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate)
long onCmdShowCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
double vehiclePoly_EmergencySign[]
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
virtual SUMOReal getAngle() const =0
Returns the vehicle&#39;s direction in radians.
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:97
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.
show all vehicle&#39;s routes
long onCmdShowFoes(FXObject *, FXSelector, void *)
Called when show a vehicles foes.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
void lock()
lock mutex
Definition: MFXMutex.cpp:86
double vehiclePoly_TransportFrontGlass[]
const RGBColor & getColor() const
Returns this type&#39;s color.
const Position & getSeatPosition(size_t personIndex) const
returns the seat position for the person with the given index
double vehiclePoly_PassengerWagonBackGlass[]
render as an emergency vehicle
render as a (futuristic) e-vehicle
double vehiclePoly_DeliveryMediumRightGlass[]
virtual void drawRouteHelper(const MSRoute &r, SUMOReal exaggeration) const =0
Draws the route.
const RGBColor & getColor() const
Returns the color.
Definition: MSRoute.cpp:349
#define SUMOReal
Definition: config.h:214
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
empty max
int vehicleQuality
The quality of vehicle drawing.
static SUMOReal getRange()
Returns the configured range.
double vehiclePoly_TransportRightGlass[]
MSBaseVehicle & myVehicle
The vehicle to which all calls should be delegated.
FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[]
virtual void drawAction_drawVehicleBlueLight() const
GUIGlObject * myObject
The object that belongs to this popup-menu.
render as a transport vehicle with one trailer
render as a wagon passenger vehicle ("Combi")
double vehiclePoly_Cyclist[]
const MSVehicleType & myVType
A shortcut to myVehicle.myType.
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
render as a coach
std::vector< MSDevice * > myDevices
The devices this vehicle has.
show vehicle&#39;s current route
const int VTYPEPARS_COLOR_SET
render as a semi-trailer transport vehicle ("Sattelschlepper")
virtual int getTrackedID() const
get tracked id
void drawAction_drawVehicleAsTrianglePlus() const
long onCmdShowLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
double vehiclePoly_PassengerVanBodyFront[]
double vehiclePoly_DeliveryMediumLeftGlass[]
Start to track a vehicle.
Definition: GUIAppEnum.h:271
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
render as a trolley bus
const MSRoute * getRoute(int index) const
Called on route retrieval.
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:449