37 #include <osg/ShapeDrawable>
38 #include <osgview/GUIOSGView.h>
68 #ifdef CHECK_MEMORY_LEAKS
70 #endif // CHECK_MEMORY_LEAKS
101 double
vehiclePoly_PassengerCarBody[] = { .5, 0, 0, 0, 0, .3, 0.08, .44, 0.25, .5, 0.95, .5, 1., .4, 1., -.4, 0.95, -.5, 0.25, -.5, 0.08, -.44, 0, -.3, 0, 0, -10000 };
102 double vehiclePoly_PassengerCarBodyFront[] = { 0.1, 0, 0.025, 0, 0.025, 0.25, 0.27, 0.4, 0.27, -.4, 0.025, -0.25, 0.025, 0, -10000 };
103 double vehiclePoly_PassengerFrontGlass[] = { 0.35, 0, 0.3, 0, 0.3, 0.4, 0.43, 0.3, 0.43, -0.3, 0.3, -0.4, 0.3, 0, -10000 };
104 double vehiclePoly_PassengerSedanRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.77, -.47, 0.67, -.37, 0.45, -.37, 0.34, -.47, -10000 };
105 double vehiclePoly_PassengerSedanLeftGlass[] = { 0.36, .43, 0.34, .47, 0.77, .47, 0.67, .37, 0.45, .37, 0.34, .47, -10000 };
106 double vehiclePoly_PassengerSedanBackGlass[] = { 0.80, 0, 0.70, 0, 0.70, 0.3, 0.83, 0.4, 0.83, -.4, 0.70, -.3, 0.70, 0, -10000 };
107 double vehiclePoly_PassengerHatchbackRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.80, -.37, 0.45, -.37, 0.34, -.47, -10000 };
108 double vehiclePoly_PassengerHatchbackLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.80, .37, 0.45, .37, 0.34, .47, -10000 };
109 double vehiclePoly_PassengerHatchbackBackGlass[] = { 0.92, 0, 0.80, 0, 0.80, 0.3, 0.95, 0.4, 0.95, -.4, 0.80, -.3, 0.80, 0, -10000 };
110 double vehiclePoly_PassengerWagonRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.87, -.37, 0.45, -.37, 0.34, -.47, -10000 };
111 double vehiclePoly_PassengerWagonLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.87, .37, 0.45, .37, 0.34, .47, -10000 };
112 double vehiclePoly_PassengerWagonBackGlass[] = { 0.92, 0, 0.90, 0, 0.90, 0.3, 0.95, 0.4, 0.95, -.4, 0.90, -.3, 0.90, 0, -10000 };
114 double vehiclePoly_PassengerVanBody[] = { .5, 0, 0, 0, 0, .4, 0.1, .5, 0.97, .5, 1., .47, 1., -.47, 0.97, -.5, 0.1, -.5, 0, -.4, 0, 0, -10000 };
115 double vehiclePoly_PassengerVanBodyFront[] = { 0.1, 0, 0.025, 0, 0.025, 0.25, 0.13, 0.4, 0.13, -.4, 0.025, -0.25, 0.025, 0, -10000 };
116 double vehiclePoly_PassengerVanFrontGlass[] = { 0.21, 0, 0.16, 0, 0.16, 0.4, 0.29, 0.3, 0.29, -0.3, 0.16, -0.4, 0.16, 0, -10000 };
117 double vehiclePoly_PassengerVanRightGlass[] = { 0.36, -.43, 0.20, -.47, 0.98, -.47, 0.91, -.37, 0.31, -.37, 0.20, -.47, -10000 };
118 double vehiclePoly_PassengerVanLeftGlass[] = { 0.36, .43, 0.20, .47, 0.98, .47, 0.91, .37, 0.31, .37, 0.20, .47, -10000 };
119 double vehiclePoly_PassengerVanBackGlass[] = { 0.95, 0, 0.94, 0, 0.94, 0.3, 0.98, 0.4, 0.98, -.4, 0.94, -.3, 0.94, 0, -10000 };
121 double vehiclePoly_DeliveryMediumRightGlass[] = { 0.21, -.43, 0.20, -.47, 0.38, -.47, 0.38, -.37, 0.31, -.37, 0.20, -.47, -10000 };
122 double vehiclePoly_DeliveryMediumLeftGlass[] = { 0.21, .43, 0.20, .47, 0.38, .47, 0.38, .37, 0.31, .37, 0.20, .47, -10000 };
124 double vehiclePoly_TransportBody[] = { .5, 0, 0, 0, 0, .45, 0.05, .5, 2.25, .5, 2.25, -.5, 0.05, -.5, 0, -.45, 0, 0, -10000 };
125 double vehiclePoly_TransportFrontGlass[] = { 0.1, 0, 0.05, 0, 0.05, 0.45, 0.25, 0.4, 0.25, -.4, 0.05, -0.45, 0.05, 0, -10000 };
126 double vehiclePoly_TransportRightGlass[] = { 0.36, -.47, 0.10, -.48, 1.25, -.48, 1.25, -.4, 0.3, -.4, 0.10, -.48, -10000 };
127 double vehiclePoly_TransportLeftGlass[] = { 0.36, .47, 0.10, .48, 1.25, .48, 1.25, .4, 0.3, .4, 0.10, .48, -10000 };
129 double vehiclePoly_EVehicleBody[] = { .5, 0, 0, 0, 0, .3, 0.08, .44, 0.25, .5, 0.75, .5, .92, .44, 1, .3, 1, -.3, .92, -.44, .75, -.5, .25, -.5, 0.08, -.44, 0, -.3, 0, 0, -1000 };
130 double vehiclePoly_EVehicleFrontGlass[] = { .5, 0, 0.05, .05, 0.05, .25, 0.13, .39, 0.3, .45, 0.70, .45, .87, .39, .95, .25, .95, -.25, .87, -.39, .70, -.45, .3, -.45, 0.13, -.39, 0.05, -.25, 0.05, 0.05, -1000 };
132 double vehiclePoly_EVehicleBackGlass[] = { 0.65, 0, 0.9, 0, 0.9, 0.4, 0.57, 0.3, 0.57, -0.3, 0.9, -0.4, 0.9, 0, -10000 };
143 GUIGlObject& o, std::map<GUISUMOAbstractView*, int>& additionalVisualizations)
144 :
GUIGLObjectPopupMenu(app, parent, o), myVehiclesAdditionalVisualizations(additionalVisualizations) {
154 if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent,
VO_SHOW_ALL_ROUTES)) {
171 if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent,
VO_SHOW_ROUTE)) {
188 if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent,
VO_SHOW_BEST_LANES)) {
205 if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent,
VO_TRACKED)) {
206 myParent->startTrack(static_cast<GUIVehicle*>(myObject)->
getGlID());
216 myParent->stopTrack();
224 if (!static_cast<GUIVehicle*>(myObject)->hasActiveAddVisualisation(myParent,
VO_SHOW_LFLINKITEMS)) {
251 MSVehicle(pars, route, type, speedFactor),
263 while (i->first->removeAdditionalGLVisualisation(
this));
266 for (std::map<GUIOSGView*, osg::ShapeDrawable*>::iterator i = myGeom.begin(); i != myGeom.end(); ++i) {
267 i->first->remove(
this);
305 new FXMenuSeparator(ret);
307 if (trackedID < 0 || (
size_t)trackedID !=
getGlID()) {
314 new FXMenuSeparator(ret);
329 ret->
mkItem(
"position [m]",
true,
331 ret->
mkItem(
"speed [m/s]",
true,
333 ret->
mkItem(
"angle [degree]",
true,
338 ret->
mkItem(
"waiting time [s]",
true,
340 ret->
mkItem(
"impatience",
true,
342 ret->
mkItem(
"last lane change [s]",
true,
346 ret->
mkItem(
"left same route [#]",
false, (
unsigned int)
getParameter().repetitionNumber);
352 ret->
mkItem(
"CO2 (HBEFA) [mg/s]",
true,
354 ret->
mkItem(
"CO (HBEFA) [mg/s]",
true,
356 ret->
mkItem(
"HC (HBEFA) [mg/s]",
true,
358 ret->
mkItem(
"NOx (HBEFA) [mg/s]",
true,
360 ret->
mkItem(
"PMx (HBEFA) [mg/s]",
true,
362 ret->
mkItem(
"fuel (HBEFA) [ml/s]",
true,
364 ret->
mkItem(
"noise (Harmonoise) [dB]",
true,
367 ret->
mkItem(
"",
false,
"");
368 ret->
mkItem(
"Type Information:",
false,
"");
398 glBegin(GL_TRIANGLE_STRIP);
400 glVertex2d(-.5, .15);
418 glBegin(GL_TRIANGLES);
430 glTranslated(0, 0, offset * .1);
431 glPolygonOffset(0, offset * -1);
432 glBegin(GL_TRIANGLE_FAN);
434 while (poses[i] > -999) {
435 glVertex2d(poses[i], poses[i + 1]);
452 glRotated(90, 0, 0, 1);
453 glScaled(length, width, 1.);
461 drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
463 drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
466 glTranslated(0, 0, .045);
468 glTranslated(0, 0, -.045);
470 glTranslated(0, 0, .04);
473 glTranslated(0, 0, -.04);
478 glTranslated(.5, 0, 0);
479 glScaled(.25 / (length), 1, 1.);
480 glTranslated(0, 0, .045);
483 glTranslated(0, 0, -.045);
484 glTranslated(0, 0, .04);
487 glTranslated(0, 0, -.04);
497 drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
499 drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
502 drawPoly(vehiclePoly_PassengerVanBody, 4);
504 drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
506 drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
507 drawPoly(vehiclePoly_PassengerVanRightGlass, 4.5);
508 drawPoly(vehiclePoly_PassengerVanLeftGlass, 4.5);
509 drawPoly(vehiclePoly_PassengerVanBackGlass, 4.5);
512 drawPoly(vehiclePoly_PassengerVanBody, 4);
514 drawPoly(vehiclePoly_PassengerVanBodyFront, 4.5);
516 drawPoly(vehiclePoly_PassengerVanFrontGlass, 4.5);
517 drawPoly(vehiclePoly_DeliveryMediumRightGlass, 4.5);
518 drawPoly(vehiclePoly_DeliveryMediumLeftGlass, 4.5);
523 glScaled(1. / (length), 1, 1.);
524 drawPoly(vehiclePoly_TransportBody, 4);
526 drawPoly(vehiclePoly_TransportFrontGlass, 4.5);
527 drawPoly(vehiclePoly_TransportRightGlass, 4.5);
528 drawPoly(vehiclePoly_TransportLeftGlass, 4.5);
535 glScaled(1. / (length), 1, 1.);
536 glTranslated(0, 0, .04);
537 glBegin(GL_TRIANGLE_FAN);
538 glVertex2d(ml / 2., 0);
541 glVertex2d(0 + .05, -.5);
542 glVertex2d(ml - .05, -.5);
543 glVertex2d(ml, -.45);
545 glVertex2d(ml - .05, .5);
546 glVertex2d(0 + .05, .5);
550 glTranslated(0, 0, -.04);
552 glTranslated(0, 0, .045);
555 glVertex2d(0 + .05, .48);
556 glVertex2d(0 + .05, -.48);
557 glVertex2d(0 + .15, -.48);
558 glVertex2d(0 + .15, .48);
560 glVertex2d(ml - .1, .45);
561 glVertex2d(ml - .1, -.45);
562 glVertex2d(ml - .05, -.45);
563 glVertex2d(ml - .05, .45);
565 glVertex2d(0 + .20, .49);
566 glVertex2d(0 + .20, .45);
567 glVertex2d(ml - .20, .45);
568 glVertex2d(ml - .20, .49);
570 glVertex2d(0 + .20, -.49);
571 glVertex2d(0 + .20, -.45);
572 glVertex2d(ml - .20, -.45);
573 glVertex2d(ml - .20, -.49);
576 glTranslated(0, 0, -.045);
599 drawPoly(vehiclePoly_EVehicleBody, 4);
601 drawPoly(vehiclePoly_EVehicleFrontGlass, 4.5);
602 glTranslated(0, 0, .048);
607 glVertex2d(.35, -.5);
610 glVertex2d(.3, -.05);
611 glVertex2d(.7, -.05);
617 glVertex2d(.65, -.5);
620 glTranslated(0, 0, -.048);
647 glTranslated(0, 0, 0.1);
649 glTranslated(.4, 0, 0);
651 glTranslated(.4, 0, 0);
658 drawPoly(vehiclePoly_PassengerCarBodyFront, 4.5);
660 drawPoly(vehiclePoly_PassengerFrontGlass, 4.5);
670 glBegin(GL_TRIANGLE_FAN);
671 glVertex2d(1 / 2., 0);
674 glVertex2d(0 + .05, -.05);
675 glVertex2d(1 - .05, -.05);
678 glVertex2d(1 - .05, .05);
679 glVertex2d(0 + .05, .05);
686 glBegin(GL_TRIANGLE_FAN);
687 glVertex2d(1 / 2., 0);
690 glVertex2d(0 + .05, -.2);
691 glVertex2d(1 - .05, -.2);
694 glVertex2d(1 - .05, .2);
695 glVertex2d(0 + .05, .2);
702 drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
703 drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
704 drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
707 drawPoly(vehiclePoly_PassengerHatchbackRightGlass, 4.5);
708 drawPoly(vehiclePoly_PassengerHatchbackLeftGlass, 4.5);
709 drawPoly(vehiclePoly_PassengerHatchbackBackGlass, 4.5);
712 drawPoly(vehiclePoly_PassengerWagonRightGlass, 4.5);
713 drawPoly(vehiclePoly_PassengerWagonLeftGlass, 4.5);
714 drawPoly(vehiclePoly_PassengerWagonBackGlass, 4.5);
737 glTranslated(0, 0, .1);
740 glTranslated(0, 0, .1);
762 drawPoly(vehiclePoly_PassengerSedanRightGlass, 4.5);
763 drawPoly(vehiclePoly_PassengerSedanLeftGlass, 4.5);
764 drawPoly(vehiclePoly_PassengerSedanBackGlass, 4.5);
858 #define BLINKER_POS_FRONT .5
859 #define BLINKER_POS_BACK .5
863 glColor3d(1.f, .8f, 0);
899 glColor3f(1.f, .2f, 0);
924 glScaled(upscale, upscale, 1);
979 glColor3d(0., 1., 0.);
982 glVertex2d(0., minGap);
983 glVertex2d(-.5, minGap);
984 glVertex2d(.5, minGap);
989 glTranslated(0, 0, .1);
1061 size_t personIndex = 0;
1062 for (std::vector<MSPerson*>::const_iterator i = ps.begin(); i != ps.end(); ++i) {
1064 assert(person != 0);
1076 glTranslated(0, 0,
getType() - .1);
1086 for (
int i = noReroutePlus1 - 1; i >= 0; i--) {
1096 if ((*i).myLink == 0) {
1099 MSLink* link = (*i).myLink;
1103 if ((*i).mySetRequest) {
1104 glColor3d(0, .8, 0);
1106 glColor3d(.8, 0, 0);
1108 const SUMOTime leaveTime = (*i).myLink->getLeaveTime(
1125 glTranslated(pos.
x(), pos.
y(), -.1);
1129 glTranslated(-pos.
x(), -pos.
y(), .1);
1132 const std::vector<MSVehicle::LaneQ>&
1152 switch (activeScheme) {
1193 SUMOReal hue = 180. + atan2(center.
x() - p.
x(), center.
y() - p.
y()) * 180. /
PI;
1202 SUMOReal hue = 180. + atan2(center.
x() - p.
x(), center.
y() - p.
y()) * 180. /
PI;
1211 SUMOReal hue = 180. + atan2(pb.
x() - pe.
x(), pb.
y() - pe.
y()) * 180. /
PI;
1225 switch (activeScheme) {
1292 glGetDoublev(GL_CURRENT_COLOR, colors);
1293 colors[0] -= darken;
1294 if (colors[0] < 0) {
1297 colors[1] -= darken;
1298 if (colors[1] < 0) {
1301 colors[2] -= darken;
1302 if (colors[2] < 0) {
1305 colors[3] -= darken;
1306 if (colors[3] < 0) {
1322 std::vector<std::vector<MSVehicle::LaneQ> > bestLanes =
myBestLanes;
1325 for (std::vector<std::vector<MSVehicle::LaneQ> >::iterator j = bestLanes.begin(); j != bestLanes.end(); ++j) {
1326 std::vector<MSVehicle::LaneQ>& lanes = *j;
1329 for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1330 gmax =
MAX2((*i).length, gmax);
1331 rmax =
MAX2((*i).occupation, rmax);
1333 for (std::vector<MSVehicle::LaneQ>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1336 SUMOReal r = (*i).occupation / rmax;
1361 size_t bestLaneIndex = (&r ==
myRoute ? 0 : bestLaneConts.
size());
1362 for (; i != r.
end(); ++i) {
1364 if (bestLaneIndex < bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) {
1365 lane =
static_cast<GUILane*
>(bestLaneConts[bestLaneIndex]);
1368 lane =
static_cast<GUILane*
>((*i)->getLanes()[0]);
1381 }
else if (routeIndex == 0) {
1388 #ifdef HAVE_INTERNAL_LANES
1389 const MSEdge* previousInternal = previous->getInternalFollowingEdge(¤t->
getEdge());
1391 const MSEdge* previousInternal = 0;
1393 if (previousInternal != 0) {
1394 return previousInternal->
getLanes()[0];
1418 const int numCarriages = floor(length / (defaultLength + carriageGap) + 0.5);
1419 assert(numCarriages > 0);
1420 const SUMOReal carriageLengthWithGap = length / numCarriages;
1421 const SUMOReal carriageLength = carriageLengthWithGap - carriageGap;
1427 int backRouteIndex = routeIndex;
1433 if (requiredSeats > 0) {
1437 for (
int i = 0; i < numCarriages; ++i) {
1438 while (carriageOffset < 0) {
1442 while (carriageBackOffset < 0) {
1444 carriageBackOffset += backLane->
getLength();
1449 if (i >= firstPassengerCarriage) {
1453 glTranslated(front.
x(), front.
y(),
getType());
1454 glRotated(angle, 0, 0, 1);
1456 glBegin(GL_TRIANGLE_FAN);
1457 glVertex2d(-halfWidth + xCornerCut, 0);
1458 glVertex2d(-halfWidth, yCornerCut);
1459 glVertex2d(-halfWidth, carriageLength - yCornerCut);
1460 glVertex2d(-halfWidth + xCornerCut, carriageLength);
1461 glVertex2d(halfWidth - xCornerCut, carriageLength);
1462 glVertex2d(halfWidth, carriageLength - yCornerCut);
1463 glVertex2d(halfWidth, yCornerCut);
1464 glVertex2d(halfWidth - xCornerCut, 0);
1468 carriageOffset -= carriageLengthWithGap;
1469 carriageBackOffset -= carriageLengthWithGap;
1493 if (requiredSeats <= 0) {
1496 const Line l(front, back);
1503 for (
SUMOReal p = 2; p <= length - 1; p += 1) {
1519 std::string result =
"";
1521 result +=
"parking";
1523 result +=
"stopped";
1527 if (
myStops.front().triggered) {
1528 result +=
", triggered";
1545 std::vector<const SUMOVehicle*> blockingFoes;
1548 for (std::vector<const SUMOVehicle*>::const_iterator it = blockingFoes.begin(); it != blockingFoes.end(); ++it) {
1551 #ifdef HAVE_INTERNAL_LANES
1553 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1556 if ((static_cast<const GUIVehicle*>(leader))->myLinkLeaders.count(
getID()) == 0) {
1567 GUIVehicle::updateColor(GUIOSGView* view) {
1570 myGeom[view]->setColor(osg::Vec4(col.
red() / 255., col.
green() / 255., col.
blue() / 255., col.
alpha() / 255.));