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