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