Skip to content

Commit e024f59

Browse files
authored
SCM: Use artIntensity from ConstellationMgr (#4682)
* connect to constmgrs art intensity * change function name
1 parent cca92e8 commit e024f59

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

plugins/SkyCultureMaker/src/ScmConstellationArtwork.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323

2424
#include "ScmConstellationArtwork.hpp"
25+
#include "ConstellationMgr.hpp"
2526
#include "StarMgr.hpp"
2627
#include "StelApp.hpp"
2728
#include "StelModuleMgr.hpp"
@@ -36,11 +37,20 @@ scm::ScmConstellationArtwork::ScmConstellationArtwork(const std::array<Anchor, 3
3637
, artwork(artwork)
3738
, hasArt(true)
3839
{
40+
initValues();
3941
}
4042

4143
scm::ScmConstellationArtwork::ScmConstellationArtwork()
4244
: hasArt(false)
4345
{
46+
initValues();
47+
}
48+
49+
void scm::ScmConstellationArtwork::initValues()
50+
{
51+
ConstellationMgr *constMgr = GETSTELMODULE(ConstellationMgr);
52+
artIntensity = constMgr->getArtIntensity();
53+
QObject::connect(constMgr, &ConstellationMgr::artIntensityChanged, [this](float v) { artIntensity = v; });
4454
}
4555

4656
void scm::ScmConstellationArtwork::setupArt()
@@ -279,7 +289,7 @@ bool scm::ScmConstellationArtwork::save(const QString &filepath) const
279289
void scm::ScmConstellationArtwork::drawOptimized(StelPainter &sPainter, const SphericalRegion &region,
280290
const Vec3d &obsVelocity) const
281291
{
282-
const float intensity = artOpacity * artIntensityFovScale;
292+
const float intensity = artIntensity * artIntensityFovScale;
283293
if (artTexture && intensity > 0.0f && region.intersects(boundingCap))
284294
{
285295
sPainter.setColor(intensity, intensity, intensity);

plugins/SkyCultureMaker/src/ScmConstellationArtwork.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535

3636
namespace scm
3737
{
38+
/**
39+
* @brief Class that represents a constellation artwork.
40+
*
41+
* Due to the lambda capture of 'this' in QObject::connect,
42+
* the address of a ScmConstellationArtwork instance must
43+
* not change during its lifetime!
44+
*/
3845
class ScmConstellationArtwork
3946
{
4047
public:
@@ -129,6 +136,11 @@ class ScmConstellationArtwork
129136
*/
130137
void drawOptimized(StelPainter &sPainter, const SphericalRegion &region, const Vec3d &obsVelocity) const;
131138

139+
/**
140+
* @brief Initializes the artwork values from the ConstellationMgr.
141+
*/
142+
void initValues();
143+
132144
/// Holds the anchors of the artwork.
133145
std::array<Anchor, 3> anchors;
134146

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

150-
/// Holds the opacity of the art.
151-
float artOpacity = 0.42;
162+
/// Holds the intensity of the art.
163+
float artIntensity = 0.42;
152164

153165
/// Indicates if the artwork has an image that can be drawn.
154166
bool hasArt = false;

0 commit comments

Comments
 (0)