void ROWdrawAction_drawLinkNo(const GUILaneWrapper &lane) { unsigned int noLinks = lane.getLinkNumber(); if (noLinks==0) { return; } // draw all links SUMOReal w = SUMO_const_laneWidth / (SUMOReal) noLinks; SUMOReal x1 = SUMO_const_laneWidth / (SUMOReal) 2.; glPushMatrix(); glColor3d(.5, .5, 1); const Position2DVector &g = lane.getShape(); const Position2D &end = g.getEnd(); const Position2D &f = g[-2]; const Position2D &s = end; SUMOReal rot = (SUMOReal) atan2((s.x()-f.x()), (f.y()-s.y()))*(SUMOReal) 180.0/(SUMOReal) PI; glTranslated(end.x(), end.y(), 0); glRotated(rot, 0, 0, 1); for (unsigned int i=0; i<noLinks; ++i) { SUMOReal x2 = x1 - (SUMOReal)(w/2.); int linkNo = lane.getLane().getLinkCont()[i]->getRespondIndex(); glPushMatrix(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pfSetPosition(0, 0); pfSetScale(1); SUMOReal tw = pfdkGetStringWidth(toString(linkNo).c_str()); glRotated(180, 0, 1, 0); glTranslated(x2-tw/2., 0.5, 0); pfDrawString(toString(linkNo).c_str()); glPopMatrix(); x1 -= w; } glPopMatrix(); }
void GUIJunctionWrapper::drawGL(const GUIVisualizationSettings &s) const throw() { // check whether it is not too small if (s.scale*myMaxSize<1.) { return; } // (optional) set id if (s.needsGlID) { glPushName(getGlID()); } glColor3d(0, 0, 0); glTranslated(0, 0, .01); GLHelper::drawFilledPoly(myJunction.getShape(), true); glTranslated(0, 0, -.01); // (optional) draw name if (s.drawJunctionName) { glPushMatrix(); glTranslated(0, 0, -.06); Position2D p = myJunction.getPosition(); glTranslated(p.x(), p.y(), 0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pfSetPosition(0, 0); pfSetScale(s.junctionNameSize / s.scale); glColor3d(s.junctionNameColor.red(), s.junctionNameColor.green(), s.junctionNameColor.blue()); SUMOReal w = pfdkGetStringWidth(getMicrosimID().c_str()); glRotated(180, 1, 0, 0); glTranslated(-w/2., 0.4, 0); pfDrawString(getMicrosimID().c_str()); glPopMatrix(); } // (optional) clear id if (s.needsGlID) { glPopName(); } }
void GUIParameterTracker::GUIParameterTrackerPanel::drawValues() { // compute which font to use /* SUMOReal fontIdx = ((SUMOReal) myWidthInPixels-300.) / 10.; if(fontIdx<=0) fontIdx = 1; if(fontIdx>4) fontIdx = 4; */ pfSetScale((SUMOReal) 0.1); pfSetScaleXY((SUMOReal)(.1*300./myWidthInPixels), (SUMOReal)(.1*300./(SUMOReal) myHeightInPixels)); // GUITexturesHelper::getFontRenderer().SetActiveFont(4-fontIdx); // glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glDisable(GL_TEXTURE_2D); size_t run = 0; for (TrackedVarsVector::iterator i=myParent->myTracked.begin(); i!=myParent->myTracked.end(); i++) { TrackerValueDesc *desc = *i; drawValue(*desc, (SUMOReal) myWidthInPixels / (SUMOReal) myParent->myTracked.size() *(SUMOReal) run); run++; } // GUITexturesHelper::getFontRenderer().Draw(myWidthInPixels, myHeightInPixels);//this, width, height); }
void GUIContainerStop::drawGL(const GUIVisualizationSettings& s) const { glPushName(getGlID()); glPushMatrix(); RGBColor grey(177, 184, 186, 171); RGBColor blue(83, 89, 172, 255); // draw the area int i; glTranslated(0, 0, getType()); GLHelper::setColor(blue); GLHelper::drawBoxLines(myFGShape, myFGShapeRotations, myFGShapeLengths, 1.0); // draw details unless zoomed out to far const SUMOReal exaggeration = s.addSize.getExaggeration(s); if (s.scale * exaggeration >= 10) { // draw the lines for (i = 0; i != (int)myLines.size(); ++i) { glPushMatrix(); glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0); glRotated(180, 1, 0, 0); glRotated(myFGSignRot, 0, 0, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pfSetPosition(0, 0); pfSetScale(1.f); glScaled(exaggeration, exaggeration, 1); glTranslated(1.2, -(double)i, 0); pfDrawString(myLines[i].c_str()); glPopMatrix(); } // draw the sign glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0); int noPoints = 9; if (s.scale * exaggeration > 25) { noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36); } glScaled(exaggeration, exaggeration, 1); GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints); glTranslated(0, 0, .1); GLHelper::setColor(grey); GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints); if (s.scale * exaggeration >= 4.5) { GLHelper::drawText("C", Position(), .1, 1.6 * exaggeration, blue, myFGSignRot); } } glPopMatrix(); glPopName(); drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); for (std::vector<MSTransportable*>::const_iterator i = myWaitingTransportables.begin(); i != myWaitingTransportables.end(); ++i) { glTranslated(0, 1, 0); // make multiple containers viewable static_cast<GUIContainer*>(*i)->drawGL(s); } }
void GLHelper::drawTextBox(const std::string& text, const Position& pos, const SUMOReal layer, const SUMOReal size, const RGBColor& txtColor, const RGBColor& bgColor, const RGBColor& borderColor, const SUMOReal angle) { SUMOReal boxAngle = angle + 90; if (boxAngle > 360) { boxAngle -= 360; } pfSetScale(size); const SUMOReal stringWidth = pfdkGetStringWidth(text.c_str()); const SUMOReal borderWidth = size / 20; const SUMOReal boxHeight = size * 0.8; const SUMOReal boxWidth = stringWidth + size / 2; glPushMatrix(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glTranslated(0, 0, layer); setColor(borderColor); Position left = pos; left.sub(boxWidth / 2, -boxHeight / 2.7); drawBoxLine(left, boxAngle, boxWidth, boxHeight); left.add(borderWidth * 1.5, 0); setColor(bgColor); glTranslated(0, 0, 0.01); drawBoxLine(left, boxAngle, boxWidth - 3 * borderWidth, boxHeight - 2 * borderWidth); // actually we should be able to use drawText here. however, there's // something about the constant 0.4 offset which causes trouble //drawText(text, pos, layer+0.02, size, txtColor, angle); setColor(txtColor); glTranslated(pos.x(), pos.y(), 0.01); pfSetPosition(0, 0); pfSetScale(size); glRotated(180, 1, 0, 0); glRotated(angle, 0, 0, 1); glTranslated(-stringWidth / 2., 0, 0); pfDrawString(text.c_str()); glPopMatrix(); }
void GUIBusStop::drawGL(const GUIVisualizationSettings& s) const { glPushName(getGlID()); glPushMatrix(); RGBColor green(76, 170, 50, 255); RGBColor yellow(255, 235, 0, 255); // draw the area glTranslated(0, 0, getType()); GLHelper::setColor(green); const SUMOReal exaggeration = s.addSize.getExaggeration(s); GLHelper::drawBoxLines(myFGShape, myFGShapeRotations, myFGShapeLengths, exaggeration); // draw details unless zoomed out to far if (s.scale * exaggeration >= 10) { // draw the lines const SUMOReal rotSign = MSNet::getInstance()->lefthand() ? -1 : 1; for (int i = 0; i != (int)myLines.size(); ++i) { glPushMatrix(); glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0); glRotated(180, 1, 0, 0); glRotated(rotSign * myFGSignRot, 0, 0, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pfSetPosition(0, 0); pfSetScale(1.f); glTranslated(1.2, -(double)i, 0); pfDrawString(myLines[i].c_str()); glPopMatrix(); } for (std::vector<Position>::const_iterator i = myAccessCoords.begin(); i != myAccessCoords.end(); ++i) { GLHelper::drawBoxLine(*i, RAD2DEG(myFGSignPos.angleTo2D(*i)) - 90, myFGSignPos.distanceTo2D(*i), .05); } // draw the sign glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0); int noPoints = 9; if (s.scale * exaggeration > 25) { noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36); } glScaled(exaggeration, exaggeration, 1); GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints); glTranslated(0, 0, .1); GLHelper::setColor(yellow); GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints); if (s.scale * exaggeration >= 4.5) { GLHelper::drawText("H", Position(), .1, 1.6, green, myFGSignRot); } } glPopMatrix(); glPopName(); drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); }
void GLHelper::drawText(const std::string& text, const Position& pos, const SUMOReal layer, const SUMOReal size, const RGBColor& col, const SUMOReal angle) { glPushMatrix(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); setColor(col); glTranslated(pos.x(), pos.y(), layer); pfSetPosition(0, 0); pfSetScale(size); SUMOReal w = pfdkGetStringWidth(text.c_str()); glRotated(180, 1, 0, 0); glRotated(angle, 0, 0, 1); glTranslated(-w / 2., size / 4, 0); pfDrawString(text.c_str()); glPopMatrix(); }
void GUITriggeredRerouter::GUITriggeredRerouterEdge::drawGL(const GUIVisualizationSettings& s) const { const SUMOReal exaggeration = s.addSize.getExaggeration(s); if (s.scale * exaggeration >= 3) { glPushName(getGlID()); const SUMOReal prob = myParent->getProbability(); if (myAmClosedEdge) { // draw closing symbol onto all lanes const RerouteInterval* const ri = myParent->getCurrentReroute(MSNet::getInstance()->getCurrentTimeStep()); if (ri != 0 && prob > 0) { // draw only if the edge is closed at this time if (std::find(ri->closed.begin(), ri->closed.end(), myEdge) != ri->closed.end()) { const size_t noLanes = myFGPositions.size(); for (size_t j = 0; j < noLanes; ++j) { Position pos = myFGPositions[j]; SUMOReal rot = myFGRotations[j]; glPushMatrix(); glTranslated(pos.x(), pos.y(), 0); glRotated(rot, 0, 0, 1); glTranslated(0, -1.5, 0); int noPoints = 9; if (s.scale > 25) { noPoints = (int)(9.0 + s.scale / 10.0); if (noPoints > 36) { noPoints = 36; } } glTranslated(0, 0, getType()); //glScaled(exaggeration, exaggeration, 1); glColor3d(0.7, 0, 0); GLHelper::drawFilledCircle((SUMOReal) 1.3, noPoints); glTranslated(0, 0, .1); glColor3d(1, 0, 0); GLHelper::drawFilledCircle((SUMOReal) 1.3, noPoints, 0, prob * 360); glTranslated(0, 0, .1); glColor3d(1, 1, 1); glRotated(-90, 0, 0, 1); glBegin(GL_TRIANGLES); glVertex2d(0 - .3, -1.); glVertex2d(0 - .3, 1.); glVertex2d(0 + .3, 1.); glVertex2d(0 + .3, -1.); glVertex2d(0 - .3, -1.); glVertex2d(0 + .3, 1.); glEnd(); glPopMatrix(); } } } } else { // draw rerouter symbol onto all lanes for (size_t i = 0; i < myFGPositions.size(); ++i) { const Position& pos = myFGPositions[i]; SUMOReal rot = myFGRotations[i]; glPushMatrix(); glTranslated(pos.x(), pos.y(), 0); glRotated(rot, 0, 0, 1); glTranslated(0, 0, getType()); glScaled(exaggeration, exaggeration, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBegin(GL_TRIANGLES); glColor3d(1, .8f, 0); // base glVertex2d(0 - 1.4, 0); glVertex2d(0 - 1.4, 6); glVertex2d(0 + 1.4, 6); glVertex2d(0 + 1.4, 0); glVertex2d(0 - 1.4, 0); glVertex2d(0 + 1.4, 6); glEnd(); glTranslated(0, 0, .1); glColor3d(0, 0, 0); pfSetPosition(0, 0); pfSetScale(3.f); SUMOReal w = pfdkGetStringWidth("U"); glRotated(180, 0, 1, 0); glTranslated(-w / 2., 2, 0); pfDrawString("U"); glTranslated(w / 2., -2, 0); std::string str = toString((int)(prob * 100)) + "%"; pfSetPosition(0, 0); pfSetScale(.7f); w = pfdkGetStringWidth(str.c_str()); glTranslated(-w / 2., 4, 0); pfDrawString(str.c_str()); glPopMatrix(); } } glPopName(); } }
void GUIChargingStation::drawGL(const GUIVisualizationSettings& s) const { // Draw Charging Station glPushName(getGlID()); glPushMatrix(); RGBColor blue(114, 210, 252, 255); RGBColor green(76, 170, 50, 255); RGBColor yellow(255, 235, 0, 255); RGBColor yellowCharge(255, 180, 0, 255); // draw the area depending if the vehicle is charging glTranslated(0, 0, getType()); if (myChargingVehicle == true) { GLHelper::setColor(yellowCharge); } else { GLHelper::setColor(blue); } const SUMOReal exaggeration = s.addSize.getExaggeration(s); GLHelper::drawBoxLines(myFGShape, myFGShapeRotations, myFGShapeLengths, exaggeration); // draw details unless zoomed out to far if (s.scale * exaggeration >= 10) { // push charging power matrix glPushMatrix(); // Traslate End positionof signal glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0); // Rotate 180 (Eje X -> Mirror) glRotated(180, 1, 0, 0); // Rotate again using myBlockIconRotation glRotated(myFGSignRot, 0, 0, 1); // Set poligon mode glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // set polyfront position on 0,0 pfSetPosition(0, 0); // Set polyfront scale to 1 pfSetScale(1.f); // traslate matrix glTranslated(1.2, 0, 0); // draw charging power pfDrawString((toString(myChargingPower) + " W").c_str()); // pop charging power matrix glPopMatrix(); // draw the sign glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0); int noPoints = 9; if (s.scale * exaggeration > 25) { noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36); } glScaled(exaggeration, exaggeration, 1); GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints); glTranslated(0, 0, .1); GLHelper::setColor(yellow); GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints); if (s.scale * exaggeration >= 4.5) { GLHelper::drawText("C", Position(), .1, 1.6, blue, myFGSignRot); } glTranslated(5, 0, 0); } glPopMatrix(); glPopName(); drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); }
void GUIParkingArea::drawGL(const GUIVisualizationSettings& s) const { glPushName(getGlID()); glPushMatrix(); RGBColor grey(177, 184, 186, 171); RGBColor blue(83, 89, 172, 255); RGBColor red(255, 0, 0, 255); RGBColor green(0, 255, 0, 255); // draw the area glTranslated(0, 0, getType()); GLHelper::setColor(blue); GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, myWidth / 2.); // draw details unless zoomed out to far const SUMOReal exaggeration = s.addSize.getExaggeration(s); if (s.scale * exaggeration >= 10) { // draw the lots glTranslated(0, 0, .1); std::map<unsigned int, LotSpaceDefinition >::const_iterator i; for (i = mySpaceOccupancies.begin(); i != mySpaceOccupancies.end(); i++) { glPushMatrix(); glTranslated((*i).second.myPosition.x(), (*i).second.myPosition.y(), (*i).second.myPosition.z()); glRotated((*i).second.myRotation, 0, 0, 1); Position pos = (*i).second.myPosition; PositionVector geom; SUMOReal w = (*i).second.myWidth / 2.; SUMOReal h = (*i).second.myLength; geom.push_back(Position(- w, + 0, 0.)); geom.push_back(Position(+ w, + 0, 0.)); geom.push_back(Position(+ w, + h, 0.)); geom.push_back(Position(- w, + h, 0.)); geom.push_back(Position(- w, + 0, 0.)); /* geom.push_back(Position(pos.x(), pos.y(), pos.z())); geom.push_back(Position(pos.x() + (*l).second.myWidth, pos.y(), pos.z())); geom.push_back(Position(pos.x() + (*l).second.myWidth, pos.y() - (*l).second.myLength, pos.z())); geom.push_back(Position(pos.x(), pos.y() - (*l).second.myLength, pos.z())); geom.push_back(Position(pos.x(), pos.y(), pos.z())); */ GLHelper::setColor((*i).second.vehicle == 0 ? green : red); GLHelper::drawBoxLines(geom, 0.1); glPopMatrix(); } GLHelper::setColor(blue); // draw the lines for (size_t i = 0; i != myLines.size(); ++i) { glPushMatrix(); glTranslated(mySignPos.x(), mySignPos.y(), 0); glRotated(180, 1, 0, 0); glRotated(mySignRot, 0, 0, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pfSetPosition(0, 0); pfSetScale(1.f); glScaled(exaggeration, exaggeration, 1); glTranslated(1.2, -(double)i, 0); pfDrawString(myLines[i].c_str()); glPopMatrix(); } // draw the sign glTranslated(mySignPos.x(), mySignPos.y(), 0); int noPoints = 9; if (s.scale * exaggeration > 25) { noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36); } glScaled(exaggeration, exaggeration, 1); GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints); glTranslated(0, 0, .1); GLHelper::setColor(grey); GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints); if (s.scale * exaggeration >= 4.5) { GLHelper::drawText("P", Position(), .1, 1.6 * exaggeration, blue, mySignRot); } } glPopMatrix(); glPopName(); drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); for (std::vector<MSTransportable*>::const_iterator i = myWaitingTransportables.begin(); i != myWaitingTransportables.end(); ++i) { glTranslated(0, 1, 0); // make multiple containers viewable static_cast<GUIContainer*>(*i)->drawGL(s); } }
void GNEVariableSpeedSignal::drawGL(const GUIVisualizationSettings& s) const { // Start drawing adding an gl identificator glPushName(getGlID()); // Add a draw matrix for drawing logo glPushMatrix(); glTranslated(myShape[0].x(), myShape[0].y(), getType()); glColor3d(1, 1, 1); glRotated(180, 0, 0, 1); // Draw icon depending of rerouter is or isn't selected if (isAdditionalSelected()) { GUITexturesHelper::drawTexturedBox(GUITextureSubSys::getTexture(GNETEXTURE_VARIABLESPEEDSIGNALSELECTED), 1); } else { GUITexturesHelper::drawTexturedBox(GUITextureSubSys::getTexture(GNETEXTURE_VARIABLESPEEDSIGNAL), 1); } // Pop draw icon matrix glPopMatrix(); // Show Lock icon depending of the Edit mode drawLockIcon(0.4); // Push matrix to draw every symbol over lane glPushMatrix(); // Traslate to 0,0 glTranslated(0, 0, getType()); // Obtain exaggeration const SUMOReal exaggeration = s.addSize.getExaggeration(s); // Iterate over lanes for (childLanes::const_iterator i = myChildLanes.begin(); i != myChildLanes.end(); i++) { // Draw every signal over Lane glPushMatrix(); glScaled(exaggeration, exaggeration, 1); glTranslated(i->positionOverLane.x(), i->positionOverLane.y(), 0); glRotated(i->rotationOverLane, 0, 0, 1); glTranslated(0, -1.5, 0); int noPoints = 9; if (s.scale > 25) { noPoints = (int)(9.0 + s.scale / 10.0); if (noPoints > 36) { noPoints = 36; } } glColor3d(1, 0, 0); GLHelper::drawFilledCircle((SUMOReal) 1.3, noPoints); if (s.scale >= 5) { glTranslated(0, 0, .1); glColor3d(0, 0, 0); GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints); // Draw speed SUMOReal speed = i->lane->getSpeed(); // Show as Km/h speed *= 3.6f; if (((int) speed + 1) % 10 == 0) { speed = (SUMOReal)(((int) speed + 1) / 10 * 10); } // draw the speed string std::string speedToDraw = toString<SUMOReal>(speed); glColor3d(1, 1, 0); glTranslated(0, 0, .1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pfSetPosition(0, 0); pfSetScale(1.2f); SUMOReal w = pfdkGetStringWidth(speedToDraw.c_str()); glRotated(180, 0, 1, 0); glTranslated(-w / 2., 0.3, 0); pfDrawString(speedToDraw.c_str()); } glPopMatrix(); } // Pop symbol matrix glPopMatrix(); // Draw connections drawConnections(); // Draw name drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); // Pop name glPopName(); }
void GUICalibrator::drawGL(const GUIVisualizationSettings& s) const { glPushName(getGlID()); std::string flow = "-"; std::string speed = "-"; if (isActive()) { if (myCurrentStateInterval->v >= 0) { speed = toString(myCurrentStateInterval->v) + "m/s"; } if (myCurrentStateInterval->q >= 0) { flow = toString((int)myCurrentStateInterval->q) + "v/h"; } } for (size_t i = 0; i < myFGPositions.size(); ++i) { const Position& pos = myFGPositions[i]; SUMOReal rot = myFGRotations[i]; glPushMatrix(); glTranslated(pos.x(), pos.y(), getType()); glRotated(rot, 0, 0, 1); glTranslated(0, 0, getType()); glScaled(s.addExaggeration, s.addExaggeration, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBegin(GL_TRIANGLES); glColor3d(1, .8f, 0); // base glVertex2d(0 - 1.4, 0); glVertex2d(0 - 1.4, 6); glVertex2d(0 + 1.4, 6); glVertex2d(0 + 1.4, 0); glVertex2d(0 - 1.4, 0); glVertex2d(0 + 1.4, 6); glEnd(); // draw text if (s.scale * s.addExaggeration >= 1.) { glTranslated(0, 0, .1); glColor3d(0, 0, 0); pfSetPosition(0, 0); pfSetScale(3.f); SUMOReal w = pfdkGetStringWidth("C"); glRotated(180, 0, 1, 0); glTranslated(-w / 2., 2, 0); pfDrawString("C"); glTranslated(w / 2., -2, 0); pfSetPosition(0, 0); pfSetScale(.7f); w = pfdkGetStringWidth(flow.c_str()); glTranslated(-w / 2., 4, 0); pfDrawString(flow.c_str()); glTranslated(w / 2., -4, 0); pfSetPosition(0, 0); pfSetScale(.7f); w = pfdkGetStringWidth(speed.c_str()); glTranslated(-w / 2., 5, 0); pfDrawString(speed.c_str()); glTranslated(-w / 2., -5, 0); } glPopMatrix(); } drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); glPopName(); }
void GUILaneSpeedTrigger::drawGL(const GUIVisualizationSettings& s) const { glPushName(getGlID()); glPushMatrix(); glTranslated(0, 0, getType()); for (size_t i = 0; i < myFGPositions.size(); ++i) { const Position& pos = myFGPositions[i]; SUMOReal rot = myFGRotations[i]; glPushMatrix(); glScaled(s.addExaggeration, s.addExaggeration, 1); glTranslated(pos.x(), pos.y(), 0); glRotated(rot, 0, 0, 1); glTranslated(0, -1.5, 0); int noPoints = 9; if (s.scale > 25) { noPoints = (int)(9.0 + s.scale / 10.0); if (noPoints > 36) { noPoints = 36; } } glColor3d(1, 0, 0); GLHelper::drawFilledCircle((SUMOReal) 1.3, noPoints); if (s.scale >= 5) { glTranslated(0, 0, .1); glColor3d(0, 0, 0); GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints); // draw the speed string // not if scale to low // compute SUMOReal value = (SUMOReal) getCurrentSpeed(); if (myShowAsKMH) { value *= 3.6f; if (((int) value + 1) % 10 == 0) { value = (SUMOReal)(((int) value + 1) / 10 * 10); } } if (value != myLastValue) { myLastValue = value; myLastValueString = toString<SUMOReal>(myLastValue); size_t idx = myLastValueString.find('.'); if (idx != std::string::npos) { if (idx > myLastValueString.length()) { idx = myLastValueString.length(); } myLastValueString = myLastValueString.substr(0, idx); } } //draw glColor3d(1, 1, 0); glTranslated(0, 0, .1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pfSetPosition(0, 0); pfSetScale(1.2f); SUMOReal w = pfdkGetStringWidth(myLastValueString.c_str()); glRotated(180, 0, 1, 0); glTranslated(-w / 2., 0.3, 0); pfDrawString(myLastValueString.c_str()); } glPopMatrix(); } glPopMatrix(); drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); glPopName(); }
void GNEContainerStop::drawGL(const GUIVisualizationSettings& s) const { // Start drawing adding an gl identificator glPushName(getGlID()); // Add a draw matrix glPushMatrix(); // Start with the drawing of the area traslating matrix to origin glTranslated(0, 0, getType()); // Set color of the base if (isAdditionalSelected()) { GLHelper::setColor(myBaseColorSelected); } else { GLHelper::setColor(myBaseColor); } // Obtain exaggeration of the draw const SUMOReal exaggeration = s.addSize.getExaggeration(s); // Draw the area using shape, shapeRotations, shapeLenghts and value of exaggeration GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, exaggeration); // Check if the distance is enought to draw details if (s.scale * exaggeration >= 10) { // Add a draw matrix glPushMatrix(); // Obtain rotation of the sing depeding of the option "lefthand" SUMOReal rotSign = OptionsCont::getOptions().getBool("lefthand"); // Set color of the lines if (isAdditionalSelected()) { GLHelper::setColor(myTextColorSelected); } else { GLHelper::setColor(myTextColor); } // Iterate over every line for (int i = 0; i < (int)myLines.size(); ++i) { // Add a new push matrix glPushMatrix(); // Traslate End positionof signal glTranslated(mySignPos.x(), mySignPos.y(), 0); // Rotate 180 (Eje X -> Mirror) glRotated(180, 1, 0, 0); // Rotate again depending of the option rotSign glRotated(rotSign * myBlockIconRotation, 0, 0, 1); // Set poligon mode glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // set polyfront position ot 0 pfSetPosition(0, 0); // Set polyfront scale to 1 pfSetScale(1.f); // traslate matrix for every line glTranslated(1.2, -(double)i, 0); // draw line pfDrawString(myLines[i].c_str()); // pop matrix glPopMatrix(); } // Start drawing sign traslating matrix to signal position glTranslated(mySignPos.x(), mySignPos.y(), 0); // Define nº points (for efficiency) int noPoints = 9; // If the scale * exaggeration is more than 25, recalculate nº points if (s.scale * exaggeration > 25) { noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36); } // scale matrix depending of the exaggeration glScaled(exaggeration, exaggeration, 1); // Draw green circle GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints); // Traslate to front glTranslated(0, 0, .1); // Set color of the lines if (isAdditionalSelected()) { GLHelper::setColor(mySignColorSelected); } else { GLHelper::setColor(mySignColor); } // draw another circle in the same position, but a little bit more small GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints); // If the scale * exageration is equal or more than 4.5, draw H if (s.scale * exaggeration >= 4.5) { if (isAdditionalSelected()) { GLHelper::drawText("C", Position(), .1, 1.6, myBaseColorSelected, myBlockIconRotation); } else { GLHelper::drawText("C", Position(), .1, 1.6, myBaseColor, myBlockIconRotation); } } // pop draw matrix glPopMatrix(); // Show Lock icon depending of the Edit mode drawLockIcon(); } // pop draw matrix glPopMatrix(); // Draw name drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); // Pop name glPopName(); }