Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dimming of DSO hints and labels #3945

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions src/core/StelApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,7 @@ void StelApp::setFlagUseFormattingOutput(bool b)
if (flagUseFormattingOutput!=b)
{
flagUseFormattingOutput = b;
StelApp::immediateSave("gui/flag_use_formatting_output", flagUseFormattingOutput);
emit flagUseFormattingOutputChanged(b);
}
}
Expand All @@ -1265,6 +1266,7 @@ void StelApp::setFlagUseCCSDesignation(bool b)
if (flagUseCCSDesignation!=b)
{
flagUseCCSDesignation = b;
StelApp::immediateSave("gui/flag_use_ccs_designations", flagUseCCSDesignation);
emit flagUseCCSDesignationChanged(b);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/StelSkyDrawer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public slots:
//! Toggle the application of user-defined deep-sky object magnitude limit.
//! If enabled, deep-sky objects fainter than the magnitude set with
//! setCustomNebulaMagnitudeLimit() will not be displayed.
void setFlagNebulaMagnitudeLimit(bool b) {if(b!=flagNebulaMagnitudeLimit){ flagNebulaMagnitudeLimit = b; emit flagNebulaMagnitudeLimitChanged(b);}}
void setFlagNebulaMagnitudeLimit(bool b) {if(b!=flagNebulaMagnitudeLimit){ flagNebulaMagnitudeLimit = b; StelApp::immediateSave("astro/flag_nebula_magnitude_limit", b); emit flagNebulaMagnitudeLimitChanged(b);}}
//! @return true if the user-defined nebula magnitude limit is in force.
bool getFlagNebulaMagnitudeLimit() const {return flagNebulaMagnitudeLimit;}
//! Toggle the application of user-defined solar system object magnitude limit.
Expand All @@ -257,7 +257,7 @@ public slots:
double getCustomNebulaMagnitudeLimit() const {return customNebulaMagLimit;}
//! Sets a lower limit for nebula magnitudes (anything fainter is ignored).
//! In force only if flagNebulaMagnitudeLimit is set.
void setCustomNebulaMagnitudeLimit(double limit) { customNebulaMagLimit=limit; emit customNebulaMagLimitChanged(limit);}
void setCustomNebulaMagnitudeLimit(double limit) { customNebulaMagLimit=limit; StelApp::immediateSave("astro/nebula_magnitude_limit", limit); emit customNebulaMagLimitChanged(limit);}
//! Get the value used for forced solar system object magnitude limiting.
double getCustomPlanetMagnitudeLimit() const {return customPlanetMagLimit;}
//! Sets a lower limit for solar system object magnitudes (anything fainter is ignored).
Expand Down
143 changes: 72 additions & 71 deletions src/core/modules/Nebula.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ StelTextureSP Nebula::texPlanetaryNebula;
bool Nebula::drawHintProportional = false;
bool Nebula::surfaceBrightnessUsage = false;
bool Nebula::designationUsage = false;
float Nebula::hintsBrightness = 0.f;
double Nebula::hintsBrightness = 1.;
double Nebula::labelsBrightness = 1.;
Vec3f Nebula::labelColor = Vec3f(0.4f,0.3f,0.5f);
QMap<Nebula::NebulaType, Vec3f>Nebula::hintColorMap;
bool Nebula::flagUseTypeFilters = false;
Expand Down Expand Up @@ -702,12 +703,15 @@ float Nebula::getVisibilityLevelByMagnitude(void) const

void Nebula::drawOutlines(StelPainter &sPainter, float maxMagHints) const
{
if (!objectInDisplayedType())
return;

size_t segments = outlineSegments.size();

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

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

StelCore *core=StelApp::getInstance().getCore();
Vec3d vel=core->getCurrentPlanet()->getHeliocentricEclipticVelocity();
Expand Down Expand Up @@ -976,7 +980,7 @@ 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());
scaledSize = static_cast<float>(getAngularRadius(Q_NULLPTR)) *(M_PI_180f/2.f)*static_cast<float>(sPainter.getProjector()->getPixelPerRadAtCenter());
if (nType==NebRegion)
scaledSize = 12.f;

Expand All @@ -985,9 +989,11 @@ float Nebula::getHintSize(StelPainter& sPainter) const

void Nebula::drawHints(StelPainter& sPainter, float maxMagHints, StelCore *core) const
{
size_t segments = outlineSegments.size();
if (segments>0 && flagUseOutlines)
if (!objectInDisplayedType())
return;
if (outlineSegments.size()>0 && flagUseOutlines)
return;

Vec3d win;
// Check visibility of DSO hints
if (!(sPainter.getProjector()->projectCheck(XYZ, win)))
Expand All @@ -997,12 +1003,8 @@ void Nebula::drawHints(StelPainter& sPainter, float maxMagHints, StelCore *core)
return;

Vec3f color = getHintColor(nType);

float finalSize = getHintSize(sPainter);

if (!objectInDisplayedType())
return;

switch (nType)
{
case NebGx:
Expand Down Expand Up @@ -1080,6 +1082,9 @@ void Nebula::drawHints(StelPainter& sPainter, float maxMagHints, StelCore *core)

void Nebula::drawLabel(StelPainter& sPainter, float maxMagLabel) const
{
if (!objectInDisplayedType())
return;

Vec3d win;
// Check visibility of DSO labels
if (!(sPainter.getProjector()->projectCheck(XYZ, win)))
Expand All @@ -1088,7 +1093,7 @@ void Nebula::drawLabel(StelPainter& sPainter, float maxMagLabel) const
if (getVisibilityLevelByMagnitude()>maxMagLabel)
return;

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

const float shift = 15.f + (drawHintProportional ? getHintSize(sPainter) : 0.f);

Expand Down Expand Up @@ -1230,67 +1235,63 @@ bool Nebula::objectInDisplayedType() const
if (!flagUseTypeFilters)
return true;

int cntype = -1;
switch (nType)
{
case NebGx:
cntype = 0; // Galaxies
break;
case NebAGx:
case NebRGx:
case NebQSO:
case NebPossQSO:
case NebBLL:
case NebBLA:
cntype = 1; // Active Galaxies
break;
case NebIGx:
cntype = 2; // Interacting Galaxies
break;
case NebOc:
case NebCl:
case NebSA:
case NebSC:
cntype = 3; // Open Star Clusters
break;
case NebHII:
case NebISM:
cntype = 4; // Hydrogen regions (include interstellar matter)
break;
case NebN:
case NebBn:
case NebEn:
case NebRn:
cntype = 5; // Bright Nebulae
break;
case NebDn:
case NebMolCld:
case NebYSO:
cntype = 6; // Dark Nebulae
break;
case NebPn:
case NebPossPN:
case NebPPN:
cntype = 7; // Planetary Nebulae
break;
case NebSNR:
case NebSNC:
case NebSNRC:
cntype = 8; // Supernova Remnants
break;
case NebCn:
cntype = 9;
break;
case NebGxCl:
cntype = 10;
break;
case NebGc:
cntype = 11;
break;
default:
cntype = 12;
break;
}
// a QMap which translates all defined nTypes to yet another int for easier filtering. Note some nTypes (commented away) have not been translated so far and are just qualified as "other/unknown"!
static const QMap<NebulaType, int>map={
{NebGx , 0 }, // m Galaxy
{NebAGx , 1 }, // Active galaxy
{NebRGx , 1 }, // m Radio galaxy
{NebIGx , 2 }, // Interacting galaxy
{NebQSO , 1 }, // Quasar
{NebCl , 3 }, // Star cluster
{NebOc , 3 }, // Open star cluster
{NebGc , 11 }, // Globular star cluster, usually in the Milky Way Galaxy
{NebSA , 3 }, // Stellar association
{NebSC , 3 }, // Star cloud
{NebN , 5 }, // A nebula
{NebPn , 7 }, // Planetary nebula
{NebDn , 6 }, // Dark Nebula
{NebRn , 5 }, // Reflection nebula
{NebBn , 5 }, // Bipolar nebula
{NebEn , 5 }, // Emission nebula
{NebCn , 9 }, // Cluster associated with nebulosity
{NebHII , 4 }, // HII Region
{NebSNR , 8 }, // Supernova remnant
{NebISM , 4 }, // Interstellar matter
//{NebEMO , }, // Emission object
{NebBLL , 1 }, // BL Lac object
{NebBLA , 1 }, // Blazar
{NebMolCld , 6 }, // Molecular Cloud
{NebYSO , 6 }, // Young Stellar Object
{NebPossQSO , 1 }, // Possible Quasar
{NebPossPN , 7 }, // Possible Planetary Nebula
{NebPPN , 7 }, // Protoplanetary Nebula
//{NebStar , }, // Star
//{NebSymbioticStar , }, // Symbiotic Star
//{NebEmissionLineStar , }, // Emission-line Star
{NebSNC , 8 }, // Supernova Candidate
{NebSNRC , 8 }, // Supernova Remnant Candidate
{NebGxCl , 10 }, // Cluster of Galaxies
//{NebPartOfGx , }, // Part of a Galaxy
//{NebRegion , }, // Region of the sky
{NebUnknown , 12 } // m Unknown type, catalog errors, "Unidentified Southern Objects" etc.
};
const int cntype = map.value(nType, 12);
// These "displayed types" are now:
// 0 = Galaxies
// 1 = Active Galaxies
// 2 = Interacting Galaxies
// 3 = Open Star Clusters
// 4 = Hydrogen regions (include interstellar matter)
// 5 = Bright Nebulae
// 6 = Dark Nebulae
// 7 = Planetary Nebulae
// 8 = Supernova Remnants
// 9 = Cl. assoc.w.Neb
//10 = Galaxy cluster
//11 = Globular Cluster
//12 = Unknown or other
// TODO: Why can we not just map to TypeGroupFlags and need yet another cntype index?

bool r = ( (typeFilters&TypeGalaxies && cntype==0)
|| (typeFilters&TypeActiveGalaxies && cntype==1)
|| (typeFilters&TypeInteractingGalaxies && cntype==2)
Expand Down
6 changes: 5 additions & 1 deletion src/core/modules/Nebula.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ friend class NebulaMgr;
QString getEnglishName() const override {return englishName;}
QString getEnglishAliases() const;
QString getI18nAliases() const;
//! Return the angular radius of a circle containing the object as seen from the observer
//! with the circle center assumed to be at getJ2000EquatorialPos().
//! @return radius in degree. This value is the apparent angular size of the object, and is independent of the current FOV.
double getAngularRadius(const StelCore*) const override;
SphericalRegionP getRegion() const override {return pointRegion;}

Expand Down Expand Up @@ -347,7 +350,8 @@ friend class NebulaMgr;
static StelTextureSP texRegion; // The symbolic dashed shape texture
static StelTextureSP texPointElement;
static StelTextureSP texPlanetaryNebula; // Type 3
static float hintsBrightness;
static double hintsBrightness;
static double labelsBrightness;

static Vec3f labelColor; // The color of labels
static QMap<Nebula::NebulaType, Vec3f>hintColorMap; // map for rapid lookup. Updated by NebulaMgr whenever a color changes.
Expand Down
Loading
Loading