本文整理汇总了C++中StelPainter::drawLine2d方法的典型用法代码示例。如果您正苦于以下问题:C++ StelPainter::drawLine2d方法的具体用法?C++ StelPainter::drawLine2d怎么用?C++ StelPainter::drawLine2d使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StelPainter
的用法示例。
在下文中一共展示了StelPainter::drawLine2d方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
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;
}