• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 15670918640

16 Jun 2025 02:08AM UTC coverage: 11.775% (-0.2%) from 11.931%
15670918640

push

github

alex-w
Updated data

14700 of 124846 relevant lines covered (11.77%)

18324.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.86
/src/core/StelSkyCultureMgr.hpp
1
/*
2
 * Stellarium
3
 * Copyright (C) 2006 Fabien Chereau
4
 * 
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 * 
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 * 
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
18
 */
19

20
#ifndef STELSKYCULTUREMGR_HPP
21
#define STELSKYCULTUREMGR_HPP
22

23
#include <QObject>
24
#include <QMap>
25
#include <QString>
26
#include <QStringList>
27
#include <QJsonObject>
28
#include <QJsonArray>
29
#include "StelObject.hpp"
30
#include "StelModule.hpp"
31
#include "StelSkyCultureSkyPartition.hpp"
32

33
class StelTranslator;
34

35
//! @class StelSkyCulture
36
//! Store basic info about a sky culture for Stellarium.
37
//! Different human cultures have used different names for stars, and visualised
38
//! different constellations in the sky (and in different parts of the sky).
39
class StelSkyCulture
40
{
41
        Q_GADGET
42
public:
43
        //! Possible values for boundary lines between constellations.
44
        //! Most traditional skies do not have boundaries.
45
        //! Some atlases in the 18th and 19th centuries had curved boundaries that differed between authors.
46
        //! Only IAU implemented "approved" boundaries, but a similar technique could be used for other skycultures.
47
        enum class BoundariesType
48
        {
49
                None = -1,
50
                IAU,
51
                Own
52
        };
53
        Q_ENUM(BoundariesType)
×
54

55
        //! Since V0.19. A rough classification scheme that may allow filtering and at least some rough idea of quality control.
56
        //! In future versions, this scheme could be refined or changed, and external reviewers
57
        //! can probably provide more quality control. For now, we can at least highlight and discern
58
        //! "nice tries" from scientific work.
59
        //! The classes are not "quality grades" in ascending order, but also allow estimates about particular content.
60
        //! INCOMPLETE requires improvements, and PERSONAL usually means "nice, but not even Stellarium developers believe in it".
61
        enum CLASSIFICATION
62
        {
63
                INCOMPLETE=0,        //!< Looks like there is something interesting to it, but lacks references. Should evolve into one of the other kinds.
64
                                //!< There are some examples in our repositories from previous times that should be improved,
65
                                //!< else no new ones should be accepted.
66
                PERSONAL,        //!< Privately developed after ca. 1950, not based on published ethnographic or historical research, not supported by a noteworthy community.
67
                TRADITIONAL,        //!< Most "living" skycultures. May have evolved over centuries, with mixed influences from other cultures.
68
                                //!< Also for self-presentations by members of respective cultures, indigenous peoples or tribes.
69
                                //!< Description should provide a short description of the people and traditions, and the "cosmovision" of the people,
70
                                //!< some celestial myths, background information about the constellations (e.g. what does a "rabbit ghost" or "yellow man" mean for you?)
71
                                //!< Star names with meaning should be translated to English.
72
                                //!< Please provide "further reading" links for more information.
73
                ETHNOGRAPHIC,        //!< Created by foreigners doing ethnographic fieldwork in modern times.
74
                                //!< This usually is an "outside view", e.g. from ethnographic fieldwork, missionary reports, travelers, "adventurers" of the 19th century etc.
75
                                //!< Description should provide a short description of the way this skyculture has been recorded, about the
76
                                //!< people and traditions, and the "cosmovision" of the people, some celestial myths,
77
                                //!< background information about the constellations (e.g. what does a "rabbit ghost" or "yellow man" mean for them?)
78
                                //!< Star names with meaning should be translated to English.
79
                                //!< This is often published in singular rare to find books, or found in university collections or museum archives.
80
                                //!< These should come with links for published books, or how to find this information elsewhere.
81
                HISTORICAL,        //!< Skyculture from past time, recreated from textual transmission by historians.
82
                                //!< Typically nobody alive today shares the world view of these past cultures.
83
                                //!< The description should provide some insight over sources and how data were retrieved and interpreted,
84
                                //!< and should provide references to (optimally: peer-reviewed) published work.
85
                SINGLE,                //!< Implementation of a single book or atlas usually providing a "snapshot" of a traditional skyculture.
86
                                //!< e.g. Bayer, Schiller, Hevelius, Bode, Rey, ...
87
                                //!< Content (star names, artwork, spelling, ...) should not deviate from what the atlas contains.
88
                                //!< The description should provide information about the presented work, and if possible a link to a digital online version.
89
                COMPARATIVE        //!< Special-purpose compositions of artwork from one and stick figures from another skyculture. These figures
90
                                //!< sometimes will appear not to fit together well. This may be intended, to explain and highlight just those differences!
91
                                //!< The description text must clearly explain and identify both sources and how these differences should be interpreted.
92
        };
93
        Q_ENUM(CLASSIFICATION)
×
94

95
        //! Sky culture identifier (usually same as directory name)
96
        QString id;
97
        //! Full directory path
98
        QString path;
99
        //! English name
100
        QString englishName;
101
        //! The license
102
        QString license;
103
        //! The name of region following the United Nations geoscheme UN~M49 https://unstats.un.org/unsd/methodology/m49/
104
        //! For skycultures of worldwide applicability (mostly those adhering to IAU constellation borders), use "World".
105
        QString region;
106
        //! Type of the boundaries
107
        BoundariesType boundariesType;
108
        //! JSON data describing the constellations (names, lines, artwork)
109
        QJsonArray constellations;
110
        //! JSON data describing boundaries of the constellations
111
        QJsonArray boundaries;
112
        //! Epoch for boundary definition. E.g. "J2000" (default), "B1875", "J2050.0", "B1950.5", "JD1234567.89" or just any JD value
113
        //! The first two examples are treated most efficiently.
114
        QString boundariesEpoch;
115
        //! JSON data describing asterism lines and names
116
        QJsonArray asterisms;
117
        //! Classification of sky culture (enum)
118
        CLASSIFICATION classification;
119
        //! JSON data containing culture-specific names of celestial objects (stars, planets, DSO)
120
        QJsonObject names;
121
        //! JSON data describing the policy on the usage of native names vs the English ones
122
        QJsonArray langsUseNativeNames;
123
        //! Whether to show common names in addition to the culture-specific ones
124
        bool fallbackToInternationalNames = false;
125
        //! optional element: Zodiac. Classical SCs usually have 12 signs of 30 degrees with 60 minutes.
126
        QJsonObject zodiac;
127
        //! optional element. This is more elaborate, with variants in India (ecliptical) and China (equatorial!)
128
        QJsonObject lunarSystem;
129
};
130

