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 //#define DRAW_BOUNDING_BOX
70 //#define DEBUG_FOES
71 
72 // ===========================================================================
73 // FOX callback mapping
74 // ===========================================================================
75 
76 // Object implementation
77 
78 
79 /* -------------------------------------------------------------------------
80  * GUIVehicle - methods
81  * ----------------------------------------------------------------------- */
82 #ifdef _MSC_VER
83 #pragma warning(push)
84 #pragma warning(disable: 4355)
85 #endif
87  const MSVehicleType* type, const double speedFactor) :
88  MSVehicle(pars, route, type, speedFactor),
89  GUIBaseVehicle((MSBaseVehicle&) * this) {
90 }
91 #ifdef _MSC_VER
92 #pragma warning(pop)
93 #endif
94 
95 
97 }
98 
99 
104  new GUIParameterTableWindow(app, *this, 37);
105  // add items
106  ret->mkItem("lane [id]", false, Named::getIDSecure(myLane, "n/a"));
108  const MSLane* shadowLane = getLaneChangeModel().getShadowLane();
109  ret->mkItem("shadow lane [id]", false, shadowLane == 0 ? "" : shadowLane->getID());
110  }
111  ret->mkItem("position [m]", true,
113  ret->mkItem("lateral offset [m]", true,
115  ret->mkItem("speed [m/s]", true,
117  ret->mkItem("acceleration [m/s^2]", 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, 23);
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("height", false, myType->getHeight());
198  ret->mkItem("minGap", false, myType->getMinGap());
199  ret->mkItem("vehicle class", false, SumoVehicleClassStrings.getString(myType->getVehicleClass()));
200  ret->mkItem("emission class", false, PollutantsInterface::getName(myType->getEmissionClass()));
201  ret->mkItem("car follow model", false, SUMOXMLDefinitions::CarFollowModels.getString((SumoXMLTag)getCarFollowModel().getModelID()));
202  ret->mkItem("maximum speed [m/s]", false, getMaxSpeed());
203  ret->mkItem("maximum acceleration [m/s^2]", false, getCarFollowModel().getMaxAccel());
204  ret->mkItem("maximum deceleration [m/s^2]", false, getCarFollowModel().getMaxDecel());
205  ret->mkItem("imperfection (sigma)", false, getCarFollowModel().getImperfection());
206  ret->mkItem("reaction time (tau)", false, getCarFollowModel().getHeadwayTime());
207  ret->mkItem("person capacity", false, myType->getPersonCapacity());
208  ret->mkItem("boarding time", false, STEPS2TIME(myType->getBoardingDuration()));
209  ret->mkItem("container capacity", false, myType->getContainerCapacity());
210  ret->mkItem("loading time", false, STEPS2TIME(myType->getLoadingDuration()));
212  ret->mkItem("minGapLat", false, myType->getMinGapLat());
213  ret->mkItem("maxSpeedLat", false, myType->getMaxSpeedLat());
214  ret->mkItem("latAlignment", false, toString(myType->getPreferredLateralAlignment()));
215  }
216 
217  ret->mkItem("type parameters [key:val]", false, toString(myType->getParameter().getMap()));
218  // close building
219  ret->closeBuilding();
220  return ret;
221 }
222 
223 
224 
225 
226 void
228  if (myPersonDevice != 0) {
229  const std::vector<MSTransportable*>& ps = myPersonDevice->getTransportables();
230  int personIndex = 0;
231  for (std::vector<MSTransportable*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
232  GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
233  assert(person != 0);
234  person->setPositionInVehicle(getSeatPosition(personIndex++));
235  person->drawGL(s);
236  }
237  }
238  if (myContainerDevice != 0) {
239  const std::vector<MSTransportable*>& cs = myContainerDevice->getTransportables();
240  int containerIndex = 0;
241  for (std::vector<MSTransportable*>::const_iterator i = cs.begin(); i != cs.end(); ++i) {
242  GUIContainer* container = dynamic_cast<GUIContainer*>(*i);
243  assert(container != 0);
244  container->setPositionInVehicle(getSeatPosition(containerIndex++));
245  container->drawGL(s);
246  }
247  }
248 #ifdef DRAW_BOUNDING_BOX
249  glPushName(getGlID());
250  glPushMatrix();
251  glTranslated(0, 0, getType());
252  PositionVector boundingBox = getBoundingBox();
253  boundingBox.push_back(boundingBox.front());
254  PositionVector smallBB = getBoundingPoly();
255  glColor3d(0, .8, 0);
256  GLHelper::drawLine(boundingBox);
257  glColor3d(0.5, .8, 0);
258  GLHelper::drawLine(smallBB);
259  //GLHelper::drawBoxLines(getBoundingBox(), 0.5);
260  glPopMatrix();
261  glPopName();
262 #endif
263 }
264 
265 
266 void
268  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
269  if ((*i).myLink == 0) {
270  continue;
271  }
272  MSLink* link = (*i).myLink;
273  MSLane* via = link->getViaLaneOrLane();
274  if (via != 0) {
275  Position p = via->getShape()[0];
276  if ((*i).mySetRequest) {
277  glColor3d(0, .8, 0);
278  } else {
279  glColor3d(.8, 0, 0);
280  }
281  const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
282  (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(), getVehicleType().getLength());
283  drawLinkItem(p, (*i).myArrivalTime, leaveTime, s.vehicleName.size / s.scale);
284  // the time slot that ego vehicle uses when checking opened may
285  // differ from the one it requests in setApproaching
286  MSLink::ApproachingVehicleInformation avi = (*i).myLink->getApproaching(this);
287  assert(avi.arrivalTime == (*i).myArrivalTime && avi.leavingTime == leaveTime);
288  UNUSED_PARAMETER(avi); // only used for assertion
289  }
290  }
291 }
292 
293 
294 bool
296  switch (guiShape) {
297  case SVS_BUS_FLEXIBLE:
298  drawAction_drawRailCarriages(s, 8.25, 0, 0, asImage); // 16.5 overall, 2 modules http://de.wikipedia.org/wiki/Ikarus_180
299  break;
300  case SVS_RAIL:
301  drawAction_drawRailCarriages(s, 24.5, 1, 1, asImage); // http://de.wikipedia.org/wiki/UIC-Y-Wagen_%28DR%29
302  break;
303  case SVS_RAIL_CAR:
304  drawAction_drawRailCarriages(s, 16.85, 1, 0, asImage); // 67.4m overall, 4 carriages http://de.wikipedia.org/wiki/DB-Baureihe_423
305 // drawAction_drawRailCarriages(s, 5.71, 0, 0, asImage); // 40.0m overall, 7 modules http://de.wikipedia.org/wiki/Bombardier_Flexity_Berlin
306 // drawAction_drawRailCarriages(s, 9.44, 1, 1, asImage); // actually length of the locomotive http://de.wikipedia.org/wiki/KJI_Nr._20_und_21
307 // drawAction_drawRailCarriages(s, 24.775, 0, 0, asImage); // http://de.wikipedia.org/wiki/ICE_3
308  break;
309  case SVS_RAIL_CARGO:
310  drawAction_drawRailCarriages(s, 13.86, 1, 0, asImage); // UIC 571-1 http://de.wikipedia.org/wiki/Flachwagen
311  break;
312  default:
313  return false;
314  }
315  return true;
316 }
317 
318 #define BLINKER_POS_FRONT .5
319 #define BLINKER_POS_BACK .5
320 
321 inline void
322 drawAction_drawBlinker(double dir, double length) {
323  glColor3d(1.f, .8f, 0);
324  glPushMatrix();
325  glTranslated(dir, BLINKER_POS_FRONT, -0.1);
327  glPopMatrix();
328  glPushMatrix();
329  glTranslated(dir, length - BLINKER_POS_BACK, -0.1);
331  glPopMatrix();
332 }
333 
334 
335 void
338  return;
339  }
340  const double offset = MAX2(.5 * getVehicleType().getWidth(), .4);
342  drawAction_drawBlinker(-offset, length);
343  }
345  drawAction_drawBlinker(offset, length);;
346  }
348  drawAction_drawBlinker(-offset, length);
349  drawAction_drawBlinker(offset, length);
350  }
351 }
352 
353 
354 inline void
355 GUIVehicle::drawAction_drawVehicleBrakeLight(double length, bool onlyOne) const {
357  return;
358  }
359  glColor3f(1.f, .2f, 0);
360  glPushMatrix();
361  if (onlyOne) {
362  glTranslated(0, length, -0.1);
364  } else {
365  glTranslated(-getVehicleType().getWidth() * 0.5, length, -0.1);
367  glPopMatrix();
368  glPushMatrix();
369  glTranslated(getVehicleType().getWidth() * 0.5, length, -0.1);
371  }
372  glPopMatrix();
373 }
374 
375 inline void
378  glPushMatrix();
379  glTranslated(0, 2.5, .5);
380  glColor3f(0, 0, 1);
382  glPopMatrix();
383  }
384 }
385 
386 
387 double
388 GUIVehicle::getColorValue(int activeScheme) const {
389  switch (activeScheme) {
390  case 8:
391  return getSpeed();
392  case 9:
393  return getWaitingSeconds();
394  case 10:
396  case 11:
397  return getLastLaneChangeOffset();
398  case 12:
399  return getLane()->getVehicleMaxSpeed(this);
400  case 13:
401  return getCO2Emissions();
402  case 14:
403  return getCOEmissions();
404  case 15:
405  return getPMxEmissions();
406  case 16:
407  return getNOxEmissions();
408  case 17:
409  return getHCEmissions();
410  case 18:
411  return getFuelConsumption();
412  case 19:
414  case 20:
415  if (getNumberReroutes() == 0) {
416  return -1;
417  }
418  return getNumberReroutes();
419  case 21:
421  case 22:
422  return getBestLaneOffset();
423  case 23:
424  return getAcceleration();
425  case 24:
426  return getTimeGapOnLane();
427  case 25:
428  return STEPS2TIME(getDepartDelay());
429  case 26:
430  return getElectricityConsumption();
431  case 27:
432  return getTimeLossSeconds();
433  }
434  return 0;
435 }
436 
437 
438 void
440  myLock.lock();
441  std::vector<std::vector<MSVehicle::LaneQ> > bestLanes = myBestLanes;
442  myLock.unlock();
443  for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
444  std::vector<MSVehicle::LaneQ>& lanes = *j;
445  double gmax = -1;
446  double rmax = -1;
447  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
448  gmax = MAX2((*i).length, gmax);
449  rmax = MAX2((*i).occupation, rmax);
450  }
451  for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
452  const PositionVector& shape = (*i).lane->getShape();
453  double g = (*i).length / gmax;
454  double r = (*i).occupation / rmax;
455  glColor3d(r, g, 0);
456  double width = 0.5 / (1 + abs((*i).bestLaneOffset));
457  GLHelper::drawBoxLines(shape, width);
458 
459  PositionVector s1 = shape;
460  s1.move2side((double) .1);
461  glColor3d(r, 0, 0);
462  GLHelper::drawLine(s1);
463  s1.move2side((double) - .2);
464  glColor3d(0, g, 0);
465  GLHelper::drawLine(s1);
466 
467  glColor3d(r, g, 0);
468  }
469  }
470 }
471 
472 
473 void
474 GUIVehicle::drawRouteHelper(const MSRoute& r, double exaggeration) const {
475  MSRouteIterator i = r.begin();
476  const std::vector<MSLane*>& bestLaneConts = getBestLanesContinuation();
477  // draw continuation lanes when drawing the current route where available
478  int bestLaneIndex = (&r == myRoute ? 0 : (int)bestLaneConts.size());
479  for (; i != r.end(); ++i) {
480  const GUILane* lane;
481  if (bestLaneIndex < (int)bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) {
482  lane = static_cast<GUILane*>(bestLaneConts[bestLaneIndex]);
483  ++bestLaneIndex;
484  } else {
485  const std::vector<MSLane*>* allowed = (*i)->allowedLanes(getVClass());
486  if (allowed != 0 && allowed->size() != 0) {
487  lane = static_cast<GUILane*>((*allowed)[0]);
488  } else {
489  lane = static_cast<GUILane*>((*i)->getLanes()[0]);
490  }
491  }
492  GLHelper::drawBoxLines(lane->getShape(), lane->getShapeRotations(), lane->getShapeLengths(), exaggeration);
493  }
494 }
495 
496 
497 
498 MSLane*
499 GUIVehicle::getPreviousLane(MSLane* current, int& furtherIndex) const {
500  if (furtherIndex < (int)myFurtherLanes.size()) {
501  return myFurtherLanes[furtherIndex++];
502  } else {
503  return current;
504  }
505 }
506 
507 
508 void
509 GUIVehicle::drawAction_drawRailCarriages(const GUIVisualizationSettings& s, double defaultLength, double carriageGap, int firstPassengerCarriage, bool asImage) const {
510  RGBColor current = GLHelper::getColor();
511  RGBColor darker = current.changedBrightness(-51);
512  const double exaggeration = s.vehicleSize.getExaggeration(s);
513  defaultLength *= exaggeration;
514  if (exaggeration == 0) {
515  return;
516  }
517  carriageGap *= exaggeration;
518  const double length = getVehicleType().getLength() * exaggeration;
519  const double halfWidth = getVehicleType().getWidth() / 2.0 * exaggeration;
520  glPopMatrix(); // undo scaling and 90 degree rotation
521  glPopMatrix(); // undo initial translation and rotation
522  GLHelper::setColor(darker);
523  const double xCornerCut = 0.3 * exaggeration;
524  const double yCornerCut = 0.4 * exaggeration;
525  // round to closest integer
526  const int numCarriages = (int)(length / (defaultLength + carriageGap) + 0.5);
527  assert(numCarriages > 0);
528  const double carriageLengthWithGap = length / numCarriages;
529  const double carriageLength = carriageLengthWithGap - carriageGap;
530  // lane on which the carriage front is situated
531  MSLane* lane = myLane;
532  int furtherIndex = 0;
533  // lane on which the carriage back is situated
534  MSLane* backLane = myLane;
535  int backFurtherIndex = furtherIndex;
536  // offsets of front and back
537  double carriageOffset = myState.pos();
538  double carriageBackOffset = myState.pos() - carriageLength;
539  // handle seats
540  int requiredSeats = getNumPassengers();
541  if (requiredSeats > 0) {
542  mySeatPositions.clear();
543  }
544  Position front, back;
545  double angle = 0.;
546  // draw individual carriages
547  for (int i = 0; i < numCarriages; ++i) {
548  while (carriageOffset < 0) {
549  MSLane* prev = getPreviousLane(lane, furtherIndex);
550  if (prev != lane) {
551  carriageOffset += prev->getLength();
552  } else {
553  // no lane available for drawing.
554  carriageOffset = 0;
555  }
556  lane = prev;
557  }
558  while (carriageBackOffset < 0) {
559  MSLane* prev = getPreviousLane(backLane, backFurtherIndex);
560  if (prev != backLane) {
561  carriageBackOffset += prev->getLength();
562  } else {
563  // no lane available for drawing.
564  carriageBackOffset = 0;
565  }
566  backLane = prev;
567  }
568  front = lane->geometryPositionAtOffset(carriageOffset);
569  back = backLane->geometryPositionAtOffset(carriageBackOffset);
570  if (front == back) {
571  // no place for drawing available
572  continue;
573  }
574  const double drawnCarriageLength = front.distanceTo2D(back);
575  angle = atan2((front.x() - back.x()), (back.y() - front.y())) * (double) 180.0 / (double) PI;
576  if (i >= firstPassengerCarriage) {
577  computeSeats(front, back, requiredSeats);
578  }
579  glPushMatrix();
580  glTranslated(front.x(), front.y(), getType());
581  glRotated(angle, 0, 0, 1);
582  if (!asImage || !drawAction_drawVehicleAsImage(s, carriageLength)) {
583  glBegin(GL_TRIANGLE_FAN);
584  glVertex2d(-halfWidth + xCornerCut, 0);
585  glVertex2d(-halfWidth, yCornerCut);
586  glVertex2d(-halfWidth, drawnCarriageLength - yCornerCut);
587  glVertex2d(-halfWidth + xCornerCut, drawnCarriageLength);
588  glVertex2d(halfWidth - xCornerCut, drawnCarriageLength);
589  glVertex2d(halfWidth, drawnCarriageLength - yCornerCut);
590  glVertex2d(halfWidth, yCornerCut);
591  glVertex2d(halfWidth - xCornerCut, 0);
592  glEnd();
593  }
594  glPopMatrix();
595  carriageOffset -= carriageLengthWithGap;
596  carriageBackOffset -= carriageLengthWithGap;
597  GLHelper::setColor(current);
598  }
599  // restore matrices
600  glPushMatrix();
601  glTranslated(front.x(), front.y(), getType());
602  glRotated(angle, 0, 0, 1);
603  glPushMatrix();
604 }
605 
606 
607 int
609  if (myPersonDevice != 0) {
610  return (int)myPersonDevice->size();
611  }
612  return 0;
613 }
614 
615 
616 void
617 GUIVehicle::computeSeats(const Position& front, const Position& back, int& requiredSeats) const {
618  if (requiredSeats <= 0) {
619  return; // save some work
620  }
621  const double length = front.distanceTo2D(back);
622  if (length < 4) {
623  // small vehicle, sit at the center
624  mySeatPositions.push_back(PositionVector::positionAtOffset2D(front, back, length / 2));
625  requiredSeats--;
626  } else {
627  for (double p = 2; p <= length - 1; p += 1) {
628  mySeatPositions.push_back(PositionVector::positionAtOffset2D(front, back, p));
629  requiredSeats--;
630  }
631  }
632 }
633 
634 
635 double
638 }
639 
640 
641 std::string
643  std::string result = "";
644  if (isParking()) {
645  result += "parking";
646  } else if (isStopped()) {
647  result += "stopped";
648  } else {
649  return "";
650  }
651  if (myStops.front().triggered) {
652  result += ", triggered";
653  } else if (myStops.front().containerTriggered) {
654  result += ", containerTriggered";
655  } else {
656  result += ", duration=" + time2string(myStops.front().duration);
657  }
658  return result;
659 }
660 
661 
662 void
664  double dist = myLane->getLength() - getPositionOnLane();
665  for (DriveItemVector::const_iterator i = myLFLinkLanes.begin(); i != myLFLinkLanes.end(); ++i) {
666  const DriveProcessItem& dpi = *i;
667  if (dpi.myLink == 0) {
668  continue;
669  }
670  std::vector<const SUMOVehicle*> blockingFoes;
671  std::vector<const MSPerson*> blockingPersons;
672 #ifdef DEBUG_FOES
673  const bool isOpen =
674 #endif
677 #ifdef DEBUG_FOES
678  if (!isOpen) {
679  std::cout << SIMTIME << " veh=" << getID() << " foes at link=" << dpi.myLink->getViaLaneOrLane()->getID() << ":\n";
680  for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
681  std::cout << " " << (*it)->getID() << "\n";
682  }
683  }
684 #endif
685  if (getLaneChangeModel().getShadowLane() != 0) {
686  MSLink* parallelLink = dpi.myLink->getParallelLink(getLaneChangeModel().getShadowDirection());
687  if (parallelLink != 0) {
688  const double shadowLatPos = getLateralPositionOnLane() - getLaneChangeModel().getShadowDirection() * 0.5 * (
690 #ifdef DEBUG_FOES
691  const bool isShadowOpen =
692 #endif
693  parallelLink->opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
696  getWaitingTime(), shadowLatPos, &blockingFoes);
697 #ifdef DEBUG_FOES
698  if (!isShadowOpen) {
699  std::cout << SIMTIME << " veh=" << getID() << " foes at shadow link=" << parallelLink->getViaLaneOrLane()->getID() << ":\n";
700  for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
701  std::cout << " " << (*it)->getID() << "\n";
702  }
703  }
704 #endif
705  }
706  }
707  for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
708  gSelected.select(static_cast<const GUIVehicle*>(*it)->getGlID());
709  }
710  const MSLink::LinkLeaders linkLeaders = (dpi.myLink)->getLeaderInfo(this, dist, &blockingPersons);
711  for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
712  // the vehicle to enter the junction first has priority
713  const GUIVehicle* leader = dynamic_cast<const GUIVehicle*>(it->vehAndGap.first);
714  if (leader != 0) {
715  if (dpi.myLink->isLeader(this, leader)) {
716  gSelected.select(leader->getGlID());
717 #ifdef DEBUG_FOES
718  std::cout << SIMTIME << " veh=" << getID() << " linkLeader at link=" << dpi.myLink->getViaLaneOrLane()->getID() << " foe=" << leader->getID() << "\n";
719 #endif
720  }
721  } else {
722  for (std::vector<const MSPerson*>::iterator it_p = blockingPersons.begin(); it_p != blockingPersons.end(); ++it_p) {
723  const GUIPerson* foe = dynamic_cast<const GUIPerson*>(*it_p);
724  if (foe != 0) {
725  gSelected.select(foe->getGlID());
726  //std::cout << SIMTIME << " veh=" << getID() << " is blocked on link " << dpi.myLink->getRespondIndex() << " to " << dpi.myLink->getViaLaneOrLane()->getID() << " by pedestrian. dist=" << it->second << "\n";
727  }
728  }
729  }
730  }
731  dist += dpi.myLink->getViaLaneOrLane()->getLength();
732  }
733 }
734 
735 
736 void
739  GUISUMOAbstractView* view = mw->getActiveView();
740  if (view != 0) {
741  if (add) {
744  view->addAdditionalGLVisualisation(this);
745  }
746  } else {
749  }
750  }
751 }
752 
753 bool
756 }
757 
758 /****************************************************************************/
759 
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
void drawAction_drawVehicleBlinker(double length) const
Definition: GUIVehicle.cpp:336
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:295
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIVehicle.cpp:101
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
static double gLateralResolution
Definition: MSGlobals.h:92
double getFuelConsumption() const
Returns fuel consumption of the current state.
Definition: MSVehicle.cpp:3418
const MSVehicleType * myType
This Vehicle&#39;s type.
GUIVehicle(SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, const double speedFactor)
Constructor.
Definition: GUIVehicle.cpp:86
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs...
Definition: MSVehicle.h:580
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: MSLane.h:462
static StringBijection< SumoXMLTag > CarFollowModels
car following models
SumoXMLTag
Numbers representing SUMO-XML - element names.
double getNOxEmissions() const
Returns NOx emission of the current state.
Definition: MSVehicle.cpp:3406
render as a rail
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
double scale
information about a lane&#39;s width (temporary, used for a single view)
int size() const
Return the number of passengers / containers.
double getElectricityConsumption() const
Returns electricity consumption of the current state.
Definition: MSVehicle.cpp:3424
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:146
PositionVector getBoundingPoly() const
get bounding polygon
Definition: MSVehicle.cpp:3766
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:536
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:172
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
Definition: MSVehicle.h:570
std::vector< std::vector< LaneQ > > myBestLanes
Definition: MSVehicle.h:1521
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
Definition: MSVehicle.h:1544
State myState
This Vehicles driving state (pos and speed)
Definition: MSVehicle.h:1506
a vehicles
DriveItemVector myLFLinkLanes
Definition: MSVehicle.h:1627
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:488
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
int getNumPassengers() const
return the number of passengers
Definition: GUIVehicle.cpp:608
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:250
LateralAlignment getPreferredLateralAlignment() const
Get vehicle&#39;s preferred lateral alignment.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
int getShadowDirection() const
return the direction in which the current shadow lane lies
int getPersonNumber() const
Returns the number of persons.
Definition: MSVehicle.cpp:3508
Stores the information about how to visualize structures.
MSLane * getPreviousLane(MSLane *current, int &furtherIndex) const
Definition: GUIVehicle.cpp:499
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
render as a flexible city bus
double y() const
Returns the y-position.
Definition: Position.h:68
double getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MSVehicle.h:375
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
int getBestLaneOffset() const
Definition: MSVehicle.cpp:3305
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:60
GUIVisualizationTextSettings vehicleName
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
Definition: MSVehicle.h:1535
double x() const
Returns the x-position.
Definition: Position.h:63
double getColorValue(int activeScheme) const
gets the color value according to the current scheme index
Definition: GUIVehicle.cpp:388
double getLeaveSpeed() const
Definition: MSVehicle.h:1620
T MAX2(T a, T b)
Definition: StdDefs.h:70
SUMOTime getDepartDelay() const
Returns the depart delay.
void drawOutsideNetwork(bool add)
register vehicle for drawing while outside the network
Definition: GUIVehicle.cpp:737
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:484
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:426
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
PositionVector getBoundingBox() const
get bounding rectangle
Definition: MSVehicle.cpp:3753
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
void drawBestLanes() const
Draws the vehicle&#39;s best lanes.
Definition: GUIVehicle.cpp:439
bool addAdditionalGLVisualisation(const GUIGlObject *const which)
Adds an object to call its additional visualisation method.
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate)
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:86
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:794
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:340
void drawRouteHelper(const MSRoute &r, double exaggeration) const
Draws the route.
Definition: GUIVehicle.cpp:474
int getPersonCapacity() const
Get this vehicle type&#39;s person capacity.
double getNaviDegree() const
return the current angle in navigational degrees
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
double getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:500
std::string getStopInfo() const
retrieve information about the current stop state
Definition: GUIVehicle.cpp:642
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:38
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:2921
#define SIMTIME
Definition: SUMOTime.h:70
SUMOTime getBoardingDuration() const
Get this vehicle type&#39;s boarding duration.
Right blinker lights are switched on.
Definition: MSVehicle.h:1071
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
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
double getMaxSpeed() const
Returns the maximum speed.
bool signalSet(int which) const
Returns whether the given signal is on.
Definition: MSVehicle.h:1149
bool isSelected() const
whether this vehicle is selected in the GUI
Definition: GUIVehicle.cpp:754
GUISUMOAbstractView * getActiveView() const
get the active view or 0
const MSCFModel & getCarFollowModel() const
Returns the vehicle&#39;s car following model definition.
Definition: MSVehicle.h:796
double getCO2Emissions() const
Returns CO2 emission of the current state.
Definition: MSVehicle.cpp:3388
Left blinker lights are switched on.
Definition: MSVehicle.h:1073
#define PI
Definition: polyfonts.c:61
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:439
static GUIMainWindow * getInstance()
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
double getTimeLossSeconds() const
Returns the time loss in seconds.
Definition: MSVehicle.h:586
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
Definition: MSVehicle.cpp:3276
SUMOTime getLoadingDuration() const
Get this vehicle type&#39;s loading duration.
std::list< Stop > myStops
The vehicle&#39;s list of stops.
Definition: MSVehicle.h:1532
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:1509
Blinker lights on both sides are switched on.
Definition: MSVehicle.h:1075
~GUIVehicle()
destructor
Definition: GUIVehicle.cpp:96
void setPositionInVehicle(const Position &pos)
Definition: GUIPerson.h:126
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
Definition: MSVehicle.cpp:3430
render as a (city) rail without locomotive
double getImpatience() const
Returns this vehicles impatience.
A MSVehicle extended by some values for usage within the gui.
const PositionVector & getShape() const
Definition: GUILane.cpp:788
The brake lights are on.
Definition: MSVehicle.h:1077
void drawAction_drawRailCarriages(const GUIVisualizationSettings &s, double defaultLength, double carriageGap, int firstPassengerCarriage, bool asImage) const
Definition: GUIVehicle.cpp:509
A blue emergency light is on.
Definition: MSVehicle.h:1093
double getMinGap() const
Get the free space in front of vehicles of this class.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
#define BLINKER_POS_BACK
Definition: GUIVehicle.cpp:319
double getMaxDecel() const
Get the vehicle type&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:201
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:265
void drawAction_drawLinkItems(const GUIVisualizationSettings &s) const
Definition: GUIVehicle.cpp:267
void selectBlockingFoes() const
adds the blocking foes to the current selection
Definition: GUIVehicle.cpp:663
const SUMOVTypeParameter & getParameter() const
void move2side(double amount)
move position vector to side using certain ammount
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIPerson.cpp:261
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)
double getLateralPositionOnLane() const
Get the vehicle&#39;s lateral position on the lane.
Definition: MSVehicle.h:407
void setPositionInVehicle(const Position &pos)
Definition: GUIContainer.h:118
double getCOEmissions() const
Returns CO emission of the current state.
Definition: MSVehicle.cpp:3394
render as a cargo train
void unlock()
release mutex lock
Definition: MFXMutex.cpp:92
double getMaxSpeedLat() const
Get vehicle&#39;s maximum lateral speed [m/s].
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
SUMOVehicleClass getVClass() const
Returns the vehicle&#39;s access class.
Structure representing possible vehicle parameter.
double length() const
Returns the length.
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.
const Position & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:800
double 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
const std::string & getID() const
Returns the name of the vehicle type.
double getPMxEmissions() const
Returns PMx emission of the current state.
Definition: MSVehicle.cpp:3412
void computeSeats(const Position &front, const Position &back, int &requiredSeats) const
add seats to mySeatPositions and update requiredSeats
Definition: GUIVehicle.cpp:617
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:448
int getContainerNumber() const
Returns the number of containers.
Definition: MSVehicle.cpp:3514
double getLength() const
Get vehicle&#39;s length [m].
void lock()
lock mutex
Definition: MFXMutex.cpp:82
double getTimeGapOnLane() const
Returns the time gap in seconds to the leader of the vehicle on the same lane.
Definition: MSVehicle.cpp:3377
static SUMOTime gWaitingTimeMemory
length of memory for waiting times (in millisecs)
Definition: MSGlobals.h:116
GUIGlID getGlID() const
Returns the numerical id of the object.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
#define BLINKER_POS_FRONT
Definition: GUIVehicle.cpp:318
double getSlope() const
Returns the slope of the road at vehicle&#39;s position.
Definition: MSVehicle.cpp:766
GUIVisualizationSizeSettings vehicleSize
void drawAction_drawBlinker(double dir, double length)
Definition: GUIVehicle.cpp:322
long long int SUMOTime
Definition: TraCIDefs.h:52
MSLane * getShadowLane() const
Returns the lane the vehicles shadow is on during continuous/sublane lane change. ...
double getHCEmissions() const
Returns HC emission of the current state.
Definition: MSVehicle.cpp:3400
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:74
bool isStopped() const
Returns whether the vehicle is at a stop.
Definition: MSVehicle.cpp:1115
void drawAction_drawVehicleBlueLight() const
Definition: GUIVehicle.cpp:376
bool isParking() const
Returns whether the vehicle is parking.
Definition: MSVehicle.cpp:1127
double getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:442
static SUMOTime gLaneChangeDuration
Definition: MSGlobals.h:89
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:227
A window containing a gl-object&#39;s parameter.
SUMOEmissionClass getEmissionClass() const
Get this vehicle type&#39;s emission class.
bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, double length=-1) const
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:80
double getLastLaneChangeOffset() const
Returns the time since the last lane change in seconds.
Definition: GUIVehicle.cpp:636
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
Definition: MSVehicle.h:1538
double pos() const
Position of this state.
Definition: MSVehicle.h:113
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:445
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:61
void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=1) const
Definition: GUIVehicle.cpp:355