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

Multiple label options for Skycultures #4179

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
36 changes: 36 additions & 0 deletions src/core/StelObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,42 @@ class StelObject : public StelRegionObject
Q_DECLARE_FLAGS(InfoStringGroup, InfoStringGroupFlags)
Q_FLAG(InfoStringGroup)


//! Describes how to display culture aware labels for constellation, planets, star names, .... The viewDialog GUI has comboboxes which corresponds to these values.
//! It may be necessary to have different settings for screen labels (usually shorter) and InfoString labels (may be set to more complete)
//! Then apply separately to Constellations and Planets, and whether applied to screen labels or infoString.
//! TODO: This could of course become a bitfield, but having just a choice of discrete options may still be easier to maintain.
//! TODO: In any case, this will require methods getScreenLabel() and getInfoLabel() in StelObject.
enum class CulturalDisplayStyle // TODO: Not sure about class yet. It may be easier to store the enums as ints, not long strings.
{
Abbreviated = 0, // short label
Native = 1, // may show non-Latin glyphs
Translated = 2, // Just user language. This is the most common case for people casually interested in the topic.
Modern = 3, // Was: English. Useful in case of adding names in modern English/userlanguage terminology (planets etc.). Should show object scientific name in modern terminology, translated.
Pronounce = 4, // user-language transliteration/pronunciation aid. Usually the original form like pinyin is also used in users' languages, but it may be translatable to user language, e.g. into another coding system like Cyrillic.
Translit = 5, // Non-translatable scientific transliteration that is not a pronounciation aid. Only known use case is Tibetan/Wiley.
IPA = 6, // International Phonetic Alphabet, a standardized pronunciation aid
Pronounce_Translated, // combinations: user language letters + translation
Pronounce_IPA_Translated, // user language letters + phonetic + translation
Pronounce_Translated_Modern, // user language letters + translation + Modern Name
Pronounce_IPA_Translated_Modern, // user language letters + phonetics + translation + Modern Name
Native_Pronounce, // just help reading foreign glyphs.
Native_Pronounce_Translated, // foreign glyphs, own pronunciation aid, translation
Native_Pronounce_IPA_Translated, // foreign glyphs, own pronunciation aid, phonetics, translation
Native_Translated, // glyphs + user language
Native_Translit_Translated, // glyphs + sci.transliteration, translation
Native_Translit_Pronounce_Translated, // glyphs + sci.transliteration, pronunciation for mortals, translation
Native_Translit_Pronounce_IPA_Translated, // glyphs + sci.transliteration, pronunciation for mortals, phonetics, translation
Native_Translit_IPA_Translated, // glyphs + sci.transliteration, phonetics, translation
Translit_Translated, // sci.transliteration, translation
Translit_Pronounce_Translated, // sci.transliteration, pronunciation for mortals, translation
Translit_Pronounce_IPA_Translated, // sci.transliteration, pronunciation for mortals, phonetics, translation
Translit_IPA_Translated, // sci.transliteration, phonetics, translation
}; // MORE OPTIONS NEEDED?
Q_ENUM(CulturalDisplayStyle)



//! A pre-defined "all available" set of specifiers for the getInfoString flags argument to getInfoString
static constexpr InfoStringGroup AllInfo = static_cast<InfoStringGroup>(Name|CatalogNumber|Magnitude|RaDecJ2000|RaDecOfDate|AltAzi|
Distance|Elongation|Size|Velocity|ProperMotion|Extra|HourAngle|AbsoluteMagnitude|
Expand Down
2 changes: 1 addition & 1 deletion src/core/modules/AsterismMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void AsterismMgr::updateSkyCulture(const StelSkyCulture& skyCulture)
asterisms.clear();
selected.clear();
hasAsterism = false;
qWarning() << "No asterisms for skyculture" << currentSkyCultureID;
qInfo() << "No asterisms for skyculture" << currentSkyCultureID;
}
else
{
Expand Down
49 changes: 42 additions & 7 deletions src/core/modules/Constellation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,35 +184,70 @@
}
}

