bool ScreenLabel::draw(StelCore*, StelPainter& sPainter) { if (labelFader.getInterstate() <= 0.0) return false; sPainter.setColor(labelColor[0], labelColor[1], labelColor[2], labelFader.getInterstate()); sPainter.setFont(labelFont); sPainter.drawText(screenX, screenY, labelText, 0, 0, 0, false); return true; }
bool SkyLabel::draw(StelCore* core, StelPainter& sPainter) { if(labelFader.getInterstate() <= 0.0) return false; Vec3d objectPos = labelObject->getJ2000EquatorialPos(core); Vec3d labelXY; sPainter.getProjector()->project(objectPos,labelXY); sPainter.setFont(labelFont); double xOffset(0.); double yOffset(0.); char hJustify = 'c'; char vJustify = 'c'; if (labelSide.toUpper().contains("N")) { yOffset = 1.0; vJustify = 'b'; // bottom justify text } else if (labelSide.toUpper().contains("S")) { yOffset = -1.0; vJustify = 't'; // top justufy text } if (labelSide.toUpper().contains("E")) { xOffset = 1.0; hJustify = 'l'; // right justify text } else if (labelSide.toUpper().contains("W")) { xOffset = -1.0; hJustify = 'r'; // left justify text } if (labelDistance >= 0.0) { xOffset *= labelDistance; yOffset *= labelDistance; } else { float shift = 4.f + labelObject->getAngularSize(core)*M_PI/180.*sPainter.getProjector()->getPixelPerRadAtCenter()/1.8f; // use the object size xOffset *= shift; yOffset *= shift; } double jxOffset(0.); double jyOffset(0.); if (hJustify == 'r') jxOffset = sPainter.getFontMetrics().width(labelText); else if (hJustify == 'c') jxOffset = sPainter.getFontMetrics().width(labelText) / 2.; if (vJustify == 't') jyOffset = sPainter.getFontMetrics().height(); else if (vJustify == 'c') jyOffset = sPainter.getFontMetrics().height() / 2.; sPainter.setColor(labelColor[0], labelColor[1], labelColor[2], labelFader.getInterstate()); sPainter.drawText(labelXY[0]+xOffset-jxOffset, labelXY[1]+yOffset-jyOffset, labelText, 0, 0, 0, false); if (labelStyle == SkyLabel::Line) { sPainter.enableTexture2d(false); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // screen coordinates of object Vec3d objXY; sPainter.getProjector()->project(objectPos,objXY); double lineEndX = labelXY[0]+xOffset; double lineEndY = labelXY[1]+yOffset; if (vJustify == 'b') lineEndY -= 5; else if (vJustify == 't') lineEndY += 5; if (hJustify == 'l') lineEndX -= 5; else if (hJustify == 'r') lineEndX += 5; sPainter.setColor(labelColor[0], labelColor[1], labelColor[2], labelFader.getInterstate()); sPainter.drawLine2d(lineEndX,lineEndY,objXY[0], objXY[1]); } return true; }