131
//! @class StelSkyCultureMgr
132
//! Manage sky cultures for stellarium.
133
//! In the installation data directory and user data directory are the "skycultures"
134
//! sub-directories containing one sub-directory per sky culture.
135
//! This sub-directory name is that we refer to as sky culture ID here.
136
//! @author Fabien Chereau
137
class StelSkyCultureMgr : public StelModule
138
{
139
        Q_OBJECT
140
        Q_PROPERTY(QString currentSkyCultureID
141
                   READ getCurrentSkyCultureID
142
                   WRITE setCurrentSkyCultureID
143
                   NOTIFY currentSkyCultureIDChanged)
144
        Q_PROPERTY(QString defaultSkyCultureID
145
                   READ getDefaultSkyCultureID
146
                   WRITE setDefaultSkyCultureID
147
                   NOTIFY defaultSkyCultureIDChanged)
148
        Q_PROPERTY(StelObject::CulturalDisplayStyle screenLabelStyle
149
                   READ getScreenLabelStyle
150
                   WRITE setScreenLabelStyle
151
                   NOTIFY screenLabelStyleChanged)
152
        Q_PROPERTY(StelObject::CulturalDisplayStyle infoLabelStyle
153
                   READ getInfoLabelStyle
154
                   WRITE setInfoLabelStyle
155
                   NOTIFY infoLabelStyleChanged)
156
        Q_PROPERTY(bool flagUseAbbreviatedNames
157
                   READ getFlagUseAbbreviatedNames
158
                   WRITE setFlagUseAbbreviatedNames
159
                   NOTIFY flagUseAbbreviatedNamesChanged)
160
        Q_PROPERTY(bool flagOverrideUseCommonNames
161
                   READ getFlagOverrideUseCommonNames
162
                   WRITE setFlagOverrideUseCommonNames
163
                   NOTIFY flagOverrideUseCommonNamesChanged)
164

165
public:
166
        StelSkyCultureMgr();
167
        ~StelSkyCultureMgr();
168
        
169
        //! Initialize the StelSkyCultureMgr object.
170
        //! Gets the default sky culture name from the application's settings,
171
        //! sets that sky culture by calling setCurrentSkyCultureID().
172
        void init();
173

174
        //! Creates one label from cName
175
        //! @param commonNameI18n object common name in user language.
176
        //! @param abbrevI18n string to use as shortest possible label.
177
        //! If you call this with an actual non-default argument abbrevI18n,
178
        //! you really only want this short label, and style is not evaluated.
179
        //! If abbrevI18n starts with a dot, an empty string is returned.
180
        QString createCulturalLabel(const StelObject::CulturalName &cName,
181
                                           const StelObject::CulturalDisplayStyle style,
182
                                           const QString &commonNameI18n,
183
                                           const QString &abbrevI18n=QString()) const;
184
        
185
public slots:
186
        //! Get the current sky culture English name.
187
        QString getCurrentSkyCultureEnglishName() const;
188
        //! Get the current sky culture translated name.
189
        QString getCurrentSkyCultureNameI18() const;
190
        //! Set the sky culture from i18n name.
191
        //! @return true on success; false and doesn't change if skyculture is invalid.
192
        bool setCurrentSkyCultureNameI18(const QString& cultureName);
193
        
194
        //! Get the current sky culture ID.
195
        QString getCurrentSkyCultureID() const {return currentSkyCulture.id;}
2✔
196
        //! Set the current sky culture from the ID.
197
        //! @param id the sky culture ID.
198
        //! @return true on success; else false.
199
        bool setCurrentSkyCultureID(const QString& id);
200
        //! Reload the current sky culture
201
        void reloadSkyCulture();
202

203
        //! Get the type of boundaries of the current sky culture
204
        //! Config option: info/boundaries
205
        StelSkyCulture::BoundariesType getCurrentSkyCultureBoundariesType() const;
206

207
        //! Get the classification index for the current sky culture
208
        StelSkyCulture::CLASSIFICATION getCurrentSkyCultureClassificationIdx() const;
209

210
        //! @return a localized HTML description of the classification for the current sky culture
211
        QString getCurrentSkyCultureHtmlClassification() const;
212

213
        //! @return a localized HTML description of the license given in markdown
214
        QString getCurrentSkyCultureHtmlLicense() const;
215

216
        //! @return a localized HTML description of the region for the current sky culture
217
        QString getCurrentSkyCultureHtmlRegion() const;
218

219
        //! Returns a localized HTML description for the current sky culture.
220
        //! @return a HTML description of the current sky culture, suitable for display
221
        QString getCurrentSkyCultureHtmlDescription();
222
        
223
        //! Get the default sky culture ID
224
        QString getDefaultSkyCultureID() {return defaultSkyCultureID;}
1✔
225
        //! Set the default sky culture from the ID.
226
        //! @param id the sky culture ID.
227
        //! @return true on success; else false.
228
        bool setDefaultSkyCultureID(const QString& id);
229
        
230
        //! Get a list of sky culture names in English.
231
        //! @return A list of English sky culture names.
232
        QStringList getSkyCultureListEnglish(void) const;
233
        
234
        //! Get a list of sky culture names in the current language.
235
        //! @return A list of translated sky culture names.
236
        QStringList getSkyCultureListI18(void) const;
237

238
        //! Get a list of sky culture IDs
239
        QStringList getSkyCultureListIDs(void) const;
240

241
        //! Returns a map from sky culture IDs/folders to sky culture names.
242
        QMap<QString, StelSkyCulture> getDirToNameMap() const { return dirToNameEnglish; }
1✔
243

244
        static StelObject::CulturalDisplayStyle convertCulturalDisplayStyleFromCSVstring(const QString &csv);
245
        static QString convertCulturalDisplayStyleToCSVstring(const StelObject::CulturalDisplayStyle style);
246

247
        //! Returns the screen labeling setting for the currently active skyculture
248
        StelObject::CulturalDisplayStyle getScreenLabelStyle() const;
249
        //! Scripting version
250
        QString getScreenLabelStyleString() const;
251
        //! Sets the screen labeling setting for the currently active skyculture
252
        void setScreenLabelStyle(const StelObject::CulturalDisplayStyle style);
253
        //! scripting version
254
        void setScreenLabelStyle(const QString &style);
255

256
        //! Returns the InfoString labeling setting for the currently active skyculture
257
        StelObject::CulturalDisplayStyle getInfoLabelStyle() const;
258
        //! Scripting version
259
        QString getInfoLabelStyleString() const;
260
        //! sets the InfoString labeling setting for the currently active skyculture
261
        void setInfoLabelStyle(const StelObject::CulturalDisplayStyle style);
262
        //! scripting version
263
        void setInfoLabelStyle(const QString &style);
264

265
        //! Returns whether we ignore SC authors' settings "fallback_to_international_names"
266
        bool getFlagOverrideUseCommonNames() const {return flagOverrideUseCommonNames; }
×
267
        //! Set whether we ignore SC authors' settings "fallback_to_international_names"
268
        void setFlagOverrideUseCommonNames(bool override);
269

270
        //! Returns whether we show shortest name as screen label
271
        bool getFlagUseAbbreviatedNames() const {return flagUseAbbreviatedNames; }
×
272
        //! Set whether we ignore SC authors' settings "fallback_to_international_names"
273
        void setFlagUseAbbreviatedNames(bool b);
274

275
        //! Returns whether current skyculture uses (incorporates) common names.
276
        bool currentSkycultureUsesCommonNames() const;
277

278
signals:
279
        //! Emitted whenever the default sky culture changed.
280
        //! @see setDefaultSkyCultureID
281
        void defaultSkyCultureIDChanged(const QString& id);
282

283
        //! Emitted when the current sky culture changes
284
        void currentSkyCultureIDChanged(const QString& id);
285

286
        //! Emitted when the current sky culture changes
287
        void currentSkyCultureChanged(const StelSkyCulture& culture);
288

289
        //! Emitted when InfoLabelStyle has changed
290
        void infoLabelStyleChanged(const StelObject::CulturalDisplayStyle style);
291
        //! Emitted when ScreenLabelStyle has changed
292
        void screenLabelStyleChanged(const StelObject::CulturalDisplayStyle style);
293

294
        //! Emitted on flag change.
295
        void flagOverrideUseCommonNamesChanged(bool override);
296

297
        //! Emitted on flag change.
298
        void flagUseAbbreviatedNamesChanged(bool b);
299

300
private:
301
        //! Scan all sky cultures to get their names and other properties.
302
        void makeCulturesList();
303

304
        //! Read the English name of the sky culture from description file.
305
        //! @param idFromJSON the id from \p index.json that will be used as a default name if an error occurs.
306
        QString getSkyCultureEnglishName(const QString& idFromJSON) const;
307
        //! Get the culture name in English associated with a specified directory.
308
        //! @param directory The directory name.
309
        //! @return The English name for the culture associated with directory.
310
        QString directoryToSkyCultureEnglish(const QString& directory) const;
311
        
312
        //! Get the culture name translated to current language associated with 
313
        //! a specified directory.
314
        //! @param directory The directory name.
315
        //! @return The translated name for the culture associated with directory.
316
        QString directoryToSkyCultureI18(const QString& directory) const;
317
        
318
        //! Get the directory associated with a specified translated culture name.
319
        //! @param cultureName The culture name in the current language.
320
        //! @return The directory associated with cultureName.
321
        QString skyCultureI18ToDirectory(const QString& cultureName) const;
322

323
        QString descriptionMarkdownToHTML(const QString& markdown, const QString& descrPath);
324
        QString convertMarkdownLevel2Section(const QString& markdown, const QString& sectionName,
325
                                             qsizetype bodyStartPos, qsizetype bodyEndPos, const StelTranslator& trans);
326
        std::pair<QString/*color*/,QString/*info*/> getLicenseDescription(const QString& license, const bool singleLicenseForAll) const;
327

328
        QMap<QString, StelSkyCulture> dirToNameEnglish;
329
        
330
        StelSkyCulture currentSkyCulture;
331
        
332
        QString defaultSkyCultureID;
333

334
        //! Ignore skyculture dict setting "fallback_to_international_names"
335
        bool flagOverrideUseCommonNames;
336

337
        //! Replace any detailed cultural label by the short label (from constellation ID)
338
        //! This should be a short string, some skycultures still have numerical IDs here.
339
        bool flagUseAbbreviatedNames;
340
};
341

342
#endif // STELSKYCULTUREMGR_HPP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc