void GUIMEVehicle::drawRouteHelper(const MSRoute& r, SUMOReal exaggeration) const { MSRouteIterator i = r.begin(); for (; i != r.end(); ++i) { const GUILane* lane = static_cast<GUILane*>((*i)->getLanes()[0]); GLHelper::drawBoxLines(lane->getShape(), lane->getShapeRotations(), lane->getShapeLengths(), 1.0); GLHelper::drawBoxLines(lane->getShape(), lane->getShapeRotations(), lane->getShapeLengths(), exaggeration); } }
void GUIViewTraffic::draw(const MSRoute &r) { MSRouteIterator i = r.begin(); for (; i!=r.end(); ++i) { const MSEdge *e = *i; const GUIEdge *ge = static_cast<const GUIEdge*>(e); const GUILaneWrapper &lane = ge->getLaneGeometry((size_t) 0); GLHelper::drawBoxLines(lane.getShape(), lane.getShapeRotations(), lane.getShapeLengths(), 1.0); } }
void MSRouteProbe::addRoute(const MSRoute &route) const { if (myCurrentRouteDistribution != 0) { const MSRoute* routep = &route; if (!route.inFurtherUse()) { const std::string id = getID() + "_" + route.getID(); routep = new MSRoute(id, route.getEdges(), true, route.getColor(), route.getStops()); MSRoute::dictionary(id, routep); } myCurrentRouteDistribution->add(1., routep); } }
void GUIVehicle::drawRouteHelper(const GUIVisualizationSettings& s, const MSRoute& r, bool future) const { const double exaggeration = s.vehicleSize.getExaggeration(s, this); MSRouteIterator i = future ? myCurrEdge : r.begin(); const std::vector<MSLane*>& bestLaneConts = getBestLanesContinuation(); // draw continuation lanes when drawing the current route where available int bestLaneIndex = (&r == myRoute ? 0 : (int)bestLaneConts.size()); for (; i != r.end(); ++i) { const GUILane* lane; if (bestLaneIndex < (int)bestLaneConts.size() && bestLaneConts[bestLaneIndex] != 0 && (*i) == &(bestLaneConts[bestLaneIndex]->getEdge())) { lane = static_cast<GUILane*>(bestLaneConts[bestLaneIndex]); ++bestLaneIndex; } else { const std::vector<MSLane*>* allowed = (*i)->allowedLanes(getVClass()); if (allowed != nullptr && allowed->size() != 0) { lane = static_cast<GUILane*>((*allowed)[0]); } else { lane = static_cast<GUILane*>((*i)->getLanes()[0]); } } GLHelper::drawBoxLines(lane->getShape(), lane->getShapeRotations(), lane->getShapeLengths(), exaggeration); } // draw stop labels // (vertical shift for repeated stops at the same position std::map<std::pair<const MSLane*, double>, int> repeat; // count repeated occurrences of the same position int stopIndex = 0; for (const Stop& stop : myStops) { Position pos = stop.lane->geometryPositionAtOffset(stop.reached ? getPositionOnLane() : stop.getEndPos(*this)); GLHelper::drawBoxLines(stop.lane->getShape().getOrthogonal(pos, 10, true, stop.lane->getWidth()), 0.1); std::string label = stop.reached ? "stopped" : "stop " + toString(stopIndex); #ifdef _DEBUG label += " (" + toString(stop.edge - myCurrEdge) + "e)"; #endif if (stop.pars.until >= 0) { label += " until:" + time2string(stop.pars.until); } if (stop.duration >= 0) { if (STEPS2TIME(stop.duration) > 3600 * 24) { label += " duration:1day+"; } else { label += " duration:" + time2string(stop.duration); } } std::pair<const MSLane*, double> stopPos = std::make_pair(stop.lane, stop.getEndPos(*this)); const double textSize = s.vehicleName.size / s.scale; GLHelper::drawText(label, pos - Position(0, textSize * repeat[stopPos]), 1.0, textSize, s.vehicleName.color); repeat[stopPos]++; stopIndex++; } }
bool MSBaseVehicle::replaceRouteEdges(ConstMSEdgeVector& edges, bool onInit) { if (edges.empty()) { WRITE_WARNING("No route for vehicle '" + getID() + "' found."); return false; } // build a new id, first std::string id = getID(); if (id[0] != '!') { id = "!" + id; } if (myRoute->getID().find("!var#") != std::string::npos) { id = myRoute->getID().substr(0, myRoute->getID().rfind("!var#") + 5) + toString(getNumberReroutes() + 1); } else { id = id + "!var#1"; } int oldSize = (int)edges.size(); if (!onInit) { const MSEdge* const origin = getRerouteOrigin(); if (origin != *myCurrEdge && edges.front() == origin) { edges.insert(edges.begin(), *myCurrEdge); oldSize = (int)edges.size(); } edges.insert(edges.begin(), myRoute->begin(), myCurrEdge); } if (edges == myRoute->getEdges()) { if (onInit) { // if edges = 'from to' we still need to calculate the arrivalPos once calculateArrivalParams(); } return true; } const RGBColor& c = myRoute->getColor(); MSRoute* newRoute = new MSRoute(id, edges, false, &c == &RGBColor::DEFAULT_COLOR ? 0 : new RGBColor(c), myRoute->getStops()); if (!MSRoute::dictionary(id, newRoute)) { delete newRoute; return false; } if (!replaceRoute(newRoute, onInit, (int)edges.size() - oldSize)) { newRoute->addReference(); newRoute->release(); return false; } calculateArrivalParams(); return true; }