Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions plugins/SkyCultureMaker/src/ScmConstellation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,28 @@ scm::ScmConstellation::ScmConstellation(const QString &id, const std::vector<Con
, lines(lines)
, isDarkConstellation(isDarkConstellation)
{
ConstellationMgr *constMgr = GETSTELMODULE(ConstellationMgr);

// Initial values
constellationLineThickness = constMgr->getConstellationLineThickness();
constellationNameFont.setPixelSize(constMgr->getFontSize());
defaultConstellationLineColor = constMgr->getLinesColor();
defaultConstellationNameColor = constMgr->getLabelsColor();

// Connections
QObject::connect(constMgr, &ConstellationMgr::constellationLineThicknessChanged,
[this](int v) { constellationLineThickness = v; });
QObject::connect(constMgr, &ConstellationMgr::fontSizeChanged,
[this](int v) { constellationNameFont.setPixelSize(v); });
QObject::connect(constMgr, &ConstellationMgr::linesColorChanged,
[this](const Vec3f &c) { defaultConstellationLineColor = c; });
QObject::connect(constMgr, &ConstellationMgr::namesColorChanged,
[this](const Vec3f &c) { defaultConstellationNameColor = c; });
if (ConstellationMgr *constMgr = GETSTELMODULE(ConstellationMgr))
{
// Initial values
constellationLineThickness = constMgr->getConstellationLineThickness();
constellationNameFont.setPixelSize(constMgr->getFontSize());
defaultConstellationLineColor = constMgr->getLinesColor();
defaultConstellationNameColor = constMgr->getLabelsColor();

// Connections
QObject::connect(constMgr, &ConstellationMgr::constellationLineThicknessChanged,
[this](int v) { constellationLineThickness = v; });
QObject::connect(constMgr, &ConstellationMgr::fontSizeChanged,
[this](int v) { constellationNameFont.setPixelSize(v); });
QObject::connect(constMgr, &ConstellationMgr::linesColorChanged,
[this](const Vec3f &c) { defaultConstellationLineColor = c; });
QObject::connect(constMgr, &ConstellationMgr::namesColorChanged,
[this](const Vec3f &c) { defaultConstellationNameColor = c; });
}
else
{
qWarning() << "SkyCultureMaker: Failed to load constellation settings, because the ConstellationMgr is null";
}

updateTextPosition();
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/SkyCultureMaker/src/ScmConstellation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ class ScmConstellation
QFont constellationNameFont;

/// The default color used for drawing the constellation
Vec3f defaultConstellationLineColor = Vec3f(0.0f, 0.0f, 0.0f);
Vec3f defaultConstellationLineColor = Vec3f(0.5f, 0.5f, 0.7f);

/// The default color used for drawing the constellation names
Vec3f defaultConstellationNameColor = Vec3f(0.0f, 0.0f, 0.0f);
Vec3f defaultConstellationNameColor = Vec3f(0.5f, 0.5f, 0.7f);

/// Holds the artwork of this constellation.
ScmConstellationArtwork artwork;
Expand Down
18 changes: 17 additions & 1 deletion plugins/SkyCultureMaker/src/ScmConstellationArtwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

#include "ScmConstellationArtwork.hpp"
#include "ConstellationMgr.hpp"
#include "StarMgr.hpp"
#include "StelApp.hpp"
#include "StelModuleMgr.hpp"
Expand All @@ -36,11 +37,26 @@ scm::ScmConstellationArtwork::ScmConstellationArtwork(const std::array<Anchor, 3
, artwork(artwork)
, hasArt(true)
{
initValues();
}

scm::ScmConstellationArtwork::ScmConstellationArtwork()
: hasArt(false)
{
initValues();
}

void scm::ScmConstellationArtwork::initValues()
{
if (ConstellationMgr *constMgr = GETSTELMODULE(ConstellationMgr))
{
artIntensity = constMgr->getArtIntensity();
QObject::connect(constMgr, &ConstellationMgr::artIntensityChanged, [this](float v) { artIntensity = v; });
}
else
{
qWarning() << "SkyCultureMaker: Failed to load artwork settings, because the ConstellationMgr is null";
}
}

void scm::ScmConstellationArtwork::setupArt()
Expand Down Expand Up @@ -279,7 +295,7 @@ bool scm::ScmConstellationArtwork::save(const QString &filepath) const
void scm::ScmConstellationArtwork::drawOptimized(StelPainter &sPainter, const SphericalRegion &region,
const Vec3d &obsVelocity) const
{
const float intensity = artOpacity * artIntensityFovScale;
const float intensity = artIntensity * artIntensityFovScale;
if (artTexture && intensity > 0.0f && region.intersects(boundingCap))
{
sPainter.setColor(intensity, intensity, intensity);
Expand Down
16 changes: 14 additions & 2 deletions plugins/SkyCultureMaker/src/ScmConstellationArtwork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@

namespace scm
{
/**
* @brief Class that represents a constellation artwork.
*
* Due to the lambda capture of 'this' in QObject::connect,
* the address of a ScmConstellationArtwork instance must
* not change during its lifetime!
*/
class ScmConstellationArtwork
{
public:
Expand Down Expand Up @@ -129,6 +136,11 @@ class ScmConstellationArtwork
*/
void drawOptimized(StelPainter &sPainter, const SphericalRegion &region, const Vec3d &obsVelocity) const;

/**
* @brief Initializes the artwork values from the ConstellationMgr.
*/
void initValues();

/// Holds the anchors of the artwork.
std::array<Anchor, 3> anchors;

Expand All @@ -147,8 +159,8 @@ class ScmConstellationArtwork
/// Holds the intensity scale based on the Field of View.
float artIntensityFovScale = 1.0f;

/// Holds the opacity of the art.
float artOpacity = 0.42;
/// Holds the intensity of the art.
float artIntensity = 0.42;

/// Indicates if the artwork has an image that can be drawn.
bool hasArt = false;
Expand Down
Loading