void GUIJunctionWrapper::drawGL(const GUIVisualizationSettings& s) const { // check whether it is not too small if (s.scale * myMaxSize < 1.) { return; } if (!myIsInner && s.drawJunctionShape) { glPushMatrix(); glPushName(getGlID()); const SUMOReal colorValue = getColorValue(s); GLHelper::setColor(s.junctionColorer.getScheme().getColor(colorValue)); glTranslated(0, 0, getType()); if (s.scale * myMaxSize < 40.) { GLHelper::drawFilledPoly(myJunction.getShape(), true); } else { GLHelper::drawFilledPolyTesselated(myJunction.getShape(), true); } #ifdef GUIJunctionWrapper_DEBUG_DRAW_NODE_SHAPE_VERTICES GLHelper::debugVertices(myJunction.getShape(), 80 / s.scale); #endif glPopName(); glPopMatrix(); } if (myIsInner) { drawName(myJunction.getPosition(), s.scale, s.internalJunctionName); } else { drawName(myJunction.getPosition(), s.scale, s.junctionName); } }
void GUIPointOfInterest::drawGL(const GUIVisualizationSettings& s) const { const SUMOReal exaggeration = s.poiSize.getExaggeration(s); if (s.scale * (1.3 / 3.0) *exaggeration < s.poiSize.minSize) { return; } glPushName(getGlID()); glPushMatrix(); GLHelper::setColor(getColor()); glTranslated(x(), y(), getLayer()); glRotated(getAngle(), 0, 0, 1); if (myImgFile != "") { int textureID = GUITexturesHelper::getTextureID(myImgFile); if (textureID > 0) { GUITexturesHelper::drawTexturedBox(textureID, -myHalfImgWidth * exaggeration, -myHalfImgHeight * exaggeration, myHalfImgWidth * exaggeration, myHalfImgHeight * exaggeration); } } else { // fallback if no image is defined GLHelper::drawFilledCircle((SUMOReal) 1.3 * exaggeration, 16); } glPopMatrix(); drawName(Position(x() + 1.32 * exaggeration, y() + 1.32 * exaggeration), s.scale, s.poiName); glPopName(); }
void GUIPerson::drawGL(const GUIVisualizationSettings& s) const { glPushName(getGlID()); glPushMatrix(); Position p1 = getPosition(); if (getCurrentStageType() == DRIVING && !isWaiting4Vehicle()) { p1 = myPositionInVehicle; } glTranslated(p1.x(), p1.y(), getType()); glRotated(90, 0, 0, 1); // set person color setColor(s); // scale const SUMOReal upscale = s.personSize.getExaggeration(s, 80); glScaled(upscale, upscale, 1); switch (s.personQuality) { case 0: case 1: drawAction_drawAsTriangle(s); break; case 2: drawAction_drawAsPoly(s); break; case 3: default: drawAction_drawAsImage(s); break; } glPopMatrix(); #ifdef GUIPerson_DEBUG_DRAW_WALKINGAREA_PATHS drawAction_drawWalkingareaPath(s); #endif drawName(p1, s.scale, s.personName); glPopName(); }
void GNECalibrator::drawGL(const GUIVisualizationSettings& s) const { // get values glPushName(getGlID()); glLineWidth(1.0); const double exaggeration = s.addSize.getExaggeration(s, this); // iterate over every Calibrator symbol for (int i = 0; i < (int)myGeometry.shape.size(); ++i) { const Position& pos = myGeometry.shape[i]; double rot = myGeometry.shapeRotations[i]; glPushMatrix(); glTranslated(pos.x(), pos.y(), getType()); glRotated(rot, 0, 0, 1); glTranslated(0, 0, getType()); glScaled(exaggeration, exaggeration, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { GLHelper::setColor(RGBColor(255, 204, 0)); } // base glBegin(GL_TRIANGLES); 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 isn't being drawn for selecting if ((s.scale * exaggeration >= 1.) && !s.drawForSelecting) { // set color depending of selection status RGBColor textColor = drawUsingSelectColor() ? s.selectionColor : RGBColor::BLACK; // draw "C" GLHelper::drawText("C", Position(0, 1.5), 0.1, 3, textColor, 180); // draw "edge" or "lane " if (getLaneParents().size() > 0) { GLHelper::drawText("lane", Position(0, 3), .1, 1, textColor, 180); } else if (getEdgeParents().size() > 0) { GLHelper::drawText("edge", Position(0, 3), .1, 1, textColor, 180); } else { throw ProcessError("Both myEdge and myLane aren't defined"); } } glPopMatrix(); // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { GLHelper::drawShapeDottedContour(getType(), pos, 2.8, 6, rot, 0, 3); } } // draw name drawName(getPositionInView(), s.scale, s.addName); // pop name glPopName(); }
void InputStream::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { painter->setPen(QPen(getColorFrame())); painter->setBrush(QBrush(getColorBackground())); drawBackground(painter); drawName(painter); drawInput(painter); drawCountReceivingElements(painter); }
void drawExampleName() { int left, top; Rect rect; Str255 label = "\pCurrent Example: "; Str255 name[9] = { "\p TRANSFER MODES", "\pARITHMETIC MODES", "\p DITHERING", "\p COLORIZATION", "\p COLOR MAPPING", "\p PAINT BUCKET", "\p LASSO TOOL", "\pPIXEL AVERAGING", "\p CUSTOM" }; Rect tempRect1; left = 15; top = GetPortBounds(GetWindowPort(gWindow), &tempRect1)->bottom - 13; drawName( left, top, label ); left += StringWidth( label ); SetRect( &rect, left - 2, top - 12, left + 130, top + 4 ); eraseRect( &rect ); drawName( left, top, name[(gCurrentExample / 10) - 1] ); } void drawTime( long ticks ) { Rect rect; int left, top; float seconds; char cString[40]; Rect tempRect1; GetPortBounds(GetWindowPort(gWindow), &tempRect1); left = tempRect1.right - 130; top = tempRect1.bottom - 13; SetRect( &rect, left - 2, top - 12, left + 90, top + 4 ); eraseRect( &rect ); seconds = (float)ticks / 60.0; sprintf( &cString[0], "Draw Time: %03.03f secs", seconds ); drawName( left, top, C2PStr( cString ) ); }
void QueueSystem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { painter->setPen(QPen(getColorFrame())); painter->setBrush(QBrush(getColorBackground())); drawBackground(painter); drawInputs(painter); drawName(painter); drawNameType(painter); drawCountsRequests(painter); }
void GUIInductLoop::MyWrapper::drawGL(const GUIVisualizationSettings& s) const { glPushName(getGlID()); double width = (double) 2.0 * s.scale; glLineWidth(1.0); const double exaggeration = s.addSize.getExaggeration(s, this); // shape glColor3d(1, 1, 0); glPushMatrix(); glTranslated(0, 0, getType()); glTranslated(myFGPosition.x(), myFGPosition.y(), 0); glRotated(myFGRotation, 0, 0, 1); glScaled(exaggeration, exaggeration, 1); glBegin(GL_QUADS); glVertex2d(0 - 1.0, 2); glVertex2d(-1.0, -2); glVertex2d(1.0, -2); glVertex2d(1.0, 2); glEnd(); glTranslated(0, 0, .01); glBegin(GL_LINES); glVertex2d(0, 2 - .1); glVertex2d(0, -2 + .1); glEnd(); if (mySpecialColor == nullptr) { glColor3d(1, 1, 1); } else { GLHelper::setColor(*mySpecialColor); } // outline if (width * exaggeration > 1) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glBegin(GL_QUADS); glVertex2f(0 - 1.0, 2); glVertex2f(-1.0, -2); glVertex2f(1.0, -2); glVertex2f(1.0, 2); glEnd(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } // position indicator if (width * exaggeration > 1) { glRotated(90, 0, 0, -1); glBegin(GL_LINES); glVertex2d(0, 1.7); glVertex2d(0, -1.7); glEnd(); } glPopMatrix(); drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); glPopName(); }
void CreatureUI::drawInfo(int x, int y, float scale, bool visible) const { Creature* n = (Creature*)this; Outfit_t outfit = n->getOutfit(); if(!m_obj && !n->isPlayer() && outfit.m_lookitem == 0) return; //It is a creature which cannot be seen by a player. // NOTE (kilouco): Here we will take some position based conditions for names and healthbars to be rendered. Position playerPos = GlobalVariables::getPlayerPosition(); Position creaturePos = n->getCurrentPos(); int relative_x = creaturePos.x - playerPos.x; int relative_y = creaturePos.y - playerPos.y; if (abs(relative_x) > 7 || abs(relative_y) > 5) return; //Shouldn't render names and health bars in these cases. // NOTE (Kilouco): Generic position formula float walkoffx = 0.f, walkoffy = 0.f; getWalkOffset(walkoffx, walkoffy, scale); int c_xOffSet = 0, c_yOffSet = 0, result_x = 0, result_y = 0; if(m_obj) { c_xOffSet = m_obj->xOffset; c_yOffSet = m_obj->yOffset; if(outfit.m_lookitem == 0 && outfit.m_looktype == 0) { c_xOffSet = 8; c_yOffSet = 8; } if (c_xOffSet != 8 || c_yOffSet != 8) { c_xOffSet = 0; c_xOffSet = 0; } } result_x = (x + walkoffx + (16 * scale) - (c_xOffSet * scale)) - 13; result_y = (y + walkoffy - (c_xOffSet * scale)) - 3; if (result_y <= 0) result_y = 12; if (options.shownames) drawName(result_x, result_y, scale, visible); result_x += 23; result_y += 4; drawSkullsShields(result_x, result_y, scale); }
void GUIMEInductLoop::MyWrapper::drawGL(const GUIVisualizationSettings& s) const { glPushName(getGlID()); glPolygonOffset(0, -2); SUMOReal width = (SUMOReal) 2.0 * s.scale; glLineWidth(1.0); const SUMOReal exaggeration = s.addSize.getExaggeration(s); // shape glColor3d(1, 1, 0); glPushMatrix(); glTranslated(myFGPosition.x(), myFGPosition.y(), getType()); glRotated(myFGRotation, 0, 0, 1); glScaled(exaggeration, exaggeration, exaggeration); glBegin(GL_QUADS); glVertex2d(0 - 1.0, 2); glVertex2d(-1.0, -2); glVertex2d(1.0, -2); glVertex2d(1.0, 2); glEnd(); glBegin(GL_LINES); // without the substracted offsets, lines are partially longer // than the boxes glVertex2d(0, 2 - .1); glVertex2d(0, -2 + .1); glEnd(); // outline if (width * exaggeration > 1) { glColor3d(1, 1, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glBegin(GL_QUADS); glVertex2f(0 - 1.0, 2); glVertex2f(-1.0, -2); glVertex2f(1.0, -2); glVertex2f(1.0, 2); glEnd(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } // position indicator if (width * exaggeration > 1) { glRotated(90, 0, 0, -1); glColor3d(1, 1, 1); glBegin(GL_LINES); glVertex2d(0, 1.7); glVertex2d(0, -1.7); glEnd(); } glPopMatrix(); drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); glPopName(); }
void GUIJunctionWrapper::drawGL(const GUIVisualizationSettings& s) const { // check whether it is not too small if (s.scale * myMaxSize < 1.) { return; } if (!myIsInner) { glPushName(getGlID()); glPushMatrix(); const SUMOReal colorValue = static_cast<SUMOReal>(s.junctionColorer.getActive() == 1 && gSelected.isSelected(getType(), getGlID())); GLHelper::setColor(s.junctionColorer.getScheme().getColor(colorValue)); glTranslated(0, 0, getType()); GLHelper::drawFilledPoly(myJunction.getShape(), true); glPopMatrix(); } if (myIsInner) { drawName(myJunction.getPosition(), s.scale, s.internalJunctionName); } else { drawName(myJunction.getPosition(), s.scale, s.junctionName); } glPopName(); }
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 GUIInductLoop::MyWrapper::drawGL(const GUIVisualizationSettings& s) const { glPushName(getGlID()); SUMOReal width = (SUMOReal) 2.0 * s.scale; glLineWidth(1.0); // shape glColor3d(1, 1, 0); glPushMatrix(); glTranslated(0, 0, getType()); glTranslated(myFGPosition.x(), myFGPosition.y(), 0); glRotated(myFGRotation, 0, 0, 1); glScaled(s.addExaggeration, s.addExaggeration, 1); glBegin(GL_QUADS); glVertex2d(0 - 1.0, 2); glVertex2d(-1.0, -2); glVertex2d(1.0, -2); glVertex2d(1.0, 2); glEnd(); glTranslated(0, 0, .01); glBegin(GL_LINES); glVertex2d(0, 2 - .1); glVertex2d(0, -2 + .1); glEnd(); // outline if (width * s.addExaggeration > 1) { glColor3d(1, 1, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glBegin(GL_QUADS); glVertex2f(0 - 1.0, 2); glVertex2f(-1.0, -2); glVertex2f(1.0, -2); glVertex2f(1.0, 2); glEnd(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } // position indicator if (width * s.addExaggeration > 1) { glRotated(90, 0, 0, -1); glColor3d(1, 1, 1); glBegin(GL_LINES); glVertex2d(0, 1.7); glVertex2d(0, -1.7); glEnd(); } glPopMatrix(); drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); glPopName(); }
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 GUIE3Collector::MyWrapper::drawGL(const GUIVisualizationSettings& s) const { glPushName(getGlID()); glPushMatrix(); glTranslated(0, 0, getType()); typedef std::vector<SingleCrossingDefinition> CrossingDefinitions; CrossingDefinitions::const_iterator i; glColor3d(0, .8, 0); for (i = myEntryDefinitions.begin(); i != myEntryDefinitions.end(); ++i) { drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, s.addExaggeration); } glColor3d(.8, 0, 0); for (i = myExitDefinitions.begin(); i != myExitDefinitions.end(); ++i) { drawSingleCrossing((*i).myFGPosition, (*i).myFGRotation, s.addExaggeration); } glPopMatrix(); drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); glPopName(); }
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 double exaggeration = s.addSize.getExaggeration(s); if (s.scale * exaggeration >= 1) { // 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; double w = (*i).second.myWidth / 2. - 0.1 * exaggeration; double 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 * exaggeration); glPopMatrix(); } GLHelper::setColor(blue); // draw the lines for (size_t i = 0; i != myLines.size(); ++i) { // push a new matrix for every line glPushMatrix(); // traslate and rotate glTranslated(mySignPos.x(), mySignPos.y(), 0); glRotated(180, 1, 0, 0); glRotated(mySignRot, 0, 0, 1); // draw line GLHelper::drawText(myLines[i].c_str(), Position(1.2, (double)i), .1, 1.f, RGBColor(76, 170, 50), 0, FONS_ALIGN_LEFT); // pop matrix for every line 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((double) 1.1, noPoints); glTranslated(0, 0, .1); GLHelper::setColor(grey); GLHelper::drawFilledCircle((double) 0.9, noPoints); if (s.scale * exaggeration >= 4.5) { GLHelper::drawText("P", Position(), .1, 1.6, blue, mySignRot); } } glPopMatrix(); if (s.addFullName.show && getMyName() != "") { GLHelper::drawText(getMyName(), mySignPos, GLO_MAX - getType(), s.addFullName.scaledSize(s.scale), s.addFullName.color, s.getTextAngle(mySignRot)); } 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); } // draw parking vehicles (their lane might not be within drawing range. if it is, they are drawn twice) myLane.getVehiclesSecure(); for (std::set<const MSVehicle*>::const_iterator v = myLane.getParkingVehicles().begin(); v != myLane.getParkingVehicles().end(); ++v) { static_cast<const GUIVehicle* const>(*v)->drawGL(s); } myLane.releaseVehicles(); }
void GNEDetectorE1::drawGL(const GUIVisualizationSettings& s) const { // get values glPushName(getGlID()); double width = (double) 2.0 * s.scale; glLineWidth(1.0); const double exaggeration = s.addSize.getExaggeration(s, this); // set color if (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { GLHelper::setColor(s.SUMO_color_E1); } // draw shape glPushMatrix(); glTranslated(0, 0, getType()); glTranslated(myGeometry.shape[0].x(), myGeometry.shape[0].y(), 0); glRotated(myGeometry.shapeRotations[0], 0, 0, 1); glScaled(exaggeration, exaggeration, 1); glBegin(GL_QUADS); glVertex2d(-1.0, 2); glVertex2d(-1.0, -2); glVertex2d(1.0, -2); glVertex2d(1.0, 2); glEnd(); glTranslated(0, 0, .01); glBegin(GL_LINES); glVertex2d(0, 2 - .1); glVertex2d(0, -2 + .1); glEnd(); // outline if isn't being drawn for selecting if ((width * exaggeration > 1) && !s.drawForSelecting) { // set color if (drawUsingSelectColor()) { GLHelper::setColor(s.selectionColor); } else { GLHelper::setColor(RGBColor::WHITE); } glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glBegin(GL_QUADS); glVertex2f(-1.0, 2); glVertex2f(-1.0, -2); glVertex2f(1.0, -2); glVertex2f(1.0, 2); glEnd(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } // position indicator if isn't being drawn for selecting if ((width * exaggeration > 1) && !s.drawForSelecting) { // set color if (drawUsingSelectColor()) { GLHelper::setColor(s.selectionColor); } else { GLHelper::setColor(RGBColor::WHITE); } glRotated(90, 0, 0, -1); glBegin(GL_LINES); glVertex2d(0, 1.7); glVertex2d(0, -1.7); glEnd(); } // Pop shape matrix glPopMatrix(); // Check if the distance is enought to draw details and isn't being drawn for selecting if ((s.scale * exaggeration >= 10) && !s.drawForSelecting) { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myGeometry.shape.getLineCenter().x(), myGeometry.shape.getLineCenter().y(), getType() + 0.1); // Rotate depending of myBlockIcon.rotation glRotated(myBlockIcon.rotation, 0, 0, -1); //move to logo position glTranslated(-1, 0, 0); // draw E1 logo if (drawUsingSelectColor()) { GLHelper::drawText("E1", Position(), .1, 1.5, s.selectionColor); } else { GLHelper::drawText("E1", Position(), .1, 1.5, RGBColor::BLACK); } // pop matrix glPopMatrix(); // Show Lock icon depending of the Edit mode myBlockIcon.draw(); } // Finish draw if isn't being drawn for selecting if (!s.drawForSelecting) { drawName(getPositionInView(), s.scale, s.addName); } // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { GLHelper::drawShapeDottedContour(getType(), myGeometry.shape[0], 2, 4, myGeometry.shapeRotations[0]); } // pop name 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 GNEDetectorE2::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 (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { // set color depending if is or isn't valid if (myE2valid) { GLHelper::setColor(s.SUMO_color_E2); } else { GLHelper::setColor(RGBColor::RED); } } // Obtain exaggeration of the draw const double exaggeration = s.addSize.getExaggeration(s, this); // check if we have to drawn a E2 single lane or a E2 multiLane if (myGeometry.shape.size() > 0) { // Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration GLHelper::drawBoxLines(myGeometry.shape, myGeometry.shapeRotations, myGeometry.shapeLengths, exaggeration); } else { // iterate over multishapes for (int i = 0; i < (int)myGeometry.multiShape.size(); i++) { // don't draw shapes over connections if "show connections" is enabled if (!myViewNet->getViewOptions().showConnections() || (i % 2 == 0)) { GLHelper::drawBoxLines(myGeometry.multiShape.at(i), myGeometry.multiShapeRotations.at(i), myGeometry.multiShapeLengths.at(i), exaggeration); } } } // Pop last matrix glPopMatrix(); // Check if the distance is enougth to draw details and isn't being drawn for selecting if ((s.scale * exaggeration >= 10) && !s.drawForSelecting) { // draw logo depending if this is an Multilane E2 detector if (myTagProperty.getTag() == SUMO_TAG_E2DETECTOR) { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myGeometry.shape.getLineCenter().x(), myGeometry.shape.getLineCenter().y(), getType() + 0.1); // Rotate depending of myBlockIcon.rotation glRotated(myBlockIcon.rotation, 0, 0, -1); //move to logo position glTranslated(-0.75, 0, 0); // draw E2 logo if (drawUsingSelectColor()) { GLHelper::drawText("E2", Position(), .1, 1.5, s.selectionColor); } else { GLHelper::drawText("E2", Position(), .1, 1.5, RGBColor::BLACK); } } else { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myBlockIcon.position.x(), myBlockIcon.position.y(), getType() + 0.1); // Rotate depending of myBlockIcon.rotation glRotated(myBlockIcon.rotation, 0, 0, -1); //move to logo position glTranslated(-1.5, 0, 0); // draw E2 logo if (drawUsingSelectColor()) { GLHelper::drawText("E2", Position(), .1, 1.5, s.selectionColor); } else { GLHelper::drawText("E2", Position(), .1, 1.5, RGBColor::BLACK); } //move to logo position glTranslated(1.2, 0, 0); // Rotate depending of myBlockIcon.rotation glRotated(90, 0, 0, 1); if (drawUsingSelectColor()) { GLHelper::drawText("multi", Position(), .1, 0.9, s.selectedAdditionalColor); } else { GLHelper::drawText("multi", Position(), .1, 0.9, RGBColor::BLACK); } } // pop matrix glPopMatrix(); // Show Lock icon depending of the Edit mode myBlockIcon.draw(); } // Draw name if isn't being drawn for selecting if (!s.drawForSelecting) { drawName(getPositionInView(), s.scale, s.addName); } // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { if (myGeometry.shape.size() > 0) { GLHelper::drawShapeDottedContour(getType(), myGeometry.shape, exaggeration); } else { GLHelper::drawShapeDottedContour(getType(), myGeometry.multiShapeUnified, exaggeration); } } // Pop name glPopName(); }
void GUIPolygon::drawGL(const GUIVisualizationSettings& s) const { Boundary boundary = myShape.getBoxBoundary(); if (s.scale * MAX2(boundary.getWidth(), boundary.getHeight()) < s.minPolySize) { return; } if (getFill()) { if (myShape.size() < 3) { return; } } else { if (myShape.size() < 2) { return; } } AbstractMutex::ScopedLocker locker(myLock); //if (myDisplayList == 0 || (!getFill() && myLineWidth != s.polyExaggeration)) { // storeTesselation(s.polyExaggeration); //} glPushName(getGlID()); glPushMatrix(); glTranslated(0, 0, getLayer()); // XXX shape should be rotated around its center when initializing the polygon. do we even need this? //glRotated(getAngle(), 0, 0, 1); GLHelper::setColor(getColor()); int textureID = -1; if (getFill()) { const std::string& file = getImgFile(); if (file != "") { textureID = GUITexturesHelper::getTextureID(file); } } // init generation of texture coordinates if (textureID >= 0) { glEnable(GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); // without DEPTH_TEST vehicles may be drawn below roads glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, textureID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // http://www.gamedev.net/topic/133564-glutesselation-and-texture-mapping/ glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_S, GL_OBJECT_PLANE, xPlane); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_T, GL_OBJECT_PLANE, yPlane); } // recall tesselation //glCallList(myDisplayList); performTesselation(s.polyExaggeration); // de-init generation of texture coordinates if (textureID >= 0) { glEnable(GL_DEPTH_TEST); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); } glPopMatrix(); drawName(myShape.getPolygonCenter(), s.scale, s.polyName); glPopName(); }
void GNEDetectorExit::drawGL(const GUIVisualizationSettings& s) const { // Start drawing adding gl identificator glPushName(getGlID()); // Push detector matrix glPushMatrix(); glTranslated(0, 0, getType()); // Set initial values if (isAttributeCarrierSelected()) { GLHelper::setColor(myViewNet->getNet()->selectedAdditionalColor); } else { GLHelper::setColor(s.SUMO_color_E3Exit); } const double exaggeration = s.addSize.getExaggeration(s); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Push polygon matrix glPushMatrix(); glScaled(exaggeration, exaggeration, 1); glTranslated(myShape[0].x(), myShape[0].y(), 0); glRotated(myShapeRotations[0], 0, 0, 1); // Draw polygon glBegin(GL_LINES); glVertex2d(1.7, 0); glVertex2d(-1.7, 0); glEnd(); glBegin(GL_QUADS); glVertex2d(-1.7, .5); glVertex2d(-1.7, -.5); glVertex2d(1.7, -.5); glVertex2d(1.7, .5); glEnd(); // draw details if isn't being drawn for selecting if(!s.drawForSelecting) { // first Arrow glTranslated(1.5, 0, 0); GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05); GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25); // second Arrow glTranslated(-3, 0, 0); GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05); GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25); } // Pop polygon matrix glPopMatrix(); // Pop detector matrix glPopMatrix(); // Check if the distance is enought to draw details if (((s.scale * exaggeration) >= 10)) { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myShape.getLineCenter().x(), myShape.getLineCenter().y(), getType() + 0.1); // Rotate depending of myBlockIconRotation glRotated(myBlockIconRotation, 0, 0, -1); //move to logo position glTranslated(1.9, 0, 0); // draw Entry logo if isn't being drawn for selecting if(s.drawForSelecting) { GLHelper::setColor(s.SUMO_color_E3Exit); GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1); } else if (isAttributeCarrierSelected()) { GLHelper::drawText("E3", Position(), .1, 2.8, myViewNet->getNet()->selectedAdditionalColor); } else { GLHelper::drawText("E3", Position(), .1, 2.8, s.SUMO_color_E3Exit); } //move to logo position glTranslated(1.7, 0, 0); // Rotate depending of myBlockIconRotation glRotated(90, 0, 0, 1); // draw Entry text if isn't being drawn for selecting if(s.drawForSelecting) { GLHelper::setColor(s.SUMO_color_E3Exit); GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1); } else if (isAttributeCarrierSelected()) { GLHelper::drawText("Exit", Position(), .1, 1, myViewNet->getNet()->selectedAdditionalColor); } else { GLHelper::drawText("Exit", Position(), .1, 1, s.SUMO_color_E3Exit); } // pop matrix glPopMatrix(); // Show Lock icon depending of the Edit mode and if isn't being drawn for selecting if(!s.drawForSelecting) { drawLockIcon(0.4); } } // Draw name if isn't being drawn for selecting if(!s.drawForSelecting) { drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); } // check if dotted contour has to be drawn if(!s.drawForSelecting && (myViewNet->getACUnderCursor() == this)) { GLHelper::drawShapeDottedContour(getType(), myShape[0], 3.4, 5, myShapeRotations[0], 0, 2); } // pop gl identificator glPopName(); }
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 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 GUIPlayerView::draw(bool animating) { drawCards(animating); drawName(animating); }
void GNEStop::drawGL(const GUIVisualizationSettings& s) const { // only drawn in super mode demand if (myViewNet->getViewOptions().showDemandElements()) { // Obtain exaggeration of the draw const double exaggeration = s.addSize.getExaggeration(s, this); // 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 (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { GLHelper::setColor(s.SUMO_color_stops); } // draw lines depending if it's placed over a lane or over a stoppingPlace if (getLaneParents().size() > 0) { // Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration GLHelper::drawBoxLines(myGeometry.shape, myGeometry.shapeRotations, myGeometry.shapeLengths, exaggeration * 0.1, 0, getLaneParents().front()->getParentEdge().getNBEdge()->getLaneWidth(getLaneParents().front()->getIndex()) * 0.5); GLHelper::drawBoxLines(myGeometry.shape, myGeometry.shapeRotations, myGeometry.shapeLengths, exaggeration * 0.1, 0, getLaneParents().front()->getParentEdge().getNBEdge()->getLaneWidth(getLaneParents().front()->getIndex()) * -0.5); } else { // Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration GLHelper::drawBoxLines(myGeometry.shape, myGeometry.shapeRotations, myGeometry.shapeLengths, exaggeration * 0.1, 0, exaggeration * -1); GLHelper::drawBoxLines(myGeometry.shape, myGeometry.shapeRotations, myGeometry.shapeLengths, exaggeration * 0.1, 0, exaggeration); } // pop draw matrix glPopMatrix(); // Add a draw matrix glPushMatrix(); // move to geometry front glTranslated(myGeometry.shape.back().x(), myGeometry.shape.back().y(), getType()); glRotated(myGeometry.shapeRotations.back(), 0, 0, 1); // draw front of Stop depending if it's placed over a lane or over a stoppingPlace if (getLaneParents().size() > 0) { // draw front of Stop GLHelper::drawBoxLine(Position(0, 0), 0, exaggeration * 0.5, getLaneParents().front()->getParentEdge().getNBEdge()->getLaneWidth(getLaneParents().front()->getIndex()) * 0.5); } else { // draw front of Stop GLHelper::drawBoxLine(Position(0, 0), 0, exaggeration * 0.5, exaggeration); } // move to "S" position glTranslated(0, 1, 0); // draw "S" symbol GLHelper::drawText("S", Position(), .1, 2.8, s.SUMO_color_stops); // move to subtitle positin glTranslated(0, 1.4, 0); // draw subtitle depending of tag if (myTagProperty.getTag() == SUMO_TAG_STOP_BUSSTOP) { GLHelper::drawText("busStop", Position(), .1, .5, s.SUMO_color_stops, 180); } else if (myTagProperty.getTag() == SUMO_TAG_STOP_CONTAINERSTOP) { GLHelper::drawText("container", Position(), .1, .5, s.SUMO_color_stops, 180); glTranslated(0, 0.5, 0); GLHelper::drawText("Stop", Position(), .1, .5, s.SUMO_color_stops, 180); } else if (myTagProperty.getTag() == SUMO_TAG_STOP_CHARGINGSTATION) { GLHelper::drawText("charging", Position(), .1, .5, s.SUMO_color_stops, 180); glTranslated(0, 0.5, 0); GLHelper::drawText("Station", Position(), .1, .5, s.SUMO_color_stops, 180); } else if (myTagProperty.getTag() == SUMO_TAG_STOP_PARKINGAREA) { GLHelper::drawText("parking", Position(), .1, .5, s.SUMO_color_stops, 180); glTranslated(0, 0.5, 0); GLHelper::drawText("Area", Position(), .1, .5, s.SUMO_color_stops, 180); } else if (myTagProperty.getTag() == SUMO_TAG_STOP_LANE) { GLHelper::drawText("lane", Position(), .1, 1, s.SUMO_color_stops, 180); } // pop draw matrix glPopMatrix(); // Draw name if isn't being drawn for selecting drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { // draw dooted contour depending if it's placed over a lane or over a stoppingPlace if (getLaneParents().size() > 0) { GLHelper::drawShapeDottedContour(getType(), myGeometry.shape, getLaneParents().front()->getParentEdge().getNBEdge()->getLaneWidth(getLaneParents().front()->getIndex()) * 0.5); } else { GLHelper::drawShapeDottedContour(getType(), myGeometry.shape, exaggeration); } } // Pop name glPopName(); } }
void InfoWindow::render() { drawScrollingStuff(); GUI_RECT tmpRect = { SCROLLBOXLEFT, SCROLLBOXBOTTOM, SCROLLBOXRIGHT, INFOTOP + INFOHEIGHT }; drawRect( tmpRect, 0xff000000 ); for ( int i = 0; i < 2; i++ ) { if ( buttons[i].isEnabled() ) buttons[i].render(); } long scrollBarLength = buttons[1].location[0].y - buttons[0].location[2].y - 4 - SCROLLBUTTONHEIGHT; gos_VERTEX v[4]; for ( i = 0; i < 4; i++ ) { v[i].argb = 0xff5c96c2; v[i].frgb = 0; v[i].rhw = .5; v[i].x = SCROLLBUTTONX; v[i].y = SCROLLMIN + scrollPos; v[i].z = 0.f; v[i].u = v[i].v = 0.f; // v[i].u = ((float)SCROLLBUTTONU)/256.f + .1/256.f; // v[i].v = ((float)SCROLLBUTTONV)/256.f + .1/256.f ; } if ( infoLength < scrollBarLength || !pUnit ) { buttons[0].disable( 1 ); buttons[1].disable( 1 ); SCROLLMAX = 0; } else { buttons[0].disable( 0 ); buttons[1].disable( 0 ); float physicalRange = buttons[1].location[0].y - buttons[0].location[2].y; float buttonHeight = SCROLLBUTTONHEIGHT; float RealRange = infoLength; buttonHeight = physicalRange * physicalRange/(physicalRange + RealRange); if ( buttonHeight < SCROLLBUTTONHEIGHT ) buttonHeight = SCROLLBUTTONHEIGHT; SCROLLMAX = buttons[1].location[0].y - buttonHeight - 2; v[2].x = v[3].x = SCROLLBUTTONX + SCROLLBUTTONWIDTH; v[1].y = v[2].y = SCROLLBOTTOM; v[1].y = v[2].y = v[0].y + buttonHeight; // v[2].u = v[3].u = .1/256.f + (float)(SCROLLBUTTONU + ((float)SCROLLBUTTONWIDTH))/256.f; // v[1].v = v[2].v = .1/256.f + (float)(SCROLLBUTTONV + ((float)SCROLLBUTTONHEIGHT))/256.f; gos_SetRenderState( gos_State_Texture, 0 ); gos_DrawQuads( v, 4 ); } // draw the name of the unit if ( pUnit ) { drawName( pUnit->getIfaceName() ); gos_SetRenderState( gos_State_Texture, 0 ); // draw the health bar DWORD color; float barStatus = pUnit->getAppearance()->barStatus; if (barStatus > 1.0f) barStatus = 1.0f; if (barStatus >= 0.5) color = SB_GREEN; else if (barStatus > 0.2) color = SB_YELLOW; else color = SB_RED; v[0].x = v[1].x = HEALTHLEFT; v[2].x = v[3].x = HEALTHRIGHT; v[0].y = v[3].y = HEALTHTOP; v[1].y = v[2].y = HEALTHBOTTOM; unsigned long dimColor = ( color & 0xff7f7f7f ); for ( int i = 0; i < 4; i++ ) v[i].argb = dimColor; gos_DrawQuads( v, 4 ); v[2].x = v[3].x = HEALTHLEFT + (HEALTHRIGHT - HEALTHLEFT)* barStatus; for ( i = 0; i < 4; i++ ) v[i].argb = color | 0xff000000; gos_DrawQuads( v, 4 ); } else { char noUnit[256]; cLoadString( IDS_NOUNIT, noUnit, 255 ); drawName( noUnit ); } GUI_RECT border = { SCROLLBOXLEFT, SCROLLBOXTOP, SCROLLBOXRIGHT, SCROLLBOXBOTTOM }; drawEmptyRect( border, SCROLLCOLOR, SCROLLCOLOR ); GUI_RECT rect = { SCROLLLEFT, SCROLLTOP, SCROLLRIGHT, SCROLLBOTTOM }; drawEmptyRect( rect, SCROLLCOLOR, SCROLLCOLOR ); }
void GUIPolygon::drawGL(const GUIVisualizationSettings& s) const { if (s.polySize.getExaggeration(s) == 0) { return; } Boundary boundary = myShape.getBoxBoundary(); if (s.scale * MAX2(boundary.getWidth(), boundary.getHeight()) < s.polySize.minSize) { return; } if (getFill()) { if (myShape.size() < 3) { return; } } else { if (myShape.size() < 2) { return; } } AbstractMutex::ScopedLocker locker(myLock); //if (myDisplayList == 0 || (!getFill() && myLineWidth != s.polySize.getExaggeration(s))) { // storeTesselation(s.polySize.getExaggeration(s)); //} glPushName(getGlID()); glPushMatrix(); glTranslated(0, 0, getLayer()); glRotated(-getNaviDegree(), 0, 0, 1); GLHelper::setColor(getColor()); int textureID = -1; if (getFill()) { const std::string& file = getImgFile(); if (file != "") { textureID = GUITexturesHelper::getTextureID(file, true); } } // init generation of texture coordinates if (textureID >= 0) { glEnable(GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); // without DEPTH_TEST vehicles may be drawn below roads glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, textureID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // http://www.gamedev.net/topic/133564-glutesselation-and-texture-mapping/ glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_S, GL_OBJECT_PLANE, xPlane); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_T, GL_OBJECT_PLANE, yPlane); } // recall tesselation //glCallList(myDisplayList); performTesselation(myLineWidth * s.polySize.getExaggeration(s)); // de-init generation of texture coordinates if (textureID >= 0) { glEnable(GL_DEPTH_TEST); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); } #ifdef GUIPolygon_DEBUG_DRAW_VERTICES GLHelper::debugVertices(myShape, 80 / s.scale); #endif glPopMatrix(); const Position namePos = myShape.getPolygonCenter(); drawName(namePos, s.scale, s.polyName); if (s.polyType.show) { GLHelper::drawText(myType, namePos + Position(0, -0.6 * s.polyType.size / s.scale), GLO_MAX, s.polyType.size / s.scale, s.polyType.color); } glPopName(); }
void GUIEdge::drawGL(const GUIVisualizationSettings& s) const { if (s.hideConnectors && myFunction == MSEdge::EDGEFUNCTION_CONNECTOR) { return; } glPushName(getGlID()); // draw the lanes for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) { #ifdef HAVE_INTERNAL if (MSGlobals::gUseMesoSim) { setColor(s); } #endif GUILane* l = dynamic_cast<GUILane*>(*i); if (l != 0) { l->drawGL(s); } } #ifdef HAVE_INTERNAL if (MSGlobals::gUseMesoSim) { if (s.scale * s.vehicleSize.getExaggeration(s) > s.vehicleSize.minSize) { drawMesoVehicles(s); } } #endif glPopName(); // (optionally) draw the name and/or the street name const bool drawEdgeName = s.edgeName.show && myFunction == EDGEFUNCTION_NORMAL; const bool drawInternalEdgeName = s.internalEdgeName.show && myFunction == EDGEFUNCTION_INTERNAL; const bool drawCwaEdgeName = s.cwaEdgeName.show && (myFunction == EDGEFUNCTION_CROSSING || myFunction == EDGEFUNCTION_WALKINGAREA); const bool drawStreetName = s.streetName.show && myStreetName != ""; if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawStreetName) { GUILane* lane1 = dynamic_cast<GUILane*>((*myLanes)[0]); GUILane* lane2 = dynamic_cast<GUILane*>((*myLanes).back()); if (lane1 != 0 && lane2 != 0) { Position p = lane1->getShape().positionAtOffset(lane1->getShape().length() / (SUMOReal) 2.); p.add(lane2->getShape().positionAtOffset(lane2->getShape().length() / (SUMOReal) 2.)); p.mul(.5); SUMOReal angle = lane1->getShape().rotationDegreeAtOffset(lane1->getShape().length() / (SUMOReal) 2.); angle += 90; if (angle > 90 && angle < 270) { angle -= 180; } if (drawEdgeName) { drawName(p, s.scale, s.edgeName, angle); } else if (drawInternalEdgeName) { drawName(p, s.scale, s.internalEdgeName, angle); } else if (drawCwaEdgeName) { drawName(p, s.scale, s.cwaEdgeName, angle); } if (drawStreetName) { GLHelper::drawText(getStreetName(), p, GLO_MAX, s.streetName.size / s.scale, s.streetName.color, angle); } } } if (s.scale * s.personSize.getExaggeration(s) > s.personSize.minSize) { myLock.lock(); for (std::set<MSPerson*>::const_iterator i = myPersons.begin(); i != myPersons.end(); ++i) { GUIPerson* person = dynamic_cast<GUIPerson*>(*i); assert(person != 0); person->drawGL(s); } myLock.unlock(); } if (s.scale * s.containerSize.getExaggeration(s) > s.containerSize.minSize) { myLock.lock(); for (std::set<MSContainer*>::const_iterator i = myContainers.begin(); i != myContainers.end(); ++i) { GUIContainer* container = dynamic_cast<GUIContainer*>(*i); assert(container != 0); container->drawGL(s); } myLock.unlock(); } }
void GNEDetectorEntry::drawGL(const GUIVisualizationSettings& s) const { // Start drawing adding gl identificator glPushName(getGlID()); // Push detector matrix glPushMatrix(); glTranslated(0, 0, getType()); // Set initial values if(isAdditionalSelected()) { glColor3d(myBaseColorSelected.red(), myBaseColorSelected.green(), myBaseColorSelected.blue()); } else { glColor3d(myBaseColor.red(), myBaseColor.green(), myBaseColor.blue()); } const SUMOReal exaggeration = s.addSize.getExaggeration(s); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Push poligon matrix glPushMatrix(); glScaled(exaggeration, exaggeration, 1); glTranslated(myShape[0].x(), myShape[0].y(), 0); glRotated(myShapeRotations[0], 0, 0, 1); // Draw poligon glBegin(GL_LINES); glVertex2d(1.7, 0); glVertex2d(-1.7, 0); glEnd(); glBegin(GL_QUADS); glVertex2d(-1.7, .5); glVertex2d(-1.7, -.5); glVertex2d(1.7, -.5); glVertex2d(1.7, .5); glEnd(); // first Arrow glTranslated(1.5, 0, 0); GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05); GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (SUMOReal) 1, (SUMOReal) .25); // second Arrow glTranslated(-3, 0, 0); GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05); GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (SUMOReal) 1, (SUMOReal) .25); // Pop poligon matrix glPopMatrix(); // Pop detector matrix glPopMatrix(); // Check if the distance is enought to draw details if (s.scale * exaggeration >= 10) { // Draw icon drawDetectorIcon(GUITextureSubSys::getGif(GNETEXTURE_ENTRY), 1.5, 1); // Show Lock icon depending of the Edit mode drawLockIcon(0.4); } // Draw name drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); // pop gl identificator glPopName(); }
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(); }