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

Stellarium / stellarium / 15084037079

17 May 2025 09:50AM UTC coverage: 11.938%. First build
15084037079

Pull #4179

github

gzotti
Use different braces
Pull Request #4179: Multiple label options for Skycultures

22 of 1583 new or added lines in 34 files covered. (1.39%)

14635 of 122592 relevant lines covered (11.94%)

18661.53 hits per line

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

0.0
/src/core/modules/Asterism.hpp
1
/*
2
 * Stellarium
3
 * Copyright (C) 2017 Alexander Wolf
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 ASTERISM_HPP
21
#define ASTERISM_HPP
22

23
#include "StelObject.hpp"
24
#include "StelTranslator.hpp"
25
#include "StelFader.hpp"
26
#include "StelSphereGeometry.hpp"
27
#include "AsterismMgr.hpp"
28

29
#include <vector>
30
#include <QString>
31
#include <QFont>
32

33
class StarMgr;
34
class StelPainter;
35
class QJsonObject;
36

37
//! @class Asterism
38
//! The Asterism class models a grouping of stars in a Sky Culture.
39
//! Each Asterism consists of a list of stars identified by their
40
//! abbreviation and Hipparcos catalogue numbers (taken from file: asterismship.fab),
41
//! another entry in file asterism_names.eng.fab with the defining abbreviated name
42
//! and translatable englishName (translation goes into nameI18).
43
class Asterism : public StelObject
44
{
45
        friend class AsterismMgr;
46
private:
47
        static const QString ASTERISM_TYPE;
48
        Asterism();
49
        ~Asterism() override;
50

51
        // StelObject method to override
52
        //! Get a string with data about the Asterism.
53
        //! Constellations support the following InfoStringGroup flags:
54
        //! - Name
55
        //! @param core the StelCore object
56
        //! @param flags a set of InfoStringGroup items to include in the return value.
57
        //! @return a QString a description of the constellation.
58
        QString getInfoString(const StelCore*, const InfoStringGroup& flags) const override;
59

60
        //! Get the module/object type string.
61
        //! @return "Asterism"
62
        QString getType() const override {return ASTERISM_TYPE;}
×
63
        QString getObjectType() const override {return N_("asterism"); }
×
64
        QString getObjectTypeI18n() const override {return q_(getObjectType()); }
×
65
        QString getID() const override { return abbreviation; }
×
66

67
        //! observer centered J2000 coordinates.
68
        Vec3d getJ2000EquatorialPos(const StelCore*) const override {return XYZname;}
×
69

70
        //! @param record string containing the following whitespace
71
        //! separated fields: abbreviation - a three character abbreviation
72
        //! for the asterism, a number of lines (pairs), and a list of Hipparcos
73
        //! catalogue numbers which, when connected pairwise, form the lines of the
74
        //! asterism.
75
        //! @param starMgr a pointer to the StarManager object.
76
        //! @param excludeRefs a QSet of reference exclusions (user-defined preference in config.ini)
77
        //! @return false if can't parse record, else true.
78
        bool read(const QJsonObject& data, StarMgr *starMgr, const QSet<int> &excludeRefs);
79

80
        //! Draw the asterism name
81
        void drawName(StelPainter& sPainter, bool abbreviateLabel) const;
82

83
        //! Get the translated name for the Asterism.
NEW
84
        QString getNameI18n() const override {return culturalName.translatedI18n;}
×
85
        //! Get the English name for the Asterism.
NEW
86
        QString getEnglishName() const override {return culturalName.translated;}
×
87
        //! Get the native name for the Asterism
NEW
88
        QString getNameNative() const override {return culturalName.native;}
×
89
        //! Get (translated) pronouncement of the native name for the Asterism
NEW
90
        QString getNamePronounce() const override {return (culturalName.pronounceI18n.isEmpty() ? culturalName.native : culturalName.pronounceI18n);}
×
91
        //! Get the short name for the Asterism (returns the translated version of abbreviation).
92
        QString getShortName() const {return abbreviationI18n;}
93
        //! Combine screen label from various components, depending on settings in SkyCultureMgr
94
        QString getScreenLabel() const override;
95
        //! Combine InfoString label from various components, depending on settings in SkyCultureMgr
96
        QString getInfoLabel() const override;
97
        //! Underlying worker
98
        QString getCultureLabel(StelObject::CulturalDisplayStyle style) const;
99
        //! Draw the lines for the Asterism.
100
        //! This method uses the coords of the stars (optimized for use through
101
        //! the class AsterismMgr only).
102
        void drawOptim(StelPainter& sPainter, const StelCore* core, const SphericalCap& viewportHalfspace) const;
103
        //! Update fade levels according to time since various events.
104
        void update(int deltaTime);
105
        //! Turn on and off Asterism line rendering.
106
        //! @param b new state for line drawing.
107
        void setFlagLines(const bool b) { lineFader=b; }
×
108
        //! Turn on and off ray helper rendering.
109
        //! @param b new state for ray helper drawing.
110
        void setFlagRayHelpers(const bool b) { rayHelperFader=b; }
×
111
        //! Turn on and off Asterism name label rendering.
112
        //! @param b new state for name label drawing.
113
        void setFlagLabels(const bool b) { nameFader=b; }
×
114
        //! Get the current state of Asterism line rendering.
115
        //! @return true if Asterism line rendering it turned on, else false.
116
        bool getFlagLines() const { return lineFader; }
117
        //! Get the current state of ray helper rendering.
118
        //! @return true if ray helper rendering it turned on, else false.
119
        bool getFlagRayHelpers() const { return rayHelperFader; }
120
        //! Get the current state of Asterism name label rendering.
121
        //! @return true if Asterism name label rendering it turned on, else false.
122
        bool getFlagLabels() const { return nameFader; }
123

124
        //! @return true if a (real) named asterism, false for a ray helper
125
        bool isAsterism() const { return flagAsterism; }
×
126

127
        //! Asterism name. This is a culture-dependent thing, and in each skyculture an asterism has one name entry only.
128
        //! Given multiple aspects of naming, we need all the components and more.
129
        CulturalName culturalName;
130
        //! Abbreviation
131
        //! A skyculture designer must invent it. (usually 2-5 letters)
132
        //! This MUST be filled and be unique within a sky culture.
133
        //! @note Given their possible screen use, using numerical labels as abbreviation is not recommended.
134
        QString abbreviation;
135
        //! Translated version of abbreviation (the short name or designation of asterism)
136
        //! Latin-based languages should not translate it, but it may be useful to translate for other glyph systems.
137
        QString abbreviationI18n;
138
        //! Context for name
139
        QString context;
140
        //! Direction vector pointing on constellation name drawing position
141
        Vec3d XYZname;
142
        Vec3d XYname;
143
        enum class Type
144
        {
145
                RayHelper,          //!< Ray helper
146
                Asterism,           //!< An asterism with lines between HIP/Gaia stars
147
                TelescopicAsterism, //!< An asterism with lines defined by J2000.0 coordinates
148
        };
149
        //! Type of asterism
150
        Type typeOfAsterism = Type::Asterism;
151
        bool flagAsterism; //!< True for genuine asterisms, false for ray helpers
152
        //! List of stars forming the segments
153
        std::vector<StelObjectP> asterism;
154
        //! In case this describes a single-star asterism (i.e. just one line segment that starts and ends at the same star),
155
        //! or we have a line segment with such single star somewhere within the asterism,
156
        //! we will draw a circle with this opening radius.
157
        double singleStarAsterismRadius;
158

159
        SphericalCap boundingCap;
160

161
        //! Define whether lines and names must be drawn
162
        LinearFader lineFader, rayHelperFader, nameFader;
163

164
        //! Currently we only need one color for all asterisms, this may change at some point
165
        static Vec3f lineColor;
166
        static Vec3f rayHelperColor;
167
        static Vec3f labelColor;
168
};
169

170
#endif // ASTERISM_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