Eclipse SUMO - Simulation of Urban MObility
GUIBaseVehicle.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// A MSVehicle extended by some values for usage within the gui
22/****************************************************************************/
23#include <config.h>
24
25#include <cmath>
26#include <vector>
27#include <string>
28#include <functional>
42#include <mesosim/MEVehicle.h>
43#include <mesosim/MELoop.h>
44#include <microsim/MSVehicle.h>
45#include <microsim/MSLane.h>
49#include <microsim/MSStop.h>
55#include <gui/GUIGlobals.h>
57
58#include "GUIBaseVehicle.h"
59#include "GUIPerson.h"
60#include "GUIContainer.h"
61#include "GUINet.h"
62#include "GUIEdge.h"
63#include "GUILane.h"
64#include "GUIParkingArea.h"
65
66//#define DRAW_BOUNDING_BOX
67
68// ===========================================================================
69// FOX callback mapping
70// ===========================================================================
71FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[] = {
90};
91
92// Object implementation
93FXIMPLEMENT(GUIBaseVehicle::GUIBaseVehiclePopupMenu, GUIGLObjectPopupMenu, GUIBaseVehiclePopupMenuMap, ARRAYNUMBER(GUIBaseVehiclePopupMenuMap))
94
95// ===========================================================================
96// method definitions
97// ===========================================================================
98/* -------------------------------------------------------------------------
99 * GUIBaseVehicle::GUIBaseVehiclePopupMenu - methods
100 * ----------------------------------------------------------------------- */
103 : GUIGLObjectPopupMenu(app, parent, o) {
104}
105
106
108
109
110long
112 assert(myObject->getType() == GLO_VEHICLE);
113 if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES)) {
114 static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES);
115 }
116 return 1;
117}
118
119long
121 assert(myObject->getType() == GLO_VEHICLE);
122 static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_ALL_ROUTES);
123 return 1;
124}
125
126
127long
129 assert(myObject->getType() == GLO_VEHICLE);
130 if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ROUTE)) {
131 static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_ROUTE);
132 }
133 return 1;
134}
135
136long
138 assert(myObject->getType() == GLO_VEHICLE);
139 static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_ROUTE);
140 return 1;
141}
142
143
144long
146 assert(myObject->getType() == GLO_VEHICLE);
147 if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_FUTURE_ROUTE)) {
148 static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_FUTURE_ROUTE);
149 }
150 return 1;
151}
152
153long
155 assert(myObject->getType() == GLO_VEHICLE);
156 static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_FUTURE_ROUTE);
157 return 1;
158}
159
160
161long
163 assert(myObject->getType() == GLO_VEHICLE);
164 if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ROUTE_NOLOOP)) {
165 static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_ROUTE_NOLOOP);
166 }
167 return 1;
168}
169
170long
172 assert(myObject->getType() == GLO_VEHICLE);
173 static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_ROUTE_NOLOOP);
174 return 1;
175}
176
177
178long
180 assert(myObject->getType() == GLO_VEHICLE);
181 if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES)) {
182 static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES);
183 }
184 return 1;
185}
186
187long
189 assert(myObject->getType() == GLO_VEHICLE);
190 static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_BEST_LANES);
191 return 1;
192}
193
194
195long
197 assert(myObject->getType() == GLO_VEHICLE);
198 if (myParent->getTrackedID() != static_cast<GUIBaseVehicle*>(myObject)->getGlID()) {
199 myParent->startTrack(static_cast<GUIBaseVehicle*>(myObject)->getGlID());
200 }
201 return 1;
202}
203
204long
206 assert(myObject->getType() == GLO_VEHICLE);
207 myParent->stopTrack();
208 return 1;
209}
210
211
212long
214 assert(myObject->getType() == GLO_VEHICLE);
215 if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS)) {
216 static_cast<GUIBaseVehicle*>(myObject)->addActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS);
217 }
218 return 1;
219}
220
221long
223 assert(myObject->getType() == GLO_VEHICLE);
224 static_cast<GUIBaseVehicle*>(myObject)->removeActiveAddVisualisation(myParent, VO_SHOW_LFLINKITEMS);
225 return 1;
226}
227
228long
230 assert(myObject->getType() == GLO_VEHICLE);
231 static_cast<GUIBaseVehicle*>(myObject)->selectBlockingFoes();
232 myParent->update();
233 return 1;
234}
235
236
237long
239 assert(myObject->getType() == GLO_VEHICLE);
240 const MSBaseVehicle& veh = static_cast<GUIBaseVehicle*>(myObject)->getVehicle();
241 for (const MSTransportable* t : veh.getPersons()) {
242 gSelected.select((static_cast<const GUIPerson*>(t))->getGlID());
243 }
244 for (MSTransportable* t : veh.getContainers()) {
245 gSelected.select((static_cast<const GUIContainer*>(t))->getGlID());
246 }
247 myParent->update();
248 return 1;
249}
250
251long
253 GUIBaseVehicle* baseVeh = static_cast<GUIBaseVehicle*>(myObject);
254 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&baseVeh->myVehicle);
255 if (microVeh != nullptr) {
256 MSLane* lane = microVeh->getMutableLane();
257 if (lane != nullptr) {
258 lane->getVehiclesSecure();
260 }
262 if (lane != nullptr) {
263 lane->releaseVehicles();
264 }
265 } else {
266 MEVehicle* mesoVeh = dynamic_cast<MEVehicle*>(&baseVeh->myVehicle);
268 }
270 myParent->destroyPopup();
271 myParent->update();
272 return 1;
273}
274
275
276long
278 GUIBaseVehicle* baseVeh = static_cast<GUIBaseVehicle*>(myObject);
279 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&baseVeh->myVehicle);
280 if (microVeh != nullptr) {
281 if (microVeh->isStopped()) {
282 microVeh->resumeFromStopping();
283 } else {
284 std::string errorOut;
285 const double brakeGap = microVeh->getCarFollowModel().brakeGap(microVeh->getSpeed());
286 std::pair<const MSLane*, double> stopPos = microVeh->getLanePosAfterDist(brakeGap);
287 if (stopPos.first != nullptr) {
289 stop.lane = stopPos.first->getID();
290 stop.startPos = stopPos.second;
291 stop.endPos = stopPos.second + POSITION_EPS;
292 stop.duration = TIME2STEPS(3600);
293 microVeh->addTraciStop(stop, errorOut);
294 if (errorOut != "") {
295 WRITE_WARNING(errorOut);
296 }
297 }
298 }
299 } else {
300 WRITE_WARNING(TL("GUI-triggered stop not implemented for meso"));
301 }
302 myParent->update();
303 return 1;
304}
305
306
307/* -------------------------------------------------------------------------
308 * GUIBaseVehicle - methods
309 * ----------------------------------------------------------------------- */
310
312 GUIGlObject(GLO_VEHICLE, vehicle.getID(), GUIIconSubSys::getIcon(GUIIcon::VEHICLE)),
313 myVehicle(vehicle),
314 myPopup(nullptr) {
315 // as it is possible to show all vehicle routes, we have to store them... (bug [ 2519761 ])
317 myVehicle.myMoveReminders.push_back(std::make_pair(myRoutes, 0.));
318 mySeatPositions.push_back(Seat()); // ensure length 1
319 myContainerPositions.push_back(Seat()); // ensure length 1
320}
321
322
324 myLock.lock();
325 for (std::map<GUISUMOAbstractView*, int>::iterator i = myAdditionalVisualizations.begin(); i != myAdditionalVisualizations.end(); ++i) {
326 if (i->first->getTrackedID() == getGlID()) {
327 i->first->stopTrack();
328 }
329 while (i->first->removeAdditionalGLVisualisation(this));
330 }
331 myLock.unlock();
332 delete myRoutes;
333 if (myPopup != nullptr) {
335 }
336}
337
338
341 GUISUMOAbstractView& parent) {
342 GUIGLObjectPopupMenu* ret = new GUIBaseVehiclePopupMenu(app, parent, *this);
343 buildPopupHeader(ret, app);
347 //
349 GUIDesigns::buildFXMenuCommand(ret, "Hide Current Route", nullptr, ret, MID_HIDE_CURRENTROUTE);
350 } else {
351 GUIDesigns::buildFXMenuCommand(ret, "Show Current Route", nullptr, ret, MID_SHOW_CURRENTROUTE);
352 }
354 GUIDesigns::buildFXMenuCommand(ret, "Hide Future Route", nullptr, ret, MID_HIDE_FUTUREROUTE);
355 } else {
356 GUIDesigns::buildFXMenuCommand(ret, "Show Future Route", nullptr, ret, MID_SHOW_FUTUREROUTE);
357 }
359 GUIDesigns::buildFXMenuCommand(ret, "Hide All Routes", nullptr, ret, MID_HIDE_ALLROUTES);
360 } else {
361 GUIDesigns::buildFXMenuCommand(ret, "Show All Routes", nullptr, ret, MID_SHOW_ALLROUTES);
362 }
364 FXMenuCheck* showLoops = new FXMenuCheck(ret, "Draw looped routes", ret, MID_HIDE_ROUTE_NOLOOPS);
365 showLoops->setCheck(false);
366 } else {
367 FXMenuCheck* showLoops = new FXMenuCheck(ret, "Draw looped routes", ret, MID_SHOW_ROUTE_NOLOOPS);
368 showLoops->setCheck(true);
369 }
371 GUIDesigns::buildFXMenuCommand(ret, "Hide Best Lanes", nullptr, ret, MID_HIDE_BEST_LANES);
372 } else {
373 GUIDesigns::buildFXMenuCommand(ret, "Show Best Lanes", nullptr, ret, MID_SHOW_BEST_LANES);
374 }
376 GUIDesigns::buildFXMenuCommand(ret, "Hide Link Items", nullptr, ret, MID_HIDE_LFLINKITEMS);
377 } else {
378 GUIDesigns::buildFXMenuCommand(ret, "Show Link Items", nullptr, ret, MID_SHOW_LFLINKITEMS);
379 }
380 new FXMenuSeparator(ret);
381 if (parent.getTrackedID() != getGlID()) {
382 GUIDesigns::buildFXMenuCommand(ret, "Start Tracking", nullptr, ret, MID_START_TRACK);
383 } else {
384 GUIDesigns::buildFXMenuCommand(ret, "Stop Tracking", nullptr, ret, MID_STOP_TRACK);
385 }
386 GUIDesigns::buildFXMenuCommand(ret, "Select Foes", nullptr, ret, MID_SHOW_FOES);
387 if (myVehicle.getPersons().size() + myVehicle.getContainers().size() > 0) {
388 GUIDesigns::buildFXMenuCommand(ret, "Select transported", nullptr, ret, MID_SELECT_TRANSPORTED);
389 }
390 GUIDesigns::buildFXMenuCommand(ret, myVehicle.isStopped() ? "Abort stop" : "Stop", nullptr, ret, MID_TOGGLE_STOP);
391 GUIDesigns::buildFXMenuCommand(ret, "Remove", nullptr, ret, MID_REMOVE_OBJECT);
392
393 new FXMenuSeparator(ret);
394 //
395 buildShowParamsPopupEntry(ret, false);
397 buildPositionCopyEntry(ret, app);
398 myPopup = ret;
399 return ret;
400}
401
402
403void
405 myPopup = nullptr;
406}
407
408
409double
411 return (s.vehicleSize.getExaggeration(s, this) *
413}
414
415
418 Boundary b;
421 return b;
422}
423
424
425const std::string
427 return myVehicle.getParameter().getParameter("name", "");
428}
429
430
431void
432GUIBaseVehicle::drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const double angle) const {
435 Position p1 = pos;
436 const double degAngle = RAD2DEG(angle + M_PI / 2.);
437 const double length = getVType().getLength();
438 glTranslated(p1.x(), p1.y(), getType());
439 glRotated(degAngle, 0, 0, 1);
440 RGBColor col = setColor(s);
441 // scale
442 const double upscale = getExaggeration(s);
443 const bool s2 = s.secondaryShape;
444
445 if (upscale > 1 && s.laneWidthExaggeration > 1 && myVehicle.isOnRoad()) {
446 // optionally shift according to edge exaggeration
447 double offsetFromLeftBorder = myVehicle.getCurrentEdge()->getWidth() - myVehicle.getRightSideOnEdge() - myVehicle.getVehicleType().getWidth() / 2;
448 glTranslated((s.laneWidthExaggeration - 1) * -offsetFromLeftBorder / 2, 0, 0);
449 }
450
451 double upscaleLength = upscale;
452 if (upscale > 1 && length > 5 && s.vehicleQuality != 4) {
453 // reduce the length/width ratio because this is not usefull at high zoom
454 const double widthLengthFactor = length / 5;
455 const double shrinkFactor = MIN2(widthLengthFactor, sqrt(upscaleLength));
456 upscaleLength /= shrinkFactor;
457 }
458 glScaled(upscale, upscaleLength, 1);
459 /*
460 MSLaneChangeModel::DK2004 &m2 = static_cast<MSLaneChangeModel::DK2004&>(veh->getLaneChangeModel());
461 if((m2.getState()&LCA_URGENT)!=0) {
462 glColor3d(1, .4, .4);
463 } else if((m2.getState()&LCA_SPEEDGAIN)!=0) {
464 glColor3d(.4, .4, 1);
465 } else {
466 glColor3d(.4, 1, .4);
467 }
468 */
469 // draw the vehicle
470 bool drawCarriages = false;
471 const double geometryFactor = (s.scaleLength ?
472 ((myVehicle.getLane() != nullptr
474 : (myVehicle.getEdge()->getLanes().size() > 0 ? myVehicle.getEdge()->getLanes()[0]->getLengthGeometryFactor(s2) : 1)))
475 : 1);
476 double scaledLength = length * geometryFactor;
477 if (col.alpha() != 0) {
478 switch (s.vehicleQuality) {
479 case 0:
481 break;
482 case 1:
484 break;
485 case 2:
486 drawCarriages = drawAction_drawVehicleAsPolyWithCarriagges(s, scaledLength);
487 // draw flashing blue light for emergency vehicles
488 if (getVType().getGuiShape() == SUMOVehicleShape::EMERGENCY) {
489 glTranslated(0, 0, .1);
491 }
492 break;
493 case 3:
494 drawCarriages = drawAction_drawVehicleAsPolyWithCarriagges(s, scaledLength, true);
495 break;
496 case 4: {
497 // do not scale circle radius by lengthGeometryFactor nor length and reduce the effect of width
498 const double w = 1.8 * sqrt(getVType().getWidth() / 1.8);
500 // display text at circle center
501 scaledLength = 0;
502 break;
503 }
504 default:
505 break;
506 }
507 if (s.drawMinGap) {
508 const double minGap = -getVType().getMinGap();
509 glColor3d(0., 1., 0.);
510 glBegin(GL_LINES);
511 glVertex2d(0., 0);
512 glVertex2d(0., minGap);
513 glVertex2d(-.5, minGap);
514 glVertex2d(.5, minGap);
515 glEnd();
516 }
519 const double brakeGap = -static_cast<MSVehicle&>(myVehicle).getCarFollowModel().brakeGap(myVehicle.getSpeed());
520 glColor3d(1., 0., 0.);
521 glBegin(GL_LINES);
522 glVertex2d(0., 0);
523 glVertex2d(0., brakeGap);
524 glVertex2d(-.5, brakeGap);
525 glVertex2d(.5, brakeGap);
526 glEnd();
527 }
528 if (s.showBTRange) {
530 if (dev != nullptr) {
531 glColor3d(1., 0., 0.);
532 GLHelper::drawOutlineCircle(dev->getRange(), dev->getRange() - .2, 32);
533 }
534 }
535 // draw the blinker and brakelights if wished
536 if (s.showBlinker) {
537 glTranslated(0, 0, .1);
538 switch (getVType().getGuiShape()) {
548 break;
551 drawAction_drawVehicleBlinker(scaledLength);
552 drawAction_drawVehicleBrakeLight(scaledLength, true);
553 break;
554 default:
555 // only SUMOVehicleShape::RAIL_CAR has blinkers and brake lights but they are drawn along with the carriages
556 if (!drawCarriages) {
557 drawAction_drawVehicleBlinker(scaledLength);
559 }
560 break;
561 }
562 }
563 // draw the wish to change the lane
565 /*
566 if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
567 MSLaneChangeModel::DK2004 &m = static_cast<MSLaneChangeModel::DK2004&>(veh->getLaneChangeModel());
568 glColor3d(.5, .5, 1);
569 glBegin(GL_LINES);
570 glVertex2f(0, 0);
571 glVertex2f(m.getChangeProbability(), .5);
572 glEnd();
573
574 glColor3d(1, 0, 0);
575 glBegin(GL_LINES);
576 glVertex2f(0.1, 0);
577 glVertex2f(0.1, m.myMaxJam1);
578 glEnd();
579
580 glColor3d(0, 1, 0);
581 glBegin(GL_LINES);
582 glVertex2f(-0.1, 0);
583 glVertex2f(-0.1, m.myTDist);
584 glEnd();
585 }
586 */
587 }
588 }
589 glTranslated(0, MIN2(scaledLength / 2, double(5)), -getType()); // drawing name at GLO_MAX fails unless translating z
590 glScaled(1 / upscale, 1 / upscaleLength, 1);
591 glRotated(-degAngle, 0, 0, 1);
592 drawName(Position(0, 0), s.scale, s.vehicleName, s.angle);
593 if (s.vehicleName.show(this) && myVehicle.getParameter().line != "") {
594 glRotated(-s.angle, 0, 0, 1);
595 glTranslated(0, 0.7 * s.vehicleName.scaledSize(s.scale), 0);
596 glRotated(s.angle, 0, 0, 1);
598 }
599 if (s.vehicleValue.show(this)) {
600 glRotated(-s.angle, 0, 0, 1);
601 glTranslated(0, 0.7 * s.vehicleName.scaledSize(s.scale), 0);
602 glRotated(s.angle, 0, 0, 1);
603 const double value = getColorValue(s, s.vehicleColorer.getActive());
605 }
606 if (s.vehicleScaleValue.show(this)) {
607 glRotated(-s.angle, 0, 0, 1);
608 glTranslated(0, 0.7 * s.vehicleName.scaledSize(s.scale), 0);
609 glRotated(s.angle, 0, 0, 1);
610 const double value = getScaleValue(s, s.vehicleScaler.getActive());
612 }
613 if (s.vehicleText.show(this)) {
614 std::string error;
615 std::string value = myVehicle.getPrefixedParameter(s.vehicleTextParam, error);
616 if (value != "") {
618 glRotated(-s.angle, 0, 0, 1);
619 glTranslated(0, 0.7 * s.vehicleText.scaledSize(s.scale) * (double)lines.size(), 0);
620 glRotated(s.angle, 0, 0, 1);
621 for (std::string& line : lines) {
623 glRotated(-s.angle, 0, 0, 1);
624 glTranslated(0, -0.7 * s.vehicleText.scaledSize(s.scale), 0);
625 glRotated(s.angle, 0, 0, 1);
626 }
627 }
628 }
631 glRotated(-s.angle, 0, 0, 1);
632 glTranslated(0, 0.7 * s.vehicleName.scaledSize(s.scale), 0);
633 glRotated(s.angle, 0, 0, 1);
634 const double value = myVehicle.getNumberParkingReroutes();
636 }
637
638 if (!drawCarriages) {
639 mySeatPositions.clear();
640 myContainerPositions.clear();
641 int requiredSeats = getNumPassengers();
642 int requiredContainerPositions = getNumContainers();
643 const Position back = (p1 + Position(-scaledLength * upscaleLength, 0)).rotateAround2D(angle, p1);
644 computeSeats(p1, back, SUMO_const_waitingPersonWidth, getVType().getPersonCapacity(), upscale, requiredSeats, mySeatPositions);
645 computeSeats(p1, back, SUMO_const_waitingContainerWidth, getVType().getContainerCapacity(), upscale, requiredContainerPositions, myContainerPositions);
646 }
647
651}
652
653
654void
657}
658
659
660void
662 if (!myVehicle.isOnRoad()) {
663 drawGL(s);
664 }
667 glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
670 }
671 bool noLoop = hasActiveAddVisualisation(parent, VO_SHOW_ROUTE_NOLOOP);
673 drawRoute(s, 0, 0.25, false, noLoop);
674 }
676 drawRoute(s, 0, 0.25, true, noLoop);
677 }
679 if (myVehicle.getNumberReroutes() > 0) {
680 const int noReroutePlus1 = myVehicle.getNumberReroutes() + 1;
681 for (int i = noReroutePlus1 - 1; i >= 0; i--) {
682 double darken = double(0.4) / double(noReroutePlus1) * double(i);
683 drawRoute(s, i, darken);
684 }
685 } else {
686 drawRoute(s, 0, 0.25, false, noLoop);
687 }
688 }
691 }
694}
695
696
697void
698GUIBaseVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate) {
699 glTranslated(pos.x(), pos.y(), -.1);
701 std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
702 GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
703 glTranslated(-pos.x(), -pos.y(), .1);
704}
705
706
709 RGBColor col;
710 const GUIColorer& c = s.vehicleColorer;
711 if (!setFunctionalColor(c.getActive(), &myVehicle, col)) {
712 col = c.getScheme().getColor(getColorValue(s, c.getActive()));
713 }
715 return col;
716}
717
718
719bool
720GUIBaseVehicle::setFunctionalColor(int activeScheme, const MSBaseVehicle* veh, RGBColor& col) {
721 switch (activeScheme) {
722 case 0: {
723 //test for emergency vehicle
725 col = RGBColor::WHITE;
726 return true;
727 }
728 //test for firebrigade
730 col = RGBColor::RED;
731 return true;
732 }
733 //test for police car
735 col = RGBColor::BLUE;
736 return true;
737 }
739 col = veh->getParameter().color;
740 return true;
741 }
743 col = veh->getVehicleType().getColor();
744 return true;
745 }
746 if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
747 col = veh->getRoute().getColor();
748 return true;
749 }
750 return false;
751 }
752 case 2: {
754 col = veh->getParameter().color;
755 return true;
756 }
757 return false;
758 }
759 case 3: {
761 col = veh->getVehicleType().getColor();
762 return true;
763 }
764 return false;
765 }
766 case 4: {
767 if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
768 col = veh->getRoute().getColor();
769 return true;
770 }
771 return false;
772 }
773 case 5: {
774 Position p = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
775 const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
776 Position center = b.getCenter();
777 double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
778 double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
779 col = RGBColor::fromHSV(hue, sat, 1.);
780 return true;
781 }
782 case 6: {
783 Position p = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
784 const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
785 Position center = b.getCenter();
786 double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
787 double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
788 col = RGBColor::fromHSV(hue, sat, 1.);
789 return true;
790 }
791 case 7: {
792 Position pb = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
793 Position pe = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
794 const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
795 double hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / M_PI;
796 Position minp(b.xmin(), b.ymin());
797 Position maxp(b.xmax(), b.ymax());
798 double sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
799 col = RGBColor::fromHSV(hue, sat, 1.);
800 return true;
801 }
802 case 33: { // color randomly (by pointer hash)
803 std::hash<const MSBaseVehicle*> ptr_hash;
804 const double hue = (double)(ptr_hash(veh) % 360); // [0-360]
805 const double sat = (double)((ptr_hash(veh) / 360) % 67) / 100.0 + 0.33; // [0.33-1]
806 col = RGBColor::fromHSV(hue, sat, 1.);
807 return true;
808 }
809 case 34: { // color by angle
810 double hue = GeomHelper::naviDegree(veh->getAngle());
811 col = RGBColor::fromHSV(hue, 1., 1.);
812 return true;
813 }
814 }
815 return false;
816}
817
818
819double
821 switch (activeScheme) {
822 case 0: // uniform
823 return 0;
824 case 1: // selection
825 return myVehicle.isSelected();
826 case 2: // by speed
827 if (myVehicle.isStopped()) {
828 return myVehicle.isParking() ? -2 : -1;
829 }
830 return myVehicle.getSpeed();
831 case 3:
833 case 4: {
834 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&myVehicle);
835 return (microVeh != nullptr ? microVeh->getAccumulatedWaitingSeconds() : 0);
836 }
837 case 5: {
838 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&myVehicle);
839 return (microVeh != nullptr ? microVeh->getLane()->getVehicleMaxSpeed(microVeh) : myVehicle.getEdge()->getVehicleMaxSpeed(&myVehicle));
840 }
841 case 6:
843 case 7: {
844 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&myVehicle);
845 return (microVeh != nullptr
846 ? (microVeh->getLaneChangeModel().isOpposite() ? -100 : microVeh->getBestLaneOffset())
847 : 0);
848 }
849 case 8:
850 return myVehicle.getAcceleration();
851 case 9: {
852 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&myVehicle);
853 return (microVeh != nullptr ? microVeh->getTimeGapOnLane() : 0);
854 }
855 case 10:
857 case 11:
859 case 12:
860 return myVehicle.getStopDelay();
861 case 13:
863 case 14: // by numerical param value
864 std::string error;
865 std::string val = myVehicle.getPrefixedParameter(s.vehicleScaleParam, error);
866 try {
867 if (val == "") {
868 return 0;
869 } else {
870 return StringUtils::toDouble(val);
871 }
872 } catch (NumberFormatException&) {
873 try {
874 return StringUtils::toBool(val);
875 } catch (BoolFormatException&) {
876 WRITE_WARNINGF(TL("Vehicle parameter '%' key '%' is not a number for vehicle '%'."),
878 return -1;
879 }
880 }
881 }
882 return 0;
883}
884
885
886// ------------ Additional visualisations
887bool
889 return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
890}
891
892
893void
895 if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
896 myAdditionalVisualizations[parent] = 0;
897 }
898 myAdditionalVisualizations[parent] |= which;
899 if (which != VO_TRACK) {
900 parent->addAdditionalGLVisualisation(this);
901 }
902}
903
904
905void
907 myAdditionalVisualizations[parent] &= ~which;
908 if (myAdditionalVisualizations[parent] == 0) {
909 myAdditionalVisualizations.erase(parent);
910 }
912}
913
914
915void
916GUIBaseVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, double darken, bool future, bool noLoop) const {
917 RGBColor vehColor = setColor(s);
918 RGBColor darker = vehColor.changedBrightness((int)(darken * -255));
919 if (darker == RGBColor::BLACK) {
920 darker = vehColor.multiply(1 - darken);
921 }
922 GLHelper::setColor(darker);
923 if (routeNo == 0) {
924 drawRouteHelper(s, myVehicle.getRoutePtr(), future, noLoop, darker);
925 return;
926 }
927 ConstMSRoutePtr route = myRoutes->getRoute(routeNo - 1); // only prior routes are stored
928 if (route != nullptr) {
929 drawRouteHelper(s, route, future, noLoop, darker);
930 }
931}
932
933
934void
935GUIBaseVehicle::drawStopLabels(const GUIVisualizationSettings& s, bool noLoop, const RGBColor& col) const {
936 // (vertical shift for repeated stops at the same position
937 std::map<const MSLane*, int> repeat; // count repeated occurrences of the same position
938 int stopIndex = 0;
939 for (const MSStop& stop : myVehicle.getStops()) {
940 double stopLanePos;
941 if (stop.getSpeed() > 0) {
942 stopLanePos = stop.reached ? stop.pars.endPos : stop.pars.startPos;
943 } else {
944 stopLanePos = stop.reached ? myVehicle.getPositionOnLane() : MAX2(0.0, stop.getEndPos(myVehicle));
945 }
946 if (stop.isOpposite && !stop.reached) {
947 stopLanePos = stop.lane->getLength() - stopLanePos;
948 }
949 Position pos = stop.lane->geometryPositionAtOffset(stopLanePos);
951 GLHelper::drawBoxLines(stop.lane->getShape().getOrthogonal(pos, 10, true, stop.lane->getWidth()), 0.1);
952 std::string label = (stop.getSpeed() > 0
953 ? (stop.reached ? "passing waypoint" : "waypoint ")
954 : (stop.reached ? "stopped" : "stop "));
955 if (!stop.reached) {
956 label += toString(stopIndex);
957 }
958
959 if (stop.isOpposite) {
960 label += " (opposite)";
961 }
962#ifdef _DEBUG
963 label += " (" + toString(stop.edge - myVehicle.getCurrentRouteEdge()) + "e)";
964#endif
966 label += " triggered:";
967 if (stop.triggered) {
968 label += "person";
969 if (stop.numExpectedPerson > 0) {
970 label += "(" + toString(stop.numExpectedPerson) + ")";
971 }
972 }
973 if (stop.containerTriggered) {
974 label += "container";
975 if (stop.numExpectedContainer > 0) {
976 label += "(" + toString(stop.numExpectedContainer) + ")";
977 }
978 }
979 if (stop.joinTriggered) {
980 label += "join";
981 if (stop.pars.join != "") {
982 label += "(" + stop.pars.join + ")";
983 }
984 }
985 }
986 if (stop.pars.ended >= 0 && MSGlobals::gUseStopEnded) {
987 label += " ended:" + time2string(stop.pars.ended);
988 } else if (stop.pars.until >= 0) {
989 label += " until:" + time2string(stop.pars.until);
990 }
991 if (stop.duration >= 0 || stop.pars.duration > 0) {
992 if (STEPS2TIME(stop.duration) > 3600 * 24) {
993 label += " duration:1day+";
994 } else {
995 label += " duration:" + time2string(stop.duration);
996 }
997 }
998 if (stop.getSpeed() > 0) {
999 if (stop.skipOnDemand) {
1000 label += " onDemand (skipped)";
1001 } else {
1002 label += " speed:" + toString(stop.getSpeed());
1003 }
1004 }
1005 if (stop.pars.actType != "") {
1006 label += " actType:" + stop.pars.actType;
1007 }
1008 const double nameSize = s.vehicleName.size / s.scale;
1009 Position pos2 = pos - Position(0, nameSize * repeat[stop.lane]);
1010 if (noLoop && repeat[stop.lane] > 0) {
1011 break;
1012 }
1013 GLHelper::drawTextSettings(s.vehicleText, label, pos2, s.scale, s.angle, 1.0);
1014 repeat[stop.lane]++;
1015 stopIndex++;
1016 }
1017 // indicate arrivalPos if set
1019 const int arrivalEdge = myVehicle.getParameter().arrivalEdge >= 0
1021 : (int)myVehicle.getRoute().getEdges().size() - 1;
1022 const MSLane* arrivalLane = myVehicle.getRoute().getEdges()[arrivalEdge]->getLanes()[MAX2(0, myVehicle.getArrivalLane())];
1024 GLHelper::setColor(col);
1025 GLHelper::drawBoxLines(arrivalLane->getShape().getOrthogonal(pos, 10, true, arrivalLane->getWidth() * 0.5, 90), 0.1);
1026 GLHelper::drawBoxLines(arrivalLane->getShape().getOrthogonal(pos, 10, true, arrivalLane->getWidth() * 0.5, 270), 0.1);
1027 GLHelper::drawTextSettings(s.vehicleText, "arrival", pos, s.scale, s.angle, 1.0);
1028
1029 }
1030}
1031
1032void
1034 if (s.showParkingInfo) {
1036 if (pm != nullptr) {
1037 for (auto item : *pm) {
1038 const GUIParkingArea* pa = dynamic_cast<const GUIParkingArea*>(item.first);
1039 if (item.second.blockedAtTime >= 0) {
1040 std::string seenAgo = time2string(SIMSTEP - item.second.blockedAtTime);
1041 //if (item.second.blockedAtTime >= 0) {
1042 // seenAgo += ", " + time2string(SIMSTEP - item.second.blockedAtTimeLocal);
1043 //}
1044 GLHelper::drawTextSettings(s.vehicleValue, seenAgo, pa->getSignPos(), s.scale, s.angle, 1.0);
1045 }
1046 if (item.second.score != "") {
1047 const double dist = 0.4 * (s.vehicleText.scaledSize(s.scale) + s.vehicleValue.scaledSize(s.scale));
1048 Position shift(0, -dist);
1049 GLHelper::drawTextSettings(s.vehicleText, item.second.score, pa->getSignPos() + shift, s.scale, s.angle, 1.0);
1050 }
1051 }
1052 }
1053 }
1054}
1055
1057GUIBaseVehicle::getSeatPosition(int personIndex) const {
1059 return mySeatPositions[MIN2(personIndex, (int)mySeatPositions.size() - 1)];
1060}
1061
1063GUIBaseVehicle::getContainerPosition(int containerIndex) const {
1065 return myContainerPositions[MIN2(containerIndex, (int)myContainerPositions.size() - 1)];
1066}
1067
1068
1069void
1071 if (myVehicle.myPersonDevice != nullptr) {
1072 const std::vector<MSTransportable*>& ps = myVehicle.myPersonDevice->getTransportables();
1073 int personIndex = 0;
1074 for (std::vector<MSTransportable*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
1075 GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
1076 assert(person != 0);
1077 person->setPositionInVehicle(getSeatPosition(personIndex++));
1078 person->drawGL(s);
1079 }
1080 }
1081 if (myVehicle.myContainerDevice != nullptr) {
1082 const std::vector<MSTransportable*>& cs = myVehicle.myContainerDevice->getTransportables();
1083 int containerIndex = 0;
1084 for (std::vector<MSTransportable*>::const_iterator i = cs.begin(); i != cs.end(); ++i) {
1085 GUIContainer* container = dynamic_cast<GUIContainer*>(*i);
1086 assert(container != 0);
1087 container->setPositionInVehicle(getContainerPosition(containerIndex++));
1088 container->drawGL(s);
1089 }
1090 }
1091#ifdef DRAW_BOUNDING_BOX
1093 MSVehicle& microVeh = dynamic_cast<MSVehicle&>(myVehicle);
1096 glTranslated(0, 0, getType());
1097 PositionVector smallBB = microVeh.getBoundingPoly();
1098 glColor3d(0.5, .8, 0);
1099 GLHelper::drawBoxLines(smallBB, 0.3);
1100 glTranslated(0, 0, 0.1);
1101 PositionVector boundingBox = microVeh.getBoundingBox();
1102 boundingBox.push_back(boundingBox.front());
1103 glColor3d(1, 0, 0);
1104 GLHelper::drawBoxLines(boundingBox, 0.15);
1107 }
1108#endif
1109}
1110
1111bool
1113 return myVehicle.isReversed() && s.drawReversed;
1114}
1115
1116bool
1118 if (getVType().getParameter().carriageLength > 0) {
1119 drawAction_drawCarriageClass(s, asImage);
1120 return true;
1121 } else {
1123 s, getVType().getImgFile(), this, getVType().getWidth(), scaledLength)) {
1124 return false;
1125 }
1126 GUIBaseVehicleHelper::drawAction_drawVehicleAsPoly(s, getVType().getGuiShape(), getVType().getWidth(), scaledLength, -1, myVehicle.isStopped(), drawReversed(s));
1127 return false;
1128 }
1129}
1130
1131
1132int
1134 if (myVehicle.getPersonDevice() != nullptr) {
1135 return (int)myVehicle.getPersonDevice()->size();
1136 }
1137 return 0;
1138}
1139
1140
1141int
1143 if (myVehicle.getContainerDevice() != nullptr) {
1144 return (int)myVehicle.getContainerDevice()->size();
1145 }
1146 return 0;
1147}
1148
1149std::string
1151 std::vector<std::string> devs;
1152 for (MSDevice* d : myVehicle.getDevices()) {
1153 devs.push_back(d->deviceName());
1154 }
1155 return joinToString(devs, " ");
1156}
1157
1158
1159void
1160GUIBaseVehicle::computeSeats(const Position& front, const Position& back, double seatOffset, int maxSeats, double exaggeration, int& requiredSeats, Seats& into) const {
1161 if (requiredSeats <= 0) {
1162 return;
1163 }
1164 maxSeats = MAX2(maxSeats, 1); // compute at least one seat
1165 seatOffset *= exaggeration;
1166 const double vehWidth = getVType().getSeatingWidth() * exaggeration;
1167 const double length = front.distanceTo2D(back);
1168 const int rowSize = MAX2(1, (int)floor(vehWidth / seatOffset));
1169 const double rowOffset = MAX2(1.0, (length - getVType().getFrontSeatPos() - 1)) / ceil((double)maxSeats / rowSize);
1170 const double sideOffset = (rowSize - 1) / 2.0 * seatOffset;
1171 double rowPos = getVType().getFrontSeatPos() - rowOffset;
1172 double angle = back.angleTo2D(front);
1173 const int fillDirection = MSGlobals::gLefthand ? -1 : 1;
1174 //if (myVehicle.getID() == "v0") std::cout << SIMTIME << " seatOffset=" << seatOffset << " max=" << maxSeats << " ex=" << exaggeration << " req=" << requiredSeats << " rowSize=" << rowSize << " sideOffset=" << sideOffset << " front=" << front << " back=" << back << " a=" << angle << " da=" << RAD2DEG(angle) << "\n";
1175 for (int i = 0; requiredSeats > 0 && i < maxSeats; i++) {
1176 int seat = (i % rowSize);
1177 if (seat == 0) {
1178 rowPos += rowOffset;
1179 }
1180 into.push_back(Seat(PositionVector::positionAtOffset2D(front, back, rowPos, (sideOffset - seat * seatOffset) * fillDirection), angle));
1181 requiredSeats--;
1182 }
1183}
1184
1185
1186/****************************************************************************/
long long int SUMOTime
Definition: GUI.h:36
@ MID_HIDE_ALLROUTES
Hide all vehicle's routes.
Definition: GUIAppEnum.h:502
@ MID_HIDE_BEST_LANES
Hide vehicle's best lanes.
Definition: GUIAppEnum.h:498
@ MID_HIDE_CURRENTROUTE
Hide vehicle's current route.
Definition: GUIAppEnum.h:486
@ MID_SHOW_FOES
select foes of a vehicle
Definition: GUIAppEnum.h:508
@ MID_SHOW_BEST_LANES
Show vehicle's best lanes.
Definition: GUIAppEnum.h:496
@ MID_START_TRACK
Start to track a vehicle.
Definition: GUIAppEnum.h:504
@ MID_SHOW_ALLROUTES
Show all vehicle's routes.
Definition: GUIAppEnum.h:500
@ MID_SHOW_LFLINKITEMS
Definition: GUIAppEnum.h:509
@ MID_SHOW_ROUTE_NOLOOPS
Show vehicle's future route (without loops)
Definition: GUIAppEnum.h:492
@ MID_HIDE_ROUTE_NOLOOPS
Hide vehicle's future route (without loops)
Definition: GUIAppEnum.h:494
@ MID_TOGGLE_STOP
toggle stop state of a vehicle or person
Definition: GUIAppEnum.h:514
@ MID_HIDE_LFLINKITEMS
Definition: GUIAppEnum.h:510
@ MID_REMOVE_OBJECT
remove a vehicle or person
Definition: GUIAppEnum.h:516
@ MID_SHOW_FUTUREROUTE
Show vehicle's future route.
Definition: GUIAppEnum.h:488
@ MID_HIDE_FUTUREROUTE
Hide vehicle's future route.
Definition: GUIAppEnum.h:490
@ MID_SHOW_CURRENTROUTE
Show vehicle's current route.
Definition: GUIAppEnum.h:484
@ MID_STOP_TRACK
Stop to track a vehicle.
Definition: GUIAppEnum.h:506
@ MID_SELECT_TRANSPORTED
select transportables of a vehicle
Definition: GUIAppEnum.h:512
FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[]
@ GLO_VEHICLE
a vehicle
GUISelectedStorage gSelected
A global holder of selected objects.
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
#define RAD2DEG(x)
Definition: GeomHelper.h:36
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:268
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:267
#define TL(string)
Definition: MsgHandler.h:284
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition: Route.h:32
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
#define STEPS2TIME(x)
Definition: SUMOTime.h:54
#define SIMSTEP
Definition: SUMOTime.h:60
#define TIME2STEPS(x)
Definition: SUMOTime.h:56
const long long int VTYPEPARS_COLOR_SET
@ RAIL_CARGO
render as a cargo train
@ EMERGENCY
render as an emergency vehicle
@ RAIL
render as a rail
@ SCOOTER
render as a scooter
@ RAIL_CAR
render as a (city) rail without locomotive
@ SHIP
render as a arbitrary ship
@ BICYCLE
render as a bicycle
@ MOTORCYCLE
render as a motorcycle
@ ANT
render as a giant ant
@ AIRCRAFT
render as aircraft
@ FIREBRIGADE
render as a fire brigade
@ MOPED
render as a moped
@ POLICE
render as a police car
@ PEDESTRIAN
render as a pedestrian
const int VEHPARS_COLOR_SET
const int VEHPARS_ARRIVALPOS_SET
T MIN2(T a, T b)
Definition: StdDefs.h:76
T MAX2(T a, T b)
Definition: StdDefs.h:82
const double SUMO_const_waitingContainerWidth
Definition: StdDefs.h:54
const double SUMO_const_waitingPersonWidth
Definition: StdDefs.h:52
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:283
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:112
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:78
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:130
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:118
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:136
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:124
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:583
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:498
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:139
static void drawOutlineCircle(double width, double iwidth, int steps=8)
Draws an unfilled circle around (0,0)
Definition: GLHelper.cpp:525
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
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:329
static void popName()
pop Name
Definition: GLHelper.cpp:148
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
Definition: GLHelper.cpp:685
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition: GLHelper.cpp:716
long onCmdHideFutureRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
long onCmdStartTrack(FXObject *, FXSelector, void *)
Called if the vehicle shall be tracked.
long onCmdHideBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be hidden.
long onCmdHideCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
long onCmdShowBestLanes(FXObject *, FXSelector, void *)
Called if the vehicle's best lanes shall be shown.
long onCmdShowRouteNoLoops(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
long onCmdShowLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
long onCmdShowFoes(FXObject *, FXSelector, void *)
Called to show (select) a vehicles foes.
long onCmdHideRouteNoLoops(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be hidden.
long onCmdShowFutureRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
long onCmdShowAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be shown.
long onCmdToggleStop(FXObject *, FXSelector, void *)
Called when toggling stop state.
long onCmdStopTrack(FXObject *, FXSelector, void *)
Called if the current shall not be tracked any longer.
long onCmdSelectTransported(FXObject *, FXSelector, void *)
Called to select all riding persons and containers.
long onCmdRemoveObject(FXObject *, FXSelector, void *)
Called when removing the vehicle.
long onCmdHideAllRoutes(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
long onCmdHideLFLinkItems(FXObject *, FXSelector, void *)
Called if all routes of the vehicle shall be hidden.
long onCmdShowCurrentRoute(FXObject *, FXSelector, void *)
Called if the current route of the vehicle shall be shown.
static bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, const std::string &file, const GUIGlObject *o, const double width, double length)
try to draw vehicle as raster image and return true if successful
static void drawAction_drawVehicleAsCircle(const double width, double detail)
draw vehicle as a circle
static void drawAction_drawVehicleAsTrianglePlus(const double width, const double length, bool amReversed=false)
draw vehicle as a triangle
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1, bool isStopped=false, bool amReversed=false)
draw vehicle as a polygon
static void drawAction_drawVehicleAsBoxPlus(const double width, const double length, bool amReversed=false)
draw vehicle as a Box
A MSVehicle extended by some values for usage within the gui.
void drawParkingInfo(const GUIVisualizationSettings &s, const RGBColor &col) const
const Seat & getContainerPosition(int containerIndex) const
static bool setFunctionalColor(int activeScheme, const MSBaseVehicle *veh, RGBColor &col)
sets the color according to the current scheme index and some vehicle function
const std::string getOptionalName() const
Returns the value for generic parameter 'name' or ''.
virtual void drawAction_drawLinkItems(const GUIVisualizationSettings &) const
const Seat & getSeatPosition(int personIndex) const
returns the seat position for the person with the given index
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the current settings
int getNumContainers() const
return the number of passengers
void drawOnPos(const GUIVisualizationSettings &s, const Position &pos, const double angle) const
Draws the object on the specified position with the specified angle.
GUIGLObjectPopupMenu * myPopup
current popup (to clean up in destructor). GUIBaseVehicle is not responsible for removal
GUIBaseVehicle(MSBaseVehicle &vehicle)
MSDevice_Vehroutes * myRoutes
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &s) const
bool hasActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) const
Returns whether the named feature is enabled in the given view.
virtual void drawRouteHelper(const GUIVisualizationSettings &s, ConstMSRoutePtr r, bool future, bool noLoop, const RGBColor &col) const =0
Draws the route.
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
void drawRoute(const GUIVisualizationSettings &s, int routeNo, double darken, bool future=false, bool noLoop=false) const
Chooses the route to draw and draws it, darkening it as given.
virtual Position getVisualPosition(bool s2, const double offset=0) const =0
Return current position taking into account secondary shape.
std::vector< Seat > Seats
MSBaseVehicle & myVehicle
The vehicle to which all calls should be delegated.
virtual void drawAction_drawVehicleBlinker(double) const
void removedPopupMenu()
notify object about popup menu removal
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
static void drawLinkItem(const Position &pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate)
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the size multiplier value according to the current scheme index
virtual void drawBestLanes() const
Draws the vehicle's best lanes.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void computeSeats(const Position &front, const Position &back, double seatOffset, int maxSeats, double exaggeration, int &requiredSeats, Seats &into) const
add seats to mySeatPositions and update requiredSeats
virtual Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
@ VO_SHOW_LFLINKITEMS
LFLinkItems.
@ VO_SHOW_ALL_ROUTES
show all vehicle's routes
@ VO_TRACK
track the vehicle (only needed for cleaning up)
@ VO_SHOW_ROUTE_NOLOOP
show vehicle's routes without loops
@ VO_SHOW_FUTURE_ROUTE
show vehicle's current continued from the current position
@ VO_SHOW_ROUTE
show vehicle's current route
@ VO_SHOW_BEST_LANES
show vehicle's best lanes
virtual void drawAction_drawCarriageClass(const GUIVisualizationSettings &s, bool asImage) const =0
draws the given guiShape with distinct carriages/modules
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additionally triggered visualisations.
Seats myContainerPositions
bool drawReversed(const GUIVisualizationSettings &s) const
whether to reverse trains in their reversed state
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
virtual void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
virtual double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const =0
gets the color value according to the current scheme index
int getNumPassengers() const
return the number of passengers
bool drawAction_drawVehicleAsPolyWithCarriagges(const GUIVisualizationSettings &s, double scaledLength, bool asImage=false) const
draw vehicle body and return whether carriages are being drawn
~GUIBaseVehicle()
destructor
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
virtual void drawAction_drawVehicleBlueLight() const
std::map< GUISUMOAbstractView *, int > myAdditionalVisualizations
Enabled visualisations, per view.
virtual void selectBlockingFoes() const =0
adds the blocking foes to the current selection
void drawStopLabels(const GUIVisualizationSettings &s, bool noLoop, const RGBColor &col) const
Seats mySeatPositions
positions of seats in the vehicle (updated at every drawing step)
const MSBaseVehicle & getVehicle()
std::string getDeviceDescription()
lists equipped device (types) for the current vehicle
virtual double getVisualAngle(bool s2) const =0
Returns the vehicle's direction in radians taking into account secondary shape.
const MSVehicleType & getVType() const
A shortcut to myVehicle.myType.
void setPositionInVehicle(const GUIBaseVehicle::Seat &pos)
Definition: GUIContainer.h:113
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:42
The popup menu of a globject.
GUISUMOAbstractView * getParentView()
return the real owner of this popup
void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the type parameter window.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:154
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:102
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static bool gSecondaryShape
whether secondary shapes are currently being drawn
Definition: GUIGlobals.h:49
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:82
A lane area vehicles can halt at (gui-version)
const Position & getSignPos() const
void setPositionInVehicle(const GUIBaseVehicle::Seat &pos)
Definition: GUIPerson.cpp:375
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUIPerson.cpp:285
const T getColor(const double value) const
bool removeAdditionalGLVisualisation(GUIGlObject *const which)
Removes an object from the list of objects that show additional things.
void destroyPopup()
destroys the popup
bool addAdditionalGLVisualisation(GUIGlObject *const which)
Adds an object to call its additional visualisation method.
virtual GUIGlID getTrackedID() const
get tracked id
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
Stores the information about how to visualize structures.
GUIVisualizationTextSettings vehicleName
GUIVisualizationSizeSettings vehicleSize
bool showBlinker
Information whether vehicle blinkers shall be drawn.
GUIColorer vehicleColorer
The vehicle colorer.
GUIVisualizationTextSettings vehicleScaleValue
std::string vehicleScaleParam
key for scaling by vehicle parameter
bool showParkingInfo
Set whether parking related information should be shown.
GUIVisualizationTextSettings vehicleValue
int vehicleQuality
The quality of vehicle drawing.
double laneWidthExaggeration
The lane exaggeration (upscale thickness)
std::string vehicleTextParam
key for rendering vehicle textual parameter
bool scaleLength
Whether vehicle length shall be scaled with length/geometry factor.
GUIScaler vehicleScaler
The size scaling settings for vehicles.
double scale
information about a lane's width (temporary, used for a single view)
bool secondaryShape
whether secondary lane shape shall be drawn
bool drawMinGap
Information whether the minimum gap shall be drawn.
GUIVisualizationTextSettings vehicleText
bool showBTRange
Information whether the communication range shall be drawn.
bool drawReversed
Whether to draw reversed vehicles in their reversed state.
bool drawBrakeGap
Information whether the brake gap shall be drawn.
bool drawLaneChangePreference
Information whether the lane change preference shall be drawn.
double angle
The current view rotation angle.
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:192
void vaporizeCar(MEVehicle *v, MSMoveReminder::Notification reason)
remove the given car and clean up the relevant data structures
Definition: MELoop.cpp:251
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:42
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:55
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
ConstMSRoutePtr getRoutePtr() const
Returns the current route.
virtual bool isSelected() const
whether this vehicle is selected in the GUI
const std::vector< MSTransportable * > & getPersons() const
retrieve riding persons
std::map< const MSParkingArea *, PaMemory, ComparatorIdLess > ParkingMemory
const std::vector< MSVehicleDevice * > & getDevices() const
Returns this vehicle's devices.
virtual double getArrivalPos() const
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
virtual double getStopDelay() const
Returns the estimated public transport stop (departure) delay in seconds.
MoveReminderCont myMoveReminders
Currently relevant move reminders.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
int getNumberParkingReroutes() const
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
virtual const MSEdge * getCurrentEdge() const
Returns the edge the vehicle is currently at (possibly an internal edge)
bool isReversed() const
Returns whether the logical state of the vehicle is reversed - for drawing.
virtual double getTimeLossSeconds() const
Returns the time loss in seconds.
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
bool isParking() const
Returns whether the vehicle is parking.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
virtual int getArrivalLane() const
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
const std::list< MSStop > & getStops() const
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
const MSDevice_Transportable * getPersonDevice() const
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
std::string getPrefixedParameter(const std::string &key, std::string &error) const
retrieve parameters of devices, models and the vehicle itself
virtual double getStopArrivalDelay() const
Returns the estimated public transport stop arrival delay in seconds.
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
virtual double getAcceleration() const
Returns the vehicle's acceleration.
virtual double getRightSideOnEdge(const MSLane *lane=0) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0)
const MSRoute & getRoute() const
Returns the current route.
const MSDevice_Transportable * getContainerDevice() const
SUMOTime getDepartDelay() const
Returns the depart delay.
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
const std::vector< MSTransportable * > & getContainers() const
retrieve riding containers
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool isStopped() const
Returns whether the vehicle is at a stop.
const ParkingMemory * getParkingMemory() const
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
Definition: MSCFModel.h:380
static double getRange()
Returns the configured range.
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
int size() const
Return the number of passengers / containers.
ConstMSRoutePtr getRoute(int index) const
Called on route retrieval.
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, int maxRoutes=std::numeric_limits< int >::max())
Build devices for the given vehicle, if needed.
Abstract in-vehicle / in-person device.
Definition: MSDevice.h:61
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
double getWidth() const
Returns the edges's width (sum over all lanes)
Definition: MSEdge.h:629
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition: MSEdge.cpp:1068
static bool gUseMesoSim
Definition: MSGlobals.h:103
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:109
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition: MSGlobals.h:169
static bool gUseStopEnded
whether the simulation should replay previous stop times
Definition: MSGlobals.h:130
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2544
virtual double getLengthGeometryFactor(bool) const
Definition: MSLane.h:289
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:565
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:474
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:504
virtual const PositionVector & getShape(bool) const
Definition: MSLane.h:293
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:622
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:551
@ NOTIFICATION_VAPORIZED_GUI
The vehicle got removed via the GUI.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:183
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:378
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:124
const RGBColor & getColor() const
Returns the color.
Definition: MSRoute.cpp:397
Definition: MSStop.h:44
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
double getTimeGapOnLane() const
Returns the time gap in seconds to the leader of the vehicle on the same lane.
Definition: MSVehicle.cpp:6288
PositionVector getBoundingPoly(double offset=0) const
get bounding polygon
Definition: MSVehicle.cpp:6716
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs.
Definition: MSVehicle.h:715
MSAbstractLaneChangeModel & getLaneChangeModel()
Definition: MSVehicle.cpp:5510
bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string &errorMsg)
Definition: MSVehicle.cpp:6841
PositionVector getBoundingBox(double offset=0) const
get bounding rectangle
Definition: MSVehicle.cpp:6685
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
Definition: MSVehicle.cpp:1020
bool resumeFromStopping()
Definition: MSVehicle.cpp:6879
int getBestLaneOffset() const
Definition: MSVehicle.cpp:6176
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:584
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
Definition: MSVehicle.h:592
std::pair< const MSLane *, double > getLanePosAfterDist(double distance) const
return lane and position along bestlanes at the given distance
Definition: MSVehicle.cpp:6211
double getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:493
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition: MSVehicle.h:973
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getSeatingWidth() const
Get the width of the passenger compartment when being drawn.
double getMinGap() const
Get the free space in front of vehicles of this class.
double getFrontSeatPos() const
Get offset of first seat from vehicle front.
double getLength() const
Get vehicle's length [m].
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:80
const RGBColor & getColor() const
Returns this type's color.
const std::string & getID() const
Returns the id.
Definition: Named.h:74
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:254
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:244
double x() const
Returns the x-position.
Definition: Position.h:55
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
Definition: Position.h:264
double y() const
Returns the y-position.
Definition: Position.h:60
A list of positions.
PositionVector getOrthogonal(const Position &p, double extend, bool before, double length=1.0, double deg=90) const
return orthogonal through p (extending this vector if necessary)
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const RGBColor WHITE
Definition: RGBColor.h:192
static const RGBColor BLUE
Definition: RGBColor.h:187
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.cpp:92
RGBColor multiply(double factor) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:230
static const RGBColor GREEN
Definition: RGBColor.h:186
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
Definition: RGBColor.cpp:371
static const RGBColor BLACK
Definition: RGBColor.h:193
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:200
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:199
static const RGBColor RED
named colors
Definition: RGBColor.h:185
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
virtual double getAngle() const =0
Get the vehicle's angle.
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
double startPos
The stopping position start.
double endPos
The stopping position end.
SUMOTime duration
The stopping duration.
RGBColor color
The vehicle's color, TraCI may change this.
bool wasSet(int what) const
Returns whether the given parameter was set.
int arrivalEdge
(optional) The final edge within the route of the vehicle
std::string line
The vehicle's line (mainly for public transport)
static const int NEWLINE
identifier for splitting the given string at all newline characters
std::vector< std::string > getVector()
return vector of strings
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
#define M_PI
Definition: odrSpiral.cpp:45
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool constantSizeSelected
whether only selected objects shall be drawn with constant
bool show(const GUIGlObject *o) const
whether to show the text
double scaledSize(double scale, double constFactor=0.1) const
get scale size