void Constellation::drawName(StelPainter& sPainter, ConstellationMgr::ConstellationDisplayStyle style) const
void Constellation::drawName(StelPainter& sPainter, StelObject::CulturalDisplayStyle style) const
{
if (nameFader.getInterstate()==0.0f)
return;

// TODO: Find a solution of fallbacks when components are missing?
if (checkVisibility())
{
QString name;
switch (style)
{
case ConstellationMgr::constellationsTranslated:
name=nameI18;
case CulturalDisplayStyle::Abbreviated:
name=(abbreviation.startsWith('.') ? "" : abbreviation);
break;
case ConstellationMgr::constellationsNative:
case CulturalDisplayStyle::Native:
name=nativeName;
break;
case ConstellationMgr::constellationsEnglish:
case CulturalDisplayStyle::Translated:
name=nameI18;
break;
case CulturalDisplayStyle::Modern:
name=englishName;
break;
case ConstellationMgr::constellationsAbbreviated:
name=(abbreviation.startsWith('.') ? "" : abbreviation);
case CulturalDisplayStyle::Pronounce:
name=englishName;
break;
case CulturalDisplayStyle::Translit:
name=englishName;
break;
case CulturalDisplayStyle::IPA:
name=nativeNameIPA;
break;
case CulturalDisplayStyle::Pronounce_Translated:
name=QString("%1 (%2)").arg(nativeNamePronounce, nameI18);
break;
case CulturalDisplayStyle::Pronounce_IPA_Translated:
name=QString("%1 [%2] (%3)").arg(nativeNamePronounce, nativeNameIPA, englishName);
break;
case CulturalDisplayStyle::Pronounce_Translated_Modern:
name=QString("%1 (%2, %3)").arg(nativeNamePronounce, nameI18, englishName);
break;
case CulturalDisplayStyle::Pronounce_IPA_Translated_Modern:
name=QString("%1 [%2] (%3, %4)").arg(nativeNamePronounce, nativeNameIPA, nameI18, englishName);
break;
case CulturalDisplayStyle::Native_Pronounce:
name=QString("%1 [%2]").arg(nativeName, nativeNamePronounce);
break;
case CulturalDisplayStyle::Native_Pronounce_Translated:
name=QString("%1 [%2] (%3)").arg(nativeName, nativeNamePronounce, nameI18);
break;
case CulturalDisplayStyle::Native_Pronounce_IPA_Translated:
name=QString("%1 [%2, %3] (%4)").arg(nativeName, nativeNamePronounce, nativeNameIPA, nameI18);
break;
// TODO: MORE TO COME!
default: // pronounce + translated...
name=QString("%1 (%2)").arg(nativeNamePronounce, nameI18);
break;
}

sPainter.setColor(labelColor, nameFader.getInterstate());
sPainter.drawText(static_cast<float>(XYname[0]), static_cast<float>(XYname[1]), name, 0., -sPainter.getFontMetrics().boundingRect(name).width()/2, 0, false);
}
}

Check notice on line 250 in src/core/modules/Constellation.cpp

View check run for this annotation

codefactor.io / CodeFactor

src/core/modules/Constellation.cpp#L187-L250

Complex Method
void Constellation::drawArtOptim(StelPainter& sPainter, const SphericalRegion& region, const Vec3d& obsVelocity) const
{
if (checkVisibility())
Expand Down
8 changes: 6 additions & 2 deletions src/core/modules/Constellation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class Constellation : public StelObject
//! @return false if can't parse record (invalid result!), else true.
bool read(const QJsonObject& data, StarMgr *starMgr, bool preferNativeNames);

//! Draw the constellation name
void drawName(StelPainter& sPainter, ConstellationMgr::ConstellationDisplayStyle style) const;
//! Draw the constellation name. Depending on completeness of names and data, there may be a rich set of options to display.
void drawName(StelPainter& sPainter, CulturalDisplayStyle style) const;
//! Draw the constellation art
void drawArt(StelPainter& sPainter) const;
//! Draw the constellation boundary. obsVelocity used for aberration
Expand Down Expand Up @@ -160,6 +160,10 @@ class Constellation : public StelObject
QString nativeName;
//! Pronouncement of the native name or the romanized version of native name of constellation
QString nativeNamePronounce;
//! Pronunciation aid in International Phonetic Alphabet (future addition)
QString nativeNameIPA;
//! A scientific transliteration that does not help pronunciation. (Example: Tibetan/Wylie.)
QString nativeNameTranslit;
//! Abbreviation (the short name or designation of constellations)
//! For non-western, a skyculture designer must invent it. (usually 2-5 letters)
//! This MUST be filled and be unique within a sky culture.
Expand Down
26 changes: 14 additions & 12 deletions src/core/modules/ConstellationMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ConstellationMgr::ConstellationMgr(StarMgr *_hip_stars)
: hipStarMgr(_hip_stars),
isolateSelected(false),
flagConstellationPick(false),
constellationDisplayStyle(ConstellationMgr::constellationsTranslated),
constellationDisplayStyle(StelObject::CulturalDisplayStyle::Translated),
artFadeDuration(2.),
artIntensity(0),
artIntensityMinimumFov(1.0),
Expand Down Expand Up @@ -107,7 +107,7 @@ void ConstellationMgr::init()
qWarning() << "viewing/constellation_name_style (" << starloreDisplayStyle << ") invalid. Using translated style.";
conf->setValue("viewing/constellation_name_style", "translated");
}
setConstellationDisplayStyle(ConstellationDisplayStyleMap.value(starloreDisplayStyle, constellationsTranslated));
setConstellationDisplayStyle(ConstellationDisplayStyleMap.value(starloreDisplayStyle, StelObject::CulturalDisplayStyle::Translated));

