SUMO - Simulation of Urban MObility
GUILaneWrapper.cpp
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // A MSLane extended for visualisation purposes.
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 
00023 
00024 // ===========================================================================
00025 // included modules
00026 // ===========================================================================
00027 #ifdef _MSC_VER
00028 #include <windows_config.h>
00029 #else
00030 #include <config.h>
00031 #endif
00032 
00033 #ifdef WIN32
00034 #include <windows.h>
00035 #endif
00036 
00037 #include <GL/gl.h>
00038 
00039 #include <string>
00040 #include <iostream>
00041 #include <utility>
00042 #include <microsim/MSLane.h>
00043 #include <microsim/MSEdge.h>
00044 #include <microsim/MSGlobals.h>
00045 #include <utils/geom/PositionVector.h>
00046 #include <microsim/MSNet.h>
00047 #include <gui/GUIGlobals.h>
00048 #include <utils/gui/windows/GUISUMOAbstractView.h>
00049 #include "GUILaneWrapper.h"
00050 #include <utils/common/ToString.h>
00051 #include <utils/geom/GeomHelper.h>
00052 #include <guisim/GUINet.h>
00053 #include <utils/gui/windows/GUIAppEnum.h>
00054 #include <utils/gui/images/GUIIconSubSys.h>
00055 #include <utils/gui/div/GUIParameterTableWindow.h>
00056 #include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
00057 #include <gui/GUIApplicationWindow.h>
00058 #include <utils/gui/div/GUIGlobalSelection.h>
00059 #include <utils/common/RandHelper.h>
00060 #include <utils/gui/div/GLHelper.h>
00061 #include <gui/GUIViewTraffic.h>
00062 #include <utils/gui/images/GUITexturesHelper.h>
00063 #include <guisim/GUIVehicle.h>
00064 #include <foreign/polyfonts/polyfonts.h>
00065 #include <utils/common/HelpersHarmonoise.h>
00066 #include <microsim/MSEdgeWeightsStorage.h>
00067 
00068 
00069 #ifdef CHECK_MEMORY_LEAKS
00070 #include <foreign/nvwa/debug_new.h>
00071 #endif // CHECK_MEMORY_LEAKS
00072 
00073 
00074 // ===========================================================================
00075 // static member definitions
00076 // ===========================================================================
00077 SUMOReal GUILaneWrapper::myAllMaxSpeed = 0;
00078 
00079 
00080 // ===========================================================================
00081 // method definitions
00082 // ===========================================================================
00083 GUILaneWrapper::GUILaneWrapper(MSLane& lane, const PositionVector& shape, unsigned int index) :
00084     GUIGlObject(GLO_LANE, lane.getID()),
00085     myLane(lane),
00086     myShape(shape),
00087     myIndex(index) {
00088     myShapeRotations.reserve(myShape.size() - 1);
00089     myShapeLengths.reserve(myShape.size() - 1);
00090     int e = (int) myShape.size() - 1;
00091     for (int i = 0; i < e; ++i) {
00092         const Position& f = myShape[i];
00093         const Position& s = myShape[i + 1];
00094         myShapeLengths.push_back(f.distanceTo2D(s));
00095         myShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
00096     }
00097     //
00098     myHalfLaneWidth = (SUMOReal)(myLane.getWidth() / 2.);
00099     myQuarterLaneWidth = (SUMOReal)(myLane.getWidth() / 4.);
00100 }
00101 
00102 
00103 GUILaneWrapper::~GUILaneWrapper() {}
00104 
00105 
00106 bool
00107 GUILaneWrapper::forLane(const MSLane& lane) const {
00108     return (&myLane) == (&lane);
00109 }
00110 
00111 
00112 
00113 void
00114 GUILaneWrapper::ROWdrawAction_drawLinkNo() const {
00115     unsigned int noLinks = getLinkNumber();
00116     if (noLinks == 0) {
00117         return;
00118     }
00119     // draw all links
00120     SUMOReal w = myLane.getWidth() / (SUMOReal) noLinks;
00121     SUMOReal x1 = myLane.getWidth() / (SUMOReal) 2.;
00122     glPushMatrix();
00123     const PositionVector& g = getShape();
00124     const Position& end = g.getEnd();
00125     const Position& f = g[-2];
00126     const Position& s = end;
00127     SUMOReal rot = (SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
00128     glTranslated(end.x(), end.y(), 0);
00129     glRotated(rot, 0, 0, 1);
00130     for (int i = noLinks; --i >= 0; ) {
00131         SUMOReal x2 = x1 - (SUMOReal)(w / 2.);
00132         GLHelper::drawText(toString(getLane().getLinkCont()[i]->getRespondIndex()),
00133                            Position(x2, 0), 0, .6, RGBColor(.5, .5, 1), 180);
00134         x1 -= w;
00135     }
00136     glPopMatrix();
00137 }
00138 
00139 
00140 void
00141 GUILaneWrapper::ROWdrawAction_drawTLSLinkNo(const GUINet& net) const {
00142     unsigned int noLinks = getLinkNumber();
00143     if (noLinks == 0) {
00144         return;
00145     }
00146     // draw all links
00147     SUMOReal w = myLane.getWidth() / (SUMOReal) noLinks;
00148     SUMOReal x1 = (SUMOReal)(myLane.getWidth() / 2.);
00149     glPushMatrix();
00150     const PositionVector& g = getShape();
00151     const Position& end = g.getEnd();
00152     const Position& f = g[-2];
00153     const Position& s = end;
00154     SUMOReal rot = (SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
00155     glTranslated(end.x(), end.y(), 0);
00156     glRotated(rot, 0, 0, 1);
00157     for (int i = noLinks; --i >= 0; ) {
00158         SUMOReal x2 = x1 - (SUMOReal)(w / 2.);
00159         int linkNo = net.getLinkTLIndex(getLane().getLinkCont()[i]);
00160         if (linkNo < 0) {
00161             continue;
00162         }
00163         GLHelper::drawText(toString(linkNo),
00164                            Position(x2, 0), 0, .6, RGBColor(.5, .5, 1), 180);
00165         x1 -= w;
00166     }
00167     glPopMatrix();
00168 }
00169 
00170 
00171 void
00172 GUILaneWrapper::ROWdrawAction_drawLinkRules(const GUINet& net) const {
00173     unsigned int noLinks = getLinkNumber();
00174     const PositionVector& g = getShape();
00175     const Position& end = g.getEnd();
00176     const Position& f = g[-2];
00177     const Position& s = end;
00178     SUMOReal rot = (SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
00179     if (noLinks == 0) {
00180         glPushName(getGlID());
00181         // draw a grey bar if no links are on the street
00182         glColor3d(0.5, 0.5, 0.5);
00183         glPushMatrix();
00184         glTranslated(end.x(), end.y(), 0);
00185         glRotated(rot, 0, 0, 1);
00186         glBegin(GL_QUADS);
00187         glVertex2d(-myHalfLaneWidth, 0.0);
00188         glVertex2d(-myHalfLaneWidth, 0.5);
00189         glVertex2d(myHalfLaneWidth, 0.5);
00190         glVertex2d(myHalfLaneWidth, 0.0);
00191         glEnd();
00192         glPopMatrix();
00193         glPopName();
00194         return;
00195     }
00196     // draw all links
00197     SUMOReal w = myLane.getWidth() / (SUMOReal) noLinks;
00198     SUMOReal x1 = 0;
00199     glPushMatrix();
00200     glTranslated(end.x(), end.y(), 0);
00201     glRotated(rot, 0, 0, 1);
00202     for (unsigned int i = 0; i < noLinks; ++i) {
00203         SUMOReal x2 = x1 + w;
00204         MSLink* link = getLane().getLinkCont()[i];
00205         // select glID
00206         switch (link->getState()) {
00207             case LINKSTATE_TL_GREEN_MAJOR:
00208             case LINKSTATE_TL_GREEN_MINOR:
00209             case LINKSTATE_TL_RED:
00210             case LINKSTATE_TL_YELLOW_MAJOR:
00211             case LINKSTATE_TL_YELLOW_MINOR:
00212             case LINKSTATE_TL_OFF_BLINKING:
00213                 glPushName(net.getLinkTLID(link));
00214                 break;
00215             case LINKSTATE_MAJOR:
00216             case LINKSTATE_MINOR:
00217             case LINKSTATE_EQUAL:
00218             case LINKSTATE_TL_OFF_NOSIGNAL:
00219             default:
00220                 glPushName(getGlID());
00221                 break;
00222         }
00223         // select color
00224         switch (link->getState()) {
00225             case LINKSTATE_TL_GREEN_MAJOR:
00226             case LINKSTATE_TL_GREEN_MINOR:
00227                 glColor3d(0, 1, 0);
00228                 break;
00229             case LINKSTATE_TL_RED:
00230                 glColor3d(1, 0, 0);
00231                 break;
00232             case LINKSTATE_TL_YELLOW_MAJOR:
00233             case LINKSTATE_TL_YELLOW_MINOR:
00234                 glColor3d(1, 1, 0);
00235                 break;
00236             case LINKSTATE_TL_OFF_BLINKING:
00237                 glColor3d(.7, .7, 0);
00238                 break;
00239             case LINKSTATE_TL_OFF_NOSIGNAL:
00240                 glColor3d(0, 1, 1);
00241                 break;
00242             case LINKSTATE_MAJOR:
00243                 glColor3d(1, 1, 1);
00244                 break;
00245             case LINKSTATE_MINOR:
00246                 glColor3d(.2, .2, .2);
00247                 break;
00248             case LINKSTATE_EQUAL:
00249                 glColor3d(.5, .5, .5);
00250                 break;
00251             case LINKSTATE_DEADEND:
00252                 glColor3d(0, 0, 0);
00253                 break;
00254         }
00255         glBegin(GL_QUADS);
00256         glVertex2d(x1 - myHalfLaneWidth, 0.0);
00257         glVertex2d(x1 - myHalfLaneWidth, 0.5);
00258         glVertex2d(x2 - myHalfLaneWidth, 0.5);
00259         glVertex2d(x2 - myHalfLaneWidth, 0.0);
00260         glEnd();
00261         glPopName();
00262         x1 = x2;
00263         x2 += w;
00264     }
00265     glPopMatrix();
00266 }
00267 
00268 
00269 void
00270 GUILaneWrapper::ROWdrawAction_drawArrows() const {
00271     unsigned int noLinks = getLinkNumber();
00272     if (noLinks == 0) {
00273         return;
00274     }
00275     // draw all links
00276     const Position& end = getShape().getEnd();
00277     const Position& f = getShape()[-2];
00278     SUMOReal rot = (SUMOReal) atan2((end.x() - f.x()), (f.y() - end.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
00279     glPushMatrix();
00280     glPushName(0);
00281     glColor3d(1, 1, 1);
00282     glTranslated(end.x(), end.y(), 0);
00283     glRotated(rot, 0, 0, 1);
00284     for (unsigned int i = 0; i < noLinks; ++i) {
00285         LinkDirection dir = getLane().getLinkCont()[i]->getDirection();
00286         LinkState state = getLane().getLinkCont()[i]->getState();
00287         if (state == LINKSTATE_TL_OFF_NOSIGNAL || dir == LINKDIR_NODIR) {
00288             continue;
00289         }
00290         switch (dir) {
00291             case LINKDIR_STRAIGHT:
00292                 GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
00293                 GLHelper::drawTriangleAtEnd(Line(Position(0, 4), Position(0, 1)), (SUMOReal) 1, (SUMOReal) .25);
00294                 break;
00295             case LINKDIR_TURN:
00296                 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
00297                 GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
00298                 GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
00299                 GLHelper::drawTriangleAtEnd(Line(Position(0.5, 2.5), Position(0.5, 4)), (SUMOReal) 1, (SUMOReal) .25);
00300                 break;
00301             case LINKDIR_LEFT:
00302                 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
00303                 GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
00304                 GLHelper::drawTriangleAtEnd(Line(Position(0, 2.5), Position(1.5, 2.5)), (SUMOReal) 1, (SUMOReal) .25);
00305                 break;
00306             case LINKDIR_RIGHT:
00307                 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
00308                 GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
00309                 GLHelper::drawTriangleAtEnd(Line(Position(0, 2.5), Position(-1.5, 2.5)), (SUMOReal) 1, (SUMOReal) .25);
00310                 break;
00311             case LINKDIR_PARTLEFT:
00312                 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
00313                 GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
00314                 GLHelper::drawTriangleAtEnd(Line(Position(0, 2.5), Position(1.2, 1.3)), (SUMOReal) 1, (SUMOReal) .25);
00315                 break;
00316             case LINKDIR_PARTRIGHT:
00317                 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
00318                 GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
00319                 GLHelper::drawTriangleAtEnd(Line(Position(0, 2.5), Position(-1.2, 1.3)), (SUMOReal) 1, (SUMOReal) .25);
00320                 break;
00321         }
00322     }
00323     glPopMatrix();
00324     glPopName();
00325 }
00326 
00327 
00328 void
00329 GUILaneWrapper::ROWdrawAction_drawLane2LaneConnections() const {
00330     unsigned int noLinks = getLinkNumber();
00331     for (unsigned int i = 0; i < noLinks; ++i) {
00332         LinkState state = getLane().getLinkCont()[i]->getState();
00333         const MSLane* connected = getLane().getLinkCont()[i]->getLane();
00334         if (connected == 0) {
00335             continue;
00336         }
00337         switch (state) {
00338             case LINKSTATE_TL_GREEN_MAJOR:
00339             case LINKSTATE_TL_GREEN_MINOR:
00340                 glColor3d(0, 1, 0);
00341                 break;
00342             case LINKSTATE_TL_RED:
00343                 glColor3d(1, 0, 0);
00344                 break;
00345             case LINKSTATE_TL_YELLOW_MAJOR:
00346             case LINKSTATE_TL_YELLOW_MINOR:
00347                 glColor3d(1, 1, 0);
00348                 break;
00349             case LINKSTATE_TL_OFF_BLINKING:
00350                 glColor3d(1, 1, 0);
00351                 break;
00352             case LINKSTATE_TL_OFF_NOSIGNAL:
00353                 glColor3d(0, 1, 1);
00354                 break;
00355             case LINKSTATE_MAJOR:
00356                 glColor3d(1, 1, 1);
00357                 break;
00358             case LINKSTATE_MINOR:
00359                 glColor3d(.2, .2, .2);
00360                 break;
00361             case LINKSTATE_EQUAL:
00362                 glColor3d(.5, .5, .5);
00363                 break;
00364             case LINKSTATE_DEADEND:
00365                 glColor3d(0, 0, 0);
00366                 break;
00367         }
00368 
00369         glBegin(GL_LINES);
00370         const Position& p1 = getShape()[-1];
00371         const Position& p2 = connected->getShape()[0];
00372         glVertex2f(p1.x(), p1.y());
00373         glVertex2f(p2.x(), p2.y());
00374         glEnd();
00375         GLHelper::drawTriangleAtEnd(Line(p1, p2), (SUMOReal) .4, (SUMOReal) .2);
00376     }
00377 }
00378 
00379 
00380 void
00381 GUILaneWrapper::drawGL(const GUIVisualizationSettings& s) const {
00382     glPushMatrix();
00383     const bool isInternal = getLane().getEdge().getPurpose() == MSEdge::EDGEFUNCTION_INTERNAL;
00384     bool mustDrawMarkings = false;
00385     if (isInternal) {
00386         // draw internal lanes on top of junctions
00387         glTranslated(0, 0, GLO_JUNCTION + 0.1);
00388     } else {
00389         glTranslated(0, 0, getType());
00390     }
00391     // set lane color
00392     if (!MSGlobals::gUseMesoSim) {
00393         setColor(s);
00394         glPushName(getGlID()); // do not register for clicks in MESOSIM
00395     }
00396     // draw lane
00397     // check whether it is not too small
00398     if (s.scale < 1.) {
00399         GLHelper::drawLine(myShape);
00400         if (!MSGlobals::gUseMesoSim) {
00401             glPopName();
00402         }
00403         glPopMatrix();
00404     } else {
00405         if (!isInternal) {
00406             GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, myHalfLaneWidth);
00407             mustDrawMarkings = true;
00408         } else {
00409             GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, myQuarterLaneWidth);
00410         }
00411         if (!MSGlobals::gUseMesoSim) {
00412             glPopName();
00413         }
00414         glPopMatrix();
00415         // draw ROWs (not for inner lanes)
00416         if (!isInternal) {
00417             glPushMatrix();
00418             glTranslated(0, 0, GLO_JUNCTION); // must draw on top of junction shape
00419             GUINet* net = (GUINet*) MSNet::getInstance();
00420             glTranslated(0, 0, .2);
00421             ROWdrawAction_drawLinkRules(*net);
00422             if (s.showLinkDecals) {
00423                 ROWdrawAction_drawArrows();
00424             }
00425             if (s.showLane2Lane) {
00426                 // this should be independent to the geometry:
00427                 //  draw from end of first to the begin of second
00428                 ROWdrawAction_drawLane2LaneConnections();
00429             }
00430             glTranslated(0, 0, .1);
00431             if (s.drawLinkJunctionIndex) {
00432                 ROWdrawAction_drawLinkNo();
00433             }
00434             if (s.drawLinkTLIndex) {
00435                 ROWdrawAction_drawTLSLinkNo(*net);
00436             }
00437             glPopMatrix();
00438         }
00439     }
00440     if (mustDrawMarkings) { // needs matrix reset
00441         drawMarkings(s);
00442     }
00443     // draw vehicles
00444     if (s.scale > s.minVehicleSize) {
00445         // retrieve vehicles from lane; disallow simulation
00446         const MSLane::VehCont& vehicles = myLane.getVehiclesSecure();
00447         for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
00448             static_cast<const GUIVehicle * const>(*v)->drawGL(s);
00449         }
00450         // allow lane simulation
00451         myLane.releaseVehicles();
00452     }
00453 }
00454 
00455 
00456 void
00457 GUILaneWrapper::drawMarkings(const GUIVisualizationSettings& s) const {
00458     glPushMatrix();
00459     glPushName(0);
00460     glTranslated(0, 0, GLO_EDGE);
00461 #ifdef HAVE_MESOSIM
00462     if (!MSGlobals::gUseMesoSim)
00463 #endif
00464         setColor(s);
00465     // optionally draw inverse markings
00466     if (myIndex > 0) {
00467         int e = (int) getShape().size() - 1;
00468         for (int i = 0; i < e; i++) {
00469             glPushMatrix();
00470             glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
00471             glRotated(myShapeRotations[i], 0, 0, 1);
00472             for (SUMOReal t = 0; t < myShapeLengths[i]; t += 6) {
00473                 glBegin(GL_QUADS);
00474                 glVertex2d(-1.8, -t);
00475                 glVertex2d(-1.8, -t - 3.);
00476                 glVertex2d(1.0, -t - 3.);
00477                 glVertex2d(1.0, -t);
00478                 glEnd();
00479             }
00480             glPopMatrix();
00481         }
00482     }
00483     // draw white boundings and white markings
00484     glColor3d(1, 1, 1);
00485     GLHelper::drawBoxLines(
00486         getShape(),
00487         getShapeRotations(),
00488         getShapeLengths(),
00489         getHalfWidth() + SUMO_const_laneOffset);
00490     glPopMatrix();
00491     glPopName();
00492 }
00493 
00494 
00495 GUIGLObjectPopupMenu*
00496 GUILaneWrapper::getPopUpMenu(GUIMainWindow& app,
00497                              GUISUMOAbstractView& parent) {
00498     GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
00499     buildPopupHeader(ret, app);
00500     buildCenterPopupEntry(ret);
00501     //
00502     buildNameCopyPopupEntry(ret);
00503     buildSelectionPopupEntry(ret);
00504     //
00505     buildShowParamsPopupEntry(ret, false);
00506     const SUMOReal pos = myShape.nearest_position_on_line_to_point2D(parent.getPositionInformation());
00507     new FXMenuCommand(ret, ("pos: " + toString(pos)).c_str(), 0, 0, 0);
00508     new FXMenuSeparator(ret);
00509     buildPositionCopyEntry(ret, false);
00510     return ret;
00511 }
00512 
00513 
00514 GUIParameterTableWindow*
00515 GUILaneWrapper::getParameterWindow(GUIMainWindow& app,
00516                                    GUISUMOAbstractView&) {
00517     GUIParameterTableWindow* ret =
00518         new GUIParameterTableWindow(app, *this, 2);
00519     // add items
00520     ret->mkItem("maxspeed [m/s]", false, myLane.getMaxSpeed());
00521     ret->mkItem("length [m]", false, myLane.getLength());
00522     // close building
00523     ret->closeBuilding();
00524     return ret;
00525 }
00526 
00527 
00528 Boundary
00529 GUILaneWrapper::getCenteringBoundary() const {
00530     Boundary b;
00531     b.add(myShape[0]);
00532     b.add(myShape[-1]);
00533     b.grow(20);
00534     return b;
00535 }
00536 
00537 
00538 
00539 
00540 const PositionVector&
00541 GUILaneWrapper::getShape() const {
00542     return myShape;
00543 }
00544 
00545 
00546 unsigned int
00547 GUILaneWrapper::getLinkNumber() const {
00548     return (unsigned int) myLane.getLinkCont().size();
00549 }
00550 
00551 
00552 const std::vector<SUMOReal>&
00553 GUILaneWrapper::getShapeRotations() const {
00554     return myShapeRotations;
00555 }
00556 
00557 
00558 const std::vector<SUMOReal>&
00559 GUILaneWrapper::getShapeLengths() const {
00560     return myShapeLengths;
00561 }
00562 
00563 
00564 SUMOReal
00565 GUILaneWrapper::firstWaitingTime() const {
00566     return myLane.myVehicles.size() == 0
00567            ? 0
00568            : (*(myLane.myVehicles.end() - 1))->getWaitingSeconds();
00569 }
00570 
00571 
00572 SUMOReal
00573 GUILaneWrapper::getEdgeLaneNumber() const {
00574     return (SUMOReal) myLane.getEdge().getLanes().size();
00575 }
00576 
00577 
00578 // ------------ Current state retrieval
00579 SUMOReal
00580 GUILaneWrapper::getNormedHBEFA_CO2Emissions() const {
00581     return myLane.getHBEFA_CO2Emissions() / myLane.getLength();
00582 }
00583 
00584 
00585 SUMOReal
00586 GUILaneWrapper::getNormedHBEFA_COEmissions() const {
00587     return myLane.getHBEFA_COEmissions() / myLane.getLength();
00588 }
00589 
00590 
00591 SUMOReal
00592 GUILaneWrapper::getNormedHBEFA_PMxEmissions() const {
00593     return myLane.getHBEFA_PMxEmissions() / myLane.getLength();
00594 }
00595 
00596 
00597 SUMOReal
00598 GUILaneWrapper::getNormedHBEFA_NOxEmissions() const {
00599     return myLane.getHBEFA_NOxEmissions() / myLane.getLength();
00600 }
00601 
00602 
00603 SUMOReal
00604 GUILaneWrapper::getNormedHBEFA_HCEmissions() const {
00605     return myLane.getHBEFA_HCEmissions() / myLane.getLength();
00606 }
00607 
00608 
00609 SUMOReal
00610 GUILaneWrapper::getNormedHBEFA_FuelConsumption() const {
00611     return myLane.getHBEFA_FuelConsumption() / myLane.getLength();
00612 }
00613 
00614 
00615 void
00616 GUILaneWrapper::setColor(const GUIVisualizationSettings& s) const {
00617     GLHelper::setColor(s.laneColorer.getScheme().getColor(getColorValue(s.laneColorer.getActive())));
00618 }
00619 
00620 
00621 SUMOReal
00622 GUILaneWrapper::getColorValue(size_t activeScheme) const {
00623     switch (activeScheme) {
00624         case 1:
00625             return gSelected.isSelected(getType(), getGlID());
00626         case 2: {
00627             if (getLane().allowsVehicleClass(SVC_PASSENGER)) {
00628                 return 0;
00629             } else {
00630                 return 1;
00631             }
00632         }
00633         case 3:
00634             return getLane().getMaxSpeed();
00635         case 4:
00636             return getLane().getOccupancy();
00637         case 5:
00638             return firstWaitingTime();
00639         case 6:
00640             return getEdgeLaneNumber();
00641         case 7:
00642             return getNormedHBEFA_CO2Emissions();
00643         case 8:
00644             return getNormedHBEFA_COEmissions();
00645         case 9:
00646             return getNormedHBEFA_PMxEmissions();
00647         case 10:
00648             return getNormedHBEFA_NOxEmissions();
00649         case 11:
00650             return getNormedHBEFA_HCEmissions();
00651         case 12:
00652             return getNormedHBEFA_FuelConsumption();
00653         case 13:
00654             return getLane().getHarmonoise_NoiseEmissions();
00655         case 14: {
00656             MSEdgeWeightsStorage& ews = MSNet::getInstance()->getWeightsStorage();
00657             MSEdge& e = getLane().getEdge();
00658             if (!ews.knowsTravelTime(&e)) {
00659                 return -1;
00660             } else {
00661                 SUMOReal value(0);
00662                 ews.retrieveExistingTravelTime(&e, 0, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
00663                 return value;
00664             }
00665         }
00666         case 15: {
00667             MSEdgeWeightsStorage& ews = MSNet::getInstance()->getWeightsStorage();
00668             MSEdge& e = getLane().getEdge();
00669             if (!ews.knowsTravelTime(&e)) {
00670                 return -1;
00671             } else {
00672                 SUMOReal value(0);
00673                 ews.retrieveExistingTravelTime(&e, 0, 0, value);
00674                 return (getLane().getLength() / getLane().getMaxSpeed()) / (getLane().getMaxSpeed() / value);
00675             }
00676         }
00677     }
00678     return 0;
00679 }
00680 
00681 /****************************************************************************/
00682 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines