Skip to content

Commit

Permalink
A few cosmetic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-w committed Sep 19, 2023
1 parent 942bb77 commit 29a76e4
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 56 deletions.
4 changes: 2 additions & 2 deletions plugins/AngleMeasure/src/AngleMeasure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void AngleMeasure::drawOne(StelCore *core, const StelCore::FrameType frameType,
painter.setLineSmooth(true);

// main line is a great circle
painter.setColor(lineColor[0], lineColor[1], lineColor[2], lineVisible.getInterstate());
painter.setColor(lineColor, lineVisible.getInterstate());
if (frameType==StelCore::FrameEquinoxEqu)
{
painter.drawGreatCircleArc(startPoint, endPoint, Q_NULLPTR);
Expand All @@ -253,7 +253,7 @@ void AngleMeasure::drawOne(StelCore *core, const StelCore::FrameType frameType,
if (messageFader.getInterstate() > 0.000001f)
{
// text block (bottom left)
painter.setColor(txtColor[0], txtColor[1], txtColor[2], messageFader.getInterstate());
painter.setColor(txtColor, messageFader.getInterstate());
const double ppx = core->getCurrentStelProjectorParams().devicePixelsPerPixel;
int x = static_cast<int>(83*ppx);
int y = static_cast<int>(120*ppx);
Expand Down
3 changes: 1 addition & 2 deletions plugins/Exoplanets/src/Exoplanets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ void Exoplanets::drawPointer(StelCore* core, StelPainter& painter)
if (!painter.getProjector()->project(pos, screenpos))
return;

const Vec3f& c(obj->getInfoColor());
painter.setColor(c[0],c[1],c[2]);
painter.setColor(obj->getInfoColor());
texPointer->bind();
painter.setBlending(true);
painter.drawSprite2dMode(static_cast<float>(screenpos[0]), static_cast<float>(screenpos[1]), 13.f, static_cast<float>(StelApp::getInstance().getTotalRunTime())*40.f);
Expand Down
3 changes: 1 addition & 2 deletions plugins/MeteorShowers/src/MeteorShowers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ void MeteorShowers::drawPointer(StelCore* core)
return;
}

const Vec3f& c(obj->getInfoColor());
painter.setColor(c[0],c[1],c[2]);
painter.setColor(obj->getInfoColor());
m_mgr->getPointerTexture()->bind();

painter.setBlending(true);
Expand Down
2 changes: 1 addition & 1 deletion plugins/NavStars/src/NavStars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void NavStars::draw(StelCore* core)
if (!markerTexture.isNull())
{
painter.setBlending(true);
painter.setColor(markerColor[0], markerColor[1], markerColor[2], markerFader.getInterstate());
painter.setColor(markerColor, markerFader.getInterstate());
markerTexture->bind();
painter.drawSprite2dMode(static_cast<float>(pos[0]), static_cast<float>(pos[1]), 11.f);
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/Novae/src/Novae.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ void Novae::drawPointer(StelCore* core, StelPainter &painter)
if (!painter.getProjector()->project(pos, screenpos))
return;

const Vec3f& c(obj->getInfoColor());
painter.setColor(c[0],c[1],c[2]);
painter.setColor(obj->getInfoColor());
texPointer->bind();
painter.setBlending(true);
painter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, StelApp::getInstance().getTotalRunTime()*40.);
Expand Down
2 changes: 1 addition & 1 deletion plugins/Observability/src/Observability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,7 @@ void Observability::renderResults() {

// Set the painter:
StelPainter painter(core->getProjection2d());
painter.setColor(fontColor[0], fontColor[1], fontColor[2], 1.f);
painter.setColor(fontColor, 1.f);
font.setPixelSize(fontSize);
painter.setFont(font);

Expand Down
2 changes: 1 addition & 1 deletion plugins/Quasars/src/Quasar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void Quasar::draw(StelCore* core, StelPainter& painter)
// allow height-dependent twinkle and suppress twinkling in higher altitudes. Keep 0.1 twinkle amount in zenith.
sd->drawPointSource(&painter, vf.toVec3d(), rcMag, sd->indexToColor(BvToColorIndex(bV)), true, qMin(1.0f, 1.0f-0.9f*altAz[2]));
sd->postDrawPointSource(&painter);
painter.setColor(color[0], color[1], color[2], 1);
painter.setColor(color, 1);
}

if (!distributionMode && (mag+2.f)<mlimit)
Expand Down
3 changes: 1 addition & 2 deletions plugins/Quasars/src/Quasars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ void Quasars::drawPointer(StelCore* core, StelPainter& painter)
if (!painter.getProjector()->project(pos.toVec3f(), screenpos))
return;

const Vec3f& c(obj->getInfoColor());
painter.setColor(c[0],c[1],c[2]);
painter.setColor(obj->getInfoColor());
texPointer->bind();
painter.setBlending(true);
painter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, StelApp::getInstance().getTotalRunTime()*40.);
Expand Down
2 changes: 1 addition & 1 deletion plugins/Scenery3d/src/Scenery3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void Scenery3d::draw(StelCore* core)
const StelProjectorP prj = core->getProjection(StelCore::FrameEquinoxEqu);
StelPainter painter(prj);
painter.setFont(font);
painter.setColor(textColor[0], textColor[1], textColor[2], messageFader.getInterstate());
painter.setColor(textColor, messageFader.getInterstate());
painter.drawText(83, 120, currentMessage);
}
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/Supernovae/src/Supernovae.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ void Supernovae::drawPointer(StelCore* core, StelPainter& painter)
if (!painter.getProjector()->project(pos, screenpos))
return;

const Vec3f& c(obj->getInfoColor());
painter.setColor(c[0],c[1],c[2]);
painter.setColor(obj->getInfoColor());
texPointer->bind();
painter.setBlending(true);
painter.drawSprite2dMode(static_cast<float>(screenpos[0]), static_cast<float>(screenpos[1]), 13.f, static_cast<float>(StelApp::getInstance().getTotalRunTime())*40.f);
Expand Down
77 changes: 37 additions & 40 deletions src/core/modules/Nebula.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,16 +684,11 @@ float Nebula::getVisibilityLevelByMagnitude(void) const
void Nebula::drawOutlines(StelPainter &sPainter, float maxMagHints) const
{
size_t segments = outlineSegments.size();
Vec3f color = getHintColor(nType);

// tune limits for outlines
float oLim = getVisibilityLevelByMagnitude() - 3.f;

float lum = 1.f;
Vec3f col(color*lum*hintsBrightness);
if (!objectInDisplayedType())
col.set(0.f,0.f,0.f);
sPainter.setColor(col, 1);
sPainter.setColor(getHintColor(nType), objectInDisplayedType() ? hintsBrightness : 0.f);

StelCore *core=StelApp::getInstance().getCore();
Vec3d vel=core->getCurrentPlanet()->getHeliocentricEclipticVelocity();
Expand Down Expand Up @@ -733,7 +728,7 @@ void Nebula::drawOutlines(StelPainter &sPainter, float maxMagHints) const
}

void Nebula::renderDarkNebulaMarker(StelPainter& sPainter, const float x, const float y,
float size, const Vec3f color) const
float size, const Vec3f color) const
{
// Take into account device pixel density and global scale ratio, as we are drawing 2D stuff.
const auto pixelRatio = sPainter.getProjector()->getDevicePixelsPerPixel();
Expand All @@ -754,10 +749,10 @@ void Nebula::renderDarkNebulaMarker(StelPainter& sPainter, const float x, const
const float topInnerY = topOuterY - roundRadius;
const float gap = 0.15*size;
const float*const cossin = StelUtils::ComputeCosSinRhoZone((M_PIf/2)/(numPointsInArc-1),
numPointsInArc-1, 0);
numPointsInArc-1, 0);
sPainter.setLineSmooth(true);
sPainter.setLineWidth(scale * std::clamp(2*size/35, 1.f, 2.5f));
sPainter.setColor(color);
sPainter.setColor(color, hintsBrightness);
sPainter.enableClientStates(true);

vertexData.clear();
Expand Down Expand Up @@ -820,7 +815,7 @@ void Nebula::renderDarkNebulaMarker(StelPainter& sPainter, const float x, const
}

void Nebula::renderMarkerRoundedRect(StelPainter& sPainter, const float x, const float y,
float size, const Vec3f color) const
float size, const Vec3f color) const
{
// Take into account device pixel density and global scale ratio, as we are drawing 2D stuff.
const auto pixelRatio = sPainter.getProjector()->getDevicePixelsPerPixel();
Expand All @@ -840,7 +835,7 @@ void Nebula::renderMarkerRoundedRect(StelPainter& sPainter, const float x, const
const float topOuterY = y + size;
const float topInnerY = topOuterY - roundRadius;
const float*const cossin = StelUtils::ComputeCosSinRhoZone((M_PIf/2)/(numPointsInArc-1),
numPointsInArc-1, 0);
numPointsInArc-1, 0);
for(int n = 0; n < numPointsInArc; ++n)
{
const auto cosa = cossin[2*n], sina = cossin[2*n+1];
Expand Down Expand Up @@ -868,15 +863,15 @@ void Nebula::renderMarkerRoundedRect(StelPainter& sPainter, const float x, const
const auto vertCount = vertexData.size() / 2;
sPainter.setLineSmooth(true);
sPainter.setLineWidth(scale * std::clamp(2*size/35, 1.f, 2.5f));
sPainter.setColor(color);
sPainter.setColor(color, hintsBrightness);
sPainter.enableClientStates(true);
sPainter.setVertexPointer(2, GL_FLOAT, vertexData.data());
sPainter.drawFromArray(StelPainter::LineLoop, vertCount, 0, false);
sPainter.enableClientStates(false);
}

void Nebula::renderRoundMarker(StelPainter& sPainter, const float x, const float y,
float size, const Vec3f color, const bool crossed) const
float size, const Vec3f color, const bool crossed) const
{
// Take into account device pixel density and global scale ratio, as we are drawing 2D stuff.
const auto pixelRatio = sPainter.getProjector()->getDevicePixelsPerPixel();
Expand All @@ -885,7 +880,7 @@ void Nebula::renderRoundMarker(StelPainter& sPainter, const float x, const float

sPainter.setLineSmooth(true);
sPainter.setLineWidth(scale * std::clamp(size/7, 1.f, 2.5f));
sPainter.setColor(color);
sPainter.setColor(color, hintsBrightness);

sPainter.drawCircle(x, y, size);
if(!crossed) return;
Expand All @@ -902,7 +897,7 @@ void Nebula::renderRoundMarker(StelPainter& sPainter, const float x, const float
}

void Nebula::renderEllipticMarker(StelPainter& sPainter, const float x, const float y, float size,
const float aspectRatio, const float angle, const Vec3f color) const
const float aspectRatio, const float angle, const Vec3f color) const
{
// Take into account device pixel density and global scale ratio, as we are drawing 2D stuff.
const auto pixelRatio = sPainter.getProjector()->getDevicePixelsPerPixel();
Expand All @@ -928,23 +923,23 @@ void Nebula::renderEllipticMarker(StelPainter& sPainter, const float x, const fl
const auto vertCount = vertexData.size() / 2;
sPainter.setLineSmooth(true);
sPainter.setLineWidth(scale * std::clamp(size/40, 1.f, 2.f));
sPainter.setColor(color);
sPainter.setColor(color, hintsBrightness);
sPainter.enableClientStates(true);
sPainter.setVertexPointer(2, GL_FLOAT, vertexData.data());
sPainter.drawFromArray(StelPainter::LineLoop, vertCount, 0, false);
sPainter.enableClientStates(false);
}

void Nebula::renderMarkerPointedCircle(StelPainter& sPainter, const float x, const float y,
float size, const Vec3f color, const bool insideRect) const
float size, const Vec3f color, const bool insideRect) const
{
// Take into account device pixel density and global scale ratio, as we are drawing 2D stuff.
const auto pixelRatio = sPainter.getProjector()->getDevicePixelsPerPixel();
const auto scale = pixelRatio * StelApp::getInstance().getGlobalScalingRatio();
size *= scale;

texPointElement->bind();
sPainter.setColor(color);
sPainter.setColor(color, hintsBrightness);
sPainter.setBlending(true, GL_ONE, GL_ONE);
const auto numPoints = StelUtils::getSmallerPowerOfTwo(std::clamp(int(0.4f*size), 8, 4096));
const auto spriteSize = std::min(0.25f * 2*M_PIf*size / numPoints, 5.f);
Expand All @@ -958,6 +953,18 @@ void Nebula::renderMarkerPointedCircle(StelPainter& sPainter, const float x, con
}
}

float Nebula::getHintSize(StelPainter& sPainter) const
{
const float size = 6.0f;
float scaledSize = 0.0f;
if (drawHintProportional)
scaledSize = static_cast<float>(getAngularRadius(Q_NULLPTR)) *(M_PI_180f*2.f)*static_cast<float>(sPainter.getProjector()->getPixelPerRadAtCenter());
if (nType==NebRegion)
scaledSize = 12.f;

return qMax(size, scaledSize);
}

void Nebula::drawHints(StelPainter& sPainter, float maxMagHints, StelCore *core) const
{
size_t segments = outlineSegments.size();
Expand All @@ -973,14 +980,8 @@ void Nebula::drawHints(StelPainter& sPainter, float maxMagHints, StelCore *core)

Vec3f color = getHintColor(nType);

const float size = 6.0f;
float scaledSize = 0.0f;
if (drawHintProportional)
scaledSize = static_cast<float>(getAngularRadius(Q_NULLPTR)) *(M_PI_180f*2.f)*static_cast<float>(sPainter.getProjector()->getPixelPerRadAtCenter());
float finalSize=qMax(size, scaledSize);
float finalSize = getHintSize(sPainter);

float lum = 1.f;
Vec3f col(color*lum*hintsBrightness);
if (!objectInDisplayedType())
return;

Expand All @@ -1003,17 +1004,17 @@ void Nebula::drawHints(StelPainter& sPainter, float maxMagHints, StelCore *core)
Vec3d XYrel;
sPainter.getProjector()->project(XYZrel, XYrel);
const auto screenAngle = atan2(XYrel[1]-XY[1], XYrel[0]-XY[0]);
renderEllipticMarker(sPainter, XY[0], XY[1], finalSize, 2, screenAngle + orientationAngle*M_PI_180f, col);
renderEllipticMarker(sPainter, XY[0], XY[1], finalSize, 2, screenAngle + orientationAngle*M_PI_180f, color);
return;
}
case NebOc:
case NebSA:
case NebSC:
case NebCl:
renderMarkerPointedCircle(sPainter, XY[0], XY[1], finalSize, col, false);
renderMarkerPointedCircle(sPainter, XY[0], XY[1], finalSize, color, false);
return;
case NebGc:
renderRoundMarker(sPainter, XY[0], XY[1], finalSize, col, true);
renderRoundMarker(sPainter, XY[0], XY[1], finalSize, color, true);
return;
case NebN:
case NebHII:
Expand All @@ -1025,38 +1026,35 @@ void Nebula::drawHints(StelPainter& sPainter, float maxMagHints, StelCore *core)
case NebEn:
case NebSNC:
case NebSNRC:
renderMarkerRoundedRect(sPainter, XY[0], XY[1], finalSize, col);
renderMarkerRoundedRect(sPainter, XY[0], XY[1], finalSize, color);
return;
case NebPn:
case NebPossPN:
case NebPPN:
Nebula::texPlanetaryNebula->bind();
break;
case NebDn:
renderDarkNebulaMarker(sPainter, XY[0], XY[1], finalSize, col);
renderDarkNebulaMarker(sPainter, XY[0], XY[1], finalSize, color);
return;
case NebCn:
{
col = getHintColor(NebN)*lum*hintsBrightness;
renderMarkerRoundedRect(sPainter, XY[0], XY[1], finalSize, col);
col = getHintColor(NebCl)*lum*hintsBrightness;
renderMarkerPointedCircle(sPainter, XY[0], XY[1], finalSize, col, true);
renderMarkerRoundedRect(sPainter, XY[0], XY[1], finalSize, getHintColor(NebN));
renderMarkerPointedCircle(sPainter, XY[0], XY[1], finalSize, getHintColor(NebCl), true);
return;
}
case NebRegion:
finalSize = size*2.f;
Nebula::texRegion->bind();
break;
//case NebEMO:
//case NebStar:
//case NebSymbioticStar:
//case NebEmissionLineStar:
default:
renderRoundMarker(sPainter, XY[0], XY[1], finalSize, col, false);
renderRoundMarker(sPainter, XY[0], XY[1], finalSize, color, false);
return;
}

sPainter.setColor(col, 1);
sPainter.setColor(color, hintsBrightness);
sPainter.setBlending(true, GL_ONE, GL_ONE);

sPainter.drawSprite2dMode(static_cast<float>(XY[0]), static_cast<float>(XY[1]), finalSize);
Expand All @@ -1074,14 +1072,13 @@ void Nebula::drawLabel(StelPainter& sPainter, float maxMagLabel) const

sPainter.setColor(labelColor, objectInDisplayedType() ? hintsBrightness : 0.f);

const float size = static_cast<float>(getAngularRadius(Q_NULLPTR))*(M_PI_180f*2.f)*sPainter.getProjector()->getPixelPerRadAtCenter();
const float shift = 5.f + (drawHintProportional ? size*0.9f : 0.f);
const float shift = 15.f + (drawHintProportional ? getHintSize(sPainter) : 0.f);

QString str = getNameI18n();
if (str.isEmpty() || designationUsage)
str = getDSODesignation();

sPainter.drawText(static_cast<float>(XY[0])+shift, static_cast<float>(XY[1])+shift, str, 0, 0, 0, false);
sPainter.drawText(static_cast<float>(XY[0]), static_cast<float>(XY[1]), str, 0, shift, shift, false);
}

QString Nebula::getDSODesignation() const
Expand Down
1 change: 1 addition & 0 deletions src/core/modules/Nebula.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ friend class NebulaMgr;

static Vec3f getHintColor(Nebula::NebulaType nType);
float getVisibilityLevelByMagnitude() const;
float getHintSize(StelPainter& sPainter) const;

//! Get the printable description of morphological nebula type.
//! @return the nebula morphological type string.
Expand Down

0 comments on commit 29a76e4

Please sign in to comment.