// Load colors from config file
QString defaultColor = conf->value("color/default_color").toString();
Expand Down Expand Up @@ -173,7 +173,7 @@ void ConstellationMgr::updateSkyCulture(const StelSkyCulture& skyCulture)
int i = 1;
for (auto* constellation : constellations)
{
qWarning() << "[Constellation] #" << i << " abbr:" << constellation->abbreviation << " name:" << constellation->getEnglishName() << " segments:" << constellation->numberOfSegments;
qInfo() << "[Constellation] #" << i << " abbr:" << constellation->abbreviation << " name:" << constellation->getEnglishName() << " segments:" << constellation->numberOfSegments;
i++;
}
}
Expand Down Expand Up @@ -391,19 +391,20 @@ int ConstellationMgr::getFontSize() const
return asterFont.pixelSize();
}

void ConstellationMgr::setConstellationDisplayStyle(ConstellationDisplayStyle style)
void ConstellationMgr::setConstellationDisplayStyle(StelObject::CulturalDisplayStyle style)
{
// TODO: Store this per-skyculture! Maybe open a new group in config.ini?
constellationDisplayStyle=style;
StelApp::immediateSave("viewing/constellation_name_style", ConstellationDisplayStyleMap.key(style));
emit constellationsDisplayStyleChanged(constellationDisplayStyle);
}

QString ConstellationMgr::getConstellationDisplayStyleString(ConstellationDisplayStyle style)
QString ConstellationMgr::getConstellationDisplayStyleString(StelObject::CulturalDisplayStyle style)
{
return (style == constellationsAbbreviated ? "abbreviated" : (style == constellationsNative ? "native" : "translated"));
return (style == StelObject::CulturalDisplayStyle::Abbreviated ? "abbreviated" : (style == StelObject::CulturalDisplayStyle::Native ? "native" : "translated"));
}

ConstellationMgr::ConstellationDisplayStyle ConstellationMgr::getConstellationDisplayStyle()
StelObject::CulturalDisplayStyle ConstellationMgr::getConstellationDisplayStyle()
{
return constellationDisplayStyle;
}
Expand Down Expand Up @@ -1354,8 +1355,9 @@ Constellation* ConstellationMgr::isObjectIn(const StelObject *s) const
return Q_NULLPTR;
}

const QMap<QString, ConstellationMgr::ConstellationDisplayStyle>ConstellationMgr::ConstellationDisplayStyleMap={
{ "translated", constellationsTranslated},
{ "native", constellationsNative},
{ "abbreviated", constellationsAbbreviated},
{ "english", constellationsEnglish}};
// TODO: More to come. Probably move to StelObject!
const QMap<QString, StelObject::CulturalDisplayStyle>ConstellationMgr::ConstellationDisplayStyleMap={
{ "translated", StelObject::CulturalDisplayStyle::Translated},
{ "native", StelObject::CulturalDisplayStyle::Native},
{ "abbreviated", StelObject::CulturalDisplayStyle::Abbreviated},
{ "english", StelObject::CulturalDisplayStyle::Modern}};
36 changes: 20 additions & 16 deletions src/core/modules/ConstellationMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "StelObjectType.hpp"
#include "StelObjectModule.hpp"
#include "StelObject.hpp"

