本文整理汇总了C++中StelPainter类的典型用法代码示例。如果您正苦于以下问题:C++ StelPainter类的具体用法?C++ StelPainter怎么用?C++ StelPainter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StelPainter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawLines
// Draw constellations lines
void ConstellationMgr::drawLines(StelPainter& sPainter, const StelCore* core) const
{
sPainter.enableTexture2d(false);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (constellationLineThickness>1.f)
glLineWidth(constellationLineThickness); // set line thickness
// 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
const SphericalCap& viewportHalfspace = sPainter.getProjector()->getBoundingCap();
vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{
(*iter)->drawOptim(sPainter, core, viewportHalfspace);
}
if (constellationLineThickness>1.f)
glLineWidth(1.f); // restore line thickness
// 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)
glDisable(GL_LINE_SMOOTH);
#endif
}
示例2: drawName
void Constellation::drawName(StelPainter& sPainter, ConstellationMgr::ConstellationDisplayStyle style) const
{
if (!nameFader.getInterstate())
return;
if (checkVisibility())
{
QString name;
switch (style)
{
case ConstellationMgr::constellationsTranslated:
name=nameI18;
break;
case ConstellationMgr::constellationsNative:
name=nativeName;
break;
case ConstellationMgr::constellationsEnglish:
name=englishName;
break;
case ConstellationMgr::constellationsAbbreviated:
name=(abbreviation.startsWith('.') ? "" : abbreviation);
break;
Q_ASSERT(0);
}
sPainter.setColor(labelColor[0], labelColor[1], labelColor[2], nameFader.getInterstate());
sPainter.drawText(XYname[0], XYname[1], name, 0., -sPainter.getFontMetrics().width(name)/2, 0, false);
}
}
示例3: StelPainter
void Comet::drawComa(StelCore* core, StelProjector::ModelViewTranformP transfo)
{
// Find rotation matrix from 0/0/1 to viewdirection! crossproduct for axis (normal vector), dotproduct for angle.
Vec3d eclposNrm=eclipticPos - core->getObserverHeliocentricEclipticPos() ; eclposNrm.normalize();
Mat4d comarot=Mat4d::rotation(Vec3d(0.0, 0.0, 1.0)^(eclposNrm), std::acos(Vec3d(0.0, 0.0, 1.0).dot(eclposNrm)) );
StelProjector::ModelViewTranformP transfo2 = transfo->clone();
transfo2->combine(comarot);
StelPainter* sPainter = new StelPainter(core->getProjection(transfo2));
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glDisable(GL_CULL_FACE);
// GZ: For the coma, we can use extinction via atmosphere.
// In addition, light falloff is a bit reduced for better visibility. Power basis should be 0.4, we use 0.6.
float minSkyMag=core->getSkyDrawer()->getLimitMagnitude();
float mag100pct=minSkyMag-6.0f; // should be 5, but let us draw it a bit brighter.
float magDrop=getVMagnitudeWithExtinction(core)-mag100pct;
float magFactor=std::pow(0.6f , magDrop);
magFactor=qMin(magFactor, 2.0f); // Limit excessively bright display.
comaTexture->bind();
sPainter->setColor(magFactor,magFactor,0.6f*magFactor);
sPainter->setArrays((Vec3d*)comaVertexArr.constData(), (Vec2f*)comaTexCoordArr.constData());
sPainter->drawFromArray(StelPainter::Triangles, comaVertexArr.size()/3);
glDisable(GL_BLEND);
if (sPainter)
delete sPainter;
sPainter=NULL;
}
示例4: draw
void Supernova::draw(StelCore* core, StelPainter& painter)
{
StelSkyDrawer* sd = core->getSkyDrawer();
Vec3f color = Vec3f(1.f,1.f,1.f);
if (StelApp::getInstance().getVisionModeNight())
color = StelUtils::getNightColor(color);
float rcMag[2], size, shift;
double mag;
StelUtils::spheToRect(snra, snde, XYZ);
mag = getVMagnitude(core, true);
sd->preDrawPointSource(&painter);
if (mag <= sd->getLimitMagnitude())
{
sd->computeRCMag(mag, rcMag);
// sd->drawPointSource(&painter, Vec3f(XYZ[0], XYZ[1], XYZ[2]), rcMag, color, false);
sd->drawPointSource(&painter, XYZ, rcMag, color, false);
painter.setColor(color[0], color[1], color[2], 1);
size = getAngularSize(NULL)*M_PI/180.*painter.getProjector()->getPixelPerRadAtCenter();
shift = 6.f + size/1.8f;
if (labelsFader.getInterstate()<=0.f)
{
painter.drawText(XYZ, designation, 0, shift, shift, false);
}
}
sd->postDrawPointSource(&painter);
}
示例5: drawLabel
void Nebula::drawLabel(StelPainter& sPainter, float maxMagLabel)
{
float lim = mag;
if (lim > 50) lim = 15.f;
// temporary workaround of this bug: https://bugs.launchpad.net/stellarium/+bug/1115035 --AW
if (getEnglishName().contains("Pleiades"))
lim = 5.f;
if (lim>maxMagLabel)
return;
Vec3f col(labelColor[0], labelColor[1], labelColor[2]);
sPainter.setColor(col[0], col[1], col[2], hintsBrightness);
float size = getAngularSize(NULL)*M_PI/180.*sPainter.getProjector()->getPixelPerRadAtCenter();
float shift = 4.f + size/1.8f;
QString str;
if (!nameI18.isEmpty())
str = getNameI18n();
else
{
if (M_nb > 0)
str = QString("M %1").arg(M_nb);
else if (C_nb > 0)
str = QString("C %1").arg(C_nb);
else if (NGC_nb > 0)
str = QString("NGC %1").arg(NGC_nb);
else if (IC_nb > 0)
str = QString("IC %1").arg(IC_nb);
}
sPainter.drawText(XY[0]+shift, XY[1]+shift, str, 0, 0, 0, false);
}
示例6: drawPointer
void StarMgr::drawPointer(StelPainter& sPainter, const StelCore* core)
{
const QList<StelObjectP> newSelected = objectMgr->getSelectedObject("Star");
if (!newSelected.empty())
{
const StelObjectP obj = newSelected[0];
Vec3d pos=obj->getJ2000EquatorialPos(core);
Vec3d screenpos;
// Compute 2D pos and return if outside screen
if (!sPainter.getProjector()->project(pos, screenpos))
return;
Vec3f c(obj->getInfoColor());
if (StelApp::getInstance().getVisionModeNight())
c = StelUtils::getNightColor(c);
sPainter.setColor(c[0], c[1], c[2]);
texPointer->bind();
sPainter.enableTexture2d(true);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
sPainter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, StelApp::getInstance().getTotalRunTime()*40.);
}
}
示例7: draw
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;
}
示例8: drawOrbit
void TleTraj::drawOrbit(StelPainter &painter)
{
StelVertexArray vertexArray(StelVertexArray::LineStrip);
for (QList<Vec3d>::iterator it = trajectory.begin(); it != trajectory.end(); ++it)
{
vertexArray.vertex.append(*it);
}
painter.setColor(orbitColor->redF(), orbitColor->greenF(), orbitColor->blueF());
painter.drawGreatCircleArcs(vertexArray, &viewportHalfspace);
}
示例9: drawArt
// Draw the art texture
void Constellation::drawArt(StelPainter& sPainter) const
{
glBlendFunc(GL_ONE, GL_ONE);
sPainter.enableTexture2d(true);
glEnable(GL_BLEND);
glEnable(GL_CULL_FACE);
SphericalRegionP region = sPainter.getProjector()->getViewportConvexPolygon();
drawArtOptim(sPainter, *region);
glDisable(GL_CULL_FACE);
}
示例10: drawLines
// Draw constellations lines
void ConstellationMgr::drawLines(StelPainter& sPainter, const StelCore* core) const
{
sPainter.enableTexture2d(false);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
const SphericalCap& viewportHalfspace = sPainter.getProjector()->getBoundingCap();
vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{
(*iter)->drawOptim(sPainter, core, viewportHalfspace);
}
}
示例11: draw
// returns true if visible
// Assumes that we are in local frame
void MeteorStream::draw(const StelCore* core, StelPainter& sPainter)
{
if(!alive)
return;
Vec3d spos = position;
Vec3d epos = posTrain;
// convert to equ
spos.transfo4d(viewMatrix);
epos.transfo4d(viewMatrix);
// convert to local and correct for earth radius
//[since equ and local coordinates in stellarium use same 0 point!]
spos = core->j2000ToAltAz(spos);
epos = core->j2000ToAltAz(epos);
spos[2] -= EARTH_RADIUS;
epos[2] -= EARTH_RADIUS;
// 1216 is to scale down under 1 for desktop version
spos/=1216;
epos/=1216;
// connect this point with last drawn point
double tmag = mag*distMultiplier;
QVector<Vec4f> colorArray;
QVector<Vec3d> vertexArray;
// last point - dark
colorArray.push_back(Vec4f(0,0,0,0));
vertexArray.push_back(epos);
// compute intermediate points to curve along projection distortions
int segments = 10;
for (int i=1; i<segments; i++) {
Vec3d posi = posInternal;
posi[2] = posTrain[2] + i*(position[2] - posTrain[2])/segments;
posi.transfo4d(viewMatrix);
posi = core->j2000ToAltAz(posi);
posi[2] -= EARTH_RADIUS;
posi/=1216;
colorArray.push_back(Vec4f(1,1,1,i*tmag/segments));
vertexArray.push_back(posi);
}
// first point - light
colorArray.push_back(Vec4f(1,1,1,tmag));
vertexArray.push_back(spos);
sPainter.setColorPointer(4, GL_FLOAT, colorArray.constData());
sPainter.setVertexPointer(3, GL_DOUBLE, vertexArray.constData());
sPainter.enableClientStates(true, false, true);
sPainter.drawFromArray(StelPainter::LineStrip, vertexArray.size(), 0, true);
sPainter.enableClientStates(false);
}
示例12: drawNames
// Draw the names of all the constellations
void ConstellationMgr::drawNames(StelPainter& sPainter) const
{
glEnable(GL_BLEND);
sPainter.enableTexture2d(true);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); iter++)
{
// Check if in the field of view
if (sPainter.getProjector()->projectCheck((*iter)->XYZname, (*iter)->XYname))
(*iter)->drawName(sPainter);
}
}
示例13: drawArt
// Draw constellations art textures
void ConstellationMgr::drawArt(StelPainter& sPainter) const
{
glBlendFunc(GL_ONE, GL_ONE);
sPainter.enableTexture2d(true);
glEnable(GL_BLEND);
glEnable(GL_CULL_FACE);
vector < Constellation * >::const_iterator iter;
SphericalRegionP region = sPainter.getProjector()->getViewportConvexPolygon();
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{
(*iter)->drawArtOptim(sPainter, *region);
}
glDisable(GL_CULL_FACE);
}
示例14: draw
void TleTraj::draw(const StelCore *core, StelPainter& painter)
{
Vec3d pos;
satd2StelCoord(curData, pos);
XYZ = core->altAzToJ2000(pos);
Vec3d xy;
if (painter.getProjector()->project(pos, xy))
{
glEnable(GL_TEXTURE_2D);
glColor3f(orbitColor->redF(), orbitColor->greenF(), orbitColor->blueF());
hintTexture->bind();
painter.drawSprite2dMode(xy[0], xy[1], 16);
glDisable(GL_TEXTURE_2D);
drawOrbit(painter);
}
}
示例15: drawArtOptim
void Constellation::drawArtOptim(StelPainter& sPainter, const SphericalRegion& region) const
{
if (checkVisibility())
{
const float intensity = artFader.getInterstate();
if (artTexture && intensity && region.intersects(boundingCap))
{
sPainter.setColor(intensity,intensity,intensity);
// The texture is not fully loaded
if (artTexture->bind()==false)
return;
sPainter.drawStelVertexArray(artPolygon);
}
}
}