Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIBaseVehicle.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2026 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>
43#include <mesosim/MEVehicle.h>
44#include <mesosim/MELoop.h>
45#include <microsim/MSVehicle.h>
46#include <microsim/MSLane.h>
50#include <microsim/MSStop.h>
58#include <gui/GUIGlobals.h>
60
61#include "GUIBaseVehicle.h"
62#include "GUIChargingStation.h"
63#include "GUIPerson.h"
64#include "GUIContainer.h"
65#include "GUINet.h"
66#include "GUIEdge.h"
67#include "GUILane.h"
68#include "GUIParkingArea.h"
69
70//#define DRAW_BOUNDING_BOX
71
72// ===========================================================================
73// FOX callback mapping
74// ===========================================================================
75FXDEFMAP(GUIBaseVehicle::GUIBaseVehiclePopupMenu) GUIBaseVehiclePopupMenuMap[] = {
94};
95
96// Object implementation
97FXIMPLEMENT(GUIBaseVehicle::GUIBaseVehiclePopupMenu, GUIGLObjectPopupMenu, GUIBaseVehiclePopupMenuMap, ARRAYNUMBER(GUIBaseVehiclePopupMenuMap))
98
99// ===========================================================================
100// method definitions
101// ===========================================================================
102/* -------------------------------------------------------------------------
103 * GUIBaseVehicle::GUIBaseVehiclePopupMenu - methods
104 * ----------------------------------------------------------------------- */
109
110
112
113
114long
116 assert(myObject->getType() == GLO_VEHICLE);
119 }
120 return 1;
121}
122
123long
125 assert(myObject->getType() == GLO_VEHICLE);
127 return 1;
128}
129
130
131long
133 assert(myObject->getType() == GLO_VEHICLE);
134 if (!static_cast<GUIBaseVehicle*>(myObject)->hasActiveAddVisualisation(myParent, VO_SHOW_ROUTE)) {
136 }
137 return 1;
138}
139
140long
142 assert(myObject->getType() == GLO_VEHICLE);
144 return 1;
145}
146
147
148long
150 assert(myObject->getType() == GLO_VEHICLE);
153 }
154 return 1;
155}
156
157long
159 assert(myObject->getType() == GLO_VEHICLE);
161 return 1;
162}
163
164
165long
167 assert(myObject->getType() == GLO_VEHICLE);
170 }
171 return 1;
172}
173
174long
176 assert(myObject->getType() == GLO_VEHICLE);
178 return 1;
179}
180
181
182long
184 assert(myObject->getType() == GLO_VEHICLE);
187 }
188 return 1;
189}
190
191long
193 assert(myObject->getType() == GLO_VEHICLE);
195 return 1;
196}
197
198
199long
201 assert(myObject->getType() == GLO_VEHICLE);
202 if (myParent->getTrackedID() != static_cast<GUIBaseVehicle*>(myObject)->getGlID()) {
203 myParent->startTrack(static_cast<GUIBaseVehicle*>(myObject)->getGlID());
204 }
205 return 1;
206}
207
208long
210 assert(myObject->getType() == GLO_VEHICLE);
211 myParent->stopTrack();
212 return 1;
213}
214
215
216long
218 assert(myObject->getType() == GLO_VEHICLE);
221 }
222 return 1;
223}
224
225long
227 assert(myObject->getType() == GLO_VEHICLE);
229 return 1;
230}
231
232long
234 assert(myObject->getType() == GLO_VEHICLE);
235 static_cast<GUIBaseVehicle*>(myObject)->selectBlockingFoes();
236 myParent->update();
237 return 1;
238}
239
240
241long
243 assert(myObject->getType() == GLO_VEHICLE);
244 const MSBaseVehicle& veh = static_cast<GUIBaseVehicle*>(myObject)->getVehicle();
245 for (const MSTransportable* t : veh.getPersons()) {
246 gSelected.select((static_cast<const GUIPerson*>(t))->getGlID());
247 }
248 for (MSTransportable* t : veh.getContainers()) {
249 gSelected.select((static_cast<const GUIContainer*>(t))->getGlID());
250 }
251 myParent->update();
252 return 1;
253}
254
255long
257 GUIBaseVehicle* baseVeh = static_cast<GUIBaseVehicle*>(myObject);
258 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&baseVeh->myVehicle);
259 if (microVeh != nullptr) {
260 MSLane* lane = microVeh->getMutableLane();
261 if (lane != nullptr) {
262 lane->getVehiclesSecure();
264 }
266 if (lane != nullptr) {
267 lane->releaseVehicles();
268 }
269 } else {
270 MEVehicle* mesoVeh = dynamic_cast<MEVehicle*>(&baseVeh->myVehicle);
272 }
274 myParent->destroyPopup();
275 myParent->update();
276 return 1;
277}
278
279
280long
282 GUIBaseVehicle* baseVeh = static_cast<GUIBaseVehicle*>(myObject);
283 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&baseVeh->myVehicle);
284 if (microVeh != nullptr) {
285 if (microVeh->isStopped()) {
286 microVeh->resumeFromStopping();
287 } else {
288 std::string errorOut;
289 const double brakeGap = microVeh->getCarFollowModel().brakeGap(microVeh->getSpeed());
290 std::pair<const MSLane*, double> stopPos = microVeh->getLanePosAfterDist(brakeGap);
291 if (stopPos.first != nullptr) {
293 stop.lane = stopPos.first->getID();
294 stop.startPos = stopPos.second;
295 stop.endPos = stopPos.second + POSITION_EPS;
296 stop.duration = TIME2STEPS(3600);
297 microVeh->addTraciStop(stop, errorOut);
298 if (errorOut != "") {
299 WRITE_WARNING(errorOut);
300 }
301 }
302 }
303 } else {
304 WRITE_WARNING(TL("GUI-triggered stop not implemented for meso"));
305 }
306 myParent->update();
307 return 1;
308}
309
310
311/* -------------------------------------------------------------------------
312 * GUIBaseVehicle - methods
313 * ----------------------------------------------------------------------- */
314
316 GUIGlObject(GLO_VEHICLE, vehicle.getID(), GUIIconSubSys::getIcon(GUIIcon::VEHICLE)),
317 myVehicle(vehicle),
318 myPopup(nullptr) {
319 // as it is possible to show all vehicle routes, we have to store them... (bug [ 2519761 ])
321 myVehicle.myMoveReminders.push_back(std::make_pair(myRoutes, 0.));
322 mySeatPositions.push_back(Seat()); // ensure length 1
323 myContainerPositions.push_back(Seat()); // ensure length 1
324}
325
326
328 myLock.lock();
329 for (std::map<GUISUMOAbstractView*, int>::iterator i = myAdditionalVisualizations.begin(); i != myAdditionalVisualizations.end(); ++i) {
330 if (i->first->getTrackedID() == getGlID()) {
331 i->first->stopTrack();
332 }
333 while (i->first->removeAdditionalGLVisualisation(this));
334 }
335 myLock.unlock();
336 delete myRoutes;
337 if (myPopup != nullptr) {
339 }
340}
341
342
345 GUIGLObjectPopupMenu* ret = new GUIBaseVehiclePopupMenu(app, parent, this);
346 buildPopupHeader(ret, app);
350 //
352 GUIDesigns::buildFXMenuCommand(ret, TL("Hide Current Route"), nullptr, ret, MID_HIDE_CURRENTROUTE);
353 } else {
354 GUIDesigns::buildFXMenuCommand(ret, TL("Show Current Route"), nullptr, ret, MID_SHOW_CURRENTROUTE);
355 }
357 GUIDesigns::buildFXMenuCommand(ret, TL("Hide Future Route"), nullptr, ret, MID_HIDE_FUTUREROUTE);
358 } else {
359 GUIDesigns::buildFXMenuCommand(ret, TL("Show Future Route"), nullptr, ret, MID_SHOW_FUTUREROUTE);
360 }
362 GUIDesigns::buildFXMenuCommand(ret, TL("Hide All Routes"), nullptr, ret, MID_HIDE_ALLROUTES);
363 } else {
364 GUIDesigns::buildFXMenuCommand(ret, TL("Show All Routes"), nullptr, ret, MID_SHOW_ALLROUTES);
365 }
367 FXMenuCheck* showLoops = new FXMenuCheck(ret, TL("Draw looped routes"), ret, MID_HIDE_ROUTE_NOLOOPS);
368 showLoops->setCheck(false);
369 } else {
370 FXMenuCheck* showLoops = new FXMenuCheck(ret, TL("Draw looped routes"), ret, MID_SHOW_ROUTE_NOLOOPS);
371 showLoops->setCheck(true);
372 }
374 GUIDesigns::buildFXMenuCommand(ret, TL("Hide Best Lanes"), nullptr, ret, MID_HIDE_BEST_LANES);
375 } else {
376 GUIDesigns::buildFXMenuCommand(ret, TL("Show Best Lanes"), nullptr, ret, MID_SHOW_BEST_LANES);
377 }
379 GUIDesigns::buildFXMenuCommand(ret, TL("Hide Link Items"), nullptr, ret, MID_HIDE_LFLINKITEMS);
380 } else {
381 GUIDesigns::buildFXMenuCommand(ret, TL("Show Link Items"), nullptr, ret, MID_SHOW_LFLINKITEMS);
382 }
383 new FXMenuSeparator(ret);
384 if (parent.getTrackedID() != getGlID()) {
385 GUIDesigns::buildFXMenuCommand(ret, TL("Start Tracking"), nullptr, ret, MID_START_TRACK);
386 } else {
387 GUIDesigns::buildFXMenuCommand(ret, TL("Stop Tracking"), nullptr, ret, MID_STOP_TRACK);
388 }
389 GUIDesigns::buildFXMenuCommand(ret, TL("Select Foes"), nullptr, ret, MID_SHOW_FOES);
390 if (myVehicle.getPersons().size() + myVehicle.getContainers().size() > 0) {
391 GUIDesigns::buildFXMenuCommand(ret, TL("Select transported"), nullptr, ret, MID_SELECT_TRANSPORTED);
392 }
393 GUIDesigns::buildFXMenuCommand(ret, myVehicle.isStopped() ? TL("Abort stop") : TL("Stop"), nullptr, ret, MID_TOGGLE_STOP);
394 GUIDesigns::buildFXMenuCommand(ret, TL("Remove"), nullptr, ret, MID_REMOVE_OBJECT);
395
396 new FXMenuSeparator(ret);
397 //
398 buildShowParamsPopupEntry(ret, false);
400 buildPositionCopyEntry(ret, app);
401 myPopup = ret;
402 return ret;
403}
404
405
406void
410
411
412double
417
418
426
427
428const std::string
432
433
434void
435GUIBaseVehicle::drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const double angle) const {
438 Position p1 = pos;
439 const double degAngle = RAD2DEG(angle + M_PI / 2.);
440 const double length = getVType().getLength();
441 if (s.trueZ) {
442 glTranslated(p1.x(), p1.y(), p1.z() + 1);
443 } else {
444 glTranslated(p1.x(), p1.y(), getType());
445 }
446 glRotated(degAngle, 0, 0, 1);
447 RGBColor col = setColor(s);
448 // scale
449 const double upscale = getExaggeration(s);
450 const bool s2 = s.secondaryShape;
451
452 if (upscale > 1 && s.laneWidthExaggeration > 1 && myVehicle.isOnRoad()) {
453 // optionally shift according to edge exaggeration
454 double offsetFromLeftBorder = myVehicle.getCurrentEdge()->getWidth() - myVehicle.getRightSideOnEdge() - myVehicle.getVehicleType().getWidth() / 2;
455 glTranslated((s.laneWidthExaggeration - 1) * -offsetFromLeftBorder / 2, 0, 0);
456 }
457
458 double upscaleLength = MSTrainHelper::getUpscaleLength(upscale, length, getVType().getWidth(), s.vehicleQuality);
459 glScaled(upscale, upscaleLength, 1);
460 /*
461 MSLaneChangeModel::DK2004 &m2 = static_cast<MSLaneChangeModel::DK2004&>(veh->getLaneChangeModel());
462 if((m2.getState()&LCA_URGENT)!=0) {
463 glColor3d(1, .4, .4);
464 } else if((m2.getState()&LCA_SPEEDGAIN)!=0) {
465 glColor3d(.4, .4, 1);
466 } else {
467 glColor3d(.4, 1, .4);
468 }
469 */
470 // draw the vehicle
471 bool drawCarriages = false;
472 // do not upscale vehicles on physically impossible geometry factors > 1
473 const double geometryFactor = (s.scaleLength ?
474 MIN2(1.0, (myVehicle.getLane() != nullptr
476 : (myVehicle.getEdge()->getLanes().size() > 0 ? myVehicle.getEdge()->getLanes()[0]->getLengthGeometryFactor(s2) : 1)))
477 : 1);
478 double scaledLength = length * geometryFactor;
479 if (col.alpha() != 0) {
480 switch (s.vehicleQuality) {
481 case 0:
483 break;
484 case 1:
486 break;
487 case 2:
488 drawCarriages = drawAction_drawVehicleAsPolyWithCarriagges(s, scaledLength);
489 // draw flashing blue light for emergency vehicles
490 if (getVType().getGuiShape() == SUMOVehicleShape::EMERGENCY) {
491 glTranslated(0, 0, .1);
493 }
494 break;
495 case 3:
496 drawCarriages = drawAction_drawVehicleAsPolyWithCarriagges(s, scaledLength, true);
497 break;
498 case 4: {
499 // do not scale circle radius by lengthGeometryFactor nor length and reduce the effect of width
500 const double w = 1.8 * sqrt(getVType().getWidth() / 1.8);
502 // display text at circle center
503 scaledLength = 0;
504 break;
505 }
506 default:
507 break;
508 }
509 if (s.drawMinGap) {
510 const double minGap = -getVType().getMinGap();
511 glColor3d(0., 1., 0.);
512 glBegin(GL_LINES);
513 glVertex2d(0., 0);
514 glVertex2d(0., minGap);
515 glVertex2d(-.5, minGap);
516 glVertex2d(.5, minGap);
517 glEnd();
518 }
521 const double brakeGap = -static_cast<MSVehicle&>(myVehicle).getCarFollowModel().brakeGap(myVehicle.getSpeed());
522 glColor3d(1., 0., 0.);
523 glBegin(GL_LINES);
524 glVertex2d(0., 0);
525 glVertex2d(0., brakeGap);
526 glVertex2d(-.5, brakeGap);
527 glVertex2d(.5, brakeGap);
528 glEnd();
529 }
530 if (s.showBTRange) {
532 if (dev != nullptr) {
533 glColor3d(1., 0., 0.);
534 GLHelper::drawOutlineCircle(dev->getRange(), dev->getRange() - .2, 32);
535 }
536 }
537 // draw the blinker and brakelights if wished
538 if (s.showBlinker) {
539 glTranslated(0, 0, .1);
540 switch (getVType().getGuiShape()) {
554 break;
557 drawAction_drawVehicleBlinker(scaledLength);
558 drawAction_drawVehicleBrakeLight(scaledLength, true);
559 break;
560 default:
561 // only SUMOVehicleShape::RAIL_CAR has blinkers and brake lights but they are drawn along with the carriages
562 if (!drawCarriages) {
563 drawAction_drawVehicleBlinker(scaledLength);
565 }
566 break;
567 }
568 }
569 // draw the wish to change the lane
571 /*
572 if(gSelected.isSelected(GLO_VEHICLE, veh->getGlID())) {
573 MSLaneChangeModel::DK2004 &m = static_cast<MSLaneChangeModel::DK2004&>(veh->getLaneChangeModel());
574 glColor3d(.5, .5, 1);
575 glBegin(GL_LINES);
576 glVertex2f(0, 0);
577 glVertex2f(m.getChangeProbability(), .5);
578 glEnd();
579
580 glColor3d(1, 0, 0);
581 glBegin(GL_LINES);
582 glVertex2f(0.1, 0);
583 glVertex2f(0.1, m.myMaxJam1);
584 glEnd();
585
586 glColor3d(0, 1, 0);
587 glBegin(GL_LINES);
588 glVertex2f(-0.1, 0);
589 glVertex2f(-0.1, m.myTDist);
590 glEnd();
591 }
592 */
593 }
594 }
595 glTranslated(0, MIN2(scaledLength / 2, double(5)), -getType()); // drawing name at GLO_MAX fails unless translating z
596 glScaled(1 / upscale, 1 / upscaleLength, 1);
597 glRotated(-degAngle, 0, 0, 1);
598 drawName(Position(0, 0), s.scale, s.vehicleName, s.angle);
599 if (s.vehicleName.show(this) && myVehicle.getParameter().line != "") {
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);
604 }
605 if (s.vehicleValue.show(this)) {
606 glRotated(-s.angle, 0, 0, 1);
607 glTranslated(0, 0.7 * s.vehicleName.scaledSize(s.scale), 0);
608 glRotated(s.angle, 0, 0, 1);
609 const double value = getColorValue(s, s.vehicleColorer.getActive());
610 if (value != s.MISSING_DATA) {
612 }
613 }
614 if (s.vehicleScaleValue.show(this)) {
615 glRotated(-s.angle, 0, 0, 1);
616 glTranslated(0, 0.7 * s.vehicleName.scaledSize(s.scale), 0);
617 glRotated(s.angle, 0, 0, 1);
618 const double value = getScaleValue(s, s.vehicleScaler.getActive());
619 if (value != s.MISSING_DATA) {
621 }
622 }
623 if (s.vehicleText.show(this)) {
624 std::string error;
625 std::string value = myVehicle.getPrefixedParameter(s.vehicleTextParam, error);
626 if (value != "") {
628 glRotated(-s.angle, 0, 0, 1);
629 glTranslated(0, 0.7 * s.vehicleText.scaledSize(s.scale) * (double)lines.size(), 0);
630 glRotated(s.angle, 0, 0, 1);
631 for (std::string& line : lines) {
633 glRotated(-s.angle, 0, 0, 1);
634 glTranslated(0, -0.7 * s.vehicleText.scaledSize(s.scale), 0);
635 glRotated(s.angle, 0, 0, 1);
636 }
637 }
638 }
641 glRotated(-s.angle, 0, 0, 1);
642 glTranslated(0, 0.7 * s.vehicleName.scaledSize(s.scale), 0);
643 glRotated(s.angle, 0, 0, 1);
644 const double value = myVehicle.getNumberParkingReroutes();
646 }
647
648 if (!drawCarriages) {
649 mySeatPositions.clear();
650 myContainerPositions.clear();
651 int requiredSeats = getNumPassengers();
652 int requiredContainerPositions = getNumContainers();
653 const Position back = (p1 + Position(-scaledLength * upscaleLength, 0)).rotateAround2D(angle, p1);
654 double extraOffset = scaledLength * 0.15;
655 computeSeats(p1, back, SUMO_const_waitingPersonWidth, getVType().getPersonCapacity(), upscale, requiredSeats, mySeatPositions, extraOffset);
656 computeSeats(p1, back, SUMO_const_waitingContainerWidth, getVType().getContainerCapacity(), upscale, requiredContainerPositions, myContainerPositions, extraOffset);
657 }
658
662}
663
664
665void
669
670
671void
673 if (!myVehicle.isOnRoad()) {
674 drawGL(s);
675 }
678 glTranslated(0, 0, getType() - .1); // don't draw on top of other cars
681 }
682 bool noLoop = hasActiveAddVisualisation(parent, VO_SHOW_ROUTE_NOLOOP);
684 drawRoute(s, 0, 0.15, false, noLoop);
685 }
687 drawRoute(s, 0, 0.15, true, noLoop);
688 }
690 if (myVehicle.getNumberReroutes() > 0) {
691 const int noReroutePlus1 = myVehicle.getNumberReroutes() + 1;
692 for (int i = noReroutePlus1 - 1; i >= 0; i--) {
693 double darken = double(0.4) / double(noReroutePlus1) * double(i);
694 drawRoute(s, i, darken);
695 }
696 } else {
697 drawRoute(s, 0, 0.15, false, noLoop);
698 }
699 }
702 }
705}
706
707
708void
709GUIBaseVehicle::drawLinkItem(const Position& pos, SUMOTime arrivalTime, SUMOTime leaveTime, double exagerate) {
710 glTranslated(pos.x(), pos.y(), -.1);
712 std::string times = toString(STEPS2TIME(arrivalTime)) + "/" + toString(STEPS2TIME(leaveTime));
713 GLHelper::drawText(times.c_str(), Position(), .1, 1.6 * exagerate, RGBColor::GREEN, 0);
714 glTranslated(-pos.x(), -pos.y(), .1);
715}
716
717
720 RGBColor col;
721 const GUIColorer& c = s.vehicleColorer;
722 if (!setFunctionalColor(c.getActive(), &myVehicle, col)) {
723 col = c.getScheme().getColor(getColorValue(s, c.getActive()));
724 }
726 return col;
727}
728
729
730bool
731GUIBaseVehicle::setFunctionalColor(int activeScheme, const MSBaseVehicle* veh, RGBColor& col) {
732 switch (activeScheme) {
733 case 0: {
734 //test for emergency vehicle
736 col = RGBColor::WHITE;
737 return true;
738 }
739 //test for firebrigade
741 col = RGBColor::RED;
742 return true;
743 }
744 //test for police car
746 col = RGBColor::BLUE;
747 return true;
748 }
750 col = veh->getParameter().color;
751 return true;
752 }
754 col = veh->getVehicleType().getColor();
755 return true;
756 }
757 if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
758 col = veh->getRoute().getColor();
759 return true;
760 }
761 return false;
762 }
763 case 2: {
765 col = veh->getParameter().color;
766 return true;
767 }
768 return false;
769 }
770 case 3: {
772 col = veh->getVehicleType().getColor();
773 return true;
774 }
775 return false;
776 }
777 case 4: {
778 if (&(veh->getRoute().getColor()) != &RGBColor::DEFAULT_COLOR) {
779 col = veh->getRoute().getColor();
780 return true;
781 }
782 return false;
783 }
784 case 5: {
785 Position p = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
786 const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
787 Position center = b.getCenter();
788 double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
789 double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
790 col = RGBColor::fromHSV(hue, sat, 1.);
791 return true;
792 }
793 case 6: {
794 Position p = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
795 const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
796 Position center = b.getCenter();
797 double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
798 double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
799 col = RGBColor::fromHSV(hue, sat, 1.);
800 return true;
801 }
802 case 7: {
803 Position pb = veh->getRoute().getEdges()[0]->getLanes()[0]->getShape()[0];
804 Position pe = veh->getRoute().getEdges().back()->getLanes()[0]->getShape()[-1];
805 const Boundary& b = ((GUINet*) MSNet::getInstance())->getBoundary();
806 double hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / M_PI;
807 Position minp(b.xmin(), b.ymin());
808 Position maxp(b.xmax(), b.ymax());
809 double sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
810 col = RGBColor::fromHSV(hue, sat, 1.);
811 return true;
812 }
813 case 35: { // color randomly (by pointer hash)
814 std::hash<const MSBaseVehicle*> ptr_hash;
815 const double hue = (double)(ptr_hash(veh) % 360); // [0-360]
816 const double sat = (double)((ptr_hash(veh) / 360) % 67) / 100.0 + 0.33; // [0.33-1]
817 col = RGBColor::fromHSV(hue, sat, 1.);
818 return true;
819 }
820 case 36: { // color by angle
821 double hue = GeomHelper::naviDegree(veh->getAngle());
822 col = RGBColor::fromHSV(hue, 1., 1.);
823 return true;
824 }
825 }
826 return false;
827}
828
829
830double
832 switch (activeScheme) {
833 case 0: // uniform
834 return 0;
835 case 1: // selection
836 return myVehicle.isSelected();
837 case 2: // by speed
838 if (myVehicle.isStopped()) {
839 return myVehicle.isParking() ? -2 : -1;
840 }
841 return myVehicle.getSpeed();
842 case 3:
844 case 4: {
845 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&myVehicle);
846 return (microVeh != nullptr ? microVeh->getAccumulatedWaitingSeconds() : 0);
847 }
848 case 5: {
849 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&myVehicle);
850 return (microVeh != nullptr ? microVeh->getLane()->getVehicleMaxSpeed(microVeh) : myVehicle.getEdge()->getVehicleMaxSpeed(&myVehicle));
851 }
852 case 6:
854 case 7: {
855 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&myVehicle);
856 return (microVeh != nullptr
857 ? (microVeh->getLaneChangeModel().isOpposite() ? -100 : microVeh->getBestLaneOffset())
858 : 0);
859 }
860 case 8:
861 return myVehicle.getAcceleration();
862 case 9: {
863 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(&myVehicle);
864 return (microVeh != nullptr ? microVeh->getTimeGapOnLane() : 0);
865 }
866 case 10:
868 case 11:
870 case 12:
871 return myVehicle.getStopDelay();
872 case 13:
874 case 14: // by numerical param value
875 std::string error;
876 std::string val = myVehicle.getPrefixedParameter(s.vehicleScaleParam, error);
877 try {
878 if (val == "") {
879 return 0;
880 } else {
881 return StringUtils::toDouble(val);
882 }
883 } catch (NumberFormatException&) {
884 try {
885 return StringUtils::toBool(val);
886 } catch (BoolFormatException&) {
887 WRITE_WARNINGF(TL("Vehicle parameter '%' key '%' is not a number for vehicle '%'."),
889 return -1;
890 }
891 }
892 }
893 return 0;
894}
895
896
897// ------------ Additional visualizations
898bool
900 return myAdditionalVisualizations.find(parent) != myAdditionalVisualizations.end() && (myAdditionalVisualizations.find(parent)->second & which) != 0;
901}
902
903
904void
906 if (myAdditionalVisualizations.find(parent) == myAdditionalVisualizations.end()) {
907 myAdditionalVisualizations[parent] = 0;
908 }
909 myAdditionalVisualizations[parent] |= which;
910 if (which != VO_TRACK) {
911 parent->addAdditionalGLVisualisation(this);
912 }
913}
914
915
916void
918 myAdditionalVisualizations[parent] &= ~which;
919 if (myAdditionalVisualizations[parent] == 0) {
920 myAdditionalVisualizations.erase(parent);
921 }
923}
924
925
926void
927GUIBaseVehicle::drawRoute(const GUIVisualizationSettings& s, int routeNo, double darken, bool future, bool noLoop) const {
928 RGBColor vehColor = setColor(s);
929 RGBColor darker = vehColor.changedBrightness((int)(darken * -255));
930 if (darker == RGBColor::BLACK) {
931 darker = vehColor.multiply(1 - darken);
932 }
933 GLHelper::setColor(darker);
934 if (routeNo == 0) {
935 drawRouteHelper(s, myVehicle.getRoutePtr(), future, noLoop, darker);
936 return;
937 }
938 ConstMSRoutePtr route = myRoutes->getRoute(routeNo - 1); // only prior routes are stored
939 if (route != nullptr) {
940 drawRouteHelper(s, route, future, noLoop, darker);
941 }
942}
943
944
945void
946GUIBaseVehicle::drawStopLabels(const GUIVisualizationSettings& s, bool noLoop, const RGBColor& col) const {
947 // (vertical shift for repeated stops at the same position
948 std::map<const MSLane*, int> repeat; // count repeated occurrences of the same position
949 int stopIndex = 0;
950 for (const MSStop& stop : myVehicle.getStops()) {
951 double stopLanePos;
952 if (stop.getSpeed() > 0) {
953 stopLanePos = stop.reached ? stop.pars.endPos : stop.pars.startPos;
954 } else {
955 stopLanePos = stop.reached ? myVehicle.getPositionOnLane() : MAX2(0.0, stop.getEndPos(myVehicle));
956 }
957 if (stop.isOpposite && !stop.reached) {
958 stopLanePos = stop.lane->getLength() - stopLanePos;
959 }
960 Position pos = stop.lane->geometryPositionAtOffset(stopLanePos);
962 GLHelper::drawBoxLines(stop.lane->getShape().getOrthogonal(pos, 10, true, stop.lane->getWidth()), 0.1);
963 std::string label = (stop.getSpeed() > 0
964 ? (stop.reached ? "passing waypoint" : "waypoint ")
965 : (stop.reached ? "stopped" : "stop "));
966 if (!stop.reached) {
967 label += toString(stopIndex);
968 }
969
970 if (stop.isOpposite) {
971 label += " (opposite)";
972 }
973#ifdef _DEBUG
974 label += " (" + toString(stop.edge - myVehicle.getCurrentRouteEdge()) + "e)";
975#endif
977 label += " triggered:";
978 if (stop.triggered) {
979 label += "person";
980 if (stop.numExpectedPerson > 0) {
981 label += "(" + toString(stop.numExpectedPerson) + ")";
982 }
983 }
984 if (stop.containerTriggered) {
985 label += "container";
986 if (stop.numExpectedContainer > 0) {
987 label += "(" + toString(stop.numExpectedContainer) + ")";
988 }
989 }
990 if (stop.joinTriggered) {
991 label += "join";
992 if (stop.pars.join != "") {
993 label += "(" + stop.pars.join + ")";
994 }
995 }
996 }
997 if (stop.pars.ended >= 0 && MSGlobals::gUseStopEnded) {
998 label += " ended:" + time2string(stop.pars.ended);
999 } else if (stop.pars.until >= 0) {
1000 label += " until:" + time2string(stop.pars.until);
1001 }
1002 if (stop.duration >= 0 || stop.pars.duration > 0) {
1003 if (STEPS2TIME(stop.duration) > 3600 * 24) {
1004 label += " duration:1day+";
1005 } else {
1006 label += " duration:" + time2string(stop.duration);
1007 }
1008 }
1009 if (stop.getSpeed() > 0) {
1010 if (stop.skipOnDemand) {
1011 label += " onDemand (skipped)";
1012 } else {
1013 label += " speed:" + toString(stop.getSpeed());
1014 }
1015 }
1016 if (stop.pars.actType != "") {
1017 label += " actType:" + stop.pars.actType;
1018 }
1019 const double nameSize = s.vehicleName.size / s.scale;
1020 Position pos2 = pos - Position(0, nameSize * repeat[stop.lane]);
1021 if (noLoop && repeat[stop.lane] > 0) {
1022 break;
1023 }
1024 GLHelper::drawTextSettings(s.vehicleText, label, pos2, s.scale, s.angle, 1.0);
1025 repeat[stop.lane]++;
1026 stopIndex++;
1027 }
1028 // indicate arrivalPos if set
1030 const int arrivalEdge = myVehicle.getParameter().arrivalEdge >= 0
1032 : (int)myVehicle.getRoute().getEdges().size() - 1;
1033 const MSLane* arrivalLane = myVehicle.getRoute().getEdges()[arrivalEdge]->getLanes()[MAX2(0, myVehicle.getArrivalLane())];
1035 GLHelper::setColor(col);
1036 GLHelper::drawBoxLines(arrivalLane->getShape().getOrthogonal(pos, 10, true, arrivalLane->getWidth() * 0.5, 90), 0.1);
1037 GLHelper::drawBoxLines(arrivalLane->getShape().getOrthogonal(pos, 10, true, arrivalLane->getWidth() * 0.5, 270), 0.1);
1038 GLHelper::drawTextSettings(s.vehicleText, "arrival", pos, s.scale, s.angle, 1.0);
1039
1040 }
1041}
1042
1043void
1045 if (s.showParkingInfo) {
1047 if (pm != nullptr) {
1048 for (auto item : *pm) {
1049 const GUIParkingArea* pa = dynamic_cast<const GUIParkingArea*>(item.first);
1050 if (item.second.blockedAtTime >= 0) {
1051 std::string seenAgo = time2string(SIMSTEP - item.second.blockedAtTime);
1052 //if (item.second.blockedAtTime >= 0) {
1053 // seenAgo += ", " + time2string(SIMSTEP - item.second.blockedAtTimeLocal);
1054 //}
1055 GLHelper::drawTextSettings(s.vehicleValue, seenAgo, pa->getSignPos(), s.scale, s.angle, 1.0);
1056 }
1057 if (item.second.score != "") {
1058 const double dist = 0.4 * (s.vehicleText.scaledSize(s.scale) + s.vehicleValue.scaledSize(s.scale));
1059 Position shift(0, -dist);
1060 GLHelper::drawTextSettings(s.vehicleText, item.second.score, pa->getSignPos() + shift, s.scale, s.angle, 1.0);
1061 }
1062 }
1063 }
1064 }
1065}
1066
1067void
1069 if (s.showChargingInfo) {
1071 if (pm != nullptr) {
1072 for (auto item : *pm) {
1073 const GUIChargingStation* cs = dynamic_cast<const GUIChargingStation*>(item.first);
1074 if (item.second.blockedAtTime >= 0) {
1075 std::string seenAgo = time2string(SIMSTEP - item.second.blockedAtTime);
1076 GLHelper::drawTextSettings(s.vehicleValue, seenAgo, cs->getSignPos(), s.scale, s.angle, 1.0);
1077 }
1078 if (item.second.score != "") {
1079 const double dist = 0.4 * (s.vehicleText.scaledSize(s.scale) + s.vehicleValue.scaledSize(s.scale));
1080 Position shift(0, -dist);
1081 GLHelper::drawTextSettings(s.vehicleText, item.second.score, cs->getSignPos() + shift, s.scale, s.angle, 1.0);
1082 }
1083 }
1084 }
1085 }
1086}
1087
1089GUIBaseVehicle::getSeatPosition(int personIndex) const {
1091 return mySeatPositions[MIN2(personIndex, (int)mySeatPositions.size() - 1)];
1092}
1093
1095GUIBaseVehicle::getContainerPosition(int containerIndex) const {
1097 return myContainerPositions[MIN2(containerIndex, (int)myContainerPositions.size() - 1)];
1098}
1099
1100
1101void
1103 FXMutexLock locker(myLock);
1104 if (myVehicle.myPersonDevice != nullptr) {
1105 const std::vector<MSTransportable*>& ps = myVehicle.myPersonDevice->getTransportables();
1106 int personIndex = 0;
1107 for (std::vector<MSTransportable*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
1108 GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
1109 assert(person != 0);
1110 person->setPositionInVehicle(getSeatPosition(personIndex++));
1111 person->drawGL(s);
1112 }
1113 }
1114 if (myVehicle.myContainerDevice != nullptr) {
1115 const std::vector<MSTransportable*>& cs = myVehicle.myContainerDevice->getTransportables();
1116 int containerIndex = 0;
1117 for (std::vector<MSTransportable*>::const_iterator i = cs.begin(); i != cs.end(); ++i) {
1118 GUIContainer* container = dynamic_cast<GUIContainer*>(*i);
1119 assert(container != 0);
1120 container->setPositionInVehicle(getContainerPosition(containerIndex++));
1121 container->drawGL(s);
1122 }
1123 }
1124#ifdef DRAW_BOUNDING_BOX
1126 MSVehicle& microVeh = dynamic_cast<MSVehicle&>(myVehicle);
1129 glTranslated(0, 0, getType());
1130 PositionVector smallBB = microVeh.getBoundingPoly();
1131 glColor3d(0.5, .8, 0);
1132 GLHelper::drawBoxLines(smallBB, 0.3);
1133 glTranslated(0, 0, 0.1);
1134 PositionVector boundingBox = microVeh.getBoundingBox();
1135 boundingBox.push_back(boundingBox.front());
1136 glColor3d(1, 0, 0);
1137 GLHelper::drawBoxLines(boundingBox, 0.15);
1140 }
1141#endif
1142}
1143
1144bool
1148
1149bool
1151 if (getVType().getParameter().carriageLength > 0 &&
1153 drawAction_drawCarriageClass(s, scaledLength, asImage);
1154 return true;
1155 } else {
1157 s, getVType().getImgFile(), this, getVType().getWidth(), scaledLength)) {
1158 return false;
1159 }
1160 GUIBaseVehicleHelper::drawAction_drawVehicleAsPoly(s, getVType().getGuiShape(), getVType().getWidth(), scaledLength, -1, myVehicle.isStopped(), drawReversed(s));
1161 return false;
1162 }
1163}
1164
1165
1166int
1168 if (myVehicle.getPersonDevice() != nullptr) {
1169 return (int)myVehicle.getPersonDevice()->size();
1170 }
1171 return 0;
1172}
1173
1174
1175int
1177 if (myVehicle.getContainerDevice() != nullptr) {
1178 return (int)myVehicle.getContainerDevice()->size();
1179 }
1180 return 0;
1181}
1182
1183std::string
1185 std::vector<std::string> devs;
1186 for (MSDevice* d : myVehicle.getDevices()) {
1187 devs.push_back(d->deviceName());
1188 }
1189 return joinToString(devs, " ");
1190}
1191
1192
1193void
1194GUIBaseVehicle::computeSeats(const Position& front, const Position& back, double seatOffset, int maxSeats, double exaggeration, int& requiredSeats, Seats& into, double extraOffset) const {
1195 if (requiredSeats <= 0) {
1196 return;
1197 }
1198 maxSeats = MAX2(maxSeats, 1); // compute at least one seat
1199 seatOffset *= exaggeration;
1200 const double vehWidth = getVType().getSeatingWidth() * exaggeration;
1201 const double length = front.distanceTo2D(back);
1202 const int rowSize = MAX2(1, (int)floor(vehWidth / seatOffset));
1203 const double frontSeatPos = getVType().getFrontSeatPos() + extraOffset;
1204 const double rowOffset = MAX2(1.0, (length - frontSeatPos - 1)) / ceil((double)maxSeats / rowSize);
1205 const double sideOffset = (rowSize - 1) / 2.0 * seatOffset;
1206 double rowPos = frontSeatPos - rowOffset;
1207 double angle = back.angleTo2D(front);
1208 const int fillDirection = MSGlobals::gLefthand ? -1 : 1;
1209 //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";
1210 for (int i = 0; requiredSeats > 0 && i < maxSeats; i++) {
1211 int seat = (i % rowSize);
1212 if (seat == 0) {
1213 rowPos += rowOffset;
1214 }
1215 into.push_back(Seat(PositionVector::positionAtOffset2D(front, back, rowPos, (sideOffset - seat * seatOffset) * fillDirection), angle));
1216 requiredSeats--;
1217 }
1218}
1219
1220
1221/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
@ MID_HIDE_ALLROUTES
Hide all vehicle's routes.
Definition GUIAppEnum.h:523
@ MID_HIDE_BEST_LANES
Hide vehicle's best lanes.
Definition GUIAppEnum.h:519
@ MID_HIDE_CURRENTROUTE
Hide vehicle's current route.
Definition GUIAppEnum.h:507
@ MID_SHOW_FOES
select foes of a vehicle
Definition GUIAppEnum.h:529
@ MID_SHOW_BEST_LANES
Show vehicle's best lanes.
Definition GUIAppEnum.h:517
@ MID_START_TRACK
Start to track a vehicle.
Definition GUIAppEnum.h:525
@ MID_SHOW_ALLROUTES
Show all vehicle's routes.
Definition GUIAppEnum.h:521
@ MID_SHOW_LFLINKITEMS
Definition GUIAppEnum.h:530
@ MID_SHOW_ROUTE_NOLOOPS
Show vehicle's future route (without loops)
Definition GUIAppEnum.h:513
@ MID_HIDE_ROUTE_NOLOOPS
Hide vehicle's future route (without loops)
Definition GUIAppEnum.h:515
@ MID_TOGGLE_STOP
toggle stop state of a vehicle or person
Definition GUIAppEnum.h:535
@ MID_HIDE_LFLINKITEMS
Definition GUIAppEnum.h:531
@ MID_REMOVE_OBJECT
remove a vehicle or person
Definition GUIAppEnum.h:537
@ MID_SHOW_FUTUREROUTE
Show vehicle's future route.
Definition GUIAppEnum.h:509
@ MID_HIDE_FUTUREROUTE
Hide vehicle's future route.
Definition GUIAppEnum.h:511
@ MID_SHOW_CURRENTROUTE
Show vehicle's current route.
Definition GUIAppEnum.h:505
@ MID_STOP_TRACK
Stop to track a vehicle.
Definition GUIAppEnum.h:527
@ MID_SELECT_TRANSPORTED
select transportables of a vehicle
Definition GUIAppEnum.h:533
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:299
#define WRITE_WARNING(msg)
Definition MsgHandler.h:298
#define TL(string)
Definition MsgHandler.h:316
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:107
#define STEPS2TIME(x)
Definition SUMOTime.h:58
#define SIMSTEP
Definition SUMOTime.h:69
constexpr SUMOTime TIME2STEPS(double x)
Definition SUMOTime.h:60
const long long int VTYPEPARS_COLOR_SET
@ RAIL_CARGO
render as a cargo train
@ CABLE_CAR
render as a cable car
@ 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
@ BICYCLE_CARGO
render as a front-loading cargo 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
@ WHEELCHAIR
render as a wheelchair
@ DRONE
render as a drone
@ POLICE
render as a police car
@ PEDESTRIAN
render as a pedestrian
const long long int VEHPARS_COLOR_SET
const long long int VEHPARS_ARRIVALPOS_SET
T MIN2(T a, T b)
Definition StdDefs.h:80
T MAX2(T a, T b)
Definition StdDefs.h:86
const double SUMO_const_waitingContainerWidth
Definition StdDefs.h:58
const double SUMO_const_waitingPersonWidth
Definition StdDefs.h:56
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition ToString.h:322
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:57
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
Position getCenter() const
Returns the center of the boundary.
Definition Boundary.cpp:109
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:75
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:127
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:115
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:133
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:121
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void drawOutlineCircle(double radius, double iRadius, int steps=8)
Draws an unfilled circle around (0,0)
Definition GLHelper.cpp:591
static void pushName(unsigned int name)
push Name
Definition GLHelper.cpp:140
static void drawFilledCircle(const double widradiusth, const int steps=8)
Draws a filled circle around (0,0)
Definition GLHelper.cpp:564
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
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:348
static void popName()
pop Name
Definition GLHelper.cpp:149
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
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:742
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:773
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.
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
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.
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
GUIGLObjectPopupMenu * myPopup
current popup (to clean up in destructor). GUIBaseVehicle is not responsible for removal
void drawParkingInfo(const GUIVisualizationSettings &s) const
GUIBaseVehicle(MSBaseVehicle &vehicle)
MSDevice_Vehroutes * myRoutes
virtual void drawAction_drawPersonsAndContainers(const GUIVisualizationSettings &s) const
virtual void drawAction_drawCarriageClass(const GUIVisualizationSettings &s, double scaledLength, bool asImage) const =0
draws the given guiShape with distinct carriages/modules
void removedPopupMenu() override
notify object about popup menu removal
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 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
virtual Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
const std::string getOptionalName() const override
Returns the value for generic parameter 'name' or ''.
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const override
Draws additionally triggered visualisations.
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.
void drawChargingInfo(const GUIVisualizationSettings &s) const
@ 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
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) override
Adds the named visualisation feature to the given view.
bool drawReversed(const GUIVisualizationSettings &s) const
whether to reverse trains in their reversed state
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
virtual void drawAction_drawVehicleBrakeLight(double length, bool onlyOne=false) const
void computeSeats(const Position &front, const Position &back, double seatOffset, int maxSeats, double exaggeration, int &requiredSeats, Seats &into, double extraOffset=0) const
add seats to mySeatPositions and update requiredSeats
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
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
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
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.
A lane area vehicles can halt at (gui-version)
const Position & getSignPos() const
void setPositionInVehicle(const GUIBaseVehicle::Seat &pos)
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, const bool disable=false)
build menu command
The popup menu of a globject.
GUISUMOAbstractView * getParentView()
return the real owner of this popup
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app, bool addSeparator=true) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
virtual double getColorValue(const GUIVisualizationSettings &, int) const
void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the type parameter window.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
GUIGlObject * myParent
parent of this GLObject (usually used for lanes and edges)
GUIGlID getGlID() const
Returns the numerical id of the object.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, 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)
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
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
bool trueZ
drawl all objects according to their z data
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.
bool showChargingInfo
Set whether the charging search related information should be shown.
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)
void vaporizeCar(MEVehicle *v, MSMoveReminder::Notification reason)
remove the given car and clean up the relevant data structures
Definition MELoop.cpp:354
A vehicle from the mesoscopic point of view.
Definition MEVehicle.h:42
The base class for microscopic and mesoscopic vehicles.
ConstMSRoutePtr getRoutePtr() const
Returns the current route.
virtual bool isSelected() const
whether this vehicle is selected in the GUI
const StoppingPlaceMemory * getParkingMemory() const
const std::vector< MSTransportable * > & getPersons() const
retrieve riding persons
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.
const MSStop & getNextStop() const
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 StoppingPlaceMemory * getChargingMemory() const
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool isStopped() const
Returns whether the vehicle is at a stop.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
Definition MSCFModel.h:424
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:62
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition MSEdge.h:169
double getWidth() const
Returns the edges's width (sum over all lanes)
Definition MSEdge.h:666
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition MSEdge.cpp:1254
static bool gUseMesoSim
Definition MSGlobals.h:106
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition MSGlobals.h:115
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition MSGlobals.h:177
static bool gUseStopEnded
whether the simulation should replay previous stop times
Definition MSGlobals.h:133
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:2887
virtual double getLengthGeometryFactor(bool) const
Definition MSLane.h:290
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition MSLane.h:575
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition MSLane.h:484
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition MSLane.h:514
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:294
double getWidth() const
Returns the lane's width.
Definition MSLane.h:661
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:561
@ 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:201
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:403
bool parkOnRoad() const
whether vehicles park on the road
const ConstMSEdgeVector & getEdges() const
Definition MSRoute.h:128
const RGBColor & getColor() const
Returns the color.
Definition MSRoute.cpp:407
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
Definition MSStop.h:58
double getUpscaleLength() const
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.
PositionVector getBoundingPoly(double offset=0) const
get bounding polygon
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs.
Definition MSVehicle.h:714
MSAbstractLaneChangeModel & getLaneChangeModel()
bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string &errorMsg)
PositionVector getBoundingBox(double offset=0) const
get bounding rectangle
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
bool resumeFromStopping()
int getBestLaneOffset() const
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition MSVehicle.h:581
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
Definition MSVehicle.h:589
std::pair< const MSLane *, double > getLanePosAfterDist(double distance) const
return lane and position along bestlanes at the given distance
double getSpeed() const
Returns the vehicle's current speed.
Definition MSVehicle.h:490
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.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
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.
const RGBColor & getColor() const
Returns this type's color.
const std::string & getID() const
Returns the id.
Definition Named.h:73
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:273
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimensions
Definition Position.h:263
double x() const
Returns the x-position.
Definition Position.h:52
double z() const
Returns the z-position.
Definition Position.h:62
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition Position.h:283
double y() const
Returns the y-position.
Definition Position.h:57
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, bool extrapolateBeyond=false) const
Returns the position at the given length.
static const RGBColor WHITE
Definition RGBColor.h:211
static const RGBColor BLUE
Definition RGBColor.h:206
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition RGBColor.cpp:96
RGBColor multiply(double factor) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:258
static RGBColor fromHSV(double h, double s, double v, bool random=false)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
Definition RGBColor.cpp:431
static const RGBColor GREEN
Definition RGBColor.h:205
static const RGBColor BLACK
Definition RGBColor.h:212
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:228
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition RGBColor.h:218
static const RGBColor RED
named colors
Definition RGBColor.h:204
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.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
RGBColor color
The vehicle's color, TraCI may change this.
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