Eclipse 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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // A MSVehicle extended by some values for usage within the gui
22 /****************************************************************************/
23 #include <config.h>
24 
25 #include <cmath>
26 #include <vector>
27 #include <string>
28 #include <functional>
31 #include <utils/geom/GeomHelper.h>
39 #include <utils/gui/div/GLHelper.h>
42 #include <mesosim/MEVehicle.h>
43 #include <mesosim/MELoop.h>
44 #include <microsim/MSVehicle.h>
45 #include <microsim/MSLane.h>
54 #include <gui/GUIGlobals.h>
56 
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 //#define DRAW_BOUNDING_BOX
65 
66 // ===========================================================================
67 // FOX callback mapping
68 // ===========================================================================
69 FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[] = {
87 };
88 
89 // Object implementation
90 FXIMPLEMENT(GUIBaseVehicle::GUIBaseVehiclePopupMenu, GUIGLObjectPopupMenu, GUIBaseVehiclePopupMenuMap, ARRAYNUMBER(GUIBaseVehiclePopupMenuMap))
91 
92 // ===========================================================================
93 // method definitions
94 // ===========================================================================
95 /* -------------------------------------------------------------------------
96  * GUIBaseVehicle::GUIBaseVehiclePopupMenu - methods
97  * ----------------------------------------------------------------------- */
100  : GUIGLObjectPopupMenu(app, parent, o) {
101 }
102 
103 
105 
106 
107 long
109  assert(myObject->getType() == GLO_VEHICLE);
110  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES)) {
111  static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES);
112  }
113  return 1;
114 }
115 
116 long
118  assert(myObject->getType() == GLO_VEHICLE);
119  static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES);
120  return 1;
121 }
122 
123 
124 long
126  assert(myObject->getType() == GLO_VEHICLE);
127  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ROUTE)) {
128  static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_ROUTE);
129  }
130  return 1;
131 }
132 
133 long
135  assert(myObject->getType() == GLO_VEHICLE);
136  static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_ROUTE);
137  return 1;
138 }
139 
140 
141 long
143  assert(myObject->getType() == GLO_VEHICLE);
144  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_FUTURE_ROUTE)) {
145  static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_FUTURE_ROUTE);
146  }
147  return 1;
148 }
149 
150 long
152  assert(myObject->getType() == GLO_VEHICLE);
153  static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_FUTURE_ROUTE);
154  return 1;
155 }
156 
157 
158 long
160  assert(myObject->getType() == GLO_VEHICLE);
161  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ROUTE_NOLOOP)) {
162  static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_ROUTE_NOLOOP);
163  }
164  return 1;
165 }
166 
167 long
169  assert(myObject->getType() == GLO_VEHICLE);
170  static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_ROUTE_NOLOOP);
171  return 1;
172 }
173 
174 
175 long
177  assert(myObject->getType() == GLO_VEHICLE);
178  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES)) {
179  static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES);
180  }
181  return 1;
182 }
183 
184 long
186  assert(myObject->getType() == GLO_VEHICLE);
187  static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES);
188  return 1;
189 }
190 
191 
192 long
194  assert(myObject->getType() == GLO_VEHICLE);
195  if (myParent->getTrackedID() != static_cast<GUIBaseVehicle*>(myObject)->getGlID()) {
196  myParent->startTrack(static_cast<GUIBaseVehicle*>(myObject)->getGlID());
197  }
198  return 1;
199 }
200 
201 long
203  assert(myObject->getType() == GLO_VEHICLE);
204  myParent->stopTrack();
205  return 1;
206 }
207 
208 
209 long
211  assert(myObject->getType() == GLO_VEHICLE);
212  if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS)) {
213  static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS);
214  }
215  return 1;
216 }
217 
218 long
220  assert(myObject->getType() == GLO_VEHICLE);
221  static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS);
222  return 1;
223 }
224 
225 long
227  assert(myObject->getType() == GLO_VEHICLE);
228  static_cast<GUIBaseVehicle*>(myObject)->selectBlockingFoes();
229  myParent->update();
230  return 1;
231 }
232 
233 
234 long
236  GUIBaseVehicle* baseVeh = static_cast<GUIBaseVehicle*>(myObject);
237  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&baseVeh->myVehicle);
238  if (microVeh != nullptr) {
240  if (microVeh->getLane() != nullptr) {
241  MSLane* lane = microVeh->getMutableLane();
243  }
244  } else {
245  MEVehicle* mesoVeh = dynamic_cast<MEVehicle*>(&baseVeh->myVehicle);
247  }
249  myParent->update();
250  return 1;
251 }
252 
253 
254 long
256  GUIBaseVehicle* baseVeh = static_cast<GUIBaseVehicle*>(myObject);
257  MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&baseVeh->myVehicle);
258  if (microVeh != nullptr) {
259  if (microVeh->isStopped()) {
260  microVeh->resumeFromStopping();
261  } else {
262  std::string errorOut;
263  const double brakeGap = microVeh->getCarFollowModel().brakeGap(microVeh->getSpeed());
264  std::pair<const MSLane*, double> stopPos = microVeh->getLanePosAfterDist(brakeGap);
265  if (stopPos.first != nullptr) {
267  stop.lane = stopPos.first->getID();
268  stop.startPos = stopPos.second;
269  stop.endPos = stopPos.second + POSITION_EPS;
270  stop.duration = TIME2STEPS(3600);
271  microVeh->addTraciStop(stop, errorOut);
272  if (errorOut != "") {
273  WRITE_WARNING(errorOut);
274  }
275  }
276  }
277  } else {
278  WRITE_WARNING("GUI-triggered stop not implemented for meso");
279  }
280  myParent->update();
281  return 1;
282 }
283 
284 
285 /* -------------------------------------------------------------------------
286  * GUIBaseVehicle - methods
287  * ----------------------------------------------------------------------- */
288 
290  GUIGlObject(GLO_VEHICLE, vehicle.getID()),
291  myVehicle(vehicle),
292  myPopup(nullptr) {
293  // as it is possible to show all vehicle routes, we have to store them... (bug [ 2519761 ])
295  myVehicle.myMoveReminders.push_back(std::make_pair(myRoutes, 0.));
296  mySeatPositions.push_back(Seat()); // ensure length 1
297  myContainerPositions.push_back(Seat()); // ensure length 1
298 }
299 
300 
302  myLock.lock();
303  for (std::map<GUISUMOAbstractView*, int>::iterator i = myAdditionalVisualizations.begin(); i != myAdditionalVisualizations.end(); ++i) {
304  while (i->first->removeAdditionalGLVisualisation(this));
305  }
306  myLock.unlock();
307  delete myRoutes;
308  if (myPopup != nullptr) {
310  }
311 }
312 
313 
316  GUISUMOAbstractView& parent) {
317  GUIGLObjectPopupMenu* ret = new GUIBaseVehiclePopupMenu(app, parent, *this);
318  buildPopupHeader(ret, app);
322  //
324  GUIDesigns::buildFXMenuCommand(ret, "Hide Current Route", nullptr, ret, MID_HIDE_CURRENTROUTE);
325  } else {
326  GUIDesigns::buildFXMenuCommand(ret, "Show Current Route", nullptr, ret, MID_SHOW_CURRENTROUTE);
327  }
329  GUIDesigns::buildFXMenuCommand(ret, "Hide Future Route", nullptr, ret, MID_HIDE_FUTUREROUTE);
330  } else {
331  GUIDesigns::buildFXMenuCommand(ret, "Show Future Route", nullptr, ret, MID_SHOW_FUTUREROUTE);
332  }
334  GUIDesigns::buildFXMenuCommand(ret, "Hide All Routes", nullptr, ret, MID_HIDE_ALLROUTES);
335  } else {
336  GUIDesigns::buildFXMenuCommand(ret, "Show All Routes", nullptr, ret, MID_SHOW_ALLROUTES);
337  }
339  FXMenuCheck* showLoops = new FXMenuCheck(ret, "Draw looped routes", ret, MID_HIDE_ROUTE_NOLOOPS);
340  showLoops->setCheck(false);
341  } else {
342  FXMenuCheck* showLoops = new FXMenuCheck(ret, "Draw looped routes", ret, MID_SHOW_ROUTE_NOLOOPS);
343  showLoops->setCheck(true);
344  }
346  GUIDesigns::buildFXMenuCommand(ret, "Hide Best Lanes", nullptr, ret, MID_HIDE_BEST_LANES);
347  } else {
348  GUIDesigns::buildFXMenuCommand(ret, "Show Best Lanes", nullptr, ret, MID_SHOW_BEST_LANES);
349  }
351  GUIDesigns::buildFXMenuCommand(ret, "Hide Link Items", nullptr, ret, MID_HIDE_LFLINKITEMS);
352  } else {
353  GUIDesigns::buildFXMenuCommand(ret, "Show Link Items", nullptr, ret, MID_SHOW_LFLINKITEMS);
354  }
355  new FXMenuSeparator(ret);
356  if (parent.getTrackedID() != getGlID()) {
357  GUIDesigns::buildFXMenuCommand(ret, "Start Tracking", nullptr, ret, MID_START_TRACK);
358  } else {
359  GUIDesigns::buildFXMenuCommand(ret, "Stop Tracking", nullptr, ret, MID_STOP_TRACK);
360  }
361  GUIDesigns::buildFXMenuCommand(ret, "Select Foes", nullptr, ret, MID_SHOW_FOES);
362 
363  GUIDesigns::buildFXMenuCommand(ret, myVehicle.isStopped() ? "Abort stop" : "Stop", nullptr, ret, MID_TOGGLE_STOP);
364  GUIDesigns::buildFXMenuCommand(ret, "Remove", nullptr, ret, MID_REMOVE_OBJECT);
365 
366  new FXMenuSeparator(ret);
367  //
368  buildShowParamsPopupEntry(ret, false);
370  buildPositionCopyEntry(ret, false);
371  myPopup = ret;
372  return ret;
373 }
374 
375 void
377  myPopup = nullptr;
378 }
379 
380 Boundary
382  Boundary b;
383  b.add(getPosition());
385  return b;
386 }
387 
388 
389 const std::string
391  return myVehicle.getParameter().getParameter("name", "");
392 }
393 
394 
395 void
396 GUIBaseVehicle::drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const double angle) const {
397  glPushName(getGlID());
398  glPushMatrix();
399  Position p1 = pos;
400  const double degAngle = RAD2DEG(angle + M_PI / 2.);
401  const double length = getVType().getLength();
402  glTranslated(p1.x(), p1.y(), getType());
403  glRotated(degAngle, 0, 0, 1);
404  // set lane color
405  setColor(s);
406  // scale
407  const double upscale = s.vehicleSize.getExaggeration(s, this);
408  double upscaleLength = upscale;
409  if (upscale > 1 && length > 5) {
410  // reduce the length/width ratio because this is not usefull at high zoom
411  const double widthLengthFactor = length / getVType().getWidth();
412  const double shrinkFactor = MIN2(widthLengthFactor, sqrt(upscaleLength));
413  upscaleLength /= shrinkFactor;
414  }
415  glScaled(upscale, upscaleLength, 1);
416  /*
417  MSLCM_DK2004 &m2 = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
418  if((m2.getState()&LCA_URGENT)!=0) {
419  glColor3d(1, .4, .4);
420  } else if((m2.getState()&LCA_SPEEDGAIN)!=0) {
421  glColor3d(.4, .4, 1);
422  } else {
423  glColor3d(.4, 1, .4);
424  }
425  */
426  // draw the vehicle
427  bool drawCarriages = false;
428  switch (s.vehicleQuality) {
429  case 0:
431  break;
432  case 1:
434  break;
435  case 2:
437  // draw flashing blue light for emergency vehicles
438  if (getVType().getGuiShape() == SVS_EMERGENCY) {
439  glTranslated(0, 0, .1);
441  }
442  break;
443  case 3:
444  default:
445  drawCarriages = drawAction_drawVehicleAsPolyWithCarriagges(s, true);
446  break;
447  }
448  if (s.drawMinGap) {
449  const double minGap = -getVType().getMinGap();
450  glColor3d(0., 1., 0.);
451  glBegin(GL_LINES);
452  glVertex2d(0., 0);
453  glVertex2d(0., minGap);
454  glVertex2d(-.5, minGap);
455  glVertex2d(.5, minGap);
456  glEnd();
457  }
459  const double brakeGap = -static_cast<MSVehicle&>(myVehicle).getCarFollowModel().brakeGap(myVehicle.getSpeed());
460  glColor3d(1., 0., 0.);
461  glBegin(GL_LINES);
462  glVertex2d(0., 0);
463  glVertex2d(0., brakeGap);
464  glVertex2d(-.5, brakeGap);
465  glVertex2d(.5, brakeGap);
466  glEnd();
467  }
469  if (dev != nullptr && s.showBTRange) {
470  glColor3d(1., 0., 0.);
471  GLHelper::drawOutlineCircle(dev->getRange(), dev->getRange() - .2, 32);
472  }
473  // draw the blinker and brakelights if wished
474  if (s.showBlinker) {
475  glTranslated(0, 0, .1);
476  switch (getVType().getGuiShape()) {
477  case SVS_PEDESTRIAN:
478  case SVS_BICYCLE:
479  case SVS_ANT:
480  case SVS_SHIP:
481  case SVS_RAIL:
482  case SVS_RAIL_CARGO:
483  case SVS_RAIL_CAR:
484  break;
485  case SVS_MOTORCYCLE:
486  case SVS_MOPED:
488  drawAction_drawVehicleBrakeLight(length, true);
489  break;
490  default:
491  // only SVS_RAIL_CAR has blinkers and brake lights but they are drawn along with the carriages
492  if (!drawCarriages) {
495  }
496  break;
497  }
498  }
499  // draw the wish to change the lane
500  if (s.drawLaneChangePreference) {
501  /*
502  if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
503  MSLCM_DK2004 &m = static_cast<MSLCM_DK2004&>(veh->getLaneChangeModel());
504  glColor3d(.5, .5, 1);
505  glBegin(GL_LINES);
506  glVertex2f(0, 0);
507  glVertex2f(m.getChangeProbability(), .5);
508  glEnd();
509 
510  glColor3d(1, 0, 0);
511  glBegin(GL_LINES);
512  glVertex2f(0.1, 0);
513  glVertex2f(0.1, m.myMaxJam1);
514  glEnd();
515 
516  glColor3d(0, 1, 0);
517  glBegin(GL_LINES);
518  glVertex2f(-0.1, 0);
519  glVertex2f(-0.1, m.myTDist);
520  glEnd();
521  }
522  */
523  }
524  // draw best lanes
525  /*
526  if (true) {
527  const MSLane &l = veh->getLane();
528  double r1 = veh->allowedContinuationsLength(&l, 0);
529  double r2 = l.getLeftLane()!=0 ? veh->allowedContinuationsLength(l.getLeftLane(), 0) : 0;
530  double r3 = l.getRightLane()!=0 ? veh->allowedContinuationsLength(l.getRightLane(), 0) : 0;
531  double mmax = MAX3(r1, r2, r3);
532  glBegin(GL_LINES);
533  glVertex2f(0, 0);
534  glVertex2f(0, r1/mmax/2.);
535  glEnd();
536  glBegin(GL_LINES);
537  glVertex2f(.4, 0);
538  glVertex2f(.4, r2/mmax/2.);
539  glEnd();
540  glBegin(GL_LINES);
541  glVertex2f(-.4, 0);
542  glVertex2f(-.4, r3/mmax/2.);
543  glEnd();
544  }
545  */
546  glTranslated(0, MIN2(length / 2, double(5)), -getType()); // drawing name at GLO_MAX fails unless translating z
547  glScaled(1 / upscale, 1 / upscaleLength, 1);
548  glRotated(-degAngle, 0, 0, 1);
549  drawName(Position(0, 0), s.scale, s.vehicleName, s.angle);
550  if (s.vehicleName.show && myVehicle.getParameter().line != "") {
551  glRotated(-s.angle, 0, 0, 1);
552  glTranslated(0, 0.7 * s.vehicleName.scaledSize(s.scale), 0);
553  glRotated(s.angle, 0, 0, 1);
555  }
556  if (s.vehicleValue.show) {
557  glRotated(-s.angle, 0, 0, 1);
558  glTranslated(0, 0.7 * s.vehicleName.scaledSize(s.scale), 0);
559  glRotated(s.angle, 0, 0, 1);
560  const double value = getColorValue(s, s.vehicleColorer.getActive());
562  }
563  if (s.vehicleText.show) {
564  std::string error;
565  std::string value = myVehicle.getPrefixedParameter(s.vehicleTextParam, error);
566  if (value != "") {
567  auto lines = StringTokenizer(value, StringTokenizer::NEWLINE).getVector();
568  glRotated(-s.angle, 0, 0, 1);
569  glTranslated(0, 0.7 * s.vehicleText.scaledSize(s.scale) * lines.size(), 0);
570  glRotated(s.angle, 0, 0, 1);
571  for (std::string& line : lines) {
573  glRotated(-s.angle, 0, 0, 1);
574  glTranslated(0, -0.7 * s.vehicleText.scaledSize(s.scale), 0);
575  glRotated(s.angle, 0, 0, 1);
576  }
577  }
578  }
579 
580  if (!drawCarriages) {
581  mySeatPositions.clear();
582  myContainerPositions.clear();
583  int requiredSeats = getNumPassengers();
584  int requiredContainerPositions = getNumContainers();
585  const Position back = (p1 + Position(-length * upscaleLength, 0)).rotateAround2D(angle, p1);
586  computeSeats(p1, back, SUMO_const_waitingPersonWidth, getVType().getPersonCapacity(), upscale, requiredSeats, mySeatPositions);
587  computeSeats(p1, back, SUMO_const_waitingContainerWidth, getVType().getContainerCapacity(), upscale, requiredContainerPositions, myContainerPositions);
588  }
589 
590  glPopMatrix();
591  glPopName();
593 }
594 
595 
596 void
598  drawOnPos(s, getPosition(), getAngle());
599 }
600 
601 
602 void
604  if (!myVehicle.isOnRoad()) {
605  drawGL(s);
606  }
607  glPushName(getGlID());
608  glPushMatrix();
609  glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
611  drawBestLanes();
612  }
613  bool noLoop = hasActiveAddVisualisation(parent, VO_SHOW_ROUTE_NOLOOP);
615  drawRoute(s, 0, 0.25, false, noLoop);
616  }
618  drawRoute(s, 0, 0.25, true, noLoop);
619  }
621  if (myVehicle.getNumberReroutes() > 0) {
622  const int noReroutePlus1 = myVehicle.getNumberReroutes() + 1;
623  for (int i = noReroutePlus1 - 1; i >= 0; i--) {
624  double darken = double(0.4) / double(noReroutePlus1) * double(i);
625  drawRoute(s, i, darken);
626  }
627  } else {
628  drawRoute(s, 0, 0.25, false, noLoop);
629  }
630  }
633  }
634  glPopMatrix();
635  glPopName();
636 }
637 
638 
639 void
640 GUIBaseVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate) {
641  glTranslated(pos.x(), pos.y(), -.1);
643  std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
644  GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
645  glTranslated(-pos.x(), -pos.y(), .1);
646 }
647 
648 
649 RGBColor
651  RGBColor col;
652  const GUIColorer& c = s.vehicleColorer;
653  if (!setFunctionalColor(c.getActive(), &myVehicle, col)) {
654  col = c.getScheme().getColor(getColorValue(s, c.getActive()));
655  }
656  GLHelper::setColor(col);
657  return col;
658 }
659 
660 
661 bool
662 GUIBaseVehicle::setFunctionalColor(int activeScheme, const MSBaseVehicle* veh, RGBColor& col) {
663  switch (activeScheme) {
664  case 0: {
665  //test for emergency vehicle
666  if (veh->getVehicleType().getGuiShape() == SVS_EMERGENCY) {
667  col = RGBColor::WHITE;
668  return true;
669  }
670  //test for firebrigade
671  if (veh->getVehicleType().getGuiShape() == SVS_FIREBRIGADE) {
672  col = RGBColor::RED;
673  return true;
674  }
675  //test for police car
676  if (veh->getVehicleType().getGuiShape() == SVS_POLICE) {
677  col = RGBColor::BLUE;
678  return true;
679  }
680  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
681  col = veh->getParameter().color;
682  return true;
683  }
685  col = veh->getVehicleType().getColor();
686  return true;
687  }
688  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
689  col = veh->getRoute().getColor();
690  return true;
691  }
692  return false;
693  }
694  case 2: {
695  if (veh->getParameter().wasSet(VEHPARS_COLOR_SET)) {
696  col = veh->getParameter().color;
697  return true;
698  }
699  return false;
700  }
701  case 3: {
703  col = veh->getVehicleType().getColor();
704  return true;
705  }
706  return false;
707  }
708  case 4: {
709  if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
710  col = veh->getRoute().getColor();
711  return true;
712  }
713  return false;
714  }
715  case 5: {
716  Position p = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
717  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
718  Position center = b.getCenter();
719  double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
720  double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
721  col = RGBColor::fromHSV(hue, sat, 1.);
722  return true;
723  }
724  case 6: {
725  Position p = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
726  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
727  Position center = b.getCenter();
728  double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
729  double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
730  col = RGBColor::fromHSV(hue, sat, 1.);
731  return true;
732  }
733  case 7: {
734  Position pb = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
735  Position pe = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
736  const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
737  double hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / M_PI;
738  Position minp(b.xmin(), b.ymin());
739  Position maxp(b.xmax(), b.ymax());
740  double sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
741  col = RGBColor::fromHSV(hue, sat, 1.);
742  return true;
743  }
744  case 33: { // color randomly (by pointer hash)
745  std::hash<const MSBaseVehicle*> ptr_hash;
746  const double hue = (double)(ptr_hash(veh) % 360); // [0-360]
747  const double sat = ((ptr_hash(veh) / 360) % 67) / 100.0 + 0.33; // [0.33-1]
748  col = RGBColor::fromHSV(hue, sat, 1.);
749  return true;
750  }
751  case 34: { // color by angle
752  double hue = GeomHelper::naviDegree(veh->getAngle());
753  col = RGBColor::fromHSV(hue, 1., 1.);
754  return true;
755  }
756  }
757  return false;
758 }
759 
760 
761 // ------------ Additional visualisations
762 bool
764  return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
765 }
766 
767 
768 void
770  if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
771  myAdditionalVisualizations[parent] = 0;
772  }
773  myAdditionalVisualizations[parent] |= which;
774  parent->addAdditionalGLVisualisation(this);
775 }
776 
777 
778 void
780  myAdditionalVisualizations[parent] &= ~which;
781  if (myAdditionalVisualizations[parent] == 0) {
782  myAdditionalVisualizations.erase(parent);
783  }
784  parent->removeAdditionalGLVisualisation(this);
785 }
786 
787 
788 void
789 GUIBaseVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, double darken, bool future, bool noLoop) const {
790  RGBColor darker = setColor(s).changedBrightness((int)(darken * -255));
791  GLHelper::setColor(darker);
792  if (routeNo == 0) {
793  drawRouteHelper(s, myVehicle.getRoute(), future, noLoop, darker);
794  return;
795  }
796  const MSRoute* route = myRoutes->getRoute(routeNo - 1); // only prior routes are stored
797  if (route != nullptr) {
798  drawRouteHelper(s, *route, future, noLoop, darker);
799  }
800 }
801 
802 
804 GUIBaseVehicle::getSeatPosition(int personIndex) const {
806  return mySeatPositions[MIN2(personIndex, (int)mySeatPositions.size() - 1)];
807 }
808 
810 GUIBaseVehicle::getContainerPosition(int containerIndex) const {
812  return myContainerPositions[MIN2(containerIndex, (int)myContainerPositions.size() - 1)];
813 }
814 
815 
816 void
818  if (myVehicle.myPersonDevice != nullptr) {
819  const std::vector<MSTransportable*>& ps = myVehicle.myPersonDevice->getTransportables();
820  int personIndex = 0;
821  for (std::vector<MSTransportable*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
822  GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
823  assert(person != 0);
824  person->setPositionInVehicle(getSeatPosition(personIndex++));
825  person->drawGL(s);
826  }
827  }
828  if (myVehicle.myContainerDevice != nullptr) {
829  const std::vector<MSTransportable*>& cs = myVehicle.myContainerDevice->getTransportables();
830  int containerIndex = 0;
831  for (std::vector<MSTransportable*>::const_iterator i = cs.begin(); i != cs.end(); ++i) {
832  GUIContainer* container = dynamic_cast<GUIContainer*>(*i);
833  assert(container != 0);
834  container->setPositionInVehicle(getContainerPosition(containerIndex++));
835  container->drawGL(s);
836  }
837  }
838 #ifdef DRAW_BOUNDING_BOX
839  glPushName(getGlID());
840  glPushMatrix();
841  glTranslated(0, 0, getType());
842  PositionVector boundingBox = getBoundingBox();
843  boundingBox.push_back(boundingBox.front());
844  PositionVector smallBB = getBoundingPoly();
845  glColor3d(0, .8, 0);
846  GLHelper::drawLine(boundingBox);
847  glColor3d(0.5, .8, 0);
848  GLHelper::drawLine(smallBB);
849  //GLHelper::drawBoxLines(getBoundingBox(), 0.5);
850  glPopMatrix();
851  glPopName();
852 #endif
853 }
854 
855 
856 bool
858  if (getVType().getParameter().carriageLength > 0) {
859  drawAction_drawCarriageClass(s, asImage);
860  return true;
861  } else {
863  s, getVType().getImgFile(), this, getVType().getWidth(), getVType().getLength())) {
864  return false;
865  }
866  GUIBaseVehicleHelper::drawAction_drawVehicleAsPoly(s, getVType().getGuiShape(), getVType().getWidth(), getVType().getLength());
867  return false;
868  }
869 }
870 
871 
872 int
874  if (myVehicle.getPersonDevice() != nullptr) {
875  return (int)myVehicle.getPersonDevice()->size();
876  }
877  return 0;
878 }
879 
880 
881 int
883  if (myVehicle.getContainerDevice() != nullptr) {
884  return (int)myVehicle.getContainerDevice()->size();
885  }
886  return 0;
887 }
888 
889 std::string
891  std::vector<std::string> devs;
892  for (MSDevice* d : myVehicle.getDevices()) {
893  devs.push_back(d->deviceName());
894  }
895  return joinToString(devs, " ");
896 }
897 
898 
899 void
900 GUIBaseVehicle::computeSeats(const Position& front, const Position& back, double seatOffset, int maxSeats, double exaggeration, int& requiredSeats, Seats& into) const {
901  if (requiredSeats <= 0) {
902  return;
903  }
904  maxSeats = MAX2(maxSeats, 1); // compute at least one seat
905  seatOffset *= exaggeration;
906  const double vehWidth = getVType().getWidth() * exaggeration;
907  const double length = front.distanceTo2D(back);
908  const int rowSize = MAX2(1, (int)floor(vehWidth / seatOffset));
909  const double rowOffset = (length - 1) / ceil((double)maxSeats / rowSize);
910  const double sideOffset = (rowSize - 1) / 2.0 * seatOffset;
911  double rowPos = 1 - rowOffset;
912  double angle = back.angleTo2D(front);
913  //if (myVehicle.getID() == "v0") std::cout << SIMTIME << " seatOffset=" << seatOffset << " max=" << maxSeats << " ex=" << exaggeration << " req=" << requiredSeats << " rowSize=" << rowSize << " sideOffset=" << sideOffset << " front=" << front << " back=" << back << " a=" << angle << " da=" << RAD2DEG(angle) << "\n";
914  for (int i = 0; requiredSeats > 0 && i < maxSeats; i++) {
915  int seat = (i % rowSize);
916  if (seat == 0) {
917  rowPos += rowOffset;
918  }
919  into.push_back(Seat(PositionVector::positionAtOffset2D(front, back, rowPos, seat * seatOffset - sideOffset), angle));
920  requiredSeats--;
921  }
922 }
923 
924 
925 /****************************************************************************/
@ MID_HIDE_ALLROUTES
Hide all vehicle's routes.
Definition: GUIAppEnum.h:453
@ MID_HIDE_BEST_LANES
Hide vehicle's best lanes.
Definition: GUIAppEnum.h:449
@ MID_HIDE_CURRENTROUTE
Hide vehicle's current route.
Definition: GUIAppEnum.h:437
@ MID_SHOW_FOES
select foes of a vehicle
Definition: GUIAppEnum.h:459
@ MID_SHOW_BEST_LANES
Show vehicle's best lanes.
Definition: GUIAppEnum.h:447
@ MID_START_TRACK
Start to track a vehicle.
Definition: GUIAppEnum.h:455
@ MID_SHOW_ALLROUTES
Show all vehicle's routes.
Definition: GUIAppEnum.h:451
@ MID_SHOW_LFLINKITEMS
Definition: GUIAppEnum.h:460
@ MID_SHOW_ROUTE_NOLOOPS
Show vehicle's future route (without loops)
Definition: GUIAppEnum.h:443
@ MID_HIDE_ROUTE_NOLOOPS
Hide vehicle's future route (without loops)
Definition: GUIAppEnum.h:445
@ MID_TOGGLE_STOP
toggle stop state of a vehice or person
Definition: GUIAppEnum.h:463
@ MID_HIDE_LFLINKITEMS
Definition: GUIAppEnum.h:461
@ MID_REMOVE_OBJECT
remove a vehice or person
Definition: GUIAppEnum.h:465
@ MID_SHOW_FUTUREROUTE
Show vehicle's future route.
Definition: GUIAppEnum.h:439
@ MID_HIDE_FUTUREROUTE
Hide vehicle's future route.
Definition: GUIAppEnum.h:441
@ MID_SHOW_CURRENTROUTE
Show vehicle's current route.
Definition: GUIAppEnum.h:435
@ MID_STOP_TRACK
Stop to track a vehicle.
Definition: GUIAppEnum.h:457
FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[]
@ GLO_VEHICLE
a vehicle
#define RAD2DEG(x)
Definition: GeomHelper.h:36
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:31
const int VTYPEPARS_COLOR_SET
@ SVS_BICYCLE
render as a bicycle
@ SVS_FIREBRIGADE
render as a fire brigade
@ SVS_ANT
render as a giant ant
@ SVS_RAIL
render as a rail
@ SVS_EMERGENCY
render as an emergency vehicle
@ SVS_MOTORCYCLE
render as a motorcycle
@ SVS_MOPED
render as a moped
@ SVS_RAIL_CARGO
render as a cargo train
@ SVS_SHIP
render as a arbitrary ship
@ SVS_RAIL_CAR
render as a (city) rail without locomotive
@ SVS_PEDESTRIAN
render as a pedestrian
@ SVS_POLICE
render as a police car
const int VEHPARS_COLOR_SET
T MIN2(T a, T b)
Definition: StdDefs.h:73
T MAX2(T a, T b)
Definition: StdDefs.h:79
const double SUMO_const_waitingContainerWidth
Definition: StdDefs.h:56
const double SUMO_const_waitingPersonWidth
Definition: StdDefs.h:54
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:250
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:111
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:77
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:129
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:117
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:299
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:135
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:123
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:273
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:446
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:347
static void drawOutlineCircle(double width, double iwidth, int steps=8)
Draws an unfilled circle around (0,0)
Definition: GLHelper.cpp:378
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, const int align=0, double width=-1)
Definition: GLHelper.cpp:498
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition: GLHelper.cpp:529
long onCmdHideFutureRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
long onCmdStartTrack(FXObject *, FXSelector, void *)
Called if the vehicle shall be tracked.
long onCmdHideBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be hidden.
long onCmdHideCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be shown.
long onCmdShowRouteNoLoops(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
long onCmdShowLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
long onCmdShowFoes(FXObject *, FXSelector, void *)
Called when show a vehicles foes.
long onCmdHideRouteNoLoops(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
long onCmdShowFutureRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
long onCmdShowAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
long onCmdToggleStop(FXObject *, FXSelector, void *)
Called when toggling stop state.
long onCmdStopTrack(FXObject *, FXSelector, void *)
Called if the current shall not be tracked any longer.
long onCmdRemoveObject(FXObject *, FXSelector, void *)
Called when removing the vehicle.
long onCmdHideAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
long onCmdShowCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1)
draw vehicle as a polygon
static void drawAction_drawVehicleAsTrianglePlus(const double width, const double length)
draw vehicle as a triangle
static bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, const std::string &file, const GUIGlObject *o, const double width, double length)
try to draw vehicle as raster image and return true if sucessful
static void drawAction_drawVehicleAsBoxPlus(const double width, const double length)
draw vehicle as a Box
A MSVehicle extended by some values for usage within the gui.
const Seat & getContainerPosition(int containerIndex) const
static bool setFunctionalColor(int activeScheme, const MSBaseVehicle *veh, RGBColor &col)
sets the color according to the current scheme index and some vehicle function
const std::string getOptionalName() const
Returns the value for generic parameter 'name' or ''.
virtual void drawAction_drawLinkItems(const GUIVisualizationSettings &) const
const Seat & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
int getNumContainers() const
return the number of passengers
void drawOnPos(const GUIVisualizationSettings &s, const Position &pos, const double angle) const
Draws the object on the specified position with the specified angle.
GUIGLObjectPopupMenu * myPopup
current popup (to clean up in destructor). GUIBaseVehicle is not responsible for removal
GUIBaseVehicle(MSBaseVehicle &vehicle)
MSDevice_Vehroutes * myRoutes
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &s) const
bool hasActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) const
Returns whether the named feature is enabled in the given view.
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
void drawRoute(const GUIVisualizationSettings &s, int routeNo, double darken, bool future=false, bool noLoop=false) const
Chooses the route to draw and draws it, darkening it as given.
std::vector< Seat > Seats
MSBaseVehicle & myVehicle
The vehicle to which all calls should be delegated.
bool drawAction_drawVehicleAsPolyWithCarriagges(const GUIVisualizationSettings &s, bool asImage=false) const
draw vehicle body and return whether carriages are being drawn
virtual void drawAction_drawVehicleBlinker(double) const
void removedPopupMenu()
notify object about popup menu removal
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate)
virtual void drawBestLanes() const
Draws the vehicle's best lanes.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void computeSeats(const Position &front, const Position &back, double seatOffset, int maxSeats, double exaggeration, int &requiredSeats, Seats &into) const
add seats to mySeatPositions and update requiredSeats
virtual Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
@ VO_SHOW_LFLINKITEMS
LFLinkItems.
@ VO_SHOW_ALL_ROUTES
show all vehicle's routes
@ VO_SHOW_ROUTE_NOLOOP
show vehicle's routes without loops
@ VO_SHOW_FUTURE_ROUTE
show vehicle's current continued from the current position
@ VO_SHOW_ROUTE
show vehicle's current route
@ VO_SHOW_BEST_LANES
show vehicle's best lanes
virtual void drawAction_drawCarriageClass(const GUIVisualizationSettings &s, bool asImage) const =0
draws the given guiShape with distinct carriages/modules
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
Seats myContainerPositions
virtual double getAngle() const =0
Returns the vehicle's direction in radians.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
virtual void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
virtual double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const =0
gets the color value according to the current scheme index
int getNumPassengers() const
return the number of passengers
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
~GUIBaseVehicle()
destructor
virtual void drawAction_drawVehicleBlueLight() const
virtual void drawRouteHelper(const GUIVisualizationSettings &s, const MSRoute &r, bool future, bool noLoop, const RGBColor &col) const =0
Draws the route.
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
virtual void selectBlockingFoes() const =0
adds the blocking foes to the current selection
Seats mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
std::string getDeviceDescription()
lists equipped device (types) for the current vehicle
const MSVehicleType & getVType() const
A shortcut to myVehicle.myType.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void setPositionInVehicle(const GUIBaseVehicle::Seat &pos)
Definition: GUIContainer.h:116
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:40
The popup menu of a globject.
GUISUMOAbstractView * getParentView()
return the real owner of this popup
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the type parameter window.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
GUIGlID getGlID() const
Returns the numerical id of the object.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:81
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIPerson.cpp:273
void setPositionInVehicle(const GUIBaseVehicle::Seat &pos)
Definition: GUIPerson.cpp:372
const T getColor(const double value) const
bool removeAdditionalGLVisualisation(GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
void destroyPopup()
destoys the popup
bool addAdditionalGLVisualisation(GUIGlObject *const which)
Adds an object to call its additional visualisation method.
virtual GUIGlID getTrackedID() const
get tracked id
Stores the information about how to visualize structures.
GUIVisualizationTextSettings vehicleName
GUIVisualizationSizeSettings vehicleSize
bool showBlinker
Information whether vehicle blinkers shall be drawn.
GUIColorer vehicleColorer
The vehicle colorer.
GUIVisualizationTextSettings vehicleValue
int vehicleQuality
The quality of vehicle drawing.
std::string vehicleTextParam
key for rendering vehicle textual parameter
double scale
information about a lane's width (temporary, used for a single view)
bool drawMinGap
Information whether the minimum gap shall be drawn.
GUIVisualizationTextSettings vehicleText
bool showBTRange
Information whether the communication range shall be drawn.
bool drawBrakeGap
Information whether the brake gap shall be drawn.
bool drawLaneChangePreference
Information whether the lane change preference shall be drawn.
double angle
The current view rotation angle.
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:192
void vaporizeCar(MEVehicle *v, MSMoveReminder::Notification reason)
remove the given car and clean up the relevant data structures
Definition: MELoop.cpp:224
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:42
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:51
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
const MSDevice_Transportable * getPersonDevice() const
MoveReminderCont myMoveReminders
Currently relevant move reminders.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
const MSDevice_Transportable * getContainerDevice() const
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
std::string getPrefixedParameter(const std::string &key, std::string &error) const
retrieve parameters of devices, models and the vehicle itself
const std::vector< MSVehicleDevice * > & getDevices() const
Returns this vehicle's devices.
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
const MSRoute & getRoute() const
Returns the current route.
bool isStopped() const
Returns whether the vehicle is at a stop.
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
Definition: MSCFModel.h:311
static double getRange()
Returns the configured range.
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
int size() const
Return the number of passengers / containers.
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, int maxRoutes=std::numeric_limits< int >::max())
Build devices for the given vehicle, if needed.
const MSRoute * getRoute(int index) const
Called on route retrieval.
Abstract in-vehicle / in-person device.
Definition: MSDevice.h:61
static bool gUseMesoSim
Definition: MSGlobals.h:88
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:94
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2193
@ NOTIFICATION_VAPORIZED_GUI
The vehicle got removed via the GUI.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:371
const RGBColor & getColor() const
Returns the color.
Definition: MSRoute.cpp:388
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:120
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
Definition: MSVehicle.h:558
bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string &errorMsg)
Definition: MSVehicle.cpp:5852
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
Definition: MSVehicle.cpp:967
bool resumeFromStopping()
Definition: MSVehicle.cpp:5987
std::pair< const MSLane *, double > getLanePosAfterDist(double distance) const
return lane and position along bestlanes at the given distance
Definition: MSVehicle.cpp:5277
double getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:458
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:550
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:930
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getMinGap() const
Get the free space in front of vehicles of this class.
const RGBColor & getColor() const
Returns this type's color.
double getLength() const
Get vehicle's length [m].
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:79
const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:241
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:231
double x() const
Returns the x-position.
Definition: Position.h:54
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
Definition: Position.h:251
double y() const
Returns the y-position.
Definition: Position.h:59
A list of positions.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const RGBColor WHITE
Definition: RGBColor.h:187
static const RGBColor BLUE
Definition: RGBColor.h:182
static const RGBColor GREEN
Definition: RGBColor.h:181
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
Definition: RGBColor.cpp:300
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:145
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:194
static const RGBColor RED
named colors
Definition: RGBColor.h:180
virtual double getSpeed() const =0
Returns the object's current speed.
virtual double getAngle() const =0
Get the vehicle's angle.
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
double startPos
The stopping position start.
double endPos
The stopping position end.
SUMOTime duration
The stopping duration.
RGBColor color
The vehicle's color, TraCI may change this.
bool wasSet(int what) const
Returns whether the given parameter was set.
std::string line
The vehicle's line (mainly for public transport)
static const int NEWLINE
identifier for splitting the given string at all newline characters
std::vector< std::string > getVector()
return vector of strings
#define M_PI
Definition: odrSpiral.cpp:40
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
double scaledSize(double scale, double constFactor=0.1) const
get scale size