本文整理汇总了C++中StelProjectorP::getViewportCenterAbsolute方法的典型用法代码示例。如果您正苦于以下问题:C++ StelProjectorP::getViewportCenterAbsolute方法的具体用法?C++ StelProjectorP::getViewportCenterAbsolute怎么用?C++ StelProjectorP::getViewportCenterAbsolute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StelProjectorP
的用法示例。
在下文中一共展示了StelProjectorP::getViewportCenterAbsolute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawViewportShape
//! Fill with black around viewport disc shape.
static void drawViewportShape(StelRenderer* renderer, StelProjectorP projector)
{
if (projector->getMaskType() != StelProjector::MaskDisk)
{
return;
}
renderer->setBlendMode(BlendMode_None);
renderer->setGlobalColor(0.0f, 0.0f, 0.0f);
const float innerRadius = 0.5 * projector->getViewportFovDiameter();
const float outerRadius = projector->getViewportWidth() + projector->getViewportHeight();
Q_ASSERT_X(innerRadius >= 0.0f && outerRadius > innerRadius,
Q_FUNC_INFO, "Inner radius must be at least zero and outer radius must be greater");
const float sweepAngle = 360.0f;
static const int resolution = 192;
float sinCache[resolution];
float cosCache[resolution];
const float deltaRadius = outerRadius - innerRadius;
const int slices = resolution - 1;
// Cache is the vertex locations cache
for (int s = 0; s <= slices; s++)
{
const float angle = (M_PI * sweepAngle) / 180.0f * s / slices;
sinCache[s] = std::sin(angle);
cosCache[s] = std::cos(angle);
}
sinCache[slices] = sinCache[0];
cosCache[slices] = cosCache[0];
const float radiusHigh = outerRadius - deltaRadius;
StelVertexBuffer<VertexP2>* vertices =
renderer->createVertexBuffer<VertexP2>(PrimitiveType_TriangleStrip);
const Vec2f center = projector->getViewportCenterAbsolute();
for (int i = 0; i <= slices; i++)
{
vertices->addVertex(VertexP2(center[0] + outerRadius * sinCache[i],
center[1] + outerRadius * cosCache[i]));
vertices->addVertex(VertexP2(center[0] + radiusHigh * sinCache[i],
center[1] + radiusHigh * cosCache[i]));
}
vertices->lock();
renderer->setCulledFaces(CullFace_None);
renderer->drawVertexBuffer(vertices);
delete vertices;
}
示例2: qMin
void StelQGLRenderer::drawTextGravityHelper
(const TextParams& params, QPainter& painter, const int baseX, const int baseY, StelProjectorP projector)
{
const Vec2f viewportCenter = projector->getViewportCenterAbsolute();
const float dx = baseX - viewportCenter[0];
const float dy = baseY - viewportCenter[1];
const float d = std::sqrt(dx * dx + dy * dy);
// Cull the text if it's too far away to be visible in the screen.
if (d > qMax(projector->getViewportXywh()[3], projector->getViewportXywh()[2]) * 2)
{
return;
}
const QString string = params.string_;
const int charCount = string.length();
const float charWidth = painter.fontMetrics().width(string) / charCount;
float theta = std::atan2(dy - 1, dx);
const float psi = qMin(5.0, std::atan2(charWidth, d + 1) * 180.0f / M_PI);
const float xVc = viewportCenter[0] + params.xShift_;
const float yVc = viewportCenter[1] + params.yShift_;
const QString lang = StelApp::getInstance().getLocaleMgr().getAppLanguage();
const bool leftToRight = !QString("ar fa ur he yi ckb").contains(lang);
// Draw each character separately
for (int i = 0; i < charCount; ++i)
{
const int charIndex = leftToRight ? i : charCount - 1 - i;
const float x = d * std::cos(theta) + xVc;
const float y = d * std::sin(theta) + yVc;
const float angle = 90.0f + theta * 180.0f / M_PI;
drawText(TextParams(x, y, string[charIndex]).angleDegrees(angle));
// Compute how much the character contributes to the angle
const float width = painter.fontMetrics().width(string[charIndex]);
theta += psi * M_PI / 180.0 * (1 + (width - charWidth) / charWidth);
}
}