#include <vector>
#include <QString>
Expand Down Expand Up @@ -91,7 +92,7 @@ class ConstellationMgr : public StelObjectModule
READ getFlagLabels
WRITE setFlagLabels
NOTIFY namesDisplayedChanged)
Q_PROPERTY(ConstellationDisplayStyle constellationDisplayStyle
Q_PROPERTY(StelObject::CulturalDisplayStyle constellationDisplayStyle
READ getConstellationDisplayStyle
WRITE setConstellationDisplayStyle
NOTIFY constellationsDisplayStyleChanged)
Expand Down Expand Up @@ -145,15 +146,18 @@ class ConstellationMgr : public StelObjectModule
QStringList listAllObjects(bool inEnglish) const override;
QString getName() const override { return "Constellations"; }
QString getStelObjectType() const override;
//! Describes how to display constellation labels. The viewDialog GUI has a combobox which corresponds to these values.
enum ConstellationDisplayStyle
{
constellationsAbbreviated = 0,
constellationsNative = 1,
constellationsTranslated = 2,
constellationsEnglish = 3 // Maybe this is not useful?
};
Q_ENUM(ConstellationDisplayStyle)
// Moved to become StelObject::CulturalDisplayStyle, Then apply maybe even separately to Constellations and Planets, and whether applied to screen labels or infoString.
// Describes how to display constellation labels. The viewDialog GUI has a combobox which corresponds to these values.
// TODO: This could of course become a bitfield, but having just discrete options may still be easier to maintain.
//enum ConstellationDisplayStyle
//{
// Abbreviated = 0, // short label
// Native = 1, // may show non-Latin glyphs
// Translated = 2, // user language
// English = 3, // Useful in case of adding names in modern English terminology (planets etc.). Maybe "Modern" would be better, and should show object scientific name in modern terminology, translated.
// Pronounce = 4, // user-language transliteration/pronunciation aid. Usually the original form like pinyin is also used in users' languages, but it may be translatable to user language, e.g. for other coding system.
//};
//Q_ENUM(ConstellationDisplayStyle)

///////////////////////////////////////////////////////////////////////////
// Properties setters and getters
Expand Down Expand Up @@ -255,12 +259,12 @@ public slots:

//! Set the way how constellation names are displayed: abbreviated/as-given/translated
//! @param style the new display style
void setConstellationDisplayStyle(ConstellationMgr::ConstellationDisplayStyle style);
void setConstellationDisplayStyle(StelObject::CulturalDisplayStyle style);
//! get the way how constellation names are displayed: abbreviated/as-given/translated
ConstellationMgr::ConstellationDisplayStyle getConstellationDisplayStyle();
StelObject::CulturalDisplayStyle getConstellationDisplayStyle();
//! Returns the currently set constellation display style as string, instead of enum
//! @see getConstellationDisplayStyle()
static QString getConstellationDisplayStyleString(ConstellationMgr::ConstellationDisplayStyle style);
static QString getConstellationDisplayStyleString(StelObject::CulturalDisplayStyle style);

//! Set the thickness of lines of the constellations
//! @param thickness of line in pixels
Expand Down Expand Up @@ -326,7 +330,7 @@ public slots:
void linesDisplayedChanged(const bool displayed);
void namesColorChanged(const Vec3f & color);
void namesDisplayedChanged(const bool displayed);
void constellationsDisplayStyleChanged(const ConstellationMgr::ConstellationDisplayStyle style);
void constellationsDisplayStyleChanged(const StelObject::CulturalDisplayStyle style);
void constellationLineThicknessChanged(int thickness);
void constellationBoundariesThicknessChanged(int thickness);

Expand Down Expand Up @@ -407,8 +411,8 @@ private slots:
QStringList constellationsEnglishNames;

//! this controls how constellations (and also star names) are printed: Abbreviated/as-given/translated
ConstellationDisplayStyle constellationDisplayStyle;
static const QMap<QString, ConstellationDisplayStyle>ConstellationDisplayStyleMap;
StelObject::CulturalDisplayStyle constellationDisplayStyle;
static const QMap<QString, StelObject::CulturalDisplayStyle>ConstellationDisplayStyleMap;

// These are THE master settings - individual constellation settings can vary based on selection status
float artFadeDuration;
Expand Down
2 changes: 1 addition & 1 deletion src/core/modules/StarMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ StarMgr::~StarMgr(void)
QString StarMgr::getCommonName(StarId hip)
{
ConstellationMgr* cmgr=GETSTELMODULE(ConstellationMgr);
if (cmgr->getConstellationDisplayStyle() == ConstellationMgr::constellationsNative)
if (cmgr->getConstellationDisplayStyle() == StelObject::CulturalDisplayStyle::Native)
return getCommonEnglishName(hip);

auto it = commonNamesMapI18n.find(hip);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/ConfigurationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ void ConfigurationDialog::saveAllSettings()
conf->setValue("viewing/flag_light_pollution_database", propMgr->getStelPropertyValue("LandscapeMgr.flagUseLightPollutionFromDatabase").toBool());
conf->setValue("viewing/flag_environment_auto_enable", propMgr->getStelPropertyValue("LandscapeMgr.flagEnvironmentAutoEnabling").toBool());
conf->setValue("viewing/constellation_art_intensity", propMgr->getStelPropertyValue("ConstellationMgr.artIntensity").toFloat());
conf->setValue("viewing/constellation_name_style", ConstellationMgr::getConstellationDisplayStyleString(static_cast<ConstellationMgr::ConstellationDisplayStyle> (propMgr->getStelPropertyValue("ConstellationMgr.constellationDisplayStyle").toInt()) ));
conf->setValue("viewing/constellation_name_style", ConstellationMgr::getConstellationDisplayStyleString(static_cast<StelObject::CulturalDisplayStyle> (propMgr->getStelPropertyValue("ConstellationMgr.constellationDisplayStyle").toInt()) ));
conf->setValue("viewing/constellation_line_thickness", propMgr->getStelPropertyValue("ConstellationMgr.constellationLineThickness").toInt());
conf->setValue("viewing/constellation_boundaries_thickness", propMgr->getStelPropertyValue("ConstellationMgr.constellationBoundariesThickness").toInt());

Expand Down
Loading