Skip to content

Commit cb6ebc4

Browse files
committed
Move ConstellationMgr::ConstellationDisplayStyle to StelObject::CulturalDisplayStyle
- Start extending options - Actual display not changed yet
1 parent 2a91673 commit cb6ebc4

7 files changed

+119
-49
lines changed

src/core/StelObject.hpp

+36
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,42 @@ class StelObject : public StelRegionObject
7979
Q_DECLARE_FLAGS(InfoStringGroup, InfoStringGroupFlags)
8080
Q_FLAG(InfoStringGroup)
8181

82+
83+
//! Describes how to display culture aware labels for constellation, planets, star names, .... The viewDialog GUI has comboboxes which corresponds to these values.
84+
//! It may be necessary to have different settings for screen labels (usually shorter) and InfoString labels (may be set to more complete)
85+
//! Then apply separately to Constellations and Planets, and whether applied to screen labels or infoString.
86+
//! TODO: This could of course become a bitfield, but having just a choice of discrete options may still be easier to maintain.
87+
//! TODO: In any case, this will require methods getScreenLabel() and getInfoLabel() in StelObject.
88+
enum class CulturalDisplayStyle // TODO: Not sure about class yet. It may be easier to store the enums as ints, not long strings.
89+
{
90+
Abbreviated = 0, // short label
91+
Native = 1, // may show non-Latin glyphs
92+
Translated = 2, // Just user language. This is the most common case for people casually interested in the topic.
93+
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.
94+
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.
95+
Translit = 5, // Non-translatable scientific transliteration that is not a pronounciation aid. Only known use case is Tibetan/Wiley.
96+
IPA = 6, // International Phonetic Alphabet, a standardized pronunciation aid
97+
Pronounce_Translated, // combinations: user language letters + translation
98+
Pronounce_IPA_Translated, // user language letters + phonetic + translation
99+
Pronounce_Translated_Modern, // user language letters + translation + Modern Name
100+
Pronounce_IPA_Translated_Modern, // user language letters + phonetics + translation + Modern Name
101+
Native_Pronounce, // just help reading foreign glyphs.
102+
Native_Pronounce_Translated, // foreign glyphs, own pronunciation aid, translation
103+
Native_Pronounce_IPA_Translated, // foreign glyphs, own pronunciation aid, phonetics, translation
104+
Native_Translated, // glyphs + user language
105+
Native_Translit_Translated, // glyphs + sci.transliteration, translation
106+
Native_Translit_Pronounce_Translated, // glyphs + sci.transliteration, pronunciation for mortals, translation
107+
Native_Translit_Pronounce_IPA_Translated, // glyphs + sci.transliteration, pronunciation for mortals, phonetics, translation
108+
Native_Translit_IPA_Translated, // glyphs + sci.transliteration, phonetics, translation
109+
Translit_Translated, // sci.transliteration, translation
110+
Translit_Pronounce_Translated, // sci.transliteration, pronunciation for mortals, translation
111+
Translit_Pronounce_IPA_Translated, // sci.transliteration, pronunciation for mortals, phonetics, translation
112+
Translit_IPA_Translated, // sci.transliteration, phonetics, translation
113+
}; // MORE OPTIONS NEEDED?
114+
Q_ENUM(CulturalDisplayStyle)
115+
116+
117+
82118
//! A pre-defined "all available" set of specifiers for the getInfoString flags argument to getInfoString
83119
static constexpr InfoStringGroup AllInfo = static_cast<InfoStringGroup>(Name|CatalogNumber|Magnitude|RaDecJ2000|RaDecOfDate|AltAzi|
84120
Distance|Elongation|Size|Velocity|ProperMotion|Extra|HourAngle|AbsoluteMagnitude|

src/core/modules/Constellation.cpp

+42-7
Original file line numberDiff line numberDiff line change
@@ -184,27 +184,62 @@ void Constellation::drawOptim(StelPainter& sPainter, const StelCore* core, const
184184
}
185185
}
186186

