//! Draw any parts on the screen which are for our module void AngleMeasure::draw(StelCore* core) { if (lineVisible.getInterstate() < 0.000001f && messageFader.getInterstate() < 0.000001f) return; const StelProjectorP prj = core->getProjection(StelCore::FrameEquinoxEqu); StelPainter painter(prj); painter.setFont(font); if (lineVisible.getInterstate() > 0.000001f) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); Vec3d xy; QString displayedText; if (prj->project(perp1EndPoint,xy)) { painter.setColor(textColor[0], textColor[1], textColor[2], lineVisible.getInterstate()); if (flagShowPA) displayedText = QString("%1 (%2%3)").arg(calculateAngle(), messagePA, calculatePositionAngle(startPoint, endPoint)); else displayedText = calculateAngle(); painter.drawText(xy[0], xy[1], displayedText, 0, 15, 15); } glDisable(GL_TEXTURE_2D); // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH // glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); // main line is a great circle painter.setColor(lineColor[0], lineColor[1], lineColor[2], lineVisible.getInterstate()); painter.drawGreatCircleArc(startPoint, endPoint, NULL); // End lines painter.drawGreatCircleArc(perp1StartPoint, perp1EndPoint, NULL); painter.drawGreatCircleArc(perp2StartPoint, perp2EndPoint, NULL); } if (messageFader.getInterstate() > 0.000001f) { painter.setColor(textColor[0], textColor[1], textColor[2], messageFader.getInterstate()); int x = 83; int y = 120; int ls = painter.getFontMetrics().lineSpacing(); painter.drawText(x, y, messageEnabled); y -= ls; painter.drawText(x, y, messageLeftButton); y -= ls; painter.drawText(x, y, messageRightButton); } }
void AngleMeasure::drawOne(StelCore *core, const StelCore::FrameType frameType, const StelCore::RefractionMode refractionMode, const Vec3f txtColor, const Vec3f lineColor) { const StelProjectorP prj = core->getProjection(frameType, refractionMode); StelPainter painter(prj); painter.setFont(font); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); if (lineVisible.getInterstate() > 0.000001f) { Vec3d xy; QString displayedText; if (frameType==StelCore::FrameEquinoxEqu) { if (prj->project(perp1EndPoint,xy)) { painter.setColor(txtColor[0], txtColor[1], txtColor[2], lineVisible.getInterstate()); if (flagShowPA) displayedText = QString("%1 (%2%3)").arg(calculateAngle(), messagePA, calculatePositionAngle(startPoint, endPoint)); else displayedText = calculateAngle(); painter.drawText(xy[0], xy[1], displayedText, 0, 15, 15); } } else { if (prj->project(perp1EndPointHor,xy)) { painter.setColor(txtColor[0], txtColor[1], txtColor[2], lineVisible.getInterstate()); if (flagShowHorizontalPA) displayedText = QString("%1 (%2%3)").arg(calculateAngle(true), messagePA, calculatePositionAngle(startPointHor, endPointHor)); else displayedText = calculateAngle(true); painter.drawText(xy[0], xy[1], displayedText, 0, 15, -5); } } glDisable(GL_TEXTURE_2D); // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH. But it looks much better. #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glEnable(GL_LINE_SMOOTH); #endif // main line is a great circle painter.setColor(lineColor[0], lineColor[1], lineColor[2], lineVisible.getInterstate()); if (frameType==StelCore::FrameEquinoxEqu) { painter.drawGreatCircleArc(startPoint, endPoint, NULL); // End lines painter.drawGreatCircleArc(perp1StartPoint, perp1EndPoint, NULL); painter.drawGreatCircleArc(perp2StartPoint, perp2EndPoint, NULL); } else { painter.drawGreatCircleArc(startPointHor, endPointHor, NULL); // End lines painter.drawGreatCircleArc(perp1StartPointHor, perp1EndPointHor, NULL); painter.drawGreatCircleArc(perp2StartPointHor, perp2EndPointHor, NULL); } #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glDisable(GL_LINE_SMOOTH); #endif } if (messageFader.getInterstate() > 0.000001f) { painter.setColor(txtColor[0], txtColor[1], txtColor[2], messageFader.getInterstate()); int x = 83; int y = 120; int ls = painter.getFontMetrics().lineSpacing(); painter.drawText(x, y, messageEnabled); y -= ls; painter.drawText(x, y, messageLeftButton); y -= ls; painter.drawText(x, y, messageRightButton); } glDisable(GL_BLEND); }