00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include <string>
00031 #include <iostream>
00032 #include <utility>
00033 #include <microsim/MSLane.h>
00034 #include <microsim/MSGlobals.h>
00035 #include <utils/geom/Position2DVector.h>
00036 #include <microsim/MSNet.h>
00037 #include <gui/GUIGlobals.h>
00038 #include <utils/gui/windows/GUISUMOAbstractView.h>
00039 #include "GUILaneWrapper.h"
00040 #include <utils/common/ToString.h>
00041 #include <utils/geom/GeomHelper.h>
00042 #include <guisim/GUINet.h>
00043 #include <utils/gui/windows/GUIAppEnum.h>
00044 #include <utils/gui/images/GUIIconSubSys.h>
00045 #include <utils/gui/div/GUIParameterTableWindow.h>
00046 #include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
00047 #include <gui/GUIApplicationWindow.h>
00048 #include <utils/gui/div/GUIGlobalSelection.h>
00049 #include <utils/common/RandHelper.h>
00050 #include <utils/gui/div/GLHelper.h>
00051 #include <gui/GUIViewTraffic.h>
00052 #include <utils/gui/images/GUITexturesHelper.h>
00053 #include <guisim/GUIVehicle.h>
00054 #include <foreign/polyfonts/polyfonts.h>
00055 #include <utils/common/HelpersHarmonoise.h>
00056
00057
00058 #ifdef CHECK_MEMORY_LEAKS
00059 #include <foreign/nvwa/debug_new.h>
00060 #endif // CHECK_MEMORY_LEAKS
00061
00062
00063
00064
00065
00066 SUMOReal GUILaneWrapper::myAllMaxSpeed = 0;
00067
00068
00069
00070
00071
00072 GUILaneWrapper::GUILaneWrapper(GUIGlObjectStorage &idStorage,
00073 MSLane &lane, const Position2DVector &shape) throw()
00074 : GUIGlObject(idStorage, "lane:"+lane.getID()),
00075 myLane(lane), myShape(shape) {
00076 SUMOReal x1 = shape[0].x();
00077 SUMOReal y1 = shape[0].y();
00078 SUMOReal x2 = shape[-1].x();
00079 SUMOReal y2 = shape[-1].y();
00080 SUMOReal length = myLane.getLength();
00081
00082 myVisLength = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
00083
00084 if (myAllMaxSpeed<lane.getMaxSpeed()) {
00085 myAllMaxSpeed = lane.getMaxSpeed();
00086 }
00087
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 Position2D &f = myShape[i];
00093 const Position2D &s = myShape[i+1];
00094 myShapeLengths.push_back(f.distanceTo(s));
00095 myShapeRotations.push_back((SUMOReal) atan2((s.x()-f.x()), (f.y()-s.y()))*(SUMOReal) 180.0/(SUMOReal) PI);
00096 }
00097 }
00098
00099
00100 GUILaneWrapper::~GUILaneWrapper() throw() {}
00101
00102
00103 MSEdge::EdgeBasicFunction
00104 GUILaneWrapper::getPurpose() const {
00105 return myLane.myEdge->getPurpose();
00106 }
00107
00108
00109 SUMOReal
00110 GUILaneWrapper::getOverallMaxSpeed() {
00111 return myAllMaxSpeed;
00112 }
00113
00114
00115 bool
00116 GUILaneWrapper::forLane(const MSLane &lane) const {
00117 return (&myLane)==(&lane);
00118 }
00119
00120
00121
00122 void
00123 ROWdrawAction_drawLinkNo(const GUILaneWrapper &lane) {
00124 unsigned int noLinks = lane.getLinkNumber();
00125 if (noLinks==0) {
00126 return;
00127 }
00128
00129
00130 SUMOReal w = SUMO_const_laneWidth / (SUMOReal) noLinks;
00131 SUMOReal x1 = SUMO_const_laneWidth / (SUMOReal) 2.;
00132 glPushMatrix();
00133 glColor3d(.5, .5, 1);
00134 const Position2DVector &g = lane.getShape();
00135 const Position2D &end = g.getEnd();
00136 const Position2D &f = g[-2];
00137 const Position2D &s = end;
00138 SUMOReal rot = (SUMOReal) atan2((s.x()-f.x()), (f.y()-s.y()))*(SUMOReal) 180.0/(SUMOReal) PI;
00139 glTranslated(end.x(), end.y(), 0);
00140 glRotated(rot, 0, 0, 1);
00141 for (unsigned int i=0; i<noLinks; ++i) {
00142 SUMOReal x2 = x1 - (SUMOReal)(w/2.);
00143 int linkNo = lane.getLinkRespondIndex(i);
00144 glPushMatrix();
00145 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00146 pfSetPosition(0, 0);
00147 pfSetScale(1);
00148 SUMOReal tw = pfdkGetStringWidth(toString(linkNo).c_str());
00149 glRotated(180, 0, 1, 0);
00150 glTranslated(x2-tw/2., 0.5, 0);
00151 pfDrawString(toString(linkNo).c_str());
00152 glPopMatrix();
00153 x1 -= w;
00154 }
00155 glPopMatrix();
00156 }
00157
00158
00159 void
00160 ROWdrawAction_drawTLSLinkNo(const GUINet &net, const GUILaneWrapper &lane) {
00161 unsigned int noLinks = lane.getLinkNumber();
00162 if (noLinks==0) {
00163 return;
00164 }
00165
00166
00167 SUMOReal w = SUMO_const_laneWidth / (SUMOReal) noLinks;
00168 SUMOReal x1 = (SUMOReal)(SUMO_const_laneWidth / 2.);
00169 glPushMatrix();
00170 glColor3d(.5, .5, 1);
00171 const Position2DVector &g = lane.getShape();
00172 const Position2D &end = g.getEnd();
00173 const Position2D &f = g[-2];
00174 const Position2D &s = end;
00175 SUMOReal rot = (SUMOReal) atan2((s.x()-f.x()), (f.y()-s.y()))*(SUMOReal) 180.0/(SUMOReal) PI;
00176 glTranslated(end.x(), end.y(), 0);
00177 glRotated(rot, 0, 0, 1);
00178 for (unsigned int i=0; i<noLinks; ++i) {
00179 SUMOReal x2 = x1 - (SUMOReal)(w/2.);
00180 int linkNo = lane.getLinkTLIndex(net, i);
00181 if (linkNo<0) {
00182 continue;
00183 }
00184 glPushMatrix();
00185 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00186 pfSetPosition(0, 0);
00187 pfSetScale(1);
00188 SUMOReal tw = pfdkGetStringWidth(toString(linkNo).c_str());
00189 glRotated(180, 0, 1, 0);
00190 glTranslated(x2-tw/2., 0.5, 0);
00191 pfDrawString(toString(linkNo).c_str());
00192 glPopMatrix();
00193 x1 -= w;
00194 }
00195 glPopMatrix();
00196 }
00197
00198
00199 void
00200 ROWdrawAction_drawLinkRules(const GUINet &net, const GUILaneWrapper &lane,
00201 bool showToolTips) {
00202 unsigned int noLinks = lane.getLinkNumber();
00203 const Position2DVector &g = lane.getShape();
00204 const Position2D &end = g.getEnd();
00205 const Position2D &f = g[-2];
00206 const Position2D &s = end;
00207 SUMOReal rot = (SUMOReal) atan2((s.x()-f.x()), (f.y()-s.y()))*(SUMOReal) 180.0/(SUMOReal) PI;
00208 if (noLinks==0) {
00209 if (showToolTips) {
00210 glPushName(lane.getGlID());
00211 }
00212
00213 glColor3d(0.5, 0.5, 0.5);
00214 glPushMatrix();
00215 glTranslated(end.x(), end.y(), 0);
00216 glRotated(rot, 0, 0, 1);
00217 glBegin(GL_QUADS);
00218 glVertex2d(-SUMO_const_halfLaneWidth, 0.0);
00219 glVertex2d(-SUMO_const_halfLaneWidth, 0.5);
00220 glVertex2d(SUMO_const_halfLaneWidth, 0.5);
00221 glVertex2d(SUMO_const_halfLaneWidth, 0.0);
00222 glEnd();
00223 glPopMatrix();
00224 if (showToolTips) {
00225 glPopName();
00226 }
00227 return;
00228 }
00229
00230 SUMOReal w = SUMO_const_laneWidth / (SUMOReal) noLinks;
00231 SUMOReal x1 = 0;
00232 glPushMatrix();
00233 glTranslated(end.x(), end.y(), 0);
00234 glRotated(rot, 0, 0, 1);
00235 for (unsigned int i=0; i<noLinks; ++i) {
00236 SUMOReal x2 = x1 + w;
00237 MSLink::LinkState state = lane.getLinkState(i);
00238 if (showToolTips) {
00239 switch (state) {
00240 case MSLink::LINKSTATE_TL_GREEN_MAJOR:
00241 case MSLink::LINKSTATE_TL_GREEN_MINOR:
00242 case MSLink::LINKSTATE_TL_RED:
00243 case MSLink::LINKSTATE_TL_YELLOW_MAJOR:
00244 case MSLink::LINKSTATE_TL_YELLOW_MINOR:
00245 case MSLink::LINKSTATE_TL_OFF_BLINKING:
00246 glPushName(lane.getLinkTLID(net, i));
00247 break;
00248 case MSLink::LINKSTATE_MAJOR:
00249 case MSLink::LINKSTATE_MINOR:
00250 case MSLink::LINKSTATE_EQUAL:
00251 case MSLink::LINKSTATE_TL_OFF_NOSIGNAL:
00252 default:
00253 glPushName(lane.getGlID());
00254 break;
00255 }
00256 }
00257 switch (state) {
00258 case MSLink::LINKSTATE_TL_GREEN_MAJOR:
00259 case MSLink::LINKSTATE_TL_GREEN_MINOR:
00260 glColor3d(0, 1, 0);
00261 break;
00262 case MSLink::LINKSTATE_TL_RED:
00263 glColor3d(1, 0, 0);
00264 break;
00265 case MSLink::LINKSTATE_TL_YELLOW_MAJOR:
00266 case MSLink::LINKSTATE_TL_YELLOW_MINOR:
00267 glColor3d(1, 1, 0);
00268 break;
00269 case MSLink::LINKSTATE_TL_OFF_BLINKING:
00270 glColor3d(1, 1, 0);
00271 break;
00272 case MSLink::LINKSTATE_TL_OFF_NOSIGNAL:
00273 glColor3d(0, 1, 1);
00274 break;
00275 case MSLink::LINKSTATE_MAJOR:
00276 glColor3d(1, 1, 1);
00277 break;
00278 case MSLink::LINKSTATE_MINOR:
00279 glColor3d(.2, .2, .2);
00280 break;
00281 case MSLink::LINKSTATE_EQUAL:
00282 glColor3d(.5, .5, .5);
00283 break;
00284 case MSLink::LINKSTATE_DEADEND:
00285 glColor3d(0, 0, 0);
00286 break;
00287 }
00288 glBegin(GL_QUADS);
00289 glVertex2d(x1-SUMO_const_halfLaneWidth, 0.0);
00290 glVertex2d(x1-SUMO_const_halfLaneWidth, 0.5);
00291 glVertex2d(x2-SUMO_const_halfLaneWidth, 0.5);
00292 glVertex2d(x2-SUMO_const_halfLaneWidth,0.0);
00293 glEnd();
00294 if (showToolTips) {
00295 glPopName();
00296 }
00297 x1 = x2;
00298 x2 += w;
00299 }
00300 glPopMatrix();
00301 }
00302
00303
00304 void
00305 ROWdrawAction_drawArrows(const GUILaneWrapper &lane, bool showToolTips) {
00306 unsigned int noLinks = lane.getLinkNumber();
00307 if (noLinks==0) {
00308 return;
00309 }
00310
00311 const Position2D &end = lane.getShape().getEnd();
00312 const Position2D &f = lane.getShape()[-2];
00313 const Position2D &s = end;
00314 SUMOReal rot = (SUMOReal) atan2((s.x()-f.x()), (f.y()-s.y()))*(SUMOReal) 180.0/(SUMOReal) PI;
00315 glPushMatrix();
00316 if (showToolTips) {
00317 glPushName(0);
00318 }
00319 glColor3d(1, 1, 1);
00320 glEnable(GL_TEXTURE_2D);
00321 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00322 glDisable(GL_CULL_FACE);
00323
00324 glDisable(GL_LIGHTING);
00325 glDisable(GL_COLOR_MATERIAL);
00326 glDisable(GL_TEXTURE_GEN_S);
00327 glDisable(GL_TEXTURE_GEN_T);
00328 glDisable(GL_ALPHA_TEST);
00329 glEnable(GL_BLEND);
00330 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
00331
00332 glTranslated(end.x(), end.y(), 0);
00333 glRotated(rot, 0, 0, 1);
00334 for (unsigned int i=0; i<noLinks; ++i) {
00335 MSLink::LinkDirection dir = lane.getLinkDirection(i);
00336 MSLink::LinkState state = lane.getLinkState(i);
00337 if (state==MSLink::LINKSTATE_TL_OFF_NOSIGNAL||dir==MSLink::LINKDIR_NODIR) {
00338 continue;
00339 }
00340 GUITexturesHelper::drawDirectionArrow((GUITexture) dir, 1.5, 4.0, -1.5, 1);
00341 }
00342 glBindTexture(GL_TEXTURE_2D, 0);
00343 glPopMatrix();
00344 if (showToolTips) {
00345 glPopName();
00346 }
00347 }
00348
00349
00350 void
00351 ROWdrawAction_drawLane2LaneConnections(const GUILaneWrapper &lane) {
00352 unsigned int noLinks = lane.getLinkNumber();
00353 for (unsigned int i=0; i<noLinks; ++i) {
00354 MSLink::LinkState state = lane.getLinkState(i);
00355 const MSLane *connected = lane.getLinkLane(i);
00356 if (connected==0) {
00357 continue;
00358 }
00359 switch (state) {
00360 case MSLink::LINKSTATE_TL_GREEN_MAJOR:
00361 case MSLink::LINKSTATE_TL_GREEN_MINOR:
00362 glColor3d(0, 1, 0);
00363 break;
00364 case MSLink::LINKSTATE_TL_RED:
00365 glColor3d(1, 0, 0);
00366 break;
00367 case MSLink::LINKSTATE_TL_YELLOW_MAJOR:
00368 case MSLink::LINKSTATE_TL_YELLOW_MINOR:
00369 glColor3d(1, 1, 0);
00370 break;
00371 case MSLink::LINKSTATE_TL_OFF_BLINKING:
00372 glColor3d(1, 1, 0);
00373 break;
00374 case MSLink::LINKSTATE_TL_OFF_NOSIGNAL:
00375 glColor3d(0, 1, 1);
00376 break;
00377 case MSLink::LINKSTATE_MAJOR:
00378 glColor3d(1, 1, 1);
00379 break;
00380 case MSLink::LINKSTATE_MINOR:
00381 glColor3d(.2, .2, .2);
00382 break;
00383 case MSLink::LINKSTATE_EQUAL:
00384 glColor3d(.5, .5, .5);
00385 break;
00386 case MSLink::LINKSTATE_DEADEND:
00387 glColor3d(0, 0, 0);
00388 break;
00389 }
00390
00391 glBegin(GL_LINES);
00392 const Position2D &p1 = lane.getShape()[-1];
00393 const Position2D &p2 = connected->getShape()[0];
00394 glVertex2f(p1.x(), p1.y());
00395 glVertex2f(p2.x(), p2.y());
00396 glEnd();
00397 GLHelper::drawTriangleAtEnd(Line2D(p1, p2), (SUMOReal) .4, (SUMOReal) .2);
00398 }
00399 }
00400
00401
00402 void
00403 GUILaneWrapper::drawGL(const GUIVisualizationSettings &s) const throw() {
00404
00405 #ifdef HAVE_MESOSIM
00406 if (!MSGlobals::gUseMesoSim)
00407 #endif
00408 s.laneColorer.setGlColor(*this);
00409
00410 if (s.needsGlID) {
00411 glPushName(getGlID());
00412 }
00413
00414
00415 if (s.scale<1.) {
00416 GLHelper::drawLine(myShape);
00417
00418 if (s.needsGlID) {
00419 glPopName();
00420 }
00421 } else {
00422 if (getPurpose()!=MSEdge::EDGEFUNCTION_INTERNAL) {
00423 glTranslated(0, 0, .005);
00424 GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, SUMO_const_halfLaneWidth);
00425 glTranslated(0, 0, -.005);
00426 } else {
00427 GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, SUMO_const_quarterLaneWidth);
00428 }
00429
00430 if (s.needsGlID) {
00431 glPopName();
00432 }
00433
00434 if (getPurpose()!=MSEdge::EDGEFUNCTION_INTERNAL) {
00435 glTranslated(0, 0, -.02);
00436 GUINet *net = (GUINet*) MSNet::getInstance();
00437 ROWdrawAction_drawLinkRules(*net, *this, s.needsGlID);
00438 if (s.showLinkDecals) {
00439 ROWdrawAction_drawArrows(*this, s.needsGlID);
00440 }
00441 if (s.showLane2Lane) {
00442
00443
00444 ROWdrawAction_drawLane2LaneConnections(*this);
00445 }
00446 glTranslated(0, 0, .02);
00447 if (s.drawLinkJunctionIndex) {
00448 glTranslated(0, 0, -.03);
00449 ROWdrawAction_drawLinkNo(*this);
00450 glTranslated(0, 0, .03);
00451 }
00452 if (s.drawLinkTLIndex) {
00453 glTranslated(0, 0, -.03);
00454 ROWdrawAction_drawTLSLinkNo(*net, *this);
00455 glTranslated(0, 0, .03);
00456 }
00457 }
00458 }
00459
00460 if (s.scale>s.minVehicleSize) {
00461
00462 const MSLane::VehCont &vehicles = myLane.getVehiclesSecure();
00463 for (MSLane::VehCont::const_iterator v=vehicles.begin(); v!=vehicles.end(); ++v) {
00464 static_cast<const GUIVehicle*const>(*v)->drawGL(s);
00465 }
00466
00467 myLane.releaseVehicles();
00468 }
00469 glPopMatrix();
00470 }
00471
00472
00473 void
00474 GUILaneWrapper::drawBordersGL(const GUIVisualizationSettings &s) const throw() {
00475 #ifdef HAVE_MESOSIM
00476 if (!MSGlobals::gUseMesoSim)
00477 #endif
00478 s.laneColorer.setGlColor(*this);
00479
00480 int e = (int) myShape.size() - 1;
00481 for (int i=0; i<e; i++) {
00482 glPushMatrix();
00483 glTranslated(myShape[i].x(), myShape[i].y(), 0);
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
00497
00498 GUIGLObjectPopupMenu *
00499 GUILaneWrapper::getPopUpMenu(GUIMainWindow &app,
00500 GUISUMOAbstractView &parent) throw() {
00501 GUIGLObjectPopupMenu *ret = new GUIGLObjectPopupMenu(app, parent, *this);
00502 buildPopupHeader(ret, app);
00503 buildCenterPopupEntry(ret);
00504
00505 buildNameCopyPopupEntry(ret);
00506 buildSelectionPopupEntry(ret);
00507
00508 buildShowParamsPopupEntry(ret, false);
00509 SUMOReal pos = myShape.nearest_position_on_line_to_point(parent.getPositionInformation());
00510 new FXMenuCommand(ret, ("pos: " + toString(pos)).c_str(), 0, 0, 0);
00511 new FXMenuSeparator(ret);
00512 buildPositionCopyEntry(ret, false);
00513 return ret;
00514 }
00515
00516
00517 GUIParameterTableWindow *
00518 GUILaneWrapper::getParameterWindow(GUIMainWindow &app,
00519 GUISUMOAbstractView &) throw() {
00520 GUIParameterTableWindow *ret =
00521 new GUIParameterTableWindow(app, *this, 2);
00522
00523 ret->mkItem("maxspeed [m/s]", false, myLane.getMaxSpeed());
00524 ret->mkItem("length [m]", false, myLane.getLength());
00525
00526 ret->closeBuilding();
00527 return ret;
00528 }
00529
00530
00531 const std::string &
00532 GUILaneWrapper::getMicrosimID() const throw() {
00533 return myLane.getID();
00534 }
00535
00536
00537 Boundary
00538 GUILaneWrapper::getCenteringBoundary() const throw() {
00539 Boundary b;
00540 b.add(myShape[0]);
00541 b.add(myShape[-1]);
00542 b.grow(20);
00543 return b;
00544 }
00545
00546
00547
00548
00549 const Position2DVector &
00550 GUILaneWrapper::getShape() const {
00551 return myShape;
00552 }
00553
00554
00555 unsigned int
00556 GUILaneWrapper::getLinkNumber() const {
00557 return (unsigned int) myLane.getLinkCont().size();
00558 }
00559
00560
00561 MSLink::LinkState
00562 GUILaneWrapper::getLinkState(unsigned int pos) const throw() {
00563 return myLane.getLinkCont()[pos]->getState();
00564 }
00565
00566
00567 MSLink::LinkDirection
00568 GUILaneWrapper::getLinkDirection(unsigned int pos) const {
00569 return myLane.getLinkCont()[pos]->getDirection();
00570 }
00571
00572
00573 MSLane *
00574 GUILaneWrapper::getLinkLane(unsigned int pos) const {
00575 return myLane.getLinkCont()[pos]->getLane();
00576 }
00577
00578
00579 int
00580 GUILaneWrapper::getLinkRespondIndex(unsigned int pos) const {
00581 return myLane.getLinkCont()[pos]->getRespondIndex();
00582 }
00583
00584
00585 const DoubleVector &
00586 GUILaneWrapper::getShapeRotations() const {
00587 return myShapeRotations;
00588 }
00589
00590
00591 const DoubleVector &
00592 GUILaneWrapper::getShapeLengths() const {
00593 return myShapeLengths;
00594 }
00595
00596
00597 unsigned int
00598 GUILaneWrapper::getLinkTLID(const GUINet &net, unsigned int pos) const {
00599 return net.getLinkTLID(myLane.getLinkCont()[pos]);
00600 }
00601
00602
00603 int
00604 GUILaneWrapper::getLinkTLIndex(const GUINet &net, unsigned int pos) const {
00605 return net.getLinkTLIndex(myLane.getLinkCont()[pos]);
00606 }
00607
00608
00609 SUMOReal
00610 GUILaneWrapper::firstWaitingTime() const {
00611 return myLane.myVehicles.size()==0
00612 ? 0
00613 : (*(myLane.myVehicles.end()-1))->getWaitingSeconds();
00614 }
00615
00616
00617 SUMOReal
00618 GUILaneWrapper::getEdgeLaneNumber() const {
00619 return (SUMOReal) myLane.getEdge().getLanes().size();
00620 }
00621
00622
00623
00624 SUMOReal
00625 GUILaneWrapper::getNormedHBEFA_CO2Emissions() const throw() {
00626 return myLane.getHBEFA_CO2Emissions() / myLane.getLength();
00627 }
00628
00629
00630 SUMOReal
00631 GUILaneWrapper::getNormedHBEFA_COEmissions() const throw() {
00632 return myLane.getHBEFA_COEmissions() / myLane.getLength();
00633 }
00634
00635
00636 SUMOReal
00637 GUILaneWrapper::getNormedHBEFA_PMxEmissions() const throw() {
00638 return myLane.getHBEFA_PMxEmissions() / myLane.getLength();
00639 }
00640
00641
00642 SUMOReal
00643 GUILaneWrapper::getNormedHBEFA_NOxEmissions() const throw() {
00644 return myLane.getHBEFA_NOxEmissions() / myLane.getLength();
00645 }
00646
00647
00648 SUMOReal
00649 GUILaneWrapper::getNormedHBEFA_HCEmissions() const throw() {
00650 return myLane.getHBEFA_HCEmissions() / myLane.getLength();
00651 }
00652
00653
00654 SUMOReal
00655 GUILaneWrapper::getNormedHBEFA_FuelConsumption() const throw() {
00656 return myLane.getHBEFA_FuelConsumption() / myLane.getLength();
00657 }
00658
00659
00660
00661
00662 GUILaneWrapper::Colorer::Colorer() {
00663 mySchemes.push_back(GUIColorScheme("uniform", RGBColor(0,0,0), "", true));
00664 mySchemes.push_back(GUIColorScheme("by selection (lane-/streetwise)", RGBColor(0.7f, 0.7f, 0.7f), "unselected", true));
00665 mySchemes.back().addColor(RGBColor(0, .4f, .8f), 1, "selected");
00666 mySchemes.push_back(GUIColorScheme("by vclass", RGBColor(0,0,0), "all", true));
00667 mySchemes.back().addColor(RGBColor(0, .1f, .5f), 1, "public");
00668
00669 mySchemes.push_back(GUIColorScheme("by allowed speed (lanewise)", RGBColor(1,0,0)));
00670 mySchemes.back().addColor(RGBColor(0, 0, 1), (SUMOReal)(150.0/3.6));
00671 mySchemes.push_back(GUIColorScheme("by current occupancy (lanewise)", RGBColor(0,0,1)));
00672 mySchemes.back().addColor(RGBColor(1, 0, 0), (SUMOReal)0.95);
00673 mySchemes.push_back(GUIColorScheme("by first vehicle waiting time (lanewise)", RGBColor(0,1,0)));
00674 mySchemes.back().addColor(RGBColor(1,0,0), (SUMOReal)200);
00675 mySchemes.push_back(GUIColorScheme("by lane number (streetwise)", RGBColor(1,0,0)));
00676 mySchemes.back().addColor(RGBColor(0,0,1), (SUMOReal)5);
00677
00678 mySchemes.push_back(GUIColorScheme("by CO2 emissions (HBEFA)", RGBColor(0,1,0)));
00679 mySchemes.back().addColor(RGBColor(1,0,0), (SUMOReal)(10./7.5/5.));
00680 mySchemes.push_back(GUIColorScheme("by CO emissions (HBEFA)", RGBColor(0,1,0)));
00681 mySchemes.back().addColor(RGBColor(1,0,0), (SUMOReal)(0.05/7.5/2.));
00682 mySchemes.push_back(GUIColorScheme("by PMx emissions (HBEFA)", RGBColor(0,1,0)));
00683 mySchemes.back().addColor(RGBColor(1,0,0), (SUMOReal)(.005/7.5/5.));
00684 mySchemes.push_back(GUIColorScheme("by NOx emissions (HBEFA)", RGBColor(0,1,0)));
00685 mySchemes.back().addColor(RGBColor(1,0,0), (SUMOReal)(.125/7.5/5.));
00686 mySchemes.push_back(GUIColorScheme("by HC emissions (HBEFA)", RGBColor(0,1,0)));
00687 mySchemes.back().addColor(RGBColor(1,0,0), (SUMOReal)(.02/7.5/4.));
00688 mySchemes.push_back(GUIColorScheme("by fuel consumption (HBEFA)", RGBColor(0,1,0)));
00689 mySchemes.back().addColor(RGBColor(1,0,0), (SUMOReal)(.005/7.5*100.));
00690 mySchemes.push_back(GUIColorScheme("by noise emissions (Harmonoise)", RGBColor(0,1,0)));
00691 mySchemes.back().addColor(RGBColor(1,0,0), (SUMOReal)100);
00692 }
00693
00694
00695 SUMOReal
00696 GUILaneWrapper::Colorer::getColorValue(const GUILaneWrapper& lane) const {
00697 switch (myActiveScheme) {
00698 case 1:
00699 return gSelected.isSelected(lane.getType(), lane.getGlID());
00700 case 2: {
00701 const std::vector<SUMOVehicleClass> &allowed = lane.myLane.getAllowedClasses();
00702 const std::vector<SUMOVehicleClass> &disallowed = lane.myLane.getNotAllowedClasses();
00703 if ((allowed.size()==0 || find(allowed.begin(), allowed.end(), SVC_PASSENGER)!=allowed.end()) && find(disallowed.begin(), disallowed.end(), SVC_PASSENGER)==disallowed.end()) {
00704 return 0;
00705 } else {
00706 return 1;
00707 }
00708 }
00709 case 3:
00710 return lane.getLane().getMaxSpeed();
00711 case 4:
00712 return lane.getLane().getOccupancy();
00713 case 5:
00714 return lane.firstWaitingTime();
00715 case 6:
00716 return lane.getEdgeLaneNumber();
00717 case 7:
00718 return lane.getNormedHBEFA_CO2Emissions();
00719 case 8:
00720 return lane.getNormedHBEFA_COEmissions();
00721 case 9:
00722 return lane.getNormedHBEFA_PMxEmissions();
00723 case 10:
00724 return lane.getNormedHBEFA_NOxEmissions();
00725 case 11:
00726 return lane.getNormedHBEFA_HCEmissions();
00727 case 12:
00728 return lane.getNormedHBEFA_FuelConsumption();
00729 case 13:
00730 return lane.getLane().getHarmonoise_NoiseEmissions();
00731 }
00732 return 0;
00733 }
00734
00735
00736