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

Stellarium / stellarium / 17068063291

19 Aug 2025 11:22AM UTC coverage: 11.766%. Remained the same
17068063291

push

github

alex-w
Reformatting

14706 of 124990 relevant lines covered (11.77%)

18303.49 hits per line

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

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

22
#ifndef CONSTELLATION_HPP
23
#define CONSTELLATION_HPP
24

25
#include "CoordObject.hpp"
26
#include "StelObject.hpp"
27
#include "StelTranslator.hpp"
28
#include "StelFader.hpp"
29
#include "StelTextureTypes.hpp"
30
#include "StelSphereGeometry.hpp"
31
#include "ConstellationMgr.hpp"
32

33
#include <vector>
34
#include <QJsonObject>
35
#include <QString>
36
#include <QFont>
37

38
class StarMgr;
39
class StelPainter;
40

41
//! @class Constellation
42
//! The Constellation class models a grouping of stars in a Sky Culture.
43
//! Each Constellation consists of a list of stars identified by their
44
//! abbreviation and Hipparcos catalogue numbers (taken from file: constellationship.fab),
45
//! another entry in file constellation_names.eng.fab with the defining abbreviated name,
46
//! nativeName, and translatable englishName (translation goes into nameI18).
47
//! GZ NEW: The nativeName should be accessible in a GUI option, so that e.g. original names as written in a
48
//! concrete book where a skyculture has been taken from can be assured even when translation is available.
49
//! TODO: There should be a distinction between constellations and asterisms, which are "unofficial" figures within a sky culture.
50
//! For example, Western sky culture has a "Big Dipper", "Coathanger", etc. These would be nice to see, but in different style.
51
class Constellation : public StelObject
52
{
53
        friend class ConstellationMgr;
54
public:
55
        static const QString CONSTELLATION_TYPE;
56
private:
57
        Constellation();
58
        ~Constellation() override;
59

60
        // StelObject method to override
61
        //! Get a string with data about the Constellation.
62
        //! Constellations support the following InfoStringGroup flags:
63
        //! - Name
64
        //! @param core the StelCore object
65
        //! @param flags a set of InfoStringGroup items to include in the return value.
66
        //! @return a QString a description of the constellation.
67
        QString getInfoString(const StelCore*, const InfoStringGroup& flags) const override;
68

69
        //! Get the module/object type string.
70
        //! @return "Constellation"
71
        QString getType() const override {return CONSTELLATION_TYPE;}
×
72
        QString getObjectType() const override { return N_("constellation"); }
×
73
        QString getObjectTypeI18n() const override { return q_(getObjectType()); }
×
74
        QString getID() const override { return abbreviation; }
×
75

76
        //! observer centered J2000 coordinates.
77
        //! These are either automatically computed from all stars forming the constellation lines,
78
        //! or from the manually defined label point(s).
79
        Vec3d getJ2000EquatorialPos(const StelCore*) const override;
80

81
        //! Specialized implementation of the getRegion method.
82
        //! Return the convex hull of the object.
83
        SphericalRegionP getRegion() const override {return convexHull;}
×
84

85
        //! @param data a JSON formatted constellation record from index.json
86
        //! @param starMgr a pointer to the StarManager object.
87
        //! @return false if can't parse record (invalid result!), else true.
88
        bool read(const QJsonObject& data, StarMgr *starMgr);
89

90
        //! Draw the constellation name. Depending on completeness of names and data, there may be a rich set of options to display.
91
        void drawName(const Vec3d &xyName, StelPainter& sPainter) const;
92
        //! Draw the constellation art
93
        void drawArt(StelPainter& sPainter) const;
94
        //! Draw the constellation boundary. obsVelocity used for aberration
95
        void drawBoundaryOptim(StelPainter& sPainter, const Vec3d &obsVelocity) const;
96
        //! Draw the constellation hull. obsVelocity used for aberration
97
        void drawHullOptim(StelPainter& sPainter, const Vec3d &obsVelocity) const;
98

99
        //! Test if a star is part of a Constellation.
100
        //! This member tests to see if a star is one of those which make up
101
        //! the lines of a Constellation.
102
        //! @return a pointer to the constellation which the star is a part of,
103
        //! or nullptr if the star is not part of a constellation
104
        //! @note: Dark constellations by definition cannot be found here.
105
        const Constellation* isStarIn(const StelObject*) const;
106

107
        //! Get the brightest star in a Constellation.
108
        //! Checks all stars which make up the constellation lines, and returns
109
        //! a pointer to the one with the brightest apparent magnitude.
110
        //! @return a pointer to the brightest star
111
        StelObjectP getBrightestStarInConstellation(void) const;
112

113
        //! Get the translated name for the Constellation.
114
        QString getNameI18n() const override {return culturalName.translatedI18n;}
×
115
        //! Get the English name for the Constellation.
116
        QString getEnglishName() const override {return culturalName.translated;}
×
117
        //! Get the native name for the Constellation
118
        QString getNameNative() const override {return culturalName.native;}
×
119
        //! Get (translated) pronouncement of the native name for the Constellation
120
        QString getNamePronounce() const override {return (culturalName.pronounceI18n.isEmpty() ? culturalName.native : culturalName.pronounceI18n);}
×
121
        //! Get the short name for the Constellation (returns the translated version of abbreviation).
122
        QString getShortName() const {return abbreviationI18n;}
×
123
public:
124
        //! Combine screen label from various components, depending on settings in SkyCultureMgr
125
        QString getScreenLabel() const override;
126
        //! Combine InfoString label from various components, depending on settings in SkyCultureMgr
127
        QString getInfoLabel() const override;
128
private:
129
        //! Underlying worker
130
        QString getCultureLabel(StelObject::CulturalDisplayStyle style) const;
131
        //! Draw the lines for the Constellation.
132
        //! This method uses the coords of the stars (optimized for use through
133
        //! the class ConstellationMgr only).
134
        void drawOptim(StelPainter& sPainter, const StelCore* core, const SphericalCap& viewportHalfspace) const;
135
        //! Draw the art texture, optimized function to be called through a constellation manager only.  obsVelocity used for aberration
136
        void drawArtOptim(StelPainter& sPainter, const SphericalRegion& region, const Vec3d& obsVelocity) const;
137
        //! Update fade levels according to time since various events.
138
        void update(int deltaTime);
139
        //! Turn on and off Constellation line rendering.
140
        //! @param b new state for line drawing.
141
        void setFlagLines(const bool b) {lineFader=b;}
×
142
        //! Turn on and off Constellation boundary rendering.
143
        //! @param b new state for boundary drawing.
144
        void setFlagBoundaries(const bool b) {boundaryFader=b;}
×
145
        //! Turn on and off Constellation hull rendering.
146
        //! @param b new state for hull drawing.
147
        void setFlagHull(const bool b) {hullFader=b;}
×
148
        //! Turn on and off Constellation name label rendering.
149
        //! @param b new state for name label drawing.
150
        void setFlagLabels(const bool b) {nameFader=b;}
×
151
        //! Turn on and off Constellation art rendering.
152
        //! @param b new state for art drawing.
153
        void setFlagArt(const bool b) {artFader=b;}
×
154
        //! Get the current state of Constellation line rendering.
155
        //! @return true if Constellation line rendering it turned on, else false.
156
        bool getFlagLines() const {return lineFader;}
157
        //! Get the current state of Constellation boundary rendering.
158
        //! @return true if Constellation boundary rendering it turned on, else false.
159
        bool getFlagBoundaries() const {return boundaryFader;}
160
        //! Get the current state of Constellation name label rendering.
161
        //! @return true if Constellation name label rendering it turned on, else false.
162
        //! Get the current state of Constellation hull rendering.
163
        //! @return true if Constellation hull rendering it turned on, else false.
164
        bool getFlagHull() const {return hullFader;}
165
        //! Get the current state of Constellation name label rendering.
166
        //! @return true if Constellation name label rendering it turned on, else false.
167
        bool getFlagLabels() const {return nameFader;}
168
        //! Get the current state of Constellation art rendering.
169
        //! @return true if Constellation art rendering it turned on, else false.
170
        bool getFlagArt() const {return artFader;}
171

172
        //! Check visibility of sky culture elements (using for seasonal rules)
173
        //! @return true if sky culture elements rendering it turned on, else false.
174
        bool isSeasonallyVisible() const;
175

176
        //! Compute the convex hull of a constellation (or asterism).
177
        //! The convex hull around stars on the sphere is described as problematic.
178
        //! For constellations of limited size we follow the recommendation to
179
        //! - project the stars (perspectively) around the projectionCenter on a tangential plane on the unit sphere.
180
        //! - apply simple Package-Wrapping from Sedgewick 1990, Algorithms in C, chapter 25.
181
        //! @note Due to the projection requirement, constellations are not allowed to span more than 90° from projectionCenter. Outliers violating this rule will be silently discarded.
182
        //! @param starLines the line array for a single constellation (Constellation::constellation or Asterism::asterism). Every second entry is used.
183
        //! @param hullExtension a list of stars (important outliers) that extends the hull without being part of the stick figures.
184
        //! @param darkOutline line array of simple Vec3d J2000 equatorial coordinates.
185
        //! @param projectionCenter (normalized Vec3d) as computed from these stars when finding the label position (XYZname)
186
        //! @param hullRadius For constellations with only 1-2 stars, define hull as circle of this radius (degrees), or a circle of half-distance between the two plus this value (degrees), around projectionCenter.
187
        //! @return SphericalRegion in equatorial J2000 coordinates.
188
        //! @note the hull should be recreated occasionally as it can change by stellar proper motion.
189
        //! @todo Connect some time trigger to recreate automatically, maybe once per year, decade or so.
190
        static SphericalRegionP makeConvexHull(const std::vector<StelObjectP> &starLines, const std::vector<StelObjectP> &hullExtension, const std::vector<StelObjectP> &darkLines, const Vec3d projectionCenter, const double hullRadius);
191
        //! compute convex hull
192
        void makeConvexHull();
193

194

195
        //! Constellation name. This is culture-dependent, but in each skyculture a constellation has one name entry only.
196
        //! Given multiple aspects of naming, we need all the components and more.
197
        CulturalName culturalName;
198
        //! Abbreviation (the short name or designation of constellations)
199
        //! For non-IAU constellations, a skyculture designer must invent it. (usually 2-5 Latin letters and numerics)
200
        //! This MUST be filled and be unique within a sky culture.
201
        //! @note Given their possible screen use, using numerical labels as abbreviation is not recommended.
202
        QString abbreviation;
203
        //! Translated version of abbreviation (the short name or designation of constellations)
204
        //! Latin-based languages should not translate it, but it may be useful to translate for other glyph systems.
205
        QString abbreviationI18n;
206
        //! The context for English name of constellation (used for correct translation via gettext)
207
        QString context;
208
        //! Direction vectors pointing on constellation name drawing position (J2000.0 coordinates)
209
        //! Usually a single position is computed from averaging star positions forming the constellation, but we can override with an entry in index.json,
210
        //! and even give more positions (e.g. for long or split-up constellations like Serpens.
211
        QList<Vec3d> XYZname;
212
        //! Number of segments in the lines
213
        unsigned int numberOfSegments;
214
        //! Month [1..12] of start visibility of constellation (seasonal rules)
215
        int beginSeason;
216
        //! Month [1..12] of end visibility of constellation (seasonal rules)
217
        int endSeason;
218
        //! List of stars forming the segments
219
        std::vector<StelObjectP> constellation;
220
        //! List of coordinates forming the segments of a dark constellation (outlining dark cloud in front of the Milky Way)
221
        //! If this is not empty, the constellation is a "dark constellation"
222
        std::vector<StelObjectP> dark_constellation;
223
        //! List of additional stars (or Nebula objects) defining the hull together with the stars from constellation
224
        std::vector<StelObjectP> hullExtension;
225
        //! In case this describes a single-star constellation (i.e. just one line segment that starts and ends at the same star),
226
        //! or we have a line segment with such single star (start==end) somewhere within the constellation,
227
        //! we will draw a circle with this opening radius.
228
        double singleStarConstellationRadius;
229
        //! In case we have a single- or two-star constellation, we will draw a circle with this opening radius.
230
        double hullRadius;
231

232
        StelTextureSP artTexture;
233
        StelVertexArray artPolygon;
234
        SphericalCap boundingCap;
235
        SphericalRegionP convexHull; //!< The convex hull formed by stars contained in the defined lines (constellation) plus extra stars (hullExtension).
236

237
        //! Define whether art, lines, names and boundary must be drawn
238
        LinearFader artFader, lineFader, nameFader, boundaryFader, hullFader;
239
        //! Constellation art opacity
240
        float artOpacity;
241
        std::vector<std::vector<Vec3d> *> isolatedBoundarySegments;
242
        std::vector<std::vector<Vec3d> *> sharedBoundarySegments;
243

244
        //! Currently we only need one color for all constellations, this may change at some point
245
        static Vec3f lineColor;
246
        static Vec3f labelColor;
247
        static Vec3f boundaryColor;
248
        static Vec3f hullColor;
249

250
        static bool singleSelected;        
251
        static bool seasonalRuleEnabled;
252
        // set by ConstellationMgr to fade out art on small FOV values
253
        // see LP:#1294483
254
        static float artIntensityFovScale;
255
};
256

257
#endif // CONSTELLATION_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