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 
67 // ===========================================================================
68 // FOX callback mapping
69 // ===========================================================================
70 FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[] = {
82 };
83 
84 // Object implementation
85 FXIMPLEMENT(GUIBaseVehicle::GUIBaseVehiclePopupMenu, GUIGLObjectPopupMenu, GUIBaseVehiclePopupMenuMap, ARRAYNUMBER(GUIBaseVehiclePopupMenuMap))
86 
87 
88 
89 // ===========================================================================
90 // data definitions
91 // ===========================================================================
92 /* -------------------------------------------------------------------------
93  * drawed shapes
94  * ----------------------------------------------------------------------- */
95 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 };
96 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 };
97 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 };
98 double vehiclePoly_PassengerSedanRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.77, -.47, 0.67, -.37, 0.45, -.37, 0.34, -.47, -10000 };
99 double vehiclePoly_PassengerSedanLeftGlass[] = { 0.36, .43, 0.34, .47, 0.77, .47, 0.67, .37, 0.45, .37, 0.34, .47, -10000 };
100 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 };
101 double vehiclePoly_PassengerHatchbackRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.80, -.37, 0.45, -.37, 0.34, -.47, -10000 };
102 double vehiclePoly_PassengerHatchbackLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.80, .37, 0.45, .37, 0.34, .47, -10000 };
103 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 };
104 double vehiclePoly_PassengerWagonRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.87, -.37, 0.45, -.37, 0.34, -.47, -10000 };
105 double vehiclePoly_PassengerWagonLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.87, .37, 0.45, .37, 0.34, .47, -10000 };
106 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 };
107 
108 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 };
109 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 };
110 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 };
111 double vehiclePoly_PassengerVanRightGlass[] = { 0.36, -.43, 0.20, -.47, 0.98, -.47, 0.91, -.37, 0.31, -.37, 0.20, -.47, -10000 };
112 double vehiclePoly_PassengerVanLeftGlass[] = { 0.36, .43, 0.20, .47, 0.98, .47, 0.91, .37, 0.31, .37, 0.20, .47, -10000 };
113 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 };
114 
115 double vehiclePoly_DeliveryMediumRightGlass[] = { 0.21, -.43, 0.20, -.47, 0.38, -.47, 0.38, -.37, 0.31, -.37, 0.20, -.47, -10000 };
116 double vehiclePoly_DeliveryMediumLeftGlass[] = { 0.21, .43, 0.20, .47, 0.38, .47, 0.38, .37, 0.31, .37, 0.20, .47, -10000 };
117 
118 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 };
119 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 };
120 double vehiclePoly_TransportRightGlass[] = { 0.36, -.47, 0.10, -.48, 1.25, -.48, 1.25, -.4, 0.3, -.4, 0.10, -.48, -10000 };
121 double vehiclePoly_TransportLeftGlass[] = { 0.36, .47, 0.10, .48, 1.25, .48, 1.25, .4, 0.3, .4, 0.10, .48, -10000 };
122 
123 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 };
124 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 };
125 //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 };
126 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 };
127 
128 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 };
129 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 };
130 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 };
131 
132 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 };
133 
134 double vehiclePoly_EmergencySign[] = { .2, .5, -.2, .5, -.2, -.5, .2, -.5, -10000 };
135 double vehiclePoly_Emergency[] = { .1, .1, -.1, .1, -.1, -.1, .1, -.1, -10000 };
136 double vehiclePoly_Emergency2[] = { .04, .3, -.04, .3, -.04, -.3, .04, -.3, -10000 };
137 
138 double vehiclePoly_EmergencyLadder[] = { -.5, .3, .5, .3, .5, .2, -.5, .2, -10000 };
139 double vehiclePoly_EmergencyLadder2[] = { -.5, -.3, .5, -.3, .5, -.2, -.5, -.2, -10000 };
140 double vehiclePoly_EmergencyLadder3[] = { -.45, .3, -.4, .3, -.4, -.3, -.45, -.3, -10000 };
141 double vehiclePoly_EmergencyLadder4[] = { .45, .3, .4, .3, .4, -.3, .45, -.3, -10000 };
142 double vehiclePoly_EmergencyLadder5[] = { .05, .3, .0, .3, .0, -.3, .05, -.3, -10000 };
143 double vehiclePoly_EmergencyLadder6[] = { -.25, .3, -.2, .3, -.2, -.3, -.25, -.3, -10000 };
144 double vehiclePoly_EmergencyLadder7[] = { .25, .3, .2, .3, .2, -.3, .25, -.3, -10000 };
145 // ===========================================================================
146 // method definitions
147 // ===========================================================================
148 /* -------------------------------------------------------------------------
149  * GUIBaseVehicle::GUIBaseVehiclePopupMenu - methods
150  * ----------------------------------------------------------------------- */
152  GUIMainWindow& app, GUISUMOAbstractView& parent,
153  GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations)
154  : GUIGLObjectPopupMenu(app, parent, o), myVehiclesAdditionalVisualizations(additionalVisualizations) {
155 }
156 
157 
159 
160 
161 long
163  assert(myObject->getType() == GLO_VEHICLE);
164  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES)) {
166  }
167  return 1;
168 }
169 
170 long
172  assert(myObject->getType() == GLO_VEHICLE);
174  return 1;
175 }
176 
177 
178 long
180  assert(myObject->getType() == GLO_VEHICLE);
181  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ROUTE)) {
183  }
184  return 1;
185 }
186 
187 long
189  assert(myObject->getType() == GLO_VEHICLE);
191  return 1;
192 }
193 
194 
195 long
197  assert(myObject->getType() == GLO_VEHICLE);
198  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES)) {
200  }
201  return 1;
202 }
203 
204 long
206  assert(myObject->getType() == GLO_VEHICLE);
208  return 1;
209 }
210 
211 
212 long
214  assert(myObject->getType() == GLO_VEHICLE);
215  if (myParent->getTrackedID() != static_cast<GUIBaseVehicle*>(myObject)->getGlID()) {
216  myParent->startTrack(static_cast<GUIBaseVehicle*>(myObject)->getGlID());
217  }
218  return 1;
219 }
220 
221 long
223  assert(myObject->getType() == GLO_VEHICLE);
224  myParent->stopTrack();
225  return 1;
226 }
227 
228 
229 long
231  assert(myObject->getType() == GLO_VEHICLE);
232  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS)) {
234  }
235  return 1;
236 }
237 
238 long
240  assert(myObject->getType() == GLO_VEHICLE);
242  return 1;
243 }
244 
245 long
247  assert(myObject->getType() == GLO_VEHICLE);
248  static_cast<GUIBaseVehicle*>(myObject)->selectBlockingFoes();
249  myParent->update();
250  return 1;
251 }
252 
253 
254 /* -------------------------------------------------------------------------
255  * GUIBaseVehicle - methods
256  * ----------------------------------------------------------------------- */
257 
259  GUIGlObject(GLO_VEHICLE, vehicle.getID()),
260  myVehicle(vehicle) {
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  if (i->first->getTrackedID() == getGlID()) {
272  i->first->stopTrack();
273  }
274  while (i->first->removeAdditionalGLVisualisation(this));
275  }
276  myLock.unlock();
278  delete myRoutes;
279 }
280 
281 
284  GUISUMOAbstractView& parent) {
286  buildPopupHeader(ret, app);
290  //
292  new FXMenuCommand(ret, "Hide Current Route", 0, ret, MID_HIDE_CURRENTROUTE);
293  } else {
294  new FXMenuCommand(ret, "Show Current Route", 0, ret, MID_SHOW_CURRENTROUTE);
295  }
297  new FXMenuCommand(ret, "Hide All Routes", 0, ret, MID_HIDE_ALLROUTES);
298  } else {
299  new FXMenuCommand(ret, "Show All Routes", 0, ret, MID_SHOW_ALLROUTES);
300  }
302  new FXMenuCommand(ret, "Hide Best Lanes", 0, ret, MID_HIDE_BEST_LANES);
303  } else {
304  new FXMenuCommand(ret, "Show Best Lanes", 0, ret, MID_SHOW_BEST_LANES);
305  }
307  new FXMenuCommand(ret, "Hide Link Items", 0, ret, MID_HIDE_LFLINKITEMS);
308  } else {
309  new FXMenuCommand(ret, "Show Link Items", 0, ret, MID_SHOW_LFLINKITEMS);
310  }
311  new FXMenuSeparator(ret);
312  if (parent.getTrackedID() != getGlID()) {
313  new FXMenuCommand(ret, "Start Tracking", 0, ret, MID_START_TRACK);
314  } else {
315  new FXMenuCommand(ret, "Stop Tracking", 0, ret, MID_STOP_TRACK);
316  }
317  new FXMenuCommand(ret, "Select Foes", 0, ret, MID_SHOW_FOES);
318 
319  new FXMenuSeparator(ret);
320  //
321  buildShowParamsPopupEntry(ret, false);
323  buildPositionCopyEntry(ret, false);
324  return ret;
325 }
326 
327 
328 Boundary
330  Boundary b;
331  b.add(getPosition());
333  return b;
334 }
335 
336 
337 void
339  glPushMatrix();
340  glScaled(getVType().getWidth(), getVType().getLength(), 1.);
341  glBegin(GL_TRIANGLE_STRIP);
342  glVertex2d(0., 0.);
343  glVertex2d(-.5, .15);
344  glVertex2d(.5, .15);
345  glVertex2d(-.5, 1.);
346  glVertex2d(.5, 1.);
347  glEnd();
348  glPopMatrix();
349 }
350 
351 
352 void
354  const double length = getVType().getLength();
355  if (length >= 8.) {
357  return;
358  }
359  glPushMatrix();
360  glScaled(getVType().getWidth(), length, 1.);
361  glBegin(GL_TRIANGLES);
362  glVertex2d(0., 0.);
363  glVertex2d(-.5, 1.);
364  glVertex2d(.5, 1.);
365  glEnd();
366  glPopMatrix();
367 }
368 
369 
370 void
371 GUIBaseVehicle::drawPoly(double* poses, double offset) {
372  glPushMatrix();
373  glTranslated(0, 0, offset * .1);
374  glPolygonOffset(0, (GLfloat) - offset);
375  glBegin(GL_TRIANGLE_FAN);
376  int i = 0;
377  while (poses[i] > -999) {
378  glVertex2d(poses[i], poses[i + 1]);
379  i = i + 2;
380  }
381  glEnd();
382  glPopMatrix();
383 }
384 
385 
386 void
388  RGBColor current = GLHelper::getColor();
389  RGBColor lighter = current.changedBrightness(51);
390  RGBColor darker = current.changedBrightness(-51);
391 
392  const double length = getVType().getLength();
393  const double width = getVType().getWidth();
394  glPushMatrix();
395  glRotated(90, 0, 0, 1);
396  glScaled(length, width, 1.);
398 
399  // draw main body
400  switch (shape) {
401  case SVS_UNKNOWN:
403  GLHelper::setColor(lighter);
404  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
405  glColor3d(0, 0, 0);
406  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
407  break;
408  case SVS_PEDESTRIAN:
409  glTranslated(0, 0, .045);
411  glTranslated(0, 0, -.045);
412  glScaled(.7, 2, 1);
413  glTranslated(0, 0, .04);
414  GLHelper::setColor(lighter);
416  glTranslated(0, 0, -.04);
417  break;
418  case SVS_BICYCLE:
419  case SVS_MOPED:
420  case SVS_MOTORCYCLE: {
421  RGBColor darker = current.changedBrightness(-50);
422  // body
423  drawPoly(vehiclePoly_Cyclist, 4);
424  // head
425  glPushMatrix();
426  glTranslated(0.4, 0, .5);
427  glScaled(0.1, 0.2, 1);
428  GLHelper::setColor(darker);
430  glPopMatrix();
431  // bike frame
433  glPushMatrix();
434  glTranslated(0.5, 0, .3);
435  glScaled(0.5, 0.05, 1);
437  glPopMatrix();
438  // handle bar
439  glPushMatrix();
440  glTranslated(0.25, 0, .3);
441  glScaled(0.02, 0.5, 1);
443  glPopMatrix();
444  }
445  break;
446  case SVS_PASSENGER:
447  case SVS_PASSENGER_SEDAN:
449  case SVS_PASSENGER_WAGON:
451  GLHelper::setColor(lighter);
452  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
453  glColor3d(0, 0, 0);
454  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
455  break;
456  case SVS_PASSENGER_VAN:
457  drawPoly(vehiclePoly_PassengerVanBody, 4);
458  GLHelper::setColor(lighter);
459  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
460  glColor3d(0, 0, 0);
461  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
462  drawPoly(vehiclePoly_PassengerVanRightGlass, 4.5);
463  drawPoly(vehiclePoly_PassengerVanLeftGlass, 4.5);
464  drawPoly(vehiclePoly_PassengerVanBackGlass, 4.5);
465  break;
466  case SVS_DELIVERY:
467  drawPoly(vehiclePoly_PassengerVanBody, 4);
468  GLHelper::setColor(lighter);
469  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
470  glColor3d(0, 0, 0);
471  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
472  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
473  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
474  break;
475  case SVS_TRUCK:
477  case SVS_TRUCK_1TRAILER:
478  glScaled(1. / (length), 1, 1.);
479  drawPoly(vehiclePoly_TransportBody, 4);
480  glColor3d(0, 0, 0);
481  drawPoly(vehiclePoly_TransportFrontGlass, 4.5);
482  drawPoly(vehiclePoly_TransportRightGlass, 4.5);
483  drawPoly(vehiclePoly_TransportLeftGlass, 4.5);
484  break;
485  case SVS_BUS:
486  case SVS_BUS_COACH:
487  case SVS_BUS_TROLLEY: {
488  double ml = length;
489  glScaled(1. / (length), 1, 1.);
490  glTranslated(0, 0, .04);
491  glBegin(GL_TRIANGLE_FAN);
492  glVertex2d(ml / 2., 0);
493  glVertex2d(0, 0);
494  glVertex2d(0, -.45);
495  glVertex2d(0 + .05, -.5);
496  glVertex2d(ml - .05, -.5);
497  glVertex2d(ml, -.45);
498  glVertex2d(ml, .45);
499  glVertex2d(ml - .05, .5);
500  glVertex2d(0 + .05, .5);
501  glVertex2d(0, .45);
502  glVertex2d(0, 0);
503  glEnd();
504  glTranslated(0, 0, -.04);
505 
506  glTranslated(0, 0, .045);
507  glColor3d(0, 0, 0);
508  glBegin(GL_QUADS);
509  glVertex2d(0 + .05, .48);
510  glVertex2d(0 + .05, -.48);
511  glVertex2d(0 + .15, -.48);
512  glVertex2d(0 + .15, .48);
513 
514  glVertex2d(ml - .1, .45);
515  glVertex2d(ml - .1, -.45);
516  glVertex2d(ml - .05, -.45);
517  glVertex2d(ml - .05, .45);
518 
519  glVertex2d(0 + .20, .49);
520  glVertex2d(0 + .20, .45);
521  glVertex2d(ml - .20, .45);
522  glVertex2d(ml - .20, .49);
523 
524  glVertex2d(0 + .20, -.49);
525  glVertex2d(0 + .20, -.45);
526  glVertex2d(ml - .20, -.45);
527  glVertex2d(ml - .20, -.49);
528 
529  glEnd();
530  glTranslated(0, 0, -.045);
531  }
532  break;
533  case SVS_BUS_FLEXIBLE:
534  case SVS_RAIL:
535  case SVS_RAIL_CAR:
536  case SVS_RAIL_CARGO:
537  drawAction_drawCarriageClass(s, shape, false);
538  break;
539  case SVS_E_VEHICLE:
540  drawPoly(vehiclePoly_EVehicleBody, 4);
541  glColor3d(0, 0, 0);
542  drawPoly(vehiclePoly_EVehicleFrontGlass, 4.5);
543  glTranslated(0, 0, .048);
544  GLHelper::setColor(current);
545  glBegin(GL_QUADS);
546  glVertex2d(.3, .5);
547  glVertex2d(.35, .5);
548  glVertex2d(.35, -.5);
549  glVertex2d(.3, -.5);
550 
551  glVertex2d(.3, -.05);
552  glVertex2d(.7, -.05);
553  glVertex2d(.7, .05);
554  glVertex2d(.3, .05);
555 
556  glVertex2d(.7, .5);
557  glVertex2d(.65, .5);
558  glVertex2d(.65, -.5);
559  glVertex2d(.7, -.5);
560  glEnd();
561  glTranslated(0, 0, -.048);
562  //drawPoly(vehiclePoly_EVehicleBackGlass, 4.5);
563  break;
564  case SVS_ANT:
565  glPushMatrix();
566  // ant is stretched via vehicle length
567  GLHelper::setColor(darker);
568  // draw left side
569  GLHelper::drawBoxLine(Position(-0.2, -.10), 350, 0.5, .02);
570  GLHelper::drawBoxLine(Position(-0.3, -.50), 240, 0.4, .03);
571  GLHelper::drawBoxLine(Position(0.3, -.10), 340, 0.8, .03);
572  GLHelper::drawBoxLine(Position(0.05, -.80), 290, 0.6, .04);
573  GLHelper::drawBoxLine(Position(0.4, -.10), 20, 0.8, .03);
574  GLHelper::drawBoxLine(Position(0.65, -.80), 75, 0.6, .04);
575  GLHelper::drawBoxLine(Position(0.5, -.10), 55, 0.8, .04);
576  GLHelper::drawBoxLine(Position(1.1, -.55), 90, 0.6, .04);
577  // draw right side
578  GLHelper::drawBoxLine(Position(-0.2, .10), 190, 0.5, .02);
579  GLHelper::drawBoxLine(Position(-0.3, .50), 300, 0.4, .03);
580  GLHelper::drawBoxLine(Position(0.3, .10), 200, 0.8, .03);
581  GLHelper::drawBoxLine(Position(0.05, .80), 250, 0.6, .04);
582  GLHelper::drawBoxLine(Position(0.4, .10), 160, 0.8, .03);
583  GLHelper::drawBoxLine(Position(0.65, .80), 105, 0.6, .04);
584  GLHelper::drawBoxLine(Position(0.5, .10), 125, 0.8, .04);
585  GLHelper::drawBoxLine(Position(1.1, .55), 90, 0.6, .04);
586  // draw body
587  GLHelper::setColor(current);
588  glTranslated(0, 0, 0.1);
590  glTranslated(.4, 0, 0);
592  glTranslated(.4, 0, 0);
594  glPopMatrix();
595  break;
596  case SVS_SHIP: {
597  RGBColor darker = current.changedBrightness(-30);
598  RGBColor darker2 = current.changedBrightness(-70);
599  drawPoly(vehiclePoly_Ship, 4);
600  GLHelper::setColor(darker);
601  drawPoly(vehiclePoly_ShipDeck, 5);
602  GLHelper::setColor(darker2);
603  drawPoly(vehiclePoly_ShipSuperStructure, 6);
604  break;
605  }
606  case SVS_EMERGENCY: // similar to delivery
607  glColor3d(1, 1, 1);
608  drawPoly(vehiclePoly_PassengerVanBody, 4);
609  glColor3d(1, 0, 0);
610  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
611  glColor3d(0, 0, 0);
612  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
613  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
614  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
615  // first aid sign
616  glTranslated(0.7, 0, 0);
617  glColor3d(.18, .55, .34);
618  drawPoly(vehiclePoly_EmergencySign, 4.5);
619  glColor3d(1, 1, 1);
620  drawPoly(vehiclePoly_Emergency, 5);
621  drawPoly(vehiclePoly_Emergency2, 5);
622  break;
623  case SVS_FIREBRIGADE: // similar to delivery in red orange
624  glColor3d(1, 0, 0);
625  drawPoly(vehiclePoly_PassengerVanBody, 4);
626  glColor3d(1, .5, 0);
627  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
628  glColor3d(0, 0, 0);
629  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
630  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
631  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
632  // draw ladder
633  glTranslated(0.7, 0, 0);
634  glColor3d(1, .5, 0);
635  drawPoly(vehiclePoly_EmergencySign, 4.5);
636  glColor3d(.5, .5, .5);
637  drawPoly(vehiclePoly_EmergencyLadder, 5);
638  drawPoly(vehiclePoly_EmergencyLadder2, 5);
639  drawPoly(vehiclePoly_EmergencyLadder3, 5);
640  drawPoly(vehiclePoly_EmergencyLadder4, 5);
641  drawPoly(vehiclePoly_EmergencyLadder5, 5);
642  drawPoly(vehiclePoly_EmergencyLadder6, 5);
643  drawPoly(vehiclePoly_EmergencyLadder7, 5);
644  break;
645  case SVS_POLICE: // similar to passenger grey with blue
646  glColor3d(.5, .5, .5);
648  glColor3d(0, 0, 1);
649  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
650  glColor3d(0, 0, 0);
651  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
652  // first aid sign
653  glTranslated(0.7, 0, 0);
654  glColor3d(0, 0, 1);
655  drawPoly(vehiclePoly_EmergencySign, 4.5);
656  glColor3d(.5, .5, .5);
657  drawPoly(vehiclePoly_Emergency, 5);
658  drawPoly(vehiclePoly_Emergency2, 5);
659  break;
660  default: // same as passenger
662  glColor3d(1, 1, 1);
663  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
664  glColor3d(0, 0, 0);
665  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
666  break;
667  }
668 
669  // draw decorations
670  switch (shape) {
671  case SVS_PEDESTRIAN:
672  break;
673  case SVS_BICYCLE:
674  //glScaled(length, 1, 1.);
675  glBegin(GL_TRIANGLE_FAN);
676  glVertex2d(1 / 2., 0);
677  glVertex2d(0, 0);
678  glVertex2d(0, -.03);
679  glVertex2d(0 + .05, -.05);
680  glVertex2d(1 - .05, -.05);
681  glVertex2d(1, -.03);
682  glVertex2d(1, .03);
683  glVertex2d(1 - .05, .05);
684  glVertex2d(0 + .05, .05);
685  glVertex2d(0, .03);
686  glVertex2d(0, 0);
687  glEnd();
688  break;
689  case SVS_MOPED:
690  case SVS_MOTORCYCLE:
691  //glScaled(length, 1, 1.);
692  glBegin(GL_TRIANGLE_FAN);
693  glVertex2d(1 / 2., 0);
694  glVertex2d(0, 0);
695  glVertex2d(0, -.03);
696  glVertex2d(0 + .05, -.2);
697  glVertex2d(1 - .05, -.2);
698  glVertex2d(1, -.03);
699  glVertex2d(1, .03);
700  glVertex2d(1 - .05, .2);
701  glVertex2d(0 + .05, .2);
702  glVertex2d(0, .03);
703  glVertex2d(0, 0);
704  glEnd();
705  break;
706  case SVS_PASSENGER:
707  case SVS_PASSENGER_SEDAN:
708  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
709  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
710  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
711  break;
713  drawPoly(vehiclePoly_PassengerHatchbackRightGlass, 4.5);
714  drawPoly(vehiclePoly_PassengerHatchbackLeftGlass, 4.5);
715  drawPoly(vehiclePoly_PassengerHatchbackBackGlass, 4.5);
716  break;
717  case SVS_PASSENGER_WAGON:
718  drawPoly(vehiclePoly_PassengerWagonRightGlass, 4.5);
719  drawPoly(vehiclePoly_PassengerWagonLeftGlass, 4.5);
720  drawPoly(vehiclePoly_PassengerWagonBackGlass, 4.5);
721  break;
722  case SVS_PASSENGER_VAN:
723  case SVS_DELIVERY:
724  break;
725  case SVS_TRUCK:
726  GLHelper::setColor(current);
727  GLHelper::drawBoxLine(Position(2.3, 0), 90., length - 2.3, .5);
728  break;
730  GLHelper::setColor(current);
731  GLHelper::drawBoxLine(Position(2.8, 0), 90., length - 2.8, .5);
732  break;
733  case SVS_TRUCK_1TRAILER: {
734  GLHelper::setColor(current);
735  double l = length - 2.3;
736  l = l / 2.;
737  GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
738  GLHelper::drawBoxLine(Position(2.3 + l + .5, 0), 90., l - .5, .5);
739  break;
740  }
741  case SVS_BUS_TROLLEY:
742  glPushMatrix();
743  glTranslated(0, 0, .1);
744  GLHelper::setColor(darker);
745  GLHelper::drawBoxLine(Position(3.8, 0), 90., 1, .3);
746  glTranslated(0, 0, .1);
747  glColor3d(0, 0, 0);
748  GLHelper::drawBoxLine(Position(4.3, .2), 90., 1, .06);
749  GLHelper::drawBoxLine(Position(4.3, -.2), 90., 1, .06);
750  GLHelper::drawBoxLine(Position(5.3, .2), 90., 3, .03);
751  GLHelper::drawBoxLine(Position(5.3, -.2), 90., 3, .03);
752  glPopMatrix();
753  break;
754  case SVS_BUS:
755  case SVS_BUS_COACH:
756  case SVS_BUS_FLEXIBLE:
757  case SVS_RAIL:
758  case SVS_RAIL_CAR:
759  case SVS_RAIL_CARGO:
760  case SVS_E_VEHICLE:
761  case SVS_ANT:
762  case SVS_SHIP:
763  case SVS_EMERGENCY:
764  case SVS_FIREBRIGADE:
765  case SVS_POLICE:
766  break;
767  default: // same as passenger/sedan
768  drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
769  drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
770  drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
771  break;
772  }
773  /*
774  glBegin(GL_TRIANGLE_FAN);
775  glVertex2d(.5,.5); // center - strip begin
776  glVertex2d(0, .5); // center, front
777  glVertex2d(0, .8); // ... clockwise ... (vehicle right side)
778  glVertex2d(0.08, .94);
779  glVertex2d(0.25, 1.);
780  glVertex2d(0.95, 1.);
781  glVertex2d(1., .9);
782  glVertex2d(1., .1); // (vehicle left side)
783  glVertex2d(0.95, 0.);
784  glVertex2d(0.25, 0.);
785  glVertex2d(0.08, .06);
786  glVertex2d(0, .2); //
787  glVertex2d(0, .5); // center, front (close)
788  glEnd();
789 
790  glPolygonOffset(0, -4.5);
791  glColor3d(1, 1, 1); // front
792  glBegin(GL_TRIANGLE_FAN);
793  glVertex2d(0.1,0.5);
794  glVertex2d(0.025,0.5);
795  glVertex2d(0.025,0.75);
796  glVertex2d(0.27,0.9);
797  glVertex2d(0.27,0.1);
798  glVertex2d(0.025,0.25);
799  glVertex2d(0.025,0.5);
800  glEnd();
801 
802  glColor3d(0, 0, 0); // front glass
803  glBegin(GL_TRIANGLE_FAN);
804  glVertex2d(0.35,0.5);
805  glVertex2d(0.3,0.5);
806  glVertex2d(0.3,0.9);
807  glVertex2d(0.43,0.8);
808  glVertex2d(0.43,0.2);
809  glVertex2d(0.3,0.1);
810  glVertex2d(0.3,0.5);
811  glEnd();
812 
813  glBegin(GL_TRIANGLE_FAN); // back glass
814  glVertex2d(0.92,0.5);
815  glVertex2d(0.90,0.5);
816  glVertex2d(0.90,0.8);
817  glVertex2d(0.95,0.9);
818  glVertex2d(0.95,0.1);
819  glVertex2d(0.90,0.2);
820  glVertex2d(0.90,0.5);
821  glEnd();
822 
823  glBegin(GL_TRIANGLE_FAN); // right glass
824  glVertex2d(0.36,0.07);
825  glVertex2d(0.34,0.03);
826  glVertex2d(0.94,0.03);
827  glVertex2d(0.87,0.13);
828  glVertex2d(0.45,0.13);
829  glVertex2d(0.34,0.03);
830  glEnd();
831 
832  glBegin(GL_TRIANGLE_FAN); // left glass
833  glVertex2d(0.36,1.-0.07);
834  glVertex2d(0.34,1.-0.03);
835  glVertex2d(0.94,1.-0.03);
836  glVertex2d(0.87,1.-0.13);
837  glVertex2d(0.45,1.-0.13);
838  glVertex2d(0.34,1.-0.03);
839  glEnd();
840  */
841 
842  glPopMatrix();
843 }
844 
845 
846 bool
848  const std::string& file = getVType().getImgFile();
849  if (file != "") {
850  int textureID = GUITexturesHelper::getTextureID(file);
851  if (textureID > 0) {
852  const double exaggeration = s.vehicleSize.getExaggeration(s);
853  if (length < 0) {
854  length = getVType().getLength() * exaggeration;
855  }
856  const double halfWidth = getVType().getWidth() / 2.0 * exaggeration;
857  GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, 0, halfWidth, length);
858  return true;
859  }
860  }
861  return false;
862 }
863 
864 
865 void
866 GUIBaseVehicle::drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const double angle) const {
867  glPushName(getGlID());
868  glPushMatrix();
869  Position p1 = pos;
870  const double degAngle = RAD2DEG(angle + PI / 2.);
871  // one seat in the center of the vehicle by default
872  if (myVehicle.getLane() != 0) {
874  } else {
875  mySeatPositions[0] = p1;
876  }
877  glTranslated(p1.x(), p1.y(), getType());
878  glRotated(degAngle, 0, 0, 1);
879  // set lane color
880  setColor(s);
881  // scale
882  const double upscale = s.vehicleSize.getExaggeration(s);
883  glScaled(upscale, upscale, 1);
884  /*
885  MSLCM_DK2004 &m2 = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
886  if((m2.getState()&LCA_URGENT)!=0) {
887  glColor3d(1, .4, .4);
888  } else if((m2.getState()&LCA_SPEEDGAIN)!=0) {
889  glColor3d(.4, .4, 1);
890  } else {
891  glColor3d(.4, 1, .4);
892  }
893  */
894  // draw the vehicle
896  switch (s.vehicleQuality) {
897  case 0:
899  break;
900  case 1:
902  break;
903  case 2:
905  // draw flashing blue light for emergency vehicles
906  if (getVType().getGuiShape() == SVS_EMERGENCY) {
907  glTranslated(0, 0, .1);
909  }
910  break;
911  case 3:
912  default:
913  // draw as image but take special care for drawing trains
914  // fallback to simple shapes
915  if (!drawAction_drawCarriageClass(s, getVType().getGuiShape(), true)) {
918  };
919  }
920  break;
921  }
922  if (s.drawMinGap) {
923  const double minGap = -getVType().getMinGap();
924  glColor3d(0., 1., 0.);
925  glBegin(GL_LINES);
926  glVertex2d(0., 0);
927  glVertex2d(0., minGap);
928  glVertex2d(-.5, minGap);
929  glVertex2d(.5, minGap);
930  glEnd();
931  }
933  if (dev != 0 && s.showBTRange) {
934  glColor3d(1., 0., 0.);
935  GLHelper::drawOutlineCircle(dev->getRange(), dev->getRange() - .2, 32);
936  }
937  // draw the blinker and brakelights if wished
938  if (s.showBlinker) {
939  glTranslated(0, 0, .1);
940  switch (getVType().getGuiShape()) {
941  case SVS_PEDESTRIAN:
942  case SVS_BICYCLE:
943  case SVS_ANT:
944  case SVS_SHIP:
945  case SVS_RAIL:
946  case SVS_RAIL_CARGO:
947  // only SVS_RAIL_CAR has blinkers and brake lights
948  break;
949  case SVS_MOTORCYCLE:
950  case SVS_MOPED:
953  break;
954  default:
957  break;
958  }
959  }
960  // draw the wish to change the lane
961  if (s.drawLaneChangePreference) {
962  /*
963  if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
964  MSLCM_DK2004 &m = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
965  glColor3d(.5, .5, 1);
966  glBegin(GL_LINES);
967  glVertex2f(0, 0);
968  glVertex2f(m.getChangeProbability(), .5);
969  glEnd();
970 
971  glColor3d(1, 0, 0);
972  glBegin(GL_LINES);
973  glVertex2f(0.1, 0);
974  glVertex2f(0.1, m.myMaxJam1);
975  glEnd();
976 
977  glColor3d(0, 1, 0);
978  glBegin(GL_LINES);
979  glVertex2f(-0.1, 0);
980  glVertex2f(-0.1, m.myTDist);
981  glEnd();
982  }
983  */
984  }
985  // draw best lanes
986  /*
987  if (true) {
988  const MSLane &l = veh->getLane();
989  double r1 = veh->allowedContinuationsLength(&l, 0);
990  double r2 = l.getLeftLane()!=0 ? veh->allowedContinuationsLength(l.getLeftLane(), 0) : 0;
991  double r3 = l.getRightLane()!=0 ? veh->allowedContinuationsLength(l.getRightLane(), 0) : 0;
992  double mmax = MAX3(r1, r2, r3);
993  glBegin(GL_LINES);
994  glVertex2f(0, 0);
995  glVertex2f(0, r1/mmax/2.);
996  glEnd();
997  glBegin(GL_LINES);
998  glVertex2f(.4, 0);
999  glVertex2f(.4, r2/mmax/2.);
1000  glEnd();
1001  glBegin(GL_LINES);
1002  glVertex2f(-.4, 0);
1003  glVertex2f(-.4, r3/mmax/2.);
1004  glEnd();
1005  }
1006  */
1007  glTranslated(0, MIN2(getVType().getLength() / 2, double(5)), -getType()); // drawing name at GLO_MAX fails unless translating z
1008  glRotated(-degAngle, 0, 0, 1);
1009  glScaled(1 / upscale, 1 / upscale, 1);
1010  drawName(Position(0, 0), s.scale,
1011  getVType().getGuiShape() == SVS_PEDESTRIAN ? s.personName : s.vehicleName);
1012  if (s.vehicleName.show && myVehicle.getParameter().line != "") {
1013  glTranslated(0, 0.6 * s.vehicleName.size / s.scale, 0);
1016  }
1017  glPopMatrix();
1018  glPopName();
1020 }
1021 
1022 
1023 void
1025  drawOnPos(s, getPosition(), getAngle());
1026 }
1027 
1028 
1029 void
1031  if (!myVehicle.isOnRoad()) {
1032  drawGL(s);
1033  }
1034  glPushName(getGlID());
1035  glPushMatrix();
1036  glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
1038  drawBestLanes();
1039  }
1041  drawRoute(s, 0, 0.25);
1042  }
1044  if (myVehicle.getNumberReroutes() > 0) {
1045  const int noReroutePlus1 = myVehicle.getNumberReroutes() + 1;
1046  for (int i = noReroutePlus1 - 1; i >= 0; i--) {
1047  double darken = double(0.4) / double(noReroutePlus1) * double(i);
1048  drawRoute(s, i, darken);
1049  }
1050  } else {
1051  drawRoute(s, 0, 0.25);
1052  }
1053  }
1056  }
1057  glPopMatrix();
1058  glPopName();
1059 }
1060 
1061 
1062 void
1063 GUIBaseVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate) {
1064  glTranslated(pos.x(), pos.y(), -.1);
1066  std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
1067  GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
1068  glTranslated(-pos.x(), -pos.y(), .1);
1069 }
1070 
1071 
1072 void
1074  const GUIColorer& c = s.vehicleColorer;
1075  if (!setFunctionalColor(c.getActive(), &myVehicle)) {
1077  }
1078 }
1079 
1080 
1081 bool
1082 GUIBaseVehicle::setFunctionalColor(int activeScheme, const MSBaseVehicle* veh) {
1083  switch (activeScheme) {
1084  case 0: {
1085  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1087  return true;
1088  }
1091  return true;
1092  }
1093  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1095  return true;
1096  }
1097  return false;
1098  }
1099  case 2: {
1100  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1102  return true;
1103  }
1104  return false;
1105  }
1106  case 3: {
1109  return true;
1110  }
1111  return false;
1112  }
1113  case 4: {
1114  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1116  return true;
1117  }
1118  return false;
1119  }
1120  case 5: {
1121  Position p = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1122  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1123  Position center = b.getCenter();
1124  double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1125  double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1126  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1127  return true;
1128  }
1129  case 6: {
1130  Position p = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1131  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1132  Position center = b.getCenter();
1133  double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / PI;
1134  double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1135  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1136  return true;
1137  }
1138  case 7: {
1139  Position pb = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1140  Position pe = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1141  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1142  double hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / PI;
1143  Position minp(b.xmin(), b.ymin());
1144  Position maxp(b.xmax(), b.ymax());
1145  double sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1146  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1147  return true;
1148  }
1149  case 28: { // color randomly (by pointer)
1150  const double hue = (long)veh % 360; // [0-360]
1151  const double sat = (((long)veh / 360) % 67) / 100.0 + 0.33; // [0.33-1]
1152  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1153  return true;
1154  }
1155  }
1156  return false;
1157 }
1158 
1159 
1160 // ------------ Additional visualisations
1161 bool
1163  return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
1164 }
1165 
1166 
1167 void
1169  if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
1170  myAdditionalVisualizations[parent] = 0;
1171  }
1172  myAdditionalVisualizations[parent] |= which;
1173  parent->addAdditionalGLVisualisation(this);
1174 }
1175 
1176 
1177 void
1179  myAdditionalVisualizations[parent] &= ~which;
1180  parent->removeAdditionalGLVisualisation(this);
1181 }
1182 
1183 
1184 void
1185 GUIBaseVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, double darken) const {
1186  setColor(s);
1187  GLdouble colors[4];
1188  glGetDoublev(GL_CURRENT_COLOR, colors);
1189  colors[0] -= darken;
1190  if (colors[0] < 0) {
1191  colors[0] = 0;
1192  }
1193  colors[1] -= darken;
1194  if (colors[1] < 0) {
1195  colors[1] = 0;
1196  }
1197  colors[2] -= darken;
1198  if (colors[2] < 0) {
1199  colors[2] = 0;
1200  }
1201  colors[3] -= darken;
1202  if (colors[3] < 0) {
1203  colors[3] = 0;
1204  }
1205  glColor3dv(colors);
1206  const double exaggeration = s.vehicleSize.getExaggeration(s);
1207  if (routeNo == 0) {
1208  drawRouteHelper(myVehicle.getRoute(), exaggeration);
1209  return;
1210  }
1211  --routeNo; // only prior routes are stored
1212  const MSRoute* route = myRoutes->getRoute(routeNo);
1213  if (route != 0) {
1214  drawRouteHelper(*route, exaggeration);
1215  }
1216 }
1217 
1218 
1219 const Position&
1220 GUIBaseVehicle::getSeatPosition(int personIndex) const {
1222  return mySeatPositions[MIN2(personIndex, (int)mySeatPositions.size() - 1)];
1223 }
1224 
1225 
1226 /****************************************************************************/
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
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.
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:138
long onCmdHideCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
double vehiclePoly_PassengerVanBody[]
SUMOVehicleShape getGuiShape() const
Get this vehicle type&#39;s shape.
render as a rail
double vehiclePoly_Emergency2[]
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:132
RGBColor color
The vehicle&#39;s color, TraCI may change this.
double scale
information about a lane&#39;s width (temporary, used for a single view)
virtual void drawAction_drawVehicleBlueLight() const
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:146
double vehiclePoly_PassengerVanRightGlass[]
double vehiclePoly_EmergencyLadder4[]
MoveReminderCont myMoveReminders
Currently relevant move reminders.
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:128
double myCarriageLength
Variable to set with the length of the last drawn carriage or the vehicle length. ...
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.
double vehiclePoly_PassengerWagonLeftGlass[]
a vehicles
Show vehicle&#39;s best lanes.
Definition: GUIAppEnum.h:265
GUIVisualizationTextSettings personName
double vehiclePoly_EVehicleFrontGlass[]
double vehiclePoly_PassengerSedanRightGlass[]
const MSVehicleType & getVType() const
A shortcut to myVehicle.myType.
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:290
render as a motorcycle
double vehiclePoly_PassengerVanFrontGlass[]
void drawAction_drawVehicleAsBoxPlus() const
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.
Stores the information about how to visualize structures.
render as a transport vehicle
render as a flexible city bus
double y() const
Returns the y-position.
Definition: Position.h:68
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
bool drawLaneChangePreference
Information whether the lane change preference shall be drawn.
show vehicle&#39;s best lanes
MSDevice_Vehroutes * myRoutes
GUIVisualizationTextSettings vehicleName
double x() const
Returns the x-position.
Definition: Position.h:63
double vehiclePoly_EVehicleBody[]
std::string getImgFile() const
Get this vehicle type&#39;s raster model file name.
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
virtual void drawAction_drawLinkItems(const GUIVisualizationSettings &) const
double vehiclePoly_PassengerFrontGlass[]
static double getRange()
Returns the configured range.
const RGBColor & getColor() const
Returns the color.
Definition: MSRoute.cpp:341
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:158
render as a delivery vehicle
double vehiclePoly_Emergency[]
const MSRoute & getRoute() const
Returns the current route.
double vehiclePoly_PassengerHatchbackLeftGlass[]
double vehiclePoly_PassengerVanBackGlass[]
double vehiclePoly_EmergencyLadder3[]
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
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate)
double vehiclePoly_PassengerSedanBackGlass[]
Show all vehicle&#39;s routes.
Definition: GUIAppEnum.h:269
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
double vehiclePoly_PassengerVanLeftGlass[]
virtual void stopTrack()
stop track
virtual void drawRouteHelper(const MSRoute &r, double exaggeration) const =0
Draws the route.
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:340
virtual void selectBlockingFoes() const =0
adds the blocking foes to the current selection
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.
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
Start to track a vehicle.
Definition: GUIAppEnum.h:273
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.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
long onCmdHideAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:91
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
GUIColorer vehicleColorer
The vehicle colorer.
double vehiclePoly_ShipDeck[]
double vehiclePoly_PassengerCarBody[]
virtual GUIGlID getTrackedID() const
get tracked id
virtual void startTrack(int)
star track
static const RGBColor GREEN
Definition: RGBColor.h:190
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &) const
static const RGBColor GREY
Definition: RGBColor.h:198
#define PI
Definition: polyfonts.c:61
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle&#39;s best lanes shall be shown.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
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:439
render as a hatchback passenger vehicle ("Fliessheck")
Hide vehicle&#39;s current route.
Definition: GUIAppEnum.h:263
select foes of a vehicle
Definition: GUIAppEnum.h:277
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[]
void drawOnPos(const GUIVisualizationSettings &s, const Position &pos, const double angle) const
Draws the object on the specified position with the specified angle.
bool drawMinGap
Information whether the minimum gap shall be drawn.
Stop to track a vehicle.
Definition: GUIAppEnum.h:275
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_EmergencyLadder6[]
double vehiclePoly_EmergencyLadder[]
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
virtual double getColorValue(int activeScheme) const =0
gets the color value according to the current scheme index
void drawAction_drawVehicleAsTrianglePlus() const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
render as a (city) rail without locomotive
Hide vehicle&#39;s best lanes.
Definition: GUIAppEnum.h:267
T MIN2(T a, T b)
Definition: StdDefs.h:64
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into, int maxRoutes=INT_MAX)
Build devices for the given vehicle, if needed.
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:126
static void drawOutlineCircle(double width, double iwidth, int steps=8)
Draws an unfilled circle around (0,0)
Definition: GLHelper.cpp:371
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
A MSVehicle extended by some values for usage within the gui.
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:234
double getMinGap() const
Get the free space in front of vehicles of this class.
render as a van
double vehiclePoly_PassengerHatchbackRightGlass[]
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
const T getColor(const double value) const
render as a passenger vehicle
double vehiclePoly_TransportBody[]
render as a police car
Hide all vehicle&#39;s routes.
Definition: GUIAppEnum.h:271
const int VEHPARS_COLOR_SET
std::string line
The vehicle&#39;s line (mainly for public transport)
const RGBColor & getColor() const
Returns this type&#39;s color.
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
static void removeObject(GUIGlObject &o)
Removes all instances that pass values from the object with the given id.
Show vehicle&#39;s current route.
Definition: GUIAppEnum.h:261
double vehiclePoly_PassengerSedanLeftGlass[]
render as a cargo train
void drawRoute(const GUIVisualizationSettings &s, int routeNo, double darken) const
Chooses the route to draw and draws it, darkening it as given.
render as a fire brigade
void unlock()
release mutex lock
Definition: MFXMutex.cpp:92
void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
double vehiclePoly_PassengerHatchbackBackGlass[]
GUIBaseVehicle(MSBaseVehicle &vehicle)
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
render as a giant ant
render as a pedestrian
render as a moped
double vehiclePoly_PassengerCarBodyFront[]
GUIBaseVehiclePopupMenu()
default constructor needed by FOX
~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.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
render as a arbitrary ship
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:89
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
const Position & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
double vehiclePoly_EmergencyLadder5[]
double vehiclePoly_EVehicleBackGlass[]
virtual double getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
long onCmdShowCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
double vehiclePoly_EmergencySign[]
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 ...
The popup menu of a globject.
show all vehicle&#39;s routes
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:448
virtual double getAngle() const =0
Returns the vehicle&#39;s direction in radians.
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.
double getLength() const
Get vehicle&#39;s length [m].
void lock()
lock mutex
Definition: MFXMutex.cpp:82
double vehiclePoly_TransportFrontGlass[]
double vehiclePoly_PassengerWagonBackGlass[]
bool wasSet(int what) const
Returns whether the given parameter was set.
render as an emergency vehicle
GUIGlID getGlID() const
Returns the numerical id of the object.
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:120
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
render as a (futuristic) e-vehicle
double vehiclePoly_DeliveryMediumRightGlass[]
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:240
GUIVisualizationSizeSettings vehicleSize
long long int SUMOTime
Definition: TraCIDefs.h:52
virtual void drawBestLanes() const
Draws the vehicle&#39;s best lanes.
empty max
const MSRoute * getRoute(int index) const
Called on route retrieval.
static void drawPoly(double *poses, double offset)
int vehicleQuality
The quality of vehicle drawing.
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:126
double vehiclePoly_TransportRightGlass[]
MSBaseVehicle & myVehicle
The vehicle to which all calls should be delegated.
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0)
draw Text with given parameters
Definition: GLHelper.cpp:456
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:86
FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[]
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:144
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.
virtual void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
double vehiclePoly_EmergencyLadder7[]
render as a coach
std::vector< MSDevice * > myDevices
The devices this vehicle has.
show vehicle&#39;s current route
const int VTYPEPARS_COLOR_SET
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, double length=-1) const
render as a semi-trailer transport vehicle ("Sattelschlepper")
long onCmdShowLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
double vehiclePoly_PassengerVanBodyFront[]
double vehiclePoly_DeliveryMediumLeftGlass[]
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
render as a trolley bus
bool hasActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) const
Returns whether the named feature is enabled in the given view.
double vehiclePoly_EmergencyLadder2[]
virtual void drawAction_drawVehicleBlinker(double) const
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:445