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-2017 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  // as it is possible to show all vehicle routes, we have to store them... (bug [ 2519761 ])
262  myVehicle.myMoveReminders.push_back(std::make_pair(myRoutes, 0.));
263  mySeatPositions.push_back(Position(0, 0)); // ensure length 1
264 }
265 
266 
268  myLock.lock();
269  for (std::map<GUISUMOAbstractView*, int>::iterator i = myAdditionalVisualizations.begin(); i != myAdditionalVisualizations.end(); ++i) {
270  while (i->first->removeAdditionalGLVisualisation(this));
271  }
272  myLock.unlock();
274  delete myRoutes;
275 }
276 
277 
280  GUISUMOAbstractView& parent) {
282  buildPopupHeader(ret, app);
286  //
288  new FXMenuCommand(ret, "Hide Current Route", 0, ret, MID_HIDE_CURRENTROUTE);
289  } else {
290  new FXMenuCommand(ret, "Show Current Route", 0, ret, MID_SHOW_CURRENTROUTE);
291  }
293  new FXMenuCommand(ret, "Hide All Routes", 0, ret, MID_HIDE_ALLROUTES);
294  } else {
295  new FXMenuCommand(ret, "Show All Routes", 0, ret, MID_SHOW_ALLROUTES);
296  }
298  new FXMenuCommand(ret, "Hide Best Lanes", 0, ret, MID_HIDE_BEST_LANES);
299  } else {
300  new FXMenuCommand(ret, "Show Best Lanes", 0, ret, MID_SHOW_BEST_LANES);
301  }
303  new FXMenuCommand(ret, "Hide Link Items", 0, ret, MID_HIDE_LFLINKITEMS);
304  } else {
305  new FXMenuCommand(ret, "Show Link Items", 0, ret, MID_SHOW_LFLINKITEMS);
306  }
307  new FXMenuSeparator(ret);
308  if (parent.getTrackedID() != getGlID()) {
309  new FXMenuCommand(ret, "Start Tracking", 0, ret, MID_START_TRACK);
310  } else {
311  new FXMenuCommand(ret, "Stop Tracking", 0, ret, MID_STOP_TRACK);
312  }
313  new FXMenuCommand(ret, "Select Foes", 0, ret, MID_SHOW_FOES);
314 
315  new FXMenuSeparator(ret);
316  //
317  buildShowParamsPopupEntry(ret, false);
319  buildPositionCopyEntry(ret, false);
320  return ret;
321 }
322 
323 
324 Boundary
326  Boundary b;
327  b.add(getPosition());
329  return b;
330 }
331 
332 
333 void
335  glPushMatrix();
336  glScaled(getVType().getWidth(), getVType().getLength(), 1.);
337  glBegin(GL_TRIANGLE_STRIP);
338  glVertex2d(0., 0.);
339  glVertex2d(-.5, .15);
340  glVertex2d(.5, .15);
341  glVertex2d(-.5, 1.);
342  glVertex2d(.5, 1.);
343  glEnd();
344  glPopMatrix();
345 }
346 
347 
348 void
350  const SUMOReal length = getVType().getLength();
351  if (length >= 8.) {
353  return;
354  }
355  glPushMatrix();
356  glScaled(getVType().getWidth(), length, 1.);
357  glBegin(GL_TRIANGLES);
358  glVertex2d(0., 0.);
359  glVertex2d(-.5, 1.);
360  glVertex2d(.5, 1.);
361  glEnd();
362  glPopMatrix();
363 }
364 
365 
366 void
367 GUIBaseVehicle::drawPoly(double* poses, SUMOReal offset) {
368  glPushMatrix();
369  glTranslated(0, 0, offset * .1);
370  glPolygonOffset(0, (GLfloat) - offset);
371  glBegin(GL_TRIANGLE_FAN);
372  int i = 0;
373  while (poses[i] > -999) {
374  glVertex2d(poses[i], poses[i + 1]);
375  i = i + 2;
376  }
377  glEnd();
378  glPopMatrix();
379 }
380 
381 
382 void
384  RGBColor current = GLHelper::getColor();
385  RGBColor lighter = current.changedBrightness(51);
386  RGBColor darker = current.changedBrightness(-51);
387 
388  const SUMOReal length = getVType().getLength();
389  const SUMOReal width = getVType().getWidth();
390  glPushMatrix();
391  glRotated(90, 0, 0, 1);
392  glScaled(length, width, 1.);
394 
395  // draw main body
396  switch (shape) {
397  case SVS_UNKNOWN:
399  GLHelper::setColor(lighter);
400  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
401  glColor3d(0, 0, 0);
402  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
403  break;
404  case SVS_PEDESTRIAN:
405  glTranslated(0, 0, .045);
407  glTranslated(0, 0, -.045);
408  glScaled(.7, 2, 1);
409  glTranslated(0, 0, .04);
410  GLHelper::setColor(lighter);
412  glTranslated(0, 0, -.04);
413  break;
414  case SVS_BICYCLE:
415  case SVS_MOPED:
416  case SVS_MOTORCYCLE: {
417  RGBColor darker = current.changedBrightness(-50);
418  // body
419  drawPoly(vehiclePoly_Cyclist, 4);
420  // head
421  glPushMatrix();
422  glTranslated(0.4, 0, .5);
423  glScaled(0.1, 0.2, 1);
424  GLHelper::setColor(darker);
426  glPopMatrix();
427  // bike frame
429  glPushMatrix();
430  glTranslated(0.5, 0, .3);
431  glScaled(0.5, 0.05, 1);
433  glPopMatrix();
434  // handle bar
435  glPushMatrix();
436  glTranslated(0.25, 0, .3);
437  glScaled(0.02, 0.5, 1);
439  glPopMatrix();
440  }
441  break;
442  case SVS_PASSENGER:
443  case SVS_PASSENGER_SEDAN:
445  case SVS_PASSENGER_WAGON:
447  GLHelper::setColor(lighter);
448  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
449  glColor3d(0, 0, 0);
450  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
451  break;
452  case SVS_PASSENGER_VAN:
453  drawPoly(vehiclePoly_PassengerVanBody, 4);
454  GLHelper::setColor(lighter);
455  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
456  glColor3d(0, 0, 0);
457  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
458  drawPoly(vehiclePoly_PassengerVanRightGlass, 4.5);
459  drawPoly(vehiclePoly_PassengerVanLeftGlass, 4.5);
460  drawPoly(vehiclePoly_PassengerVanBackGlass, 4.5);
461  break;
462  case SVS_DELIVERY:
463  drawPoly(vehiclePoly_PassengerVanBody, 4);
464  GLHelper::setColor(lighter);
465  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
466  glColor3d(0, 0, 0);
467  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
468  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
469  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
470  break;
471  case SVS_TRUCK:
473  case SVS_TRUCK_1TRAILER:
474  glScaled(1. / (length), 1, 1.);
475  drawPoly(vehiclePoly_TransportBody, 4);
476  glColor3d(0, 0, 0);
477  drawPoly(vehiclePoly_TransportFrontGlass, 4.5);
478  drawPoly(vehiclePoly_TransportRightGlass, 4.5);
479  drawPoly(vehiclePoly_TransportLeftGlass, 4.5);
480  break;
481  case SVS_BUS:
482  case SVS_BUS_COACH:
483  case SVS_BUS_TROLLEY: {
484  SUMOReal ml = length;
485  glScaled(1. / (length), 1, 1.);
486  glTranslated(0, 0, .04);
487  glBegin(GL_TRIANGLE_FAN);
488  glVertex2d(ml / 2., 0);
489  glVertex2d(0, 0);
490  glVertex2d(0, -.45);
491  glVertex2d(0 + .05, -.5);
492  glVertex2d(ml - .05, -.5);
493  glVertex2d(ml, -.45);
494  glVertex2d(ml, .45);
495  glVertex2d(ml - .05, .5);
496  glVertex2d(0 + .05, .5);
497  glVertex2d(0, .45);
498  glVertex2d(0, 0);
499  glEnd();
500  glTranslated(0, 0, -.04);
501 
502  glTranslated(0, 0, .045);
503  glColor3d(0, 0, 0);
504  glBegin(GL_QUADS);
505  glVertex2d(0 + .05, .48);
506  glVertex2d(0 + .05, -.48);
507  glVertex2d(0 + .15, -.48);
508  glVertex2d(0 + .15, .48);
509 
510  glVertex2d(ml - .1, .45);
511  glVertex2d(ml - .1, -.45);
512  glVertex2d(ml - .05, -.45);
513  glVertex2d(ml - .05, .45);
514 
515  glVertex2d(0 + .20, .49);
516  glVertex2d(0 + .20, .45);
517  glVertex2d(ml - .20, .45);
518  glVertex2d(ml - .20, .49);
519 
520  glVertex2d(0 + .20, -.49);
521  glVertex2d(0 + .20, -.45);
522  glVertex2d(ml - .20, -.45);
523  glVertex2d(ml - .20, -.49);
524 
525  glEnd();
526  glTranslated(0, 0, -.045);
527  }
528  break;
529  case SVS_BUS_FLEXIBLE:
530  case SVS_RAIL:
531  case SVS_RAIL_CAR:
532  case SVS_RAIL_CARGO:
533  drawAction_drawCarriageClass(s, shape, false);
534  break;
535  case SVS_E_VEHICLE:
536  drawPoly(vehiclePoly_EVehicleBody, 4);
537  glColor3d(0, 0, 0);
538  drawPoly(vehiclePoly_EVehicleFrontGlass, 4.5);
539  glTranslated(0, 0, .048);
540  GLHelper::setColor(current);
541  glBegin(GL_QUADS);
542  glVertex2d(.3, .5);
543  glVertex2d(.35, .5);
544  glVertex2d(.35, -.5);
545  glVertex2d(.3, -.5);
546 
547  glVertex2d(.3, -.05);
548  glVertex2d(.7, -.05);
549  glVertex2d(.7, .05);
550  glVertex2d(.3, .05);
551 
552  glVertex2d(.7, .5);
553  glVertex2d(.65, .5);
554  glVertex2d(.65, -.5);
555  glVertex2d(.7, -.5);
556  glEnd();
557  glTranslated(0, 0, -.048);
558  //drawPoly(vehiclePoly_EVehicleBackGlass, 4.5);
559  break;
560  case SVS_ANT:
561  glPushMatrix();
562  // ant is stretched via vehicle length
563  GLHelper::setColor(darker);
564  // draw left side
565  GLHelper::drawBoxLine(Position(-0.2, -.10), 350, 0.5, .02);
566  GLHelper::drawBoxLine(Position(-0.3, -.50), 240, 0.4, .03);
567  GLHelper::drawBoxLine(Position(0.3, -.10), 340, 0.8, .03);
568  GLHelper::drawBoxLine(Position(0.05, -.80), 290, 0.6, .04);
569  GLHelper::drawBoxLine(Position(0.4, -.10), 20, 0.8, .03);
570  GLHelper::drawBoxLine(Position(0.65, -.80), 75, 0.6, .04);
571  GLHelper::drawBoxLine(Position(0.5, -.10), 55, 0.8, .04);
572  GLHelper::drawBoxLine(Position(1.1, -.55), 90, 0.6, .04);
573  // draw right side
574  GLHelper::drawBoxLine(Position(-0.2, .10), 190, 0.5, .02);
575  GLHelper::drawBoxLine(Position(-0.3, .50), 300, 0.4, .03);
576  GLHelper::drawBoxLine(Position(0.3, .10), 200, 0.8, .03);
577  GLHelper::drawBoxLine(Position(0.05, .80), 250, 0.6, .04);
578  GLHelper::drawBoxLine(Position(0.4, .10), 160, 0.8, .03);
579  GLHelper::drawBoxLine(Position(0.65, .80), 105, 0.6, .04);
580  GLHelper::drawBoxLine(Position(0.5, .10), 125, 0.8, .04);
581  GLHelper::drawBoxLine(Position(1.1, .55), 90, 0.6, .04);
582  // draw body
583  GLHelper::setColor(current);
584  glTranslated(0, 0, 0.1);
586  glTranslated(.4, 0, 0);
588  glTranslated(.4, 0, 0);
590  glPopMatrix();
591  break;
592  case SVS_SHIP: {
593  RGBColor darker = current.changedBrightness(-30);
594  RGBColor darker2 = current.changedBrightness(-70);
595  drawPoly(vehiclePoly_Ship, 4);
596  GLHelper::setColor(darker);
597  drawPoly(vehiclePoly_ShipDeck, 5);
598  GLHelper::setColor(darker2);
599  drawPoly(vehiclePoly_ShipSuperStructure, 6);
600  break;
601  }
602  case SVS_EMERGENCY: // similar to delivery
603  glColor3d(1, 1, 1);
604  drawPoly(vehiclePoly_PassengerVanBody, 4);
605  glColor3d(1, 0, 0);
606  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
607  glColor3d(0, 0, 0);
608  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
609  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
610  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
611  // first aid sign
612  glTranslated(0.7, 0, 0);
613  glColor3d(.18, .55, .34);
614  drawPoly(vehiclePoly_EmergencySign, 4.5);
615  glColor3d(1, 1, 1);
616  drawPoly(vehiclePoly_Emergency, 5);
617  drawPoly(vehiclePoly_Emergency2, 5);
618  break;
619  default: // same as passenger
621  glColor3d(1, 1, 1);
622  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
623  glColor3d(0, 0, 0);
624  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
625  break;
626  }
627 
628  // draw decorations
629  switch (shape) {
630  case SVS_PEDESTRIAN:
631  break;
632  case SVS_BICYCLE:
633  //glScaled(length, 1, 1.);
634  glBegin(GL_TRIANGLE_FAN);
635  glVertex2d(1 / 2., 0);
636  glVertex2d(0, 0);
637  glVertex2d(0, -.03);
638  glVertex2d(0 + .05, -.05);
639  glVertex2d(1 - .05, -.05);
640  glVertex2d(1, -.03);
641  glVertex2d(1, .03);
642  glVertex2d(1 - .05, .05);
643  glVertex2d(0 + .05, .05);
644  glVertex2d(0, .03);
645  glVertex2d(0, 0);
646  glEnd();
647  break;
648  case SVS_MOPED:
649  case SVS_MOTORCYCLE:
650  //glScaled(length, 1, 1.);
651  glBegin(GL_TRIANGLE_FAN);
652  glVertex2d(1 / 2., 0);
653  glVertex2d(0, 0);
654  glVertex2d(0, -.03);
655  glVertex2d(0 + .05, -.2);
656  glVertex2d(1 - .05, -.2);
657  glVertex2d(1, -.03);
658  glVertex2d(1, .03);
659  glVertex2d(1 - .05, .2);
660  glVertex2d(0 + .05, .2);
661  glVertex2d(0, .03);
662  glVertex2d(0, 0);
663  glEnd();
664  break;
665  case SVS_PASSENGER:
666  case SVS_PASSENGER_SEDAN:
667  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
668  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
669  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
670  break;
672  drawPoly(vehiclePoly_PassengerHatchbackRightGlass, 4.5);
673  drawPoly(vehiclePoly_PassengerHatchbackLeftGlass, 4.5);
674  drawPoly(vehiclePoly_PassengerHatchbackBackGlass, 4.5);
675  break;
676  case SVS_PASSENGER_WAGON:
677  drawPoly(vehiclePoly_PassengerWagonRightGlass, 4.5);
678  drawPoly(vehiclePoly_PassengerWagonLeftGlass, 4.5);
679  drawPoly(vehiclePoly_PassengerWagonBackGlass, 4.5);
680  break;
681  case SVS_PASSENGER_VAN:
682  case SVS_DELIVERY:
683  break;
684  case SVS_TRUCK:
685  GLHelper::setColor(current);
686  GLHelper::drawBoxLine(Position(2.3, 0), 90., length - 2.3, .5);
687  break;
689  GLHelper::setColor(current);
690  GLHelper::drawBoxLine(Position(2.8, 0), 90., length - 2.8, .5);
691  break;
692  case SVS_TRUCK_1TRAILER: {
693  GLHelper::setColor(current);
694  SUMOReal l = length - 2.3;
695  l = l / 2.;
696  GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
697  GLHelper::drawBoxLine(Position(2.3 + l + .5, 0), 90., l - .5, .5);
698  break;
699  }
700  case SVS_BUS_TROLLEY:
701  glPushMatrix();
702  glTranslated(0, 0, .1);
703  GLHelper::setColor(darker);
704  GLHelper::drawBoxLine(Position(3.8, 0), 90., 1, .3);
705  glTranslated(0, 0, .1);
706  glColor3d(0, 0, 0);
707  GLHelper::drawBoxLine(Position(4.3, .2), 90., 1, .06);
708  GLHelper::drawBoxLine(Position(4.3, -.2), 90., 1, .06);
709  GLHelper::drawBoxLine(Position(5.3, .2), 90., 3, .03);
710  GLHelper::drawBoxLine(Position(5.3, -.2), 90., 3, .03);
711  glPopMatrix();
712  break;
713  case SVS_BUS:
714  case SVS_BUS_COACH:
715  case SVS_BUS_FLEXIBLE:
716  case SVS_RAIL:
717  case SVS_RAIL_CAR:
718  case SVS_RAIL_CARGO:
719  case SVS_E_VEHICLE:
720  case SVS_ANT:
721  case SVS_SHIP:
722  case SVS_EMERGENCY:
723  break;
724  default: // same as passenger/sedan
725  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
726  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
727  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
728  break;
729  }
730  /*
731  glBegin(GL_TRIANGLE_FAN);
732  glVertex2d(.5,.5); // center - strip begin
733  glVertex2d(0, .5); // center, front
734  glVertex2d(0, .8); // ... clockwise ... (vehicle right side)
735  glVertex2d(0.08, .94);
736  glVertex2d(0.25, 1.);
737  glVertex2d(0.95, 1.);
738  glVertex2d(1., .9);
739  glVertex2d(1., .1); // (vehicle left side)
740  glVertex2d(0.95, 0.);
741  glVertex2d(0.25, 0.);
742  glVertex2d(0.08, .06);
743  glVertex2d(0, .2); //
744  glVertex2d(0, .5); // center, front (close)
745  glEnd();
746 
747  glPolygonOffset(0, -4.5);
748  glColor3d(1, 1, 1); // front
749  glBegin(GL_TRIANGLE_FAN);
750  glVertex2d(0.1,0.5);
751  glVertex2d(0.025,0.5);
752  glVertex2d(0.025,0.75);
753  glVertex2d(0.27,0.9);
754  glVertex2d(0.27,0.1);
755  glVertex2d(0.025,0.25);
756  glVertex2d(0.025,0.5);
757  glEnd();
758 
759  glColor3d(0, 0, 0); // front glass
760  glBegin(GL_TRIANGLE_FAN);
761  glVertex2d(0.35,0.5);
762  glVertex2d(0.3,0.5);
763  glVertex2d(0.3,0.9);
764  glVertex2d(0.43,0.8);
765  glVertex2d(0.43,0.2);
766  glVertex2d(0.3,0.1);
767  glVertex2d(0.3,0.5);
768  glEnd();
769 
770  glBegin(GL_TRIANGLE_FAN); // back glass
771  glVertex2d(0.92,0.5);
772  glVertex2d(0.90,0.5);
773  glVertex2d(0.90,0.8);
774  glVertex2d(0.95,0.9);
775  glVertex2d(0.95,0.1);
776  glVertex2d(0.90,0.2);
777  glVertex2d(0.90,0.5);
778  glEnd();
779 
780  glBegin(GL_TRIANGLE_FAN); // right glass
781  glVertex2d(0.36,0.07);
782  glVertex2d(0.34,0.03);
783  glVertex2d(0.94,0.03);
784  glVertex2d(0.87,0.13);
785  glVertex2d(0.45,0.13);
786  glVertex2d(0.34,0.03);
787  glEnd();
788 
789  glBegin(GL_TRIANGLE_FAN); // left glass
790  glVertex2d(0.36,1.-0.07);
791  glVertex2d(0.34,1.-0.03);
792  glVertex2d(0.94,1.-0.03);
793  glVertex2d(0.87,1.-0.13);
794  glVertex2d(0.45,1.-0.13);
795  glVertex2d(0.34,1.-0.03);
796  glEnd();
797  */
798 
799  glPopMatrix();
800 }
801 
802 
803 bool
805  const std::string& file = getVType().getImgFile();
806  if (file != "") {
807  int textureID = GUITexturesHelper::getTextureID(file);
808  if (textureID > 0) {
809  const SUMOReal exaggeration = s.vehicleSize.getExaggeration(s);
810  if (length < 0) {
811  length = getVType().getLength() * exaggeration;
812  }
813  const SUMOReal halfWidth = getVType().getWidth() / 2.0 * exaggeration;
814  GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, 0, halfWidth, length);
815  return true;
816  }
817  }
818  return false;
819 }
820 
821 
822 void
823 GUIBaseVehicle::drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const SUMOReal angle) const {
824  glPushName(getGlID());
825  glPushMatrix();
826  Position p1 = pos;
827  const SUMOReal degAngle = RAD2DEG(angle + PI / 2.);
828  // one seat in the center of the vehicle by default
829  if (myVehicle.getLane() != 0) {
831  } else {
832  mySeatPositions[0] = p1;
833  }
834  glTranslated(p1.x(), p1.y(), getType());
835  glRotated(degAngle, 0, 0, 1);
836  // set lane color
837  setColor(s);
838  // scale
839  const SUMOReal upscale = s.vehicleSize.getExaggeration(s);
840  glScaled(upscale, upscale, 1);
841  /*
842  MSLCM_DK2004 &m2 = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
843  if((m2.getState()&LCA_URGENT)!=0) {
844  glColor3d(1, .4, .4);
845  } else if((m2.getState()&LCA_SPEEDGAIN)!=0) {
846  glColor3d(.4, .4, 1);
847  } else {
848  glColor3d(.4, 1, .4);
849  }
850  */
851  // draw the vehicle
853  switch (s.vehicleQuality) {
854  case 0:
856  break;
857  case 1:
859  break;
860  case 2:
862  // draw flashing blue light for emergency vehicles
863  if (getVType().getGuiShape() == SVS_EMERGENCY) {
864  glTranslated(0, 0, .1);
866  }
867  break;
868  case 3:
869  default:
870  // draw as image but take special care for drawing trains
871  // fallback to simple shapes
872  if (!drawAction_drawCarriageClass(s, getVType().getGuiShape(), true)) {
875  };
876  }
877  break;
878  }
879  if (s.drawMinGap) {
880  const SUMOReal minGap = -getVType().getMinGap();
881  glColor3d(0., 1., 0.);
882  glBegin(GL_LINES);
883  glVertex2d(0., 0);
884  glVertex2d(0., minGap);
885  glVertex2d(-.5, minGap);
886  glVertex2d(.5, minGap);
887  glEnd();
888  }
890  if (dev != 0 && s.showBTRange) {
891  glColor3d(1., 0., 0.);
892  GLHelper::drawOutlineCircle(dev->getRange(), dev->getRange() - .2, 32);
893  }
894  // draw the blinker and brakelights if wished
895  if (s.showBlinker) {
896  glTranslated(0, 0, .1);
897  switch (getVType().getGuiShape()) {
898  case SVS_PEDESTRIAN:
899  case SVS_BICYCLE:
900  case SVS_ANT:
901  case SVS_SHIP:
902  case SVS_RAIL:
903  case SVS_RAIL_CARGO:
904  // only SVS_RAIL_CAR has blinkers and brake lights
905  break;
906  case SVS_MOTORCYCLE:
907  case SVS_MOPED:
910  break;
911  default:
914  break;
915  }
916  }
917  // draw the wish to change the lane
918  if (s.drawLaneChangePreference) {
919  /*
920  if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
921  MSLCM_DK2004 &m = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
922  glColor3d(.5, .5, 1);
923  glBegin(GL_LINES);
924  glVertex2f(0, 0);
925  glVertex2f(m.getChangeProbability(), .5);
926  glEnd();
927 
928  glColor3d(1, 0, 0);
929  glBegin(GL_LINES);
930  glVertex2f(0.1, 0);
931  glVertex2f(0.1, m.myMaxJam1);
932  glEnd();
933 
934  glColor3d(0, 1, 0);
935  glBegin(GL_LINES);
936  glVertex2f(-0.1, 0);
937  glVertex2f(-0.1, m.myTDist);
938  glEnd();
939  }
940  */
941  }
942  // draw best lanes
943  /*
944  if (true) {
945  const MSLane &l = veh->getLane();
946  SUMOReal r1 = veh->allowedContinuationsLength(&l, 0);
947  SUMOReal r2 = l.getLeftLane()!=0 ? veh->allowedContinuationsLength(l.getLeftLane(), 0) : 0;
948  SUMOReal r3 = l.getRightLane()!=0 ? veh->allowedContinuationsLength(l.getRightLane(), 0) : 0;
949  SUMOReal mmax = MAX3(r1, r2, r3);
950  glBegin(GL_LINES);
951  glVertex2f(0, 0);
952  glVertex2f(0, r1/mmax/2.);
953  glEnd();
954  glBegin(GL_LINES);
955  glVertex2f(.4, 0);
956  glVertex2f(.4, r2/mmax/2.);
957  glEnd();
958  glBegin(GL_LINES);
959  glVertex2f(-.4, 0);
960  glVertex2f(-.4, r3/mmax/2.);
961  glEnd();
962  }
963  */
964  glTranslated(0, MIN2(getVType().getLength() / 2, SUMOReal(5)), -getType()); // drawing name at GLO_MAX fails unless translating z
965  glRotated(-degAngle, 0, 0, 1);
966  glScaled(1 / upscale, 1 / upscale, 1);
967  drawName(Position(0, 0), s.scale,
968  getVType().getGuiShape() == SVS_PEDESTRIAN ? s.personName : s.vehicleName);
969  if (s.vehicleName.show && myVehicle.getParameter().line != "") {
970  glTranslated(0, 0.6 * s.vehicleName.size / s.scale, 0);
973  }
974  glPopMatrix();
975  glPopName();
977 }
978 
979 
980 void
982  drawOnPos(s, getPosition(), getAngle());
983 }
984 
985 
986 void
988  if (!myVehicle.isOnRoad()) {
989  drawGL(s);
990  }
991  glPushName(getGlID());
992  glPushMatrix();
993  glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
995  drawBestLanes();
996  }
998  drawRoute(s, 0, 0.25);
999  }
1001  if (myVehicle.getNumberReroutes() > 0) {
1002  const int noReroutePlus1 = myVehicle.getNumberReroutes() + 1;
1003  for (int i = noReroutePlus1 - 1; i >= 0; i--) {
1004  SUMOReal darken = SUMOReal(0.4) / SUMOReal(noReroutePlus1) * SUMOReal(i);
1005  drawRoute(s, i, darken);
1006  }
1007  } else {
1008  drawRoute(s, 0, 0.25);
1009  }
1010  }
1013  }
1014  glPopMatrix();
1015  glPopName();
1016 }
1017 
1018 
1019 void
1020 GUIBaseVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate) {
1021  glTranslated(pos.x(), pos.y(), -.1);
1023  std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
1024  GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
1025  glTranslated(-pos.x(), -pos.y(), .1);
1026 }
1027 
1028 
1029 void
1031  const GUIColorer& c = s.vehicleColorer;
1032  if (!setFunctionalColor(c.getActive(), &myVehicle)) {
1034  }
1035 }
1036 
1037 
1038 bool
1039 GUIBaseVehicle::setFunctionalColor(int activeScheme, const MSBaseVehicle* veh) {
1040  switch (activeScheme) {
1041  case 0: {
1042  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1044  return true;
1045  }
1048  return true;
1049  }
1050  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1052  return true;
1053  }
1054  return false;
1055  }
1056  case 2: {
1057  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1059  return true;
1060  }
1061  return false;
1062  }
1063  case 3: {
1066  return true;
1067  }
1068  return false;
1069  }
1070  case 4: {
1071  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1073  return true;
1074  }
1075  return false;
1076  }
1077  case 5: {
1078  Position p = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1079  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1080  Position center = b.getCenter();
1081  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1082  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1083  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1084  return true;
1085  }
1086  case 6: {
1087  Position p = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1088  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1089  Position center = b.getCenter();
1090  SUMOReal hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1091  SUMOReal sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1092  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1093  return true;
1094  }
1095  case 7: {
1096  Position pb = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1097  Position pe = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1098  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1099  SUMOReal hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / PI;
1100  Position minp(b.xmin(), b.ymin());
1101  Position maxp(b.xmax(), b.ymax());
1102  SUMOReal sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1103  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1104  return true;
1105  }
1106  case 28: { // color randomly (by pointer)
1107  const SUMOReal hue = (long)veh % 360; // [0-360]
1108  const SUMOReal sat = (((long)veh / 360) % 67) / 100.0 + 0.33; // [0.33-1]
1109  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1110  return true;
1111  }
1112  }
1113  return false;
1114 }
1115 
1116 
1117 // ------------ Additional visualisations
1118 bool
1120  return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
1121 }
1122 
1123 
1124 void
1126  if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
1127  myAdditionalVisualizations[parent] = 0;
1128  }
1129  myAdditionalVisualizations[parent] |= which;
1130  parent->addAdditionalGLVisualisation(this);
1131 }
1132 
1133 
1134 void
1136  myAdditionalVisualizations[parent] &= ~which;
1137  parent->removeAdditionalGLVisualisation(this);
1138 }
1139 
1140 
1141 void
1142 GUIBaseVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, SUMOReal darken) const {
1143  setColor(s);
1144  GLdouble colors[4];
1145  glGetDoublev(GL_CURRENT_COLOR, colors);
1146  colors[0] -= darken;
1147  if (colors[0] < 0) {
1148  colors[0] = 0;
1149  }
1150  colors[1] -= darken;
1151  if (colors[1] < 0) {
1152  colors[1] = 0;
1153  }
1154  colors[2] -= darken;
1155  if (colors[2] < 0) {
1156  colors[2] = 0;
1157  }
1158  colors[3] -= darken;
1159  if (colors[3] < 0) {
1160  colors[3] = 0;
1161  }
1162  glColor3dv(colors);
1163  const SUMOReal exaggeration = s.vehicleSize.getExaggeration(s);
1164  if (routeNo == 0) {
1165  drawRouteHelper(myVehicle.getRoute(), exaggeration);
1166  return;
1167  }
1168  --routeNo; // only prior routes are stored
1169  const MSRoute* route = myRoutes->getRoute(routeNo);
1170  if (route != 0) {
1171  drawRouteHelper(*route, exaggeration);
1172  }
1173 }
1174 
1175 
1176 const Position&
1177 GUIBaseVehicle::getSeatPosition(int personIndex) const {
1179  return mySeatPositions[MIN2(personIndex, (int)mySeatPositions.size() - 1)];
1180 }
1181 
1182 
1183 /****************************************************************************/
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, TraCI may change this.
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
double vehiclePoly_PassengerVanRightGlass[]
MoveReminderCont myMoveReminders
Currently relevant move reminders.
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:124
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.
const MSVehicleType & getVType() const
A shortcut to myVehicle.myType.
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:142
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
const Position & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
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:130
MSDevice_Vehroutes * myRoutes
GUIVisualizationTextSettings vehicleName
SUMOReal getLength() const
Get vehicle&#39;s length [m].
double vehiclePoly_EVehicleBody[]
double vehiclePoly_PassengerFrontGlass[]
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
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:97
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:240
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:261
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:444
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:136
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)
virtual GUIGlID getTrackedID() const
get tracked id
GUIColorer vehicleColorer
The vehicle colorer.
double vehiclePoly_ShipDeck[]
select foes of a vehicle
Definition: GUIAppEnum.h:277
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.
virtual SUMOReal getColorValue(int activeScheme) const =0
gets the color value according to the current scheme index
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.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
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:64
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:269
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:275
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[]
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.
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into, int maxRoutes=INT_MAX)
Build devices for the given vehicle, if needed.
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
Show vehicle&#39;s best lanes.
Definition: GUIAppEnum.h:265
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:271
Hide vehicle&#39;s best lanes.
Definition: GUIAppEnum.h:267
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:263
virtual void drawAction_drawVehicleBlinker(SUMOReal) const
render as a giant ant
render as a pedestrian
render as a moped
double vehiclePoly_PassengerCarBodyFront[]
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:238
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
void add(SUMOReal x, SUMOReal y, SUMOReal z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:90
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.
The popup menu of a globject.
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.
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:208
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:148
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")
static bool setFunctionalColor(int activeScheme, const MSBaseVehicle *veh)
sets the color according to the current scheme index and some vehicle function
double vehiclePoly_Cyclist[]
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")
static void drawTexturedBox(int which, SUMOReal size)
Draws a named texture as a box with the given size.
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:273
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