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