SUMO - Simulation of Urban MObility
GUIVehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A MSVehicle extended by some values for usage within the gui
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <cmath>
34 #include <vector>
35 #include <string>
40 #include <utils/geom/GeomHelper.h>
47 #include <utils/gui/div/GLHelper.h>
50 #include <microsim/MSGlobals.h>
51 #include <microsim/MSVehicle.h>
52 #include <microsim/MSJunction.h>
53 #include <microsim/MSLane.h>
61 #include <gui/GUIGlobals.h>
62 #include "GUIVehicle.h"
63 #include "GUIPerson.h"
64 #include "GUIContainer.h"
65 #include "GUINet.h"
66 #include "GUIEdge.h"
67 #include "GUILane.h"
68 
69 #ifdef CHECK_MEMORY_LEAKS
70 #include <foreign/nvwa/debug_new.h>
71 #endif // CHECK_MEMORY_LEAKS
72 
73 //#define DRAW_BOUNDING_BOX
74 
75 // ===========================================================================
76 // FOX callback mapping
77 // ===========================================================================
78 
79 // Object implementation
80 
81 
82 /* -------------------------------------------------------------------------
83  * GUIVehicle - methods
84  * ----------------------------------------------------------------------- */
85 #ifdef _MSC_VER
86 #pragma warning(disable: 4355)
87 #endif
89  const MSVehicleType* type, const SUMOReal speedFactor) :
90  MSVehicle(pars, route, type, speedFactor),
91  GUIBaseVehicle((MSBaseVehicle&) * this) {
92 }
93 #ifdef _MSC_VER
94 #pragma warning(default: 4355)
95 #endif
96 
97 
99 }
100 
101 
106  new GUIParameterTableWindow(app, *this, 35);
107  // add items
108  ret->mkItem("lane [id]", false, myLane->getID());
110  const MSLane* shadowLane = getLaneChangeModel().getShadowLane();
111  ret->mkItem("shadow lane [id]", false, shadowLane == 0 ? "" : shadowLane->getID());
112  }
113  ret->mkItem("position [m]", true,
115  ret->mkItem("lateral offset [m]", true,
117  ret->mkItem("speed [m/s]", true,
119  ret->mkItem("angle [degree]", true,
121  ret->mkItem("slope [degree]", true,
123  if (getChosenSpeedFactor() != 1) {
124  ret->mkItem("speed factor", false, getChosenSpeedFactor());
125  }
126  ret->mkItem("time gap [s]", true,
128  ret->mkItem("waiting time [s]", true,
130  ret->mkItem(("waiting time (accumlated, " + time2string(MSGlobals::gWaitingTimeMemory) + "s) [s]").c_str(), true,
132  ret->mkItem("impatience", true,
134  ret->mkItem("last lane change [s]", true,
136  ret->mkItem("desired depart [s]", false, time2string(getParameter().depart));
137  ret->mkItem("depart delay [s]", false, time2string(getDepartDelay()));
138  if (getParameter().repetitionNumber < INT_MAX) {
139  ret->mkItem("remaining [#]", false, (int) getParameter().repetitionNumber - getParameter().repetitionsDone);
140  }
141  if (getParameter().repetitionOffset > 0) {
142  ret->mkItem("insertion period [s]", false, time2string(getParameter().repetitionOffset));
143  }
144  if (getParameter().repetitionProbability > 0) {
145  ret->mkItem("insertion probability", false, getParameter().repetitionProbability);
146  }
147  ret->mkItem("stop info", false, getStopInfo());
148  ret->mkItem("line", false, myParameter->line);
149  ret->mkItem("CO2 [mg/s]", true,
151  ret->mkItem("CO [mg/s]", true,
153  ret->mkItem("HC [mg/s]", true,
155  ret->mkItem("NOx [mg/s]", true,
157  ret->mkItem("PMx [mg/s]", true,
159  ret->mkItem("fuel [ml/s]", true,
161  ret->mkItem("electricity [Wh/s]", true,
163  ret->mkItem("noise (Harmonoise) [dB]", true,
165  std::ostringstream str;
166  for (std::vector<MSDevice*>::const_iterator i = myDevices.begin(); i != myDevices.end(); ++i) {
167  if (i != myDevices.begin()) {
168  str << ' ';
169  }
170  str << (*i)->getID().substr(0, (*i)->getID().find(getID()));
171  }
172  ret->mkItem("devices", false, str.str());
173  ret->mkItem("persons", true,
175  ret->mkItem("containers", true,
177 
178  ret->mkItem("parameters [key:val]", false, toString(getParameter().getMap()));
179  // close building
180  ret->closeBuilding();
181  return ret;
182 }
183 
184 
189  new GUIParameterTableWindow(app, *this, 14);
190  // add items
191  ret->mkItem("Type Information:", false, "");
192  ret->mkItem("type [id]", false, myType->getID());
193  ret->mkItem("length", false, myType->getLength());
194  ret->mkItem("width", false, myType->getWidth());
195  ret->mkItem("minGap", false, myType->getMinGap());
196  ret->mkItem("vehicle class", false, SumoVehicleClassStrings.getString(myType->getVehicleClass()));
197  ret->mkItem("emission class", false, PollutantsInterface::getName(myType->getEmissionClass()));
198  ret->mkItem("maximum speed [m/s]", false, getMaxSpeed());
199  ret->mkItem("maximum acceleration [m/s^2]", false, getCarFollowModel().getMaxAccel());
200  ret->mkItem("maximum deceleration [m/s^2]", false, getCarFollowModel().getMaxDecel());
201  ret->mkItem("imperfection (sigma)", false, getCarFollowModel().getImperfection());
202  ret->mkItem("reaction time (tau)", false, getCarFollowModel().getHeadwayTime());
203  ret->mkItem("person capacity", false, myType->getPersonCapacity());
204  ret->mkItem("container capacity", false, myType->getContainerCapacity());
205 
206  ret->mkItem("type parameters [key:val]", false, toString(myType->getParameter().getMap()));
207  // close building
208  ret->closeBuilding();
209  return ret;
210 }
211 
212 
213 
214 
215 void
217  if (myPersonDevice != 0) {
218  const std::vector<MSTransportable*>& ps = myPersonDevice->getTransportables();
219  int personIndex = 0;
220  for (std::vector<MSTransportable*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
221  GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
222  assert(person != 0);
223  person->setPositionInVehicle(getSeatPosition(personIndex++));
224  person->drawGL(s);
225  }
226  }
227  if (myContainerDevice != 0) {
228  const std::vector<MSTransportable*>& cs = myContainerDevice->getTransportables();
229  int containerIndex = 0;
230  for (std::vector<MSTransportable*>::const_iterator i = cs.begin(); i != cs.end(); ++i) {
231  GUIContainer* container = dynamic_cast<GUIContainer*>(*i);
232  assert(container != 0);
233  container->setPositionInVehicle(getSeatPosition(containerIndex++));
234  container->drawGL(s);
235  }
236  }
237 #ifdef DRAW_BOUNDING_BOX
238  glPushName(getGlID());
239  glPushMatrix();
240  glTranslated(0, 0, getType());
241  PositionVector boundingBox = getBoundingBox();
242  boundingBox.push_back(boundingBox.front());
243  PositionVector smallBB = getBoundingPoly();
244  glColor3d(0, .8, 0);
245  GLHelper::drawLine(boundingBox);
246  glColor3d(0.5, .8, 0);
247  GLHelper::drawLine(smallBB);
248  //GLHelper::drawBoxLines(getBoundingBox(), 0.5);
249  glPopMatrix();
250  glPopName();
251 #endif
252 }
253 
254 
255 void
257  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
258  if ((*i).myLink == 0) {
259  continue;
260  }
261  MSLink* link = (*i).myLink;
262  MSLane* via = link->getViaLaneOrLane();
263  if (via != 0) {
264  Position p = via->getShape()[0];
265  if ((*i).mySetRequest) {
266  glColor3d(0, .8, 0);
267  } else {
268  glColor3d(.8, 0, 0);
269  }
270  const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
271  (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(), getVehicleType().getLength());
272  drawLinkItem(p, (*i).myArrivalTime, leaveTime, s.vehicleName.size / s.scale);
273  // the time slot that ego vehicle uses when checking opened may
274  // differ from the one it requests in setApproaching
275  MSLink::ApproachingVehicleInformation avi = (*i).myLink->getApproaching(this);
276  assert(avi.arrivalTime == (*i).myArrivalTime && avi.leavingTime == leaveTime);
277  UNUSED_PARAMETER(avi); // only used for assertion
278  }
279  }
280 }
281 
282 
283 bool
285  switch (guiShape) {
286  case SVS_BUS_FLEXIBLE:
287  drawAction_drawRailCarriages(s, 8.25, 0, 0, asImage); // 16.5 overall, 2 modules http://de.wikipedia.org/wiki/Ikarus_180
288  break;
289  case SVS_RAIL:
290  drawAction_drawRailCarriages(s, 24.5, 1, 1, asImage); // http://de.wikipedia.org/wiki/UIC-Y-Wagen_%28DR%29
291  break;
292  case SVS_RAIL_CAR:
293  drawAction_drawRailCarriages(s, 16.85, 1, 0, asImage); // 67.4m overall, 4 carriages http://de.wikipedia.org/wiki/DB-Baureihe_423
294 // drawAction_drawRailCarriages(s, 5.71, 0, 0, asImage); // 40.0m overall, 7 modules http://de.wikipedia.org/wiki/Bombardier_Flexity_Berlin
295 // drawAction_drawRailCarriages(s, 9.44, 1, 1, asImage); // actually length of the locomotive http://de.wikipedia.org/wiki/KJI_Nr._20_und_21
296 // drawAction_drawRailCarriages(s, 24.775, 0, 0, asImage); // http://de.wikipedia.org/wiki/ICE_3
297  break;
298  case SVS_RAIL_CARGO:
299  drawAction_drawRailCarriages(s, 13.86, 1, 0, asImage); // UIC 571-1 http://de.wikipedia.org/wiki/Flachwagen
300  break;
301  default:
302  return false;
303  }
304  return true;
305 }
306 
307 #define BLINKER_POS_FRONT .5
308 #define BLINKER_POS_BACK .5
309 
310 inline void
311 drawAction_drawBlinker(double dir, SUMOReal length) {
312  glColor3d(1.f, .8f, 0);
313  glPushMatrix();
314  glTranslated(dir, BLINKER_POS_FRONT, -0.1);
316  glPopMatrix();
317  glPushMatrix();
318  glTranslated(dir, length - BLINKER_POS_BACK, -0.1);
320  glPopMatrix();
321 }
322 
323 
324 void
327  return;
328  }
329  const double offset = MAX2(.5 * getVehicleType().getWidth(), .4);
331  drawAction_drawBlinker(-offset, length);
332  }
334  drawAction_drawBlinker(offset, length);;
335  }
337  drawAction_drawBlinker(-offset, length);
338  drawAction_drawBlinker(offset, length);
339  }
340 }
341 
342 
343 inline void
346  return;
347  }
348  glColor3f(1.f, .2f, 0);
349  glPushMatrix();
350  if (onlyOne) {
351  glTranslated(0, length, -0.1);
353  } else {
354  glTranslated(-getVehicleType().getWidth() * 0.5, length, -0.1);
356  glPopMatrix();
357  glPushMatrix();
358  glTranslated(getVehicleType().getWidth() * 0.5, length, -0.1);
360  }
361  glPopMatrix();
362 }
363 
364 inline void
367  glPushMatrix();
368  glTranslated(0, 2.5, .5);
369  glColor3f(0, 0, 1);
371  glPopMatrix();
372  }
373 }
374 
375 
376 SUMOReal
377 GUIVehicle::getColorValue(int activeScheme) const {
378  switch (activeScheme) {
379  case 8:
380  return getSpeed();
381  case 9:
382  return getWaitingSeconds();
383  case 10:
385  case 11:
386  return getLastLaneChangeOffset();
387  case 12:
388  return getLane()->getVehicleMaxSpeed(this);
389  case 13:
390  return getCO2Emissions();
391  case 14:
392  return getCOEmissions();
393  case 15:
394  return getPMxEmissions();
395  case 16:
396  return getNOxEmissions();
397  case 17:
398  return getHCEmissions();
399  case 18:
400  return getFuelConsumption();
401  case 19:
403  case 20:
404  if (getNumberReroutes() == 0) {
405  return -1;
406  }
407  return getNumberReroutes();
408  case 21:
410  case 22:
411  return getBestLaneOffset();
412  case 23:
413  return getAcceleration();
414  case 24:
415  return getTimeGap();
416  case 25:
417  return STEPS2TIME(getDepartDelay());
418  case 26:
419  return getElectricityConsumption();
420  }
421  return 0;
422 }
423 
424 
425 void
427  myLock.lock();
428  std::vector<std::vector<MSVehicle::LaneQ> > bestLanes = myBestLanes;
429  myLock.unlock();
430  for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
431  std::vector<MSVehicle::LaneQ>& lanes = *j;
432  SUMOReal gmax = -1;
433  SUMOReal rmax = -1;
434  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
435  gmax = MAX2((*i).length, gmax);
436  rmax = MAX2((*i).occupation, rmax);
437  }
438  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
439  const PositionVector& shape = (*i).lane->getShape();
440  SUMOReal g = (*i).length / gmax;
441  SUMOReal r = (*i).occupation / rmax;
442  glColor3d(r, g, 0);
443  SUMOReal width = 0.5 / (1 + abs((*i).bestLaneOffset));
444  GLHelper::drawBoxLines(shape, width);
445 
446  PositionVector s1 = shape;
447  s1.move2side((SUMOReal) .1);
448  glColor3d(r, 0, 0);
449  GLHelper::drawLine(s1);
450  s1.move2side((SUMOReal) - .2);
451  glColor3d(0, g, 0);
452  GLHelper::drawLine(s1);
453 
454  glColor3d(r, g, 0);
455  }
456  }
457 }
458 
459 
460 void
461 GUIVehicle::drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const {
462  MSRouteIterator i = r.begin();
463  const std::vector<MSLane*>& bestLaneConts = getBestLanesContinuation();
464  // draw continuation lanes when drawing the current route where available
465  int bestLaneIndex = (&r == myRoute ? 0 : (int)bestLaneConts.size());
466  for (; i != r.end(); ++i) {
467  const GUILane* lane;
468  if (bestLaneIndex < (int)bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) {
469  lane = static_cast<GUILane*>(bestLaneConts[bestLaneIndex]);
470  ++bestLaneIndex;
471  } else {
472  lane = static_cast<GUILane*>((*i)->getLanes()[0]);
473  }
474  GLHelper::drawBoxLines(lane->getShape(), lane->getShapeRotations(), lane->getShapeLengths(), exaggeration);
475  }
476 }
477 
478 
479 
480 MSLane*
481 GUIVehicle::getPreviousLane(MSLane* current, int& furtherIndex) const {
482  if (furtherIndex < (int)myFurtherLanes.size()) {
483  return myFurtherLanes[furtherIndex++];
484  } else {
485  return current;
486  }
487 }
488 
489 
490 void
491 GUIVehicle::drawAction_drawRailCarriages(const GUIVisualizationSettings& s, SUMOReal defaultLength, SUMOReal carriageGap, int firstPassengerCarriage, bool asImage) const {
492  RGBColor current = GLHelper::getColor();
493  RGBColor darker = current.changedBrightness(-51);
494  const SUMOReal exaggeration = s.vehicleSize.getExaggeration(s);
495  defaultLength *= exaggeration;
496  if (exaggeration == 0) {
497  return;
498  }
499  carriageGap *= exaggeration;
500  const SUMOReal length = getVehicleType().getLength() * exaggeration;
501  const SUMOReal halfWidth = getVehicleType().getWidth() / 2.0 * exaggeration;
502  glPopMatrix(); // undo scaling and 90 degree rotation
503  glPopMatrix(); // undo initial translation and rotation
504  GLHelper::setColor(darker);
505  const SUMOReal xCornerCut = 0.3 * exaggeration;
506  const SUMOReal yCornerCut = 0.4 * exaggeration;
507  // round to closest integer
508  const int numCarriages = (int)(length / (defaultLength + carriageGap) + 0.5);
509  assert(numCarriages > 0);
510  const SUMOReal carriageLengthWithGap = length / numCarriages;
511  const SUMOReal carriageLength = carriageLengthWithGap - carriageGap;
512  // lane on which the carriage front is situated
513  MSLane* lane = myLane;
514  int furtherIndex = 0;
515  // lane on which the carriage back is situated
516  MSLane* backLane = myLane;
517  int backFurtherIndex = furtherIndex;
518  // offsets of front and back
519  SUMOReal carriageOffset = myState.pos();
520  SUMOReal carriageBackOffset = myState.pos() - carriageLength;
521  // handle seats
522  int requiredSeats = getNumPassengers();
523  if (requiredSeats > 0) {
524  mySeatPositions.clear();
525  }
526  Position front, back;
527  SUMOReal angle = 0.;
528  // draw individual carriages
529  for (int i = 0; i < numCarriages; ++i) {
530  while (carriageOffset < 0) {
531  MSLane* prev = getPreviousLane(lane, furtherIndex);
532  if (prev != lane) {
533  carriageOffset += prev->getLength();
534  } else {
535  // no lane available for drawing.
536  carriageOffset = 0;
537  }
538  lane = prev;
539  }
540  while (carriageBackOffset < 0) {
541  MSLane* prev = getPreviousLane(backLane, backFurtherIndex);
542  if (prev != backLane) {
543  carriageBackOffset += prev->getLength();
544  } else {
545  // no lane available for drawing.
546  carriageBackOffset = 0;
547  }
548  backLane = prev;
549  }
550  front = lane->geometryPositionAtOffset(carriageOffset);
551  back = backLane->geometryPositionAtOffset(carriageBackOffset);
552  if (front == back) {
553  // no place for drawing available
554  continue;
555  }
556  const SUMOReal drawnCarriageLength = front.distanceTo2D(back);
557  angle = atan2((front.x() - back.x()), (back.y() - front.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
558  if (i >= firstPassengerCarriage) {
559  computeSeats(front, back, requiredSeats);
560  }
561  glPushMatrix();
562  glTranslated(front.x(), front.y(), getType());
563  glRotated(angle, 0, 0, 1);
564  if (!asImage || !drawAction_drawVehicleAsImage(s, carriageLength)) {
565  glBegin(GL_TRIANGLE_FAN);
566  glVertex2d(-halfWidth + xCornerCut, 0);
567  glVertex2d(-halfWidth, yCornerCut);
568  glVertex2d(-halfWidth, drawnCarriageLength - yCornerCut);
569  glVertex2d(-halfWidth + xCornerCut, drawnCarriageLength);
570  glVertex2d(halfWidth - xCornerCut, drawnCarriageLength);
571  glVertex2d(halfWidth, drawnCarriageLength - yCornerCut);
572  glVertex2d(halfWidth, yCornerCut);
573  glVertex2d(halfWidth - xCornerCut, 0);
574  glEnd();
575  }
576  glPopMatrix();
577  carriageOffset -= carriageLengthWithGap;
578  carriageBackOffset -= carriageLengthWithGap;
579  GLHelper::setColor(current);
580  }
581  // restore matrices
582  glPushMatrix();
583  glTranslated(front.x(), front.y(), getType());
584  glRotated(angle, 0, 0, 1);
585  glPushMatrix();
586 }
587 
588 
589 int
591  if (myPersonDevice != 0) {
592  return (int)myPersonDevice->size();
593  }
594  return 0;
595 }
596 
597 
598 void
599 GUIVehicle::computeSeats(const Position& front, const Position& back, int& requiredSeats) const {
600  if (requiredSeats <= 0) {
601  return; // save some work
602  }
603  const SUMOReal length = front.distanceTo2D(back);
604  if (length < 4) {
605  // small vehicle, sit at the center
606  mySeatPositions.push_back(PositionVector::positionAtOffset2D(front, back, length / 2));
607  requiredSeats--;
608  } else {
609  for (SUMOReal p = 2; p <= length - 1; p += 1) {
610  mySeatPositions.push_back(PositionVector::positionAtOffset2D(front, back, p));
611  requiredSeats--;
612  }
613  }
614 }
615 
616 
617 SUMOReal
620 }
621 
622 
623 std::string
625  std::string result = "";
626  if (isParking()) {
627  result += "parking";
628  } else if (isStopped()) {
629  result += "stopped";
630  } else {
631  return "";
632  }
633  if (myStops.front().triggered) {
634  result += ", triggered";
635  } else if (myStops.front().containerTriggered) {
636  result += ", containerTriggered";
637  } else {
638  result += ", duration=" + time2string(myStops.front().duration);
639  }
640  return result;
641 }
642 
643 
644 void
647  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
648  const DriveProcessItem& dpi = *i;
649  if (dpi.myLink == 0) {
650  continue;
651  }
652  std::vector<const SUMOVehicle*> blockingFoes;
653  std::vector<const MSPerson*> blockingPersons;
656  if (getLaneChangeModel().getShadowLane() != 0) {
657  MSLink* parallelLink = dpi.myLink->getParallelLink(getLaneChangeModel().getShadowDirection());
658  if (parallelLink != 0) {
659  const SUMOReal shadowLatPos = getLateralPositionOnLane() - getLaneChangeModel().getShadowDirection() * 0.5 * (
661  parallelLink->opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
664  getWaitingTime(), shadowLatPos, &blockingFoes);
665  }
666  }
667  for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
668  gSelected.select(static_cast<const GUIVehicle*>(*it)->getGlID());
669  }
670 #ifdef HAVE_INTERNAL_LANES
671  const MSLink::LinkLeaders linkLeaders = (dpi.myLink)->getLeaderInfo(dist, getVehicleType().getMinGap(), &blockingPersons);
672  for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
673  // the vehicle to enter the junction first has priority
674  const GUIVehicle* leader = dynamic_cast<const GUIVehicle*>(it->vehAndGap.first);
675  if (leader != 0) {
676  if (dpi.myLink->isLeader(this, leader)) {
677  gSelected.select(leader->getGlID());
678  }
679  } else {
680  for (std::vector<const MSPerson*>::iterator it_p = blockingPersons.begin(); it_p != blockingPersons.end(); ++it_p) {
681  const GUIPerson* foe = dynamic_cast<const GUIPerson*>(*it_p);
682  if (foe != 0) {
683  gSelected.select(foe->getGlID());
684  //std::cout << SIMTIME << " veh=" << getID() << " is blocked on link " << dpi.myLink->getRespondIndex() << " to " << dpi.myLink->getViaLaneOrLane()->getID() << " by pedestrian. dist=" << it->second << "\n";
685  }
686  }
687  }
688  }
689 #endif
690  dist += dpi.myLink->getViaLaneOrLane()->getLength();
691  }
692 }
693 
694 
695 void
698  GUISUMOAbstractView* view = mw->getActiveView();
699  if (view != 0) {
700  if (add) {
703  view->addAdditionalGLVisualisation(this);
704  }
705  } else {
708  }
709  }
710 }
711 
712 /****************************************************************************/
713 
SUMOReal getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:496
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
bool drawAction_drawCarriageClass(const GUIVisualizationSettings &s, SUMOVehicleShape guiShape, bool asImage) const
draws the given guiShape if it has distinct carriages/modules and returns true if so ...
Definition: GUIVehicle.cpp:284
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIVehicle.cpp:103
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
const MSVehicleType * myType
This Vehicle&#39;s type.
SUMOReal getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:480
SUMOReal getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
Definition: MSVehicle.cpp:3201
render as a rail
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:82
long long int SUMOTime
Definition: SUMOTime.h:43
int size() const
Return the number of passengers / containers.
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:150
PositionVector getBoundingPoly() const
get bounding polygon
Definition: MSVehicle.cpp:3527
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:535
std::vector< std::vector< LaneQ > > myBestLanes
Definition: MSVehicle.h:1447
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
Definition: MSVehicle.h:1465
State myState
This Vehicles driving state (pos and speed)
Definition: MSVehicle.h:1437
a vehicles
DriveItemVector myLFLinkLanes
Definition: MSVehicle.h:1545
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:487
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
int getNumPassengers() const
return the number of passengers
Definition: GUIVehicle.cpp:590
int getShadowDirection() const
return the direction in which the current shadow lane lies
int getPersonNumber() const
Returns the number of persons.
Definition: MSVehicle.cpp:3269
Stores the information about how to visualize structures.
MSLane * getPreviousLane(MSLane *current, int &furtherIndex) const
Definition: GUIVehicle.cpp:481
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
render as a flexible city bus
void drawAction_drawVehicleBrakeLight(SUMOReal length, bool onlyOne=1) const
Definition: GUIVehicle.cpp:344
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
SUMOReal getMaxDecel() const
Get the vehicle type&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:201
int getBestLaneOffset() const
returns the current offset from the best lane
Definition: MSVehicle.cpp:3077
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:59
GUIVisualizationTextSettings vehicleName
SUMOReal getLength() const
Get vehicle&#39;s length [m].
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
Definition: MSVehicle.h:1456
SUMOReal getNOxEmissions() const
Returns NOx emission of the current state.
Definition: MSVehicle.cpp:3177
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width, int cornerDetail=0, SUMOReal offset=0)
Draws thick lines.
Definition: GLHelper.cpp:176
SUMOReal getLeaveSpeed() const
Definition: MSVehicle.h:1538
SUMOReal getLastLaneChangeOffset() const
Returns the time since the last lane change in seconds.
Definition: GUIVehicle.cpp:618
T MAX2(T a, T b)
Definition: StdDefs.h:75
SUMOTime getDepartDelay() const
Returns the depart delay.
void drawOutsideNetwork(bool add)
register vehicle for drawing while outside the network
Definition: GUIVehicle.cpp:696
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:427
const MSRoute * myRoute
This Vehicle&#39;s route.
PositionVector getBoundingBox() const
get bounding rectangle
Definition: MSVehicle.cpp:3514
const std::vector< SUMOReal > & getShapeLengths() const
Definition: GUILane.cpp:819
void drawBestLanes() const
Draws the vehicle&#39;s best lanes.
Definition: GUIVehicle.cpp:426
bool addAdditionalGLVisualisation(const GUIGlObject *const which)
Adds an object to call its additional visualisation method.
const SUMOVehicleParameter * myParameter
This Vehicle&#39;s parameter.
const std::string & getID() const
Returns the id.
Definition: Named.h:66
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:56
int size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:90
SUMOReal getCO2Emissions() const
Returns CO2 emission of the current state.
Definition: MSVehicle.cpp:3159
int getPersonCapacity() const
Get this vehicle type&#39;s person capacity.
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
std::string getStopInfo() const
retrieve information about the current stop state
Definition: GUIVehicle.cpp:624
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
int getContainerCapacity() const
Get this vehicle type&#39;s container capacity.
#define abs(a)
Definition: polyfonts.c:67
bool removeAdditionalGLVisualisation(const GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
The car-following model and parameter.
Definition: MSVehicleType.h:74
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:2702
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
SUMOReal getColorValue(int activeScheme) const
gets the color value according to the current scheme index
Definition: GUIVehicle.cpp:377
void drawAction_drawVehicleBlinker(SUMOReal length) const
Definition: GUIVehicle.cpp:325
Right blinker lights are switched on.
Definition: MSVehicle.h:1000
PositionVector mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:70
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:232
bool signalSet(int which) const
Returns whether the given signal is on.
Definition: MSVehicle.h:1078
static void drawFilledCircle(SUMOReal width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:344
GUISUMOAbstractView * getActiveView() const
get the active view or 0
SUMOReal getWidth() const
Get the width which vehicles of this class shall have when being drawn.
const MSCFModel & getCarFollowModel() const
Returns the vehicle&#39;s car following model definition.
Definition: MSVehicle.h:758
SUMOReal getCOEmissions() const
Returns CO emission of the current state.
Definition: MSVehicle.cpp:3165
SUMOReal getFuelConsumption() const
Returns fuel consumption of the current state.
Definition: MSVehicle.cpp:3189
Left blinker lights are switched on.
Definition: MSVehicle.h:1002
#define PI
Definition: polyfonts.c:61
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIVehicle(SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, const SUMOReal speedFactor)
Constructor.
Definition: GUIVehicle.cpp:88
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:443
static GUIMainWindow * getInstance()
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
SUMOReal getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs...
Definition: MSVehicle.h:566
SUMOReal getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:556
A list of positions.
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the subpart of best lanes that describes the vehicle&#39;s current lane and their successors...
Definition: MSVehicle.cpp:3048
SUMOReal getPMxEmissions() const
Returns PMx emission of the current state.
Definition: MSVehicle.cpp:3183
std::list< Stop > myStops
The vehicle&#39;s list of stops.
Definition: MSVehicle.h:1453
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:65
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
MSLane * myLane
The lane the vehicle is on.
Definition: MSVehicle.h:1440
Blinker lights on both sides are switched on.
Definition: MSVehicle.h:1004
SUMOReal getMaxSpeed() const
Returns the maximum speed.
~GUIVehicle()
destructor
Definition: GUIVehicle.cpp:98
void setPositionInVehicle(const Position &pos)
Definition: GUIPerson.h:119
SUMOReal getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MSVehicle.h:374
render as a (city) rail without locomotive
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
SUMOReal getTimeGap() const
Returns the time gap in seconds to the leader of the vehicle looking for a fixed distance.
Definition: MSVehicle.cpp:3149
A MSVehicle extended by some values for usage within the gui.
const PositionVector & getShape() const
Definition: GUILane.cpp:807
The brake lights are on.
Definition: MSVehicle.h:1006
void drawAction_drawRailCarriages(const GUIVisualizationSettings &s, SUMOReal defaultLength, SUMOReal carriageGap, int firstPassengerCarriage, bool asImage) const
Definition: GUIVehicle.cpp:491
A blue emergency light is on.
Definition: MSVehicle.h:1022
SUMOReal getNaviDegree() const
return the current angle in navigational degrees
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
#define BLINKER_POS_BACK
Definition: GUIVehicle.cpp:308
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SUMOReal getSlope() const
Returns the slope of the road at vehicle&#39;s position.
Definition: MSVehicle.cpp:765
void drawAction_drawLinkItems(const GUIVisualizationSettings &s) const
Definition: GUIVehicle.cpp:256
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: MSLane.h:458
SUMOReal pos() const
Position of this state.
Definition: MSVehicle.h:112
void selectBlockingFoes() const
adds the blocking foes to the current selection
Definition: GUIVehicle.cpp:645
const SUMOVTypeParameter & getParameter() const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIPerson.cpp:245
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window.
Definition: GUIVehicle.cpp:186
std::string line
The vehicle&#39;s line (mainly for public transport)
void setPositionInVehicle(const Position &pos)
Definition: GUIContainer.h:118
render as a cargo train
void unlock()
release mutex lock
Definition: MFXMutex.cpp:96
SUMOReal getLateralPositionOnLane() const
Get the vehicle&#39;s lateral position on the lane.
Definition: MSVehicle.h:406
Structure representing possible vehicle parameter.
draw vehicle outside the road network
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, SUMOReal length=-1) const
const Position & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal exagerate)
SUMOReal getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
static SUMOReal gLateralResolution
Definition: MSGlobals.h:89
const std::string & getID() const
Returns the name of the vehicle type.
void computeSeats(const Position &front, const Position &back, int &requiredSeats) const
add seats to mySeatPositions and update requiredSeats
Definition: GUIVehicle.cpp:599
void drawAction_drawBlinker(double dir, SUMOReal length)
Definition: GUIVehicle.cpp:311
int getContainerNumber() const
Returns the number of containers.
Definition: MSVehicle.cpp:3275
void lock()
lock mutex
Definition: MFXMutex.cpp:86
static SUMOTime gWaitingTimeMemory
length of memory for waiting times (in millisecs)
Definition: MSGlobals.h:110
SUMOReal getHCEmissions() const
Returns HC emission of the current state.
Definition: MSVehicle.cpp:3171
GUIGlID getGlID() const
Returns the numerical id of the object.
Position positionAtOffset2D(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
static void drawLine(const Position &beg, SUMOReal rot, SUMOReal visLength)
Draws a thin line.
Definition: GLHelper.cpp:269
void move2side(SUMOReal amount)
move position vector to side using certain ammount
#define BLINKER_POS_FRONT
Definition: GUIVehicle.cpp:307
#define SUMOReal
Definition: config.h:213
GUIVisualizationSizeSettings vehicleSize
void drawRouteHelper(const MSRoute &r, SUMOReal exaggeration) const
Draws the route.
Definition: GUIVehicle.cpp:461
SUMOReal getExaggeration(const GUIVisualizationSettings &s, SUMOReal factor=20) const
return the drawing size including exaggeration and constantSize values
const std::vector< SUMOReal > & getShapeRotations() const
Definition: GUILane.cpp:813
MSLane * getShadowLane() const
Returns the lane the vehicles shadow is on during continuous/sublane lane change. ...
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:78
bool isStopped() const
Returns whether the vehicle is at a stop.
Definition: MSVehicle.cpp:1003
void drawAction_drawVehicleBlueLight() const
Definition: GUIVehicle.cpp:365
bool isParking() const
Returns whether the vehicle is parking.
Definition: MSVehicle.cpp:1009
SUMOReal getElectricityConsumption() const
Returns electricity consumption of the current state.
Definition: MSVehicle.cpp:3195
SUMOReal getAcceleration() const
Returns the vehicle&#39;s acceleration in m/s (this is computed as the last step&#39;s mean acceleration in c...
Definition: MSVehicle.h:458
SUMOReal getImpatience() const
Returns this vehicles impatience.
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
static SUMOTime gLaneChangeDuration
Definition: MSGlobals.h:86
const std::string & getID() const
Returns the name of the vehicle.
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
GUISelectedStorage gSelected
A global holder of selected objects.
void closeBuilding()
Closes the building of the table.
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
std::vector< MSDevice * > myDevices
The devices this vehicle has.
void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &s) const
Definition: GUIVehicle.cpp:216
A window containing a gl-object&#39;s parameter.
SUMOEmissionClass getEmissionClass() const
Get this vehicle type&#39;s emission class.
SUMOReal getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:441
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:84
const Position geometryPositionAtOffset(SUMOReal offset, SUMOReal lateralOffset=0) const
Definition: MSLane.h:444
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
Definition: MSVehicle.h:1459
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:449
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:61