Skip to content

Commit 2f947dc

Browse files
committed
Show object constellation info in InfoString
- based on convex hull info. - not used when convex hulls have been disabled.
1 parent f2b98cf commit 2f947dc

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/core/StelObject.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020

2121
#include "StelObject.hpp"
22+
#include "Constellation.hpp"
2223
#include "ConstellationMgr.hpp"
2324
#include "StelObjectMgr.hpp"
2425
#include "StelApp.hpp"
@@ -35,6 +36,7 @@
3536
#include "SpecificTimeMgr.hpp"
3637
#include "planetsephems/sidereal_time.h"
3738
#include "planetsephems/precession.h"
39+
#include <qforeach.h>
3840

3941
#include <QRegularExpression>
4042
#include <QDebug>
@@ -968,6 +970,26 @@ QString StelObject::getCommonInfoString(const StelCore *core, const InfoStringGr
968970
res += QString("%1: %2<br/>").arg(q_("IAU Constellation"), constel);
969971
res += getExtraInfoStrings(flags&IAUConstellation).join("");
970972
res += omgr->getExtraInfoStrings(flags&IAUConstellation).join("");
973+
974+
// Add constellation from convex hull, if that is enabled in the first place.
975+
static QSettings *conf=StelApp::getInstance().getSettings();
976+
static const bool hullsEnabled = conf->value("gui/skyculture_enable_hulls", "false").toBool();
977+
if (hullsEnabled)
978+
{
979+
QList<Constellation*> constels=cMgr->isObjectIn(this, true);
980+
QString constelStr="---";
981+
if (!constels.isEmpty())
982+
{
983+
QStringList cNames;
984+
foreach(const auto &cst, constels)
985+
{
986+
cNames.append(cst->getInfoLabel());
987+
}
988+
constelStr = cNames.join(", ");
989+
}
990+
res += QString("%1: %2<br/>").arg(q_("Constellations"), constelStr);
991+
}
992+
971993
if (cMgr->hasZodiac() && (currentPlanet=="Earth"))
972994
{
973995
QString zodiacSystemLabel = cMgr->getZodiacSystemName();

src/core/modules/Constellation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ class Constellation : public StelObject
120120
QString getNamePronounce() const override {return (culturalName.pronounceI18n.isEmpty() ? culturalName.native : culturalName.pronounceI18n);}
121121
//! Get the short name for the Constellation (returns the translated version of abbreviation).
122122
QString getShortName() const {return abbreviationI18n;}
123+
public:
123124
//! Combine screen label from various components, depending on settings in SkyCultureMgr
124125
QString getScreenLabel() const override;
125126
//! Combine InfoString label from various components, depending on settings in SkyCultureMgr
126127
QString getInfoLabel() const override;
128+
private:
127129
//! Underlying worker
128130
QString getCultureLabel(StelObject::CulturalDisplayStyle style) const;
129131
//! Draw the lines for the Constellation.

src/core/modules/ConstellationMgr.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,12 @@ private slots:
515515

516516
QList<Constellation*> selected; // More than one can be selected at a time
517517

518+
public:
518519
//! Return list of constellations the object is member of.
519520
//! In case of IAU constellations, the list is guaranteed to be of length 1.
520521
//! @param useHull Prefer to use constellation hull, not IAU borders
521522
QList<Constellation*> isObjectIn(const StelObject *s, bool useHull) const;
523+
private:
522524
Constellation* findFromAbbreviation(const QString& abbreviation) const;
523525
QList<Constellation*> constellations; //!< Constellations in the current SkyCulture
524526
QFont asterFont;

0 commit comments

Comments
 (0)