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 + M_PI / 2.);
871  // one seat in the center of the vehicle by default
872  if (myVehicle.getLane() != 0) {
873  mySeatPositions[0] = myVehicle.getPosition(- getVType().getLength() / 2);
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  glPushMatrix(); // drawAction_drawRailCarriages assumes matrix stack depth of 2
916  if (!drawAction_drawCarriageClass(s, getVType().getGuiShape(), true)) {
919  };
920  }
921  glPopMatrix();
922  break;
923  }
924  if (s.drawMinGap) {
925  const double minGap = -getVType().getMinGap();
926  glColor3d(0., 1., 0.);
927  glBegin(GL_LINES);
928  glVertex2d(0., 0);
929  glVertex2d(0., minGap);
930  glVertex2d(-.5, minGap);
931  glVertex2d(.5, minGap);
932  glEnd();
933  }
935  if (dev != 0 && s.showBTRange) {
936  glColor3d(1., 0., 0.);
937  GLHelper::drawOutlineCircle(dev->getRange(), dev->getRange() - .2, 32);
938  }
939  // draw the blinker and brakelights if wished
940  if (s.showBlinker) {
941  glTranslated(0, 0, .1);
942  switch (getVType().getGuiShape()) {
943  case SVS_PEDESTRIAN:
944  case SVS_BICYCLE:
945  case SVS_ANT:
946  case SVS_SHIP:
947  case SVS_RAIL:
948  case SVS_RAIL_CARGO:
949  // only SVS_RAIL_CAR has blinkers and brake lights
950  break;
951  case SVS_MOTORCYCLE:
952  case SVS_MOPED:
955  break;
956  default:
959  break;
960  }
961  }
962  // draw the wish to change the lane
963  if (s.drawLaneChangePreference) {
964  /*
965  if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
966  MSLCM_DK2004 &m = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
967  glColor3d(.5, .5, 1);
968  glBegin(GL_LINES);
969  glVertex2f(0, 0);
970  glVertex2f(m.getChangeProbability(), .5);
971  glEnd();
972 
973  glColor3d(1, 0, 0);
974  glBegin(GL_LINES);
975  glVertex2f(0.1, 0);
976  glVertex2f(0.1, m.myMaxJam1);
977  glEnd();
978 
979  glColor3d(0, 1, 0);
980  glBegin(GL_LINES);
981  glVertex2f(-0.1, 0);
982  glVertex2f(-0.1, m.myTDist);
983  glEnd();
984  }
985  */
986  }
987  // draw best lanes
988  /*
989  if (true) {
990  const MSLane &l = veh->getLane();
991  double r1 = veh->allowedContinuationsLength(&l, 0);
992  double r2 = l.getLeftLane()!=0 ? veh->allowedContinuationsLength(l.getLeftLane(), 0) : 0;
993  double r3 = l.getRightLane()!=0 ? veh->allowedContinuationsLength(l.getRightLane(), 0) : 0;
994  double mmax = MAX3(r1, r2, r3);
995  glBegin(GL_LINES);
996  glVertex2f(0, 0);
997  glVertex2f(0, r1/mmax/2.);
998  glEnd();
999  glBegin(GL_LINES);
1000  glVertex2f(.4, 0);
1001  glVertex2f(.4, r2/mmax/2.);
1002  glEnd();
1003  glBegin(GL_LINES);
1004  glVertex2f(-.4, 0);
1005  glVertex2f(-.4, r3/mmax/2.);
1006  glEnd();
1007  }
1008  */
1009  glTranslated(0, MIN2(getVType().getLength() / 2, double(5)), -getType()); // drawing name at GLO_MAX fails unless translating z
1010  glRotated(-degAngle, 0, 0, 1);
1011  glScaled(1 / upscale, 1 / upscale, 1);
1012  drawName(Position(0, 0), s.scale,
1013  getVType().getGuiShape() == SVS_PEDESTRIAN ? s.personName : s.vehicleName);
1014  if (s.vehicleName.show && myVehicle.getParameter().line != "") {
1015  glTranslated(0, 0.6 * s.vehicleName.size / s.scale, 0);
1018  }
1019  glPopMatrix();
1020  glPopName();
1022 }
1023 
1024 
1025 void
1027  drawOnPos(s, getPosition(), getAngle());
1028 }
1029 
1030 
1031 void
1033  if (!myVehicle.isOnRoad()) {
1034  drawGL(s);
1035  }
1036  glPushName(getGlID());
1037  glPushMatrix();
1038  glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
1040  drawBestLanes();
1041  }
1043  drawRoute(s, 0, 0.25);
1044  }
1046  if (myVehicle.getNumberReroutes() > 0) {
1047  const int noReroutePlus1 = myVehicle.getNumberReroutes() + 1;
1048  for (int i = noReroutePlus1 - 1; i >= 0; i--) {
1049  double darken = double(0.4) / double(noReroutePlus1) * double(i);
1050  drawRoute(s, i, darken);
1051  }
1052  } else {
1053  drawRoute(s, 0, 0.25);
1054  }
1055  }
1058  }
1059  glPopMatrix();
1060  glPopName();
1061 }
1062 
1063 
1064 void
1065 GUIBaseVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate) {
1066  glTranslated(pos.x(), pos.y(), -.1);
1068  std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
1069  GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
1070  glTranslated(-pos.x(), -pos.y(), .1);
1071 }
1072 
1073 
1074 void
1076  const GUIColorer& c = s.vehicleColorer;
1077  if (!setFunctionalColor(c.getActive(), &myVehicle)) {
1079  }
1080 }
1081 
1082 
1083 bool
1084 GUIBaseVehicle::setFunctionalColor(int activeScheme, const MSBaseVehicle* veh) {
1085  switch (activeScheme) {
1086  case 0: {
1087  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1089  return true;
1090  }
1093  return true;
1094  }
1095  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1097  return true;
1098  }
1099  return false;
1100  }
1101  case 2: {
1102  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1104  return true;
1105  }
1106  return false;
1107  }
1108  case 3: {
1111  return true;
1112  }
1113  return false;
1114  }
1115  case 4: {
1116  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1118  return true;
1119  }
1120  return false;
1121  }
1122  case 5: {
1123  Position p = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1124  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1125  Position center = b.getCenter();
1126  double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
1127  double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1128  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1129  return true;
1130  }
1131  case 6: {
1132  Position p = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1133  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1134  Position center = b.getCenter();
1135  double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
1136  double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1137  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1138  return true;
1139  }
1140  case 7: {
1141  Position pb = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1142  Position pe = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1143  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1144  double hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / M_PI;
1145  Position minp(b.xmin(), b.ymin());
1146  Position maxp(b.xmax(), b.ymax());
1147  double sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1148  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1149  return true;
1150  }
1151  case 28: { // color randomly (by pointer)
1152  const double hue = (long)veh % 360; // [0-360]
1153  const double sat = (((long)veh / 360) % 67) / 100.0 + 0.33; // [0.33-1]
1154  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1155  return true;
1156  }
1157  }
1158  return false;
1159 }
1160 
1161 
1162 // ------------ Additional visualisations
1163 bool
1165  return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
1166 }
1167 
1168 
1169 void
1171  if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
1172  myAdditionalVisualizations[parent] = 0;
1173  }
1174  myAdditionalVisualizations[parent] |= which;
1175  parent->addAdditionalGLVisualisation(this);
1176 }
1177 
1178 
1179 void
1181  myAdditionalVisualizations[parent] &= ~which;
1182  parent->removeAdditionalGLVisualisation(this);
1183 }
1184 
1185 
1186 void
1187 GUIBaseVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, double darken) const {
1188  setColor(s);
1189  GLdouble colors[4];
1190  glGetDoublev(GL_CURRENT_COLOR, colors);
1191  colors[0] -= darken;
1192  if (colors[0] < 0) {
1193  colors[0] = 0;
1194  }
1195  colors[1] -= darken;
1196  if (colors[1] < 0) {
1197  colors[1] = 0;
1198  }
1199  colors[2] -= darken;
1200  if (colors[2] < 0) {
1201  colors[2] = 0;
1202  }
1203  colors[3] -= darken;
1204  if (colors[3] < 0) {
1205  colors[3] = 0;
1206  }
1207  glColor3dv(colors);
1208  const double exaggeration = s.vehicleSize.getExaggeration(s);
1209  if (routeNo == 0) {
1210  drawRouteHelper(myVehicle.getRoute(), exaggeration);
1211  return;
1212  }
1213  --routeNo; // only prior routes are stored
1214  const MSRoute* route = myRoutes->getRoute(routeNo);
1215  if (route != 0) {
1216  drawRouteHelper(*route, exaggeration);
1217  }
1218 }
1219 
1220 
1221 const Position&
1222 GUIBaseVehicle::getSeatPosition(int personIndex) const {
1224  return mySeatPositions[MIN2(personIndex, (int)mySeatPositions.size() - 1)];
1225 }
1226 
1227 
1228 /****************************************************************************/
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.
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.
void drawAction_drawVehicleAsBoxPlus() const
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:132
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:90
double getMinGap() const
Get the free space in front of vehicles of this class.
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.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
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.
double scale
information about a lane&#39;s width (temporary, used for a single view)
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, double length=-1) const
double vehiclePoly_PassengerVanRightGlass[]
double vehiclePoly_EmergencyLadder4[]
MoveReminderCont myMoveReminders
Currently relevant move reminders.
void drawOnPos(const GUIVisualizationSettings &s, const Position &pos, const double angle) const
Draws the object on the specified position with the specified angle.
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.
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:120
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
Show all vehicle&#39;s routes.
Definition: GUIAppEnum.h:269
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.
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:302
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 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.
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:144
double x() const
Returns the x-position.
Definition: Position.h:63
Stores the information about how to visualize structures.
render as a transport vehicle
render as a flexible city bus
Start to track a vehicle.
Definition: GUIAppEnum.h:273
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
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
MSDevice_Vehroutes * myRoutes
GUIVisualizationTextSettings vehicleName
double vehiclePoly_EVehicleBody[]
double vehiclePoly_PassengerFrontGlass[]
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
static double getRange()
Returns the configured range.
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:169
const MSRoute & getRoute() const
Returns the current route.
render as a delivery vehicle
double vehiclePoly_Emergency[]
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[]
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
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[]
void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
virtual void stopTrack()
stop track
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:339
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.
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.
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[]
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
double vehiclePoly_PassengerCarBody[]
virtual void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
virtual void startTrack(int)
star track
static const RGBColor GREEN
Definition: RGBColor.h:180
static const RGBColor GREY
Definition: RGBColor.h:188
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
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:438
render as a hatchback passenger vehicle ("Fliessheck")
virtual void drawBestLanes() const
Draws the vehicle&#39;s best lanes.
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.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:192
not defined
render as a bicycle
Hide all vehicle&#39;s routes.
Definition: GUIAppEnum.h:271
long onCmdHideBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle&#39;s best lanes shall be hidden.
double vehiclePoly_EmergencyLadder6[]
double y() const
Returns the y-position.
Definition: Position.h:68
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
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:128
const T getColor(const double value) const
render as a (city) rail without locomotive
T MIN2(T a, T b)
Definition: StdDefs.h:68
static void drawOutlineCircle(double width, double iwidth, int steps=8)
Draws an unfilled circle around (0,0)
Definition: GLHelper.cpp:370
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:157
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:302
render as a van
double vehiclePoly_PassengerHatchbackRightGlass[]
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
render as a passenger vehicle
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double vehiclePoly_TransportBody[]
render as a police car
const int VEHPARS_COLOR_SET
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:240
std::string line
The vehicle&#39;s line (mainly for public transport)
SUMOVehicleShape getGuiShape() const
Get this vehicle type&#39;s shape.
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
render as a fire brigade
void unlock()
release mutex lock
Definition: MFXMutex.cpp:94
double vehiclePoly_PassengerHatchbackBackGlass[]
GUIBaseVehicle(MSBaseVehicle &vehicle)
render as a giant ant
double getLength() const
Get vehicle&#39;s length [m].
render as a pedestrian
render as a moped
double vehiclePoly_PassengerCarBodyFront[]
Stop to track a vehicle.
Definition: GUIAppEnum.h:275
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
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into, int maxRoutes=std::numeric_limits< int >::max())
Build devices for the given vehicle, if needed.
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
virtual double getColorValue(int activeScheme) const =0
gets the color value according to the current scheme index
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.
Hide vehicle&#39;s current route.
Definition: GUIAppEnum.h:263
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &) const
#define M_PI
Definition: odrSpiral.cpp:40
double vehiclePoly_EmergencyLadder5[]
double vehiclePoly_EVehicleBackGlass[]
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:126
long onCmdShowCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
double vehiclePoly_EmergencySign[]
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
The popup menu of a globject.
virtual void drawRouteHelper(const MSRoute &r, double exaggeration) const =0
Draws the route.
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)
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:138
void lock()
lock mutex
Definition: MFXMutex.cpp:84
Show vehicle&#39;s current route.
Definition: GUIAppEnum.h:261
double vehiclePoly_TransportFrontGlass[]
const RGBColor & getColor() const
Returns this type&#39;s color.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
double vehiclePoly_PassengerWagonBackGlass[]
render as an emergency vehicle
render as a (futuristic) e-vehicle
double vehiclePoly_DeliveryMediumRightGlass[]
const RGBColor & getColor() const
Returns the color.
Definition: MSRoute.cpp:347
std::string getImgFile() const
Get this vehicle type&#39;s raster model file name.
GUIVisualizationSizeSettings vehicleSize
long long int SUMOTime
Definition: TraCIDefs.h:52
empty max
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
virtual double getAngle() const =0
Returns the vehicle&#39;s direction in radians.
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:455
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:86
FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[]
virtual void drawAction_drawVehicleBlueLight() const
Hide vehicle&#39;s best lanes.
Definition: GUIAppEnum.h:267
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")
select foes of a vehicle
Definition: GUIAppEnum.h:277
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.
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
virtual void drawAction_drawVehicleBlinker(double) const
render as a semi-trailer transport vehicle ("Sattelschlepper")
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[]
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
render as a trolley bus
double vehiclePoly_EmergencyLadder2[]
const MSRoute * getRoute(int index) const
Called on route retrieval.
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:444