Skip to content

Commit 6ac84fd

Browse files
committed
Move ConstellationMgr::ConstellationDisplayStyle to StelObject::CulturalDisplayStyle
- Start extending options - Actual display not changed yet
1 parent 4824507 commit 6ac84fd

7 files changed

+139
-66
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
@@ -186,27 +186,62 @@ void Constellation::drawOptim(StelPainter& sPainter, const StelCore* core, const
186186
}
187187
}
188188

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

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

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),
@@ -113,7 +113,7 @@ void ConstellationMgr::init()
113113
qWarning() << "viewing/constellation_name_style (" << skyCultureDisplayStyle << ") invalid. Using translated style.";
114114
conf->setValue("viewing/constellation_name_style", "translated");
115115
}
116-
setConstellationDisplayStyle(ConstellationDisplayStyleMap.value(skyCultureDisplayStyle, Translated));
116+
setConstellationDisplayStyle(ConstellationDisplayStyleMap.value(skyCultureDisplayStyle, StelObject::CulturalDisplayStyle::Translated));
117117

118118
// Load colors from config file
119119
QString defaultColor = conf->value("color/default_color").toString();
@@ -397,19 +397,20 @@ int ConstellationMgr::getFontSize() const
397397
return asterFont.pixelSize();
398398
}
399399

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

407-
QString ConstellationMgr::getConstellationDisplayStyleString(ConstellationDisplayStyle style)
408+
QString ConstellationMgr::getConstellationDisplayStyleString(StelObject::CulturalDisplayStyle style)
408409
{
409-
return (style == Abbreviated ? "abbreviated" : (style == Native ? "native" : "translated"));
410+
return (style == StelObject::CulturalDisplayStyle::Abbreviated ? "abbreviated" : (style == StelObject::CulturalDisplayStyle::Native ? "native" : "translated"));
410411
}
411412

412-
ConstellationMgr::ConstellationDisplayStyle ConstellationMgr::getConstellationDisplayStyle()
413+
StelObject::CulturalDisplayStyle ConstellationMgr::getConstellationDisplayStyle()
413414
{
414415
return constellationDisplayStyle;
415416
}
@@ -1433,8 +1434,9 @@ Constellation* ConstellationMgr::isObjectIn(const StelObject *s) const
14331434
return Q_NULLPTR;
14341435
}
14351436

1436-
const QMap<QString, ConstellationMgr::ConstellationDisplayStyle>ConstellationMgr::ConstellationDisplayStyleMap={
1437-
{ "translated", Translated},
1438-
{ "native", Native},
1439-
{ "abbreviated", Abbreviated},
1440-
{ "english", English}};
1437+
// TODO: More to come. Probably move to StelObject!
1438+
const QMap<QString, StelObject::CulturalDisplayStyle>ConstellationMgr::ConstellationDisplayStyleMap={
1439+
{ "translated", StelObject::CulturalDisplayStyle::Translated},
1440+
{ "native", StelObject::CulturalDisplayStyle::Native},
1441+
{ "abbreviated", StelObject::CulturalDisplayStyle::Abbreviated},
1442+
{ "english", StelObject::CulturalDisplayStyle::Modern}};

0 commit comments

Comments
 (0)