• 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

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
public:
47
        static const QString ASTERISM_TYPE;
48
private:
49
        Asterism();
50
        ~Asterism() override;
51

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

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

68
        //! observer centered J2000 coordinates.
69
        //! These are either automatically computed from all stars forming the lines,
70
        //! or from the manually defined label point(s).
71
        Vec3d getJ2000EquatorialPos(const StelCore*) const override;
72

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

83
        //! Draw the asterism name
84
        void drawName(const Vec3d &xyName, StelPainter& sPainter) const;
85

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

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

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

163
        SphericalCap boundingCap;
164

165
        //! Define whether lines and names must be drawn
166
        LinearFader lineFader, rayHelperFader, nameFader;
167

168
        //! Currently we only need one color for all asterisms, this may change at some point
169
        static Vec3f lineColor;
170
        static Vec3f rayHelperColor;
171
        static Vec3f labelColor;
172
};
173

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