SUMO - Simulation of Urban MObility
GUIBaseVehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A MSVehicle extended by some values for usage within the gui
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <cmath>
33 #include <vector>
34 #include <string>
36 #include <utils/geom/GeomHelper.h>
44 #include <utils/gui/div/GLHelper.h>
47 #include <microsim/MSVehicle.h>
48 #include <microsim/MSLane.h>
56 #include <gui/GUIGlobals.h>
57 #include "GUIBaseVehicle.h"
58 #include "GUIPerson.h"
59 #include "GUIContainer.h"
60 #include "GUINet.h"
61 #include "GUIEdge.h"
62 #include "GUILane.h"
63 
64 
65 // ===========================================================================
66 // FOX callback mapping
67 // ===========================================================================
68 FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[] = {
80 };
81 
82 // Object implementation
83 FXIMPLEMENT(GUIBaseVehicle::GUIBaseVehiclePopupMenu, GUIGLObjectPopupMenu, GUIBaseVehiclePopupMenuMap, ARRAYNUMBER(GUIBaseVehiclePopupMenuMap))
84 
85 
86 
87 // ===========================================================================
88 // data definitions
89 // ===========================================================================
90 /* -------------------------------------------------------------------------
91  * drawed shapes
92  * ----------------------------------------------------------------------- */
93 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 };
94 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 };
95 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 };
96 double vehiclePoly_PassengerSedanRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.77, -.47, 0.67, -.37, 0.45, -.37, 0.34, -.47, -10000 };
97 double vehiclePoly_PassengerSedanLeftGlass[] = { 0.36, .43, 0.34, .47, 0.77, .47, 0.67, .37, 0.45, .37, 0.34, .47, -10000 };
98 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 };
99 double vehiclePoly_PassengerHatchbackRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.80, -.37, 0.45, -.37, 0.34, -.47, -10000 };
100 double vehiclePoly_PassengerHatchbackLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.80, .37, 0.45, .37, 0.34, .47, -10000 };
101 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 };
102 double vehiclePoly_PassengerWagonRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.87, -.37, 0.45, -.37, 0.34, -.47, -10000 };
103 double vehiclePoly_PassengerWagonLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.87, .37, 0.45, .37, 0.34, .47, -10000 };
104 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 };
105 
106 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 };
107 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 };
108 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 };
109 double vehiclePoly_PassengerVanRightGlass[] = { 0.36, -.43, 0.20, -.47, 0.98, -.47, 0.91, -.37, 0.31, -.37, 0.20, -.47, -10000 };
110 double vehiclePoly_PassengerVanLeftGlass[] = { 0.36, .43, 0.20, .47, 0.98, .47, 0.91, .37, 0.31, .37, 0.20, .47, -10000 };
111 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 };
112 
113 double vehiclePoly_DeliveryMediumRightGlass[] = { 0.21, -.43, 0.20, -.47, 0.38, -.47, 0.38, -.37, 0.31, -.37, 0.20, -.47, -10000 };
114 double vehiclePoly_DeliveryMediumLeftGlass[] = { 0.21, .43, 0.20, .47, 0.38, .47, 0.38, .37, 0.31, .37, 0.20, .47, -10000 };
115 
116 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 };
117 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 };
118 double vehiclePoly_TransportRightGlass[] = { 0.36, -.47, 0.10, -.48, 1.25, -.48, 1.25, -.4, 0.3, -.4, 0.10, -.48, -10000 };
119 double vehiclePoly_TransportLeftGlass[] = { 0.36, .47, 0.10, .48, 1.25, .48, 1.25, .4, 0.3, .4, 0.10, .48, -10000 };
120 
121 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 };
122 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 };
123 //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 };
124 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 };
125 
126 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 };
127 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 };
128 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 };
129 
130 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 };
131 
132 double vehiclePoly_EmergencySign[] = { .2, .5, -.2, .5, -.2, -.5, .2, -.5, -10000 };
133 double vehiclePoly_Emergency[] = { .1, .1, -.1, .1, -.1, -.1, .1, -.1, -10000 };
134 double vehiclePoly_Emergency2[] = { .04, .3, -.04, .3, -.04, -.3, .04, -.3, -10000 };
135 
136 double vehiclePoly_EmergencyLadder[] = { -.5, .3, .5, .3, .5, .2, -.5, .2, -10000 };
137 double vehiclePoly_EmergencyLadder2[] = { -.5, -.3, .5, -.3, .5, -.2, -.5, -.2, -10000 };
138 double vehiclePoly_EmergencyLadder3[] = { -.45, .3, -.4, .3, -.4, -.3, -.45, -.3, -10000 };
139 double vehiclePoly_EmergencyLadder4[] = { .45, .3, .4, .3, .4, -.3, .45, -.3, -10000 };
140 double vehiclePoly_EmergencyLadder5[] = { .05, .3, .0, .3, .0, -.3, .05, -.3, -10000 };
141 double vehiclePoly_EmergencyLadder6[] = { -.25, .3, -.2, .3, -.2, -.3, -.25, -.3, -10000 };
142 double vehiclePoly_EmergencyLadder7[] = { .25, .3, .2, .3, .2, -.3, .25, -.3, -10000 };
143 // ===========================================================================
144 // method definitions
145 // ===========================================================================
146 /* -------------------------------------------------------------------------
147  * GUIBaseVehicle::GUIBaseVehiclePopupMenu - methods
148  * ----------------------------------------------------------------------- */
150  GUIMainWindow& app, GUISUMOAbstractView& parent,
151  GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations)
152  : GUIGLObjectPopupMenu(app, parent, o), myVehiclesAdditionalVisualizations(additionalVisualizations) {
153 }
154 
155 
157 
158 
159 long
161  assert(myObject->getType() == GLO_VEHICLE);
162  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES)) {
164  }
165  return 1;
166 }
167 
168 long
170  assert(myObject->getType() == GLO_VEHICLE);
172  return 1;
173 }
174 
175 
176 long
178  assert(myObject->getType() == GLO_VEHICLE);
179  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ROUTE)) {
181  }
182  return 1;
183 }
184 
185 long
187  assert(myObject->getType() == GLO_VEHICLE);
189  return 1;
190 }
191 
192 
193 long
195  assert(myObject->getType() == GLO_VEHICLE);
196  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES)) {
198  }
199  return 1;
200 }
201 
202 long
204  assert(myObject->getType() == GLO_VEHICLE);
206  return 1;
207 }
208 
209 
210 long
212  assert(myObject->getType() == GLO_VEHICLE);
213  if (myParent->getTrackedID() != static_cast<GUIBaseVehicle*>(myObject)->getGlID()) {
214  myParent->startTrack(static_cast<GUIBaseVehicle*>(myObject)->getGlID());
215  }
216  return 1;
217 }
218 
219 long
221  assert(myObject->getType() == GLO_VEHICLE);
222  myParent->stopTrack();
223  return 1;
224 }
225 
226 
227 long
229  assert(myObject->getType() == GLO_VEHICLE);
230  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS)) {
232  }
233  return 1;
234 }
235 
236 long
238  assert(myObject->getType() == GLO_VEHICLE);
240  return 1;
241 }
242 
243 long
245  assert(myObject->getType() == GLO_VEHICLE);
246  static_cast<GUIBaseVehicle*>(myObject)->selectBlockingFoes();
247  myParent->update();
248  return 1;
249 }
250 
251 
252 /* -------------------------------------------------------------------------
253  * GUIBaseVehicle - methods
254  * ----------------------------------------------------------------------- */
255 
257  GUIGlObject(GLO_VEHICLE, vehicle.getID()),
258  myVehicle(vehicle) {
259  // as it is possible to show all vehicle routes, we have to store them... (bug [ 2519761 ])
261  myVehicle.myMoveReminders.push_back(std::make_pair(myRoutes, 0.));
262  mySeatPositions.push_back(Position(0, 0)); // ensure length 1
263 }
264 
265 
267  myLock.lock();
268  for (std::map<GUISUMOAbstractView*, int>::iterator i = myAdditionalVisualizations.begin(); i != myAdditionalVisualizations.end(); ++i) {
269  if (i->first->getTrackedID() == getGlID()) {
270  i->first->stopTrack();
271  }
272  while (i->first->removeAdditionalGLVisualisation(this));
273  }
274  myLock.unlock();
276  delete myRoutes;
277 }
278 
279 
282  GUISUMOAbstractView& parent) {
284  buildPopupHeader(ret, app);
288  //
290  new FXMenuCommand(ret, "Hide Current Route", 0, ret, MID_HIDE_CURRENTROUTE);
291  } else {
292  new FXMenuCommand(ret, "Show Current Route", 0, ret, MID_SHOW_CURRENTROUTE);
293  }
295  new FXMenuCommand(ret, "Hide All Routes", 0, ret, MID_HIDE_ALLROUTES);
296  } else {
297  new FXMenuCommand(ret, "Show All Routes", 0, ret, MID_SHOW_ALLROUTES);
298  }
300  new FXMenuCommand(ret, "Hide Best Lanes", 0, ret, MID_HIDE_BEST_LANES);
301  } else {
302  new FXMenuCommand(ret, "Show Best Lanes", 0, ret, MID_SHOW_BEST_LANES);
303  }
305  new FXMenuCommand(ret, "Hide Link Items", 0, ret, MID_HIDE_LFLINKITEMS);
306  } else {
307  new FXMenuCommand(ret, "Show Link Items", 0, ret, MID_SHOW_LFLINKITEMS);
308  }
309  new FXMenuSeparator(ret);
310  if (parent.getTrackedID() != getGlID()) {
311  new FXMenuCommand(ret, "Start Tracking", 0, ret, MID_START_TRACK);
312  } else {
313  new FXMenuCommand(ret, "Stop Tracking", 0, ret, MID_STOP_TRACK);
314  }
315  new FXMenuCommand(ret, "Select Foes", 0, ret, MID_SHOW_FOES);
316 
317  new FXMenuSeparator(ret);
318  //
319  buildShowParamsPopupEntry(ret, false);
321  buildPositionCopyEntry(ret, false);
322  return ret;
323 }
324 
325 
326 Boundary
328  Boundary b;
329  b.add(getPosition());
331  return b;
332 }
333 
334 
335 void
337  glPushMatrix();
338  glScaled(getVType().getWidth(), getVType().getLength(), 1.);
339  glBegin(GL_TRIANGLE_STRIP);
340  glVertex2d(0., 0.);
341  glVertex2d(-.5, .15);
342  glVertex2d(.5, .15);
343  glVertex2d(-.5, 1.);
344  glVertex2d(.5, 1.);
345  glEnd();
346  glPopMatrix();
347 }
348 
349 
350 void
352  const double length = getVType().getLength();
353  if (length >= 8.) {
355  return;
356  }
357  glPushMatrix();
358  glScaled(getVType().getWidth(), length, 1.);
359  glBegin(GL_TRIANGLES);
360  glVertex2d(0., 0.);
361  glVertex2d(-.5, 1.);
362  glVertex2d(.5, 1.);
363  glEnd();
364  glPopMatrix();
365 }
366 
367 
368 void
369 GUIBaseVehicle::drawPoly(double* poses, double offset) {
370  glPushMatrix();
371  glTranslated(0, 0, offset * .1);
372  glPolygonOffset(0, (GLfloat) - offset);
373  glBegin(GL_TRIANGLE_FAN);
374  int i = 0;
375  while (poses[i] > -999) {
376  glVertex2d(poses[i], poses[i + 1]);
377  i = i + 2;
378  }
379  glEnd();
380  glPopMatrix();
381 }
382 
383 
384 bool
386  RGBColor current = GLHelper::getColor();
387  RGBColor lighter = current.changedBrightness(51);
388  RGBColor darker = current.changedBrightness(-51);
389 
390  const double length = getVType().getLength();
391  const double width = getVType().getWidth();
392  glPushMatrix();
393  glRotated(90, 0, 0, 1);
394  glScaled(length, width, 1.);
396  bool drawCarriages = false;
397 
398  // draw main body
399  switch (shape) {
400  case SVS_UNKNOWN:
402  GLHelper::setColor(lighter);
403  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
404  glColor3d(0, 0, 0);
405  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
406  break;
407  case SVS_PEDESTRIAN:
408  glTranslated(0, 0, .045);
410  glTranslated(0, 0, -.045);
411  glScaled(.7, 2, 1);
412  glTranslated(0, 0, .04);
413  GLHelper::setColor(lighter);
415  glTranslated(0, 0, -.04);
416  break;
417  case SVS_BICYCLE:
418  case SVS_MOPED:
419  case SVS_MOTORCYCLE: {
420  RGBColor darker = current.changedBrightness(-50);
421  // body
422  drawPoly(vehiclePoly_Cyclist, 4);
423  // head
424  glPushMatrix();
425  glTranslated(0.4, 0, .5);
426  glScaled(0.1, 0.2, 1);
427  GLHelper::setColor(darker);
429  glPopMatrix();
430  // bike frame
432  glPushMatrix();
433  glTranslated(0.5, 0, .3);
434  glScaled(0.5, 0.05, 1);
436  glPopMatrix();
437  // handle bar
438  glPushMatrix();
439  glTranslated(0.25, 0, .3);
440  glScaled(0.02, 0.5, 1);
442  glPopMatrix();
443  }
444  break;
445  case SVS_PASSENGER:
446  case SVS_PASSENGER_SEDAN:
448  case SVS_PASSENGER_WAGON:
450  GLHelper::setColor(lighter);
451  drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
452  glColor3d(0, 0, 0);
453  drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
454  break;
455  case SVS_PASSENGER_VAN:
456  drawPoly(vehiclePoly_PassengerVanBody, 4);
457  GLHelper::setColor(lighter);
458  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
459  glColor3d(0, 0, 0);
460  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
461  drawPoly(vehiclePoly_PassengerVanRightGlass, 4.5);
462  drawPoly(vehiclePoly_PassengerVanLeftGlass, 4.5);
463  drawPoly(vehiclePoly_PassengerVanBackGlass, 4.5);
464  break;
465  case SVS_DELIVERY:
466  drawPoly(vehiclePoly_PassengerVanBody, 4);
467  GLHelper::setColor(lighter);
468  drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
469  glColor3d(0, 0, 0);
470  drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
471  drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
472  drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
473  break;
474  case SVS_TRUCK:
476  case SVS_TRUCK_1TRAILER:
477  glScaled(1. / (length), 1, 1.);
478  drawPoly(vehiclePoly_TransportBody, 4);
479  glColor3d(0, 0, 0);
480  drawPoly(vehiclePoly_TransportFrontGlass, 4.5);
481  drawPoly(vehiclePoly_TransportRightGlass, 4.5);
482  drawPoly(vehiclePoly_TransportLeftGlass, 4.5);
483  break;
484  case SVS_BUS:
485  case SVS_BUS_COACH:
486  case SVS_BUS_TROLLEY: {
487  double ml = length;
488  glScaled(1. / (length), 1, 1.);
489  glTranslated(0, 0, .04);
490  glBegin(GL_TRIANGLE_FAN);
491  glVertex2d(ml / 2., 0);
492  glVertex2d(0, 0);
493  glVertex2d(0, -.45);
494  glVertex2d(0 + .05, -.5);
495  glVertex2d(ml - .05, -.5);
496  glVertex2d(ml, -.45);
497  glVertex2d(ml, .45);
498  glVertex2d(ml - .05, .5);
499  glVertex2d(0 + .05, .5);
500  glVertex2d(0, .45);
501  glVertex2d(0, 0);
502  glEnd();
503  glTranslated(0, 0, -.04);
504 
505  glTranslated(0, 0, .045);
506  glColor3d(0, 0, 0);
507  glBegin(GL_QUADS);
508  glVertex2d(0 + .05, .48);
509  glVertex2d(0 + .05, -.48);
510  glVertex2d(0 + .15, -.48);
511  glVertex2d(0 + .15, .48);
512 
513  glVertex2d(ml - .1, .45);
514  glVertex2d(ml - .1, -.45);
515  glVertex2d(ml - .05, -.45);
516  glVertex2d(ml - .05, .45);
517 
518  glVertex2d(0 + .20, .49);
519  glVertex2d(0 + .20, .45);
520  glVertex2d(ml - .20, .45);
521  glVertex2d(ml - .20, .49);
522 
523  glVertex2d(0 + .20, -.49);
524  glVertex2d(0 + .20, -.45);
525  glVertex2d(ml - .20, -.45);
526  glVertex2d(ml - .20, -.49);
527 
528  glEnd();
529  glTranslated(0, 0, -.045);
530  }
531  break;
532  case SVS_BUS_FLEXIBLE:
533  case SVS_RAIL:
534  case SVS_RAIL_CAR:
535  case SVS_RAIL_CARGO:
536  drawAction_drawCarriageClass(s, shape, false);
537  drawCarriages = true;
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  return drawCarriages;
844 }
845 
846 
847 bool
849  const std::string& file = getVType().getImgFile();
850  if (file != "") {
851  int textureID = GUITexturesHelper::getTextureID(file);
852  if (textureID > 0) {
853  const double exaggeration = s.vehicleSize.getExaggeration(s);
854  if (length < 0) {
855  length = getVType().getLength() * exaggeration;
856  }
857  const double halfWidth = getVType().getWidth() / 2.0 * exaggeration;
858  GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, 0, halfWidth, length);
859  return true;
860  }
861  }
862  return false;
863 }
864 
865 
866 void
867 GUIBaseVehicle::drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const double angle) const {
868  glPushName(getGlID());
869  glPushMatrix();
870  Position p1 = pos;
871  const double degAngle = RAD2DEG(angle + M_PI / 2.);
872  // one seat in the center of the vehicle by default
873  if (myVehicle.getLane() != 0) {
874  mySeatPositions[0] = myVehicle.getPosition(- getVType().getLength() / 2);
875  } else {
876  mySeatPositions[0] = p1;
877  }
878  glTranslated(p1.x(), p1.y(), getType());
879  glRotated(degAngle, 0, 0, 1);
880  // set lane color
881  setColor(s);
882  // scale
883  const double upscale = s.vehicleSize.getExaggeration(s);
884  glScaled(upscale, upscale, 1);
885  /*
886  MSLCM_DK2004 &m2 = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
887  if((m2.getState()&LCA_URGENT)!=0) {
888  glColor3d(1, .4, .4);
889  } else if((m2.getState()&LCA_SPEEDGAIN)!=0) {
890  glColor3d(.4, .4, 1);
891  } else {
892  glColor3d(.4, 1, .4);
893  }
894  */
895  // draw the vehicle
896  bool drawCarriages = false;
897  switch (s.vehicleQuality) {
898  case 0:
900  break;
901  case 1:
903  break;
904  case 2:
905  drawCarriages = drawAction_drawVehicleAsPoly(s);
906  // draw flashing blue light for emergency vehicles
907  if (getVType().getGuiShape() == SVS_EMERGENCY) {
908  glTranslated(0, 0, .1);
910  }
911  break;
912  case 3:
913  default:
914  // draw as image but take special care for drawing trains
915  // fallback to simple shapes
916  glPushMatrix(); // drawAction_drawRailCarriages assumes matrix stack depth of 2
917  if (!drawAction_drawCarriageClass(s, getVType().getGuiShape(), true)) {
919  drawCarriages = drawAction_drawVehicleAsPoly(s);
920  };
921  }
922  glPopMatrix();
923  break;
924  }
925  if (s.drawMinGap) {
926  const double minGap = -getVType().getMinGap();
927  glColor3d(0., 1., 0.);
928  glBegin(GL_LINES);
929  glVertex2d(0., 0);
930  glVertex2d(0., minGap);
931  glVertex2d(-.5, minGap);
932  glVertex2d(.5, minGap);
933  glEnd();
934  }
936  if (dev != 0 && s.showBTRange) {
937  glColor3d(1., 0., 0.);
938  GLHelper::drawOutlineCircle(dev->getRange(), dev->getRange() - .2, 32);
939  }
940  // draw the blinker and brakelights if wished
941  if (s.showBlinker) {
942  glTranslated(0, 0, .1);
943  switch (getVType().getGuiShape()) {
944  case SVS_PEDESTRIAN:
945  case SVS_BICYCLE:
946  case SVS_ANT:
947  case SVS_SHIP:
948  case SVS_RAIL:
949  case SVS_RAIL_CARGO:
950  case SVS_RAIL_CAR:
951  break;
952  case SVS_MOTORCYCLE:
953  case SVS_MOPED:
955  drawAction_drawVehicleBrakeLight(getVType().getLength(), true);
956  break;
957  default:
958  // only SVS_RAIL_CAR has blinkers and brake lights but they are drawn along with the carriages
959  if (!drawCarriages) {
962  }
963  break;
964  }
965  }
966  // draw the wish to change the lane
967  if (s.drawLaneChangePreference) {
968  /*
969  if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
970  MSLCM_DK2004 &m = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
971  glColor3d(.5, .5, 1);
972  glBegin(GL_LINES);
973  glVertex2f(0, 0);
974  glVertex2f(m.getChangeProbability(), .5);
975  glEnd();
976 
977  glColor3d(1, 0, 0);
978  glBegin(GL_LINES);
979  glVertex2f(0.1, 0);
980  glVertex2f(0.1, m.myMaxJam1);
981  glEnd();
982 
983  glColor3d(0, 1, 0);
984  glBegin(GL_LINES);
985  glVertex2f(-0.1, 0);
986  glVertex2f(-0.1, m.myTDist);
987  glEnd();
988  }
989  */
990  }
991  // draw best lanes
992  /*
993  if (true) {
994  const MSLane &l = veh->getLane();
995  double r1 = veh->allowedContinuationsLength(&l, 0);
996  double r2 = l.getLeftLane()!=0 ? veh->allowedContinuationsLength(l.getLeftLane(), 0) : 0;
997  double r3 = l.getRightLane()!=0 ? veh->allowedContinuationsLength(l.getRightLane(), 0) : 0;
998  double mmax = MAX3(r1, r2, r3);
999  glBegin(GL_LINES);
1000  glVertex2f(0, 0);
1001  glVertex2f(0, r1/mmax/2.);
1002  glEnd();
1003  glBegin(GL_LINES);
1004  glVertex2f(.4, 0);
1005  glVertex2f(.4, r2/mmax/2.);
1006  glEnd();
1007  glBegin(GL_LINES);
1008  glVertex2f(-.4, 0);
1009  glVertex2f(-.4, r3/mmax/2.);
1010  glEnd();
1011  }
1012  */
1013  glTranslated(0, MIN2(getVType().getLength() / 2, double(5)), -getType()); // drawing name at GLO_MAX fails unless translating z
1014  glRotated(-degAngle, 0, 0, 1);
1015  glScaled(1 / upscale, 1 / upscale, 1);
1016  drawName(Position(0, 0), s.scale,
1017  getVType().getGuiShape() == SVS_PEDESTRIAN ? s.personName : s.vehicleName);
1018  if (s.vehicleName.show && myVehicle.getParameter().line != "") {
1019  glTranslated(0, 0.6 * s.vehicleName.size / s.scale, 0);
1022  }
1023  glPopMatrix();
1024  glPopName();
1026 }
1027 
1028 
1029 void
1031  drawOnPos(s, getPosition(), getAngle());
1032 }
1033 
1034 
1035 void
1037  if (!myVehicle.isOnRoad()) {
1038  drawGL(s);
1039  }
1040  glPushName(getGlID());
1041  glPushMatrix();
1042  glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
1044  drawBestLanes();
1045  }
1047  drawRoute(s, 0, 0.25);
1048  }
1050  if (myVehicle.getNumberReroutes() > 0) {
1051  const int noReroutePlus1 = myVehicle.getNumberReroutes() + 1;
1052  for (int i = noReroutePlus1 - 1; i >= 0; i--) {
1053  double darken = double(0.4) / double(noReroutePlus1) * double(i);
1054  drawRoute(s, i, darken);
1055  }
1056  } else {
1057  drawRoute(s, 0, 0.25);
1058  }
1059  }
1062  }
1063  glPopMatrix();
1064  glPopName();
1065 }
1066 
1067 
1068 void
1069 GUIBaseVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate) {
1070  glTranslated(pos.x(), pos.y(), -.1);
1072  std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
1073  GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
1074  glTranslated(-pos.x(), -pos.y(), .1);
1075 }
1076 
1077 
1078 void
1080  const GUIColorer& c = s.vehicleColorer;
1081  if (!setFunctionalColor(c.getActive(), &myVehicle)) {
1083  }
1084 }
1085 
1086 
1087 bool
1088 GUIBaseVehicle::setFunctionalColor(int activeScheme, const MSBaseVehicle* veh) {
1089  switch (activeScheme) {
1090  case 0: {
1091  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1093  return true;
1094  }
1097  return true;
1098  }
1099  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1101  return true;
1102  }
1103  return false;
1104  }
1105  case 2: {
1106  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
1108  return true;
1109  }
1110  return false;
1111  }
1112  case 3: {
1115  return true;
1116  }
1117  return false;
1118  }
1119  case 4: {
1120  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
1122  return true;
1123  }
1124  return false;
1125  }
1126  case 5: {
1127  Position p = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1128  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1129  Position center = b.getCenter();
1130  double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
1131  double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1132  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1133  return true;
1134  }
1135  case 6: {
1136  Position p = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1137  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1138  Position center = b.getCenter();
1139  double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
1140  double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1141  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1142  return true;
1143  }
1144  case 7: {
1145  Position pb = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
1146  Position pe = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
1147  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
1148  double hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / M_PI;
1149  Position minp(b.xmin(), b.ymin());
1150  Position maxp(b.xmax(), b.ymax());
1151  double sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1152  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1153  return true;
1154  }
1155  case 29: { // color randomly (by pointer)
1156  const double hue = (long)veh % 360; // [0-360]
1157  const double sat = (((long)veh / 360) % 67) / 100.0 + 0.33; // [0.33-1]
1158  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1159  return true;
1160  }
1161  }
1162  return false;
1163 }
1164 
1165 
1166 // ------------ Additional visualisations
1167 bool
1169  return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
1170 }
1171 
1172 
1173 void
1175  if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
1176  myAdditionalVisualizations[parent] = 0;
1177  }
1178  myAdditionalVisualizations[parent] |= which;
1179  parent->addAdditionalGLVisualisation(this);
1180 }
1181 
1182 
1183 void
1185  myAdditionalVisualizations[parent] &= ~which;
1186  parent->removeAdditionalGLVisualisation(this);
1187 }
1188 
1189 
1190 void
1191 GUIBaseVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, double darken) const {
1192  setColor(s);
1193  GLdouble colors[4];
1194  glGetDoublev(GL_CURRENT_COLOR, colors);
1195  colors[0] -= darken;
1196  if (colors[0] < 0) {
1197  colors[0] = 0;
1198  }
1199  colors[1] -= darken;
1200  if (colors[1] < 0) {
1201  colors[1] = 0;
1202  }
1203  colors[2] -= darken;
1204  if (colors[2] < 0) {
1205  colors[2] = 0;
1206  }
1207  colors[3] -= darken;
1208  if (colors[3] < 0) {
1209  colors[3] = 0;
1210  }
1211  glColor3dv(colors);
1212  if (routeNo == 0) {
1214  return;
1215  }
1216  --routeNo; // only prior routes are stored
1217  const MSRoute* route = myRoutes->getRoute(routeNo);
1218  if (route != 0) {
1219  drawRouteHelper(s, *route);
1220  }
1221 }
1222 
1223 
1224 const Position&
1225 GUIBaseVehicle::getSeatPosition(int personIndex) const {
1227  return mySeatPositions[MIN2(personIndex, (int)mySeatPositions.size() - 1)];
1228 }
1229 
1230 
1231 /****************************************************************************/
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:137
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:131
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:156
double vehiclePoly_PassengerVanRightGlass[]
double vehiclePoly_EmergencyLadder4[]
MoveReminderCont myMoveReminders
Currently relevant move reminders.
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:127
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
GUIVisualizationTextSettings personName
Show vehicle&#39;s current route.
Definition: GUIAppEnum.h:258
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:301
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:67
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:62
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:357
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
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, int align=0, double width=-1)
Definition: GLHelper.cpp:487
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
render as a delivery vehicle
Hide vehicle&#39;s current route.
Definition: GUIAppEnum.h:260
double vehiclePoly_Emergency[]
const MSRoute & getRoute() const
Returns the current route.
Start to track a vehicle.
Definition: GUIAppEnum.h:270
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:45
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate)
double vehiclePoly_PassengerSedanBackGlass[]
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:55
virtual void drawRouteHelper(const GUIVisualizationSettings &s, const MSRoute &r) const =0
Draws the route.
double vehiclePoly_PassengerVanLeftGlass[]
virtual void stopTrack()
stop track
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:350
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.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
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:89
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:179
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &) const
static const RGBColor GREY
Definition: RGBColor.h:187
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.
bool drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s) const
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
long onCmdShowAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:449
render as a hatchback passenger vehicle ("Fliessheck")
render as a bus
double vehiclePoly_PassengerWagonRightGlass[]
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
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.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:191
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:64
virtual double getColorValue(int activeScheme) const =0
gets the color value according to the current scheme index
Hide vehicle&#39;s best lanes.
Definition: GUIAppEnum.h:264
void drawAction_drawVehicleAsTrianglePlus() const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
render as a (city) rail without locomotive
T MIN2(T a, T b)
Definition: StdDefs.h:67
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:125
static void drawOutlineCircle(double width, double iwidth, int steps=8)
Draws an unfilled circle around (0,0)
Definition: GLHelper.cpp:381
Hide all vehicle&#39;s routes.
Definition: GUIAppEnum.h:268
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:301
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
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.
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:93
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
Show vehicle&#39;s best lanes.
Definition: GUIAppEnum.h:262
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:88
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
#define M_PI
Definition: odrSpiral.cpp:40
double vehiclePoly_EmergencyLadder5[]
double vehiclePoly_EVehicleBackGlass[]
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
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.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
double getLength() const
Get vehicle&#39;s length [m].
void lock()
lock mutex
Definition: MFXMutex.cpp:83
double vehiclePoly_TransportFrontGlass[]
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.
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:119
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:239
GUIVisualizationSizeSettings vehicleSize
long long int SUMOTime
Definition: TraCIDefs.h:51
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:137
double vehiclePoly_TransportRightGlass[]
MSBaseVehicle & myVehicle
The vehicle to which all calls should be delegated.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:85
Stop to track a vehicle.
Definition: GUIAppEnum.h:272
FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[]
Show all vehicle&#39;s routes.
Definition: GUIAppEnum.h:266
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:143
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
select foes of a vehicle
Definition: GUIAppEnum.h:274
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:455