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

Stellarium / stellarium / 15291801018

28 May 2025 04:52AM UTC coverage: 11.931% (-0.02%) from 11.951%
15291801018

push

github

alex-w
Added new set of navigational stars (XIX century)

0 of 6 new or added lines in 2 files covered. (0.0%)

14124 existing lines in 74 files now uncovered.

14635 of 122664 relevant lines covered (11.93%)

18291.42 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

32
class StelTranslator;
33

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

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

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

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

160
public:
161
        StelSkyCultureMgr();
162
        ~StelSkyCultureMgr();
163
        
164
        //! Initialize the StelSkyCultureMgr object.
165
        //! Gets the default sky culture name from the application's settings,
166
        //! sets that sky culture by calling setCurrentSkyCultureID().
167
        void init();
168

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

198
        //! Get the type of boundaries of the current sky culture
199
        //! Config option: info/boundaries
200
        StelSkyCulture::BoundariesType getCurrentSkyCultureBoundariesType() const;
201

202
        //! Get the classification index for the current sky culture
203
        StelSkyCulture::CLASSIFICATION getCurrentSkyCultureClassificationIdx() const;
204

205
        //! @return a localized HTML description of the classification for the current sky culture
206
        QString getCurrentSkyCultureHtmlClassification() const;
207

208
        //! @return a localized HTML description of the license given in markdown
209
        QString getCurrentSkyCultureHtmlLicense() const;
210

211
        //! @return a localized HTML description of the region for the current sky culture
212
        QString getCurrentSkyCultureHtmlRegion() const;
213

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

233
        //! Get a list of sky culture IDs
234
        QStringList getSkyCultureListIDs(void) const;
235

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

239
        static StelObject::CulturalDisplayStyle convertCulturalDisplayStyleFromCSVstring(const QString &csv);
240
        static QString convertCulturalDisplayStyleToCSVstring(const StelObject::CulturalDisplayStyle style);
241

242
        //! Returns the screen labeling setting for the currently active skyculture
243
        StelObject::CulturalDisplayStyle getScreenLabelStyle() const;
244
        //! Scripting version
245
        QString getScreenLabelStyleString() const;
246
        //! Sets the screen labeling setting for the currently active skyculture
247
        void setScreenLabelStyle(const StelObject::CulturalDisplayStyle style);
248
        //! scripting version
249
        void setScreenLabelStyle(const QString &style);
250

251
        //! Returns the InfoString labeling setting for the currently active skyculture
252
        StelObject::CulturalDisplayStyle getInfoLabelStyle() const;
253
        //! Scripting version
254
        QString getInfoLabelStyleString() const;
255
        //! sets the InfoString labeling setting for the currently active skyculture
256
        void setInfoLabelStyle(const StelObject::CulturalDisplayStyle style);
257
        //! scripting version
258
        void setInfoLabelStyle(const QString &style);
259

260
        //! Returns whether we ignore SC authors' settings "fallback_to_international_names"
UNCOV
261
        bool getFlagOverrideUseCommonNames() const {return flagOverrideUseCommonNames; }
×
262
        //! Set whether we ignore SC authors' settings "fallback_to_international_names"
263
        void setFlagOverrideUseCommonNames(bool override);
264

265
        //! Returns whether we show shortest name as screen label
UNCOV
266
        bool getFlagUseAbbreviatedNames() const {return flagUseAbbreviatedNames; }
×
267
        //! Set whether we ignore SC authors' settings "fallback_to_international_names"
268
        void setFlagUseAbbreviatedNames(bool b);
269

270
        //! Returns whether current skyculture uses (incorporates) common names.
271
        bool currentSkycultureUsesCommonNames() const;
272

273
signals:
274
        //! Emitted whenever the default sky culture changed.
275
        //! @see setDefaultSkyCultureID
276
        void defaultSkyCultureIDChanged(const QString& id);
277

278
        //! Emitted when the current sky culture changes
279
        void currentSkyCultureIDChanged(const QString& id);
280

281
        //! Emitted when the current sky culture changes
282
        void currentSkyCultureChanged(const StelSkyCulture& culture);
283

284
        //! Emitted when InfoLabelStyle has changed
285
        void infoLabelStyleChanged(const StelObject::CulturalDisplayStyle style);
286
        //! Emitted when ScreenLabelStyle has changed
287
        void screenLabelStyleChanged(const StelObject::CulturalDisplayStyle style);
288

289
        //! Emitted on flag change.
290
        void flagOverrideUseCommonNamesChanged(bool override);
291

292
        //! Emitted on flag change.
293
        void flagUseAbbreviatedNamesChanged(bool b);
294

295
private:
296
        //! Scan all sky cultures to get their names and other properties.
297
        void makeCulturesList();
298

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

318
        QString descriptionMarkdownToHTML(const QString& markdown, const QString& descrPath);
319
        QString convertMarkdownLevel2Section(const QString& markdown, const QString& sectionName,
320
                                             qsizetype bodyStartPos, qsizetype bodyEndPos, const StelTranslator& trans);
321
        std::pair<QString/*color*/,QString/*info*/> getLicenseDescription(const QString& license, const bool singleLicenseForAll) const;
322

323
        QMap<QString, StelSkyCulture> dirToNameEnglish;
324
        
325
        StelSkyCulture currentSkyCulture;
326
        
327
        QString defaultSkyCultureID;
328

329
        //! Ignore skyculture dict setting "fallback_to_international_names"
330
        bool flagOverrideUseCommonNames;
331

332
        //! Replace any detailed cultural label by the short label (from constellation ID)
333
        //! This should be a short string, some skycultures still have numerical IDs here.
334
        bool flagUseAbbreviatedNames;
335
};
336

337
#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