187-
void Constellation::drawName(StelPainter& sPainter, ConstellationMgr::ConstellationDisplayStyle style) const
187+
void Constellation::drawName(StelPainter& sPainter, StelObject::CulturalDisplayStyle style) const
188188
{
189189
if (nameFader.getInterstate()==0.0f)
190190
return;
191191

192+
// TODO: Find a solution of fallbacks when components are missing?
192193
if (checkVisibility())
193194
{
194195
QString name;
195196
switch (style)
196197
{
197-
case ConstellationMgr::Translated:
198-
name=nameI18;
198+
case CulturalDisplayStyle::Abbreviated:
199+
name=(abbreviation.startsWith('.') ? "" : abbreviation);
199200
break;
200-
case ConstellationMgr::Native:
201+
case CulturalDisplayStyle::Native:
201202
name=nativeName;
202203
break;
203-
case ConstellationMgr::English:
204+
case CulturalDisplayStyle::Translated:
205+
name=nameI18;
206+
break;
207+
case CulturalDisplayStyle::Modern:
204208
name=englishName;
205209
break;
206-
case ConstellationMgr::Abbreviated:
207-
name=(abbreviation.startsWith('.') ? "" : abbreviation);
210+
case CulturalDisplayStyle::Pronounce:
211+
name=englishName;
212+
break;
213+
case CulturalDisplayStyle::Translit:
214+
name=englishName;
215+
break;
216+
case CulturalDisplayStyle::IPA:
217+
name=nativeNameIPA;
218+
break;
219+
case CulturalDisplayStyle::Pronounce_Translated:
220+
name=QString("%1 (%2)").arg(nativeNamePronounce, nameI18);
221+
break;
222+
case CulturalDisplayStyle::Pronounce_IPA_Translated:
223+
name=QString("%1 [%2] (%3)").arg(nativeNamePronounce, nativeNameIPA, englishName);
224+
break;
225+
case CulturalDisplayStyle::Pronounce_Translated_Modern:
226+
name=QString("%1 (%2, %3)").arg(nativeNamePronounce, nameI18, englishName);
227+
break;
228+
case CulturalDisplayStyle::Pronounce_IPA_Translated_Modern:
229+
name=QString("%1 [%2] (%3, %4)").arg(nativeNamePronounce, nativeNameIPA, nameI18, englishName);
230+
break;
231+
case CulturalDisplayStyle::Native_Pronounce:
232+
name=QString("%1 [%2]").arg(nativeName, nativeNamePronounce);
233+
break;
234+
case CulturalDisplayStyle::Native_Pronounce_Translated:
235+
name=QString("%1 [%2] (%3)").arg(nativeName, nativeNamePronounce, nameI18);
236+
break;
237+
case CulturalDisplayStyle::Native_Pronounce_IPA_Translated:
238+
name=QString("%1 [%2, %3] (%4)").arg(nativeName, nativeNamePronounce, nativeNameIPA, nameI18);
239+
break;
240+
// TODO: MORE TO COME!
241+
default: // pronounce + translated...
242+
name=QString("%1 (%2)").arg(nativeNamePronounce, nameI18);
208243
break;
209244
}
210245

src/core/modules/Constellation.hpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ class Constellation : public StelObject
8383
//! @return false if can't parse record (invalid result!), else true.
8484
bool read(const QJsonObject& data, StarMgr *starMgr, bool preferNativeNames);
8585

86-
//! Draw the constellation name
87-
void drawName(StelPainter& sPainter, ConstellationMgr::ConstellationDisplayStyle style) const;
86+
//! Draw the constellation name. Depending on completeness of names and data, there may be a rich set of options to display.
87+
void drawName(StelPainter& sPainter, CulturalDisplayStyle style) const;
8888
//! Draw the constellation art
8989
void drawArt(StelPainter& sPainter) const;
9090
//! Draw the constellation boundary. obsVelocity used for aberration
@@ -160,6 +160,10 @@ class Constellation : public StelObject
160160
QString nativeName;
161161
//! Pronouncement of the native name or the romanized version of native name of constellation
162162
QString nativeNamePronounce;
163+
//! Pronunciation aid in International Phonetic Alphabet (future addition)
164+
QString nativeNameIPA;
165+
//! A scientific transliteration that does not help pronunciation. (Example: Tibetan/Wylie.)
166+
QString nativeNameTranslit;
163167
//! Abbreviation (the short name or designation of constellations)
164168
//! For non-western, a skyculture designer must invent it. (usually 2-5 letters)
165169
//! This MUST be filled and be unique within a sky culture.

src/core/modules/ConstellationMgr.cpp

+13-11
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ConstellationMgr::ConstellationMgr(StarMgr *_hip_stars)
5252
: hipStarMgr(_hip_stars),
5353
isolateSelected(false),
5454
flagConstellationPick(false),
55-
constellationDisplayStyle(ConstellationMgr::Translated),
55+
constellationDisplayStyle(StelObject::CulturalDisplayStyle::Translated),
5656
artFadeDuration(2.),
5757
artIntensity(0),
5858
artIntensityMinimumFov(1.0),
@@ -107,7 +107,7 @@ void ConstellationMgr::init()
107107
qWarning() << "viewing/constellation_name_style (" << starloreDisplayStyle << ") invalid. Using translated style.";
108108
conf->setValue("viewing/constellation_name_style", "translated");
109109
}
110-
setConstellationDisplayStyle(ConstellationDisplayStyleMap.value(starloreDisplayStyle, Translated));
110+
setConstellationDisplayStyle(ConstellationDisplayStyleMap.value(starloreDisplayStyle, StelObject::CulturalDisplayStyle::Translated));
111111

112112
// Load colors from config file
113113
QString defaultColor = conf->value("color/default_color").toString();
@@ -391,19 +391,20 @@ int ConstellationMgr::getFontSize() const
391391
return asterFont.pixelSize();
392392
}
393393

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

401-
QString ConstellationMgr::getConstellationDisplayStyleString(ConstellationDisplayStyle style)
402+
QString ConstellationMgr::getConstellationDisplayStyleString(StelObject::CulturalDisplayStyle style)
402403
{
403-
return (style == Abbreviated ? "abbreviated" : (style == Native ? "native" : "translated"));
404+
return (style == StelObject::CulturalDisplayStyle::Abbreviated ? "abbreviated" : (style == StelObject::CulturalDisplayStyle::Native ? "native" : "translated"));
404405
}
405406

406-
ConstellationMgr::ConstellationDisplayStyle ConstellationMgr::getConstellationDisplayStyle()
407+
StelObject::CulturalDisplayStyle ConstellationMgr::getConstellationDisplayStyle()
407408
{
408409
return constellationDisplayStyle;
409410
}
@@ -1354,8 +1355,9 @@ Constellation* ConstellationMgr::isObjectIn(const StelObject *s) const
13541355
return Q_NULLPTR;
13551356
}
13561357

1357-
const QMap<QString, ConstellationMgr::ConstellationDisplayStyle>ConstellationMgr::ConstellationDisplayStyleMap={
1358-
{ "translated", Translated},
1359-
{ "native", Native},
1360-
{ "abbreviated", Abbreviated},
1361-
{ "english", English}};
1358+
// TODO: More to come. Probably move to StelObject!
1359+
const QMap<QString, StelObject::CulturalDisplayStyle>ConstellationMgr::ConstellationDisplayStyleMap={
1360+
{ "translated", StelObject::CulturalDisplayStyle::Translated},
1361+
{ "native", StelObject::CulturalDisplayStyle::Native},
1362+
{ "abbreviated", StelObject::CulturalDisplayStyle::Abbreviated},
1363+
{ "english", StelObject::CulturalDisplayStyle::Modern}};

src/core/modules/ConstellationMgr.hpp

+20-27
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "StelObjectType.hpp"
2525
#include "StelObjectModule.hpp"
26+
#include "StelObject.hpp"
2627

2728
#include <vector>
2829
#include <QString>
@@ -91,7 +92,7 @@ class ConstellationMgr : public StelObjectModule
9192
READ getFlagLabels
9293
WRITE setFlagLabels
9394
NOTIFY namesDisplayedChanged)
94-
Q_PROPERTY(ConstellationDisplayStyle constellationDisplayStyle
95+
Q_PROPERTY(StelObject::CulturalDisplayStyle constellationDisplayStyle
9596
READ getConstellationDisplayStyle
9697
WRITE setConstellationDisplayStyle
9798
NOTIFY constellationsDisplayStyleChanged)
@@ -145,26 +146,18 @@ class ConstellationMgr : public StelObjectModule
145146
QStringList listAllObjects(bool inEnglish) const override;
146147
QString getName() const override { return "Constellations"; }
147148
QString getStelObjectType() const override;
148-
//! Describes how to display constellation labels. The viewDialog GUI has a combobox which corresponds to these values.
149-
//! TODO: Move to become SkycultureMgr::DisplayStyle? Then apply separately to Constellations and Planets, and whether applied to screen labels or infoString.
150-
enum ConstellationDisplayStyle
151-
{
152-
Abbreviated = 0, // short label
153-
Native = 1, // may show non-Latin glyphs
154-
Translated = 2, // user language
155-
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.
156-
Translit = 4, // user-language transliteration/pronunciation aid
157-
Native_Translit, // combinations: just help reading foreign glyphs. MORE OPTIONS POSSIBLE!
158-
Native_Translit_Translated, // help reading foreign glyphs, show translations
159-
Native_Translit_IPA_Translated, // help reading foreign glyphs, phonetics, show translations
160-
Native_Translated, // glyphs + user language
161-
Translit_Translated, // user language letters + translation
162-
Translit_IPA_Translated, // user language letters, phonetic + translation
163-
Translit_Translated_English, // user language letters + translation + English Name
164-
Translit_IPA_Translated_English, // user language letters + translation + English Name
165-
166-
};
167-
Q_ENUM(ConstellationDisplayStyle)
149+
// Moved to become StelObject::CulturalDisplayStyle, Then apply maybe even separately to Constellations and Planets, and whether applied to screen labels or infoString.
150+
// Describes how to display constellation labels. The viewDialog GUI has a combobox which corresponds to these values.
151+
// TODO: This could of course become a bitfield, but having just discrete options may still be easier to maintain.
152+
//enum ConstellationDisplayStyle
153+
//{
154+
// Abbreviated = 0, // short label
155+
// Native = 1, // may show non-Latin glyphs
156+
// Translated = 2, // user language
157+
// 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.
158+
// 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.
159+
//};
160+
//Q_ENUM(ConstellationDisplayStyle)
168161

169162
///////////////////////////////////////////////////////////////////////////
170163
// Properties setters and getters
@@ -266,12 +259,12 @@ public slots:
266259

267260
//! Set the way how constellation names are displayed: abbreviated/as-given/translated
268261
//! @param style the new display style
269-
void setConstellationDisplayStyle(ConstellationMgr::ConstellationDisplayStyle style);
262+
void setConstellationDisplayStyle(StelObject::CulturalDisplayStyle style);
270263
//! get the way how constellation names are displayed: abbreviated/as-given/translated
271-
ConstellationMgr::ConstellationDisplayStyle getConstellationDisplayStyle();
264+
StelObject::CulturalDisplayStyle getConstellationDisplayStyle();
272265
//! Returns the currently set constellation display style as string, instead of enum
273266
//! @see getConstellationDisplayStyle()
274-
static QString getConstellationDisplayStyleString(ConstellationMgr::ConstellationDisplayStyle style);
267+
static QString getConstellationDisplayStyleString(StelObject::CulturalDisplayStyle style);
275268

276269
//! Set the thickness of lines of the constellations
277270
//! @param thickness of line in pixels
@@ -337,7 +330,7 @@ public slots:
337330
void linesDisplayedChanged(const bool displayed);
338331
void namesColorChanged(const Vec3f & color);
339332
void namesDisplayedChanged(const bool displayed);
340-
void constellationsDisplayStyleChanged(const ConstellationMgr::ConstellationDisplayStyle style);
333+
void constellationsDisplayStyleChanged(const StelObject::CulturalDisplayStyle style);
341334
void constellationLineThicknessChanged(int thickness);
342335
void constellationBoundariesThicknessChanged(int thickness);
343336

@@ -418,8 +411,8 @@ private slots:
418411
QStringList constellationsEnglishNames;
419412

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

424417
// These are THE master settings - individual constellation settings can vary based on selection status
425418
float artFadeDuration;

src/core/modules/StarMgr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ StarMgr::~StarMgr(void)
190190
QString StarMgr::getCommonName(StarId hip)
191191
{
192192
ConstellationMgr* cmgr=GETSTELMODULE(ConstellationMgr);
193-
if (cmgr->getConstellationDisplayStyle() == ConstellationMgr::Native)
193+
if (cmgr->getConstellationDisplayStyle() == StelObject::CulturalDisplayStyle::Native)
194194
return getCommonEnglishName(hip);
195195

196196
auto it = commonNamesMapI18n.find(hip);

src/gui/ConfigurationDialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ void ConfigurationDialog::saveAllSettings()
10531053
conf->setValue("viewing/flag_light_pollution_database", propMgr->getStelPropertyValue("LandscapeMgr.flagUseLightPollutionFromDatabase").toBool());
10541054
conf->setValue("viewing/flag_environment_auto_enable", propMgr->getStelPropertyValue("LandscapeMgr.flagEnvironmentAutoEnabling").toBool());
10551055
conf->setValue("viewing/constellation_art_intensity", propMgr->getStelPropertyValue("ConstellationMgr.artIntensity").toFloat());
1056-
conf->setValue("viewing/constellation_name_style", ConstellationMgr::getConstellationDisplayStyleString(static_cast<ConstellationMgr::ConstellationDisplayStyle> (propMgr->getStelPropertyValue("ConstellationMgr.constellationDisplayStyle").toInt()) ));
1056+
conf->setValue("viewing/constellation_name_style", ConstellationMgr::getConstellationDisplayStyleString(static_cast<StelObject::CulturalDisplayStyle> (propMgr->getStelPropertyValue("ConstellationMgr.constellationDisplayStyle").toInt()) ));
10571057
conf->setValue("viewing/constellation_line_thickness", propMgr->getStelPropertyValue("ConstellationMgr.constellationLineThickness").toInt());
10581058
conf->setValue("viewing/constellation_boundaries_thickness", propMgr->getStelPropertyValue("ConstellationMgr.constellationBoundariesThickness").toInt());
10591059

0 commit comments

Comments
 (0)