Kstars

starobject.h
1/*
2 SPDX-FileCopyrightText: 2001 Thomas Kabelmann <tk78@gmx.de>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9//#define PROFILE_UPDATECOORDS
10
11#include "skyobject.h"
12#include "ksnumbers.h"
13
14#include <QString>
15
16struct DeepStarData;
17class KSPopupMenu;
18struct StarData;
19
20/**
21 * @class StarObject
22 *
23 * This is a subclass of SkyObject. It adds the Spectral type, and flags
24 * for variability and multiplicity.
25 * For stars, the primary name (n) is the latin name (e.g., "Betelgeuse"). The
26 * secondary name (n2) is the genetive name (e.g., "alpha Orionis").
27 * @short subclass of SkyObject specialized for stars.
28 *
29 * @author Thomas Kabelmann
30 * @version 1.0
31 */
32class StarObject : public SkyObject
33{
34 public:
35 /**
36 * @short returns the reindex interval (in centuries!) for the given
37 * magnitude of proper motion (in milliarcsec/year). ASSUMING a
38 * 25 arc-minute margin for proper motion.
39 */
40 static double reindexInterval(double pm);
41
42 /**
43 * Constructor. Sets sky coordinates, magnitude, latin name, genetive name, and spectral type.
44 *
45 * @param r Right Ascension
46 * @param d Declination
47 * @param m magnitude
48 * @param n common name
49 * @param n2 genetive name
50 * @param sptype Spectral Type
51 * @param pmra Proper motion in RA direction [mas/yr]
52 * @param pmdec Proper motion in Dec direction [mas/yr]
53 * @param par Parallax angle [mas]
54 * @param mult Multiplicity flag (false=dingle star; true=multiple star)
55 * @param var Variability flag (true if star is a known periodic variable)
56 * @param hd Henry Draper Number
57 */
58 explicit StarObject(dms r = dms(0.0), dms d = dms(0.0), float m = 0.0, const QString &n = QString(),
59 const QString &n2 = QString(), const QString &sptype = "--", double pmra = 0.0,
60 double pmdec = 0.0, double par = 0.0, bool mult = false, bool var = false, int hd = 0);
61 /**
62 * Constructor. Sets sky coordinates, magnitude, latin name, genetive name, and
63 * spectral type. Differs from above function only in data type of RA and Dec.
64 *
65 * @param r Right Ascension
66 * @param d Declination
67 * @param m magnitude
68 * @param n common name
69 * @param n2 genetive name
70 * @param sptype Spectral Type
71 * @param pmra Proper motion in RA direction [mas/yr]
72 * @param pmdec Proper motion in Dec direction [mas/yr]
73 * @param par Parallax angle [mas]
74 * @param mult Multiplicity flag (false=dingle star; true=multiple star)
75 * @param var Variability flag (true if star is a known periodic variable)
76 * @param hd Henry Draper Number
77 */
78 StarObject(double r, double d, float m = 0.0, const QString &n = QString(), const QString &n2 = QString(),
79 const QString &sptype = "--", double pmra = 0.0, double pmdec = 0.0, double par = 0.0, bool mult = false,
80 bool var = false, int hd = 0);
81
82 StarObject *clone() const override;
83 UID getUID() const override;
84
85 /** Copy constructor */
86 StarObject(const StarObject &o);
87
88 /** Destructor. (Empty) */
89 ~StarObject() override = default;
90
91 /**
92 * @short Initializes a StarObject to given data
93 *
94 * This is almost like the StarObject constructor itself, but it avoids
95 * setting up name, gname etc for unnamed stars. If called instead of the
96 * constructor, this method will be much faster for unnamed stars
97 *
98 * @param stardata Pointer to starData object containing required data (except name and gname)
99 * @return Nothing
100 */
101 void init(const StarData *stardata);
102
103 /**
104 * @short Initializes a StarObject to given data
105 *
106 * @param stardata Pointer to deepStarData object containing the available data
107 * @return Nothing
108 */
109 void init(const DeepStarData *stardata);
110
111 /**
112 * @short Sets the name, genetive name, and long name
113 *
114 * @param name Common name
115 * @param name2 Genetive name
116 */
117 void setNames(const QString &name, const QString &name2);
118
119 /** @return true if the star has a name ("star" doesn't count) */
120 inline bool hasName() const { return (!Name.isEmpty() && Name != starString); }
121
122 /** @return true if the star has a latin name ("star" or HD... doesn't count) */
123 inline bool hasLatinName() const
124 {
125 return (!Name.isEmpty() && Name != starString && Name != gname(false) && Name != gname(true) &&
126 !Name.startsWith("HD "));
127 }
128
129 /** If star is unnamed return "star" otherwise return the name */
130 inline QString name(void) const override { return hasName() ? Name : starString; }
131
132 /** If star is unnamed return "star" otherwise return the longname */
133 inline QString longname(void) const override { return hasLongName() ? LongName : starString; }
134
135 /**
136 * Returns entire spectral type string
137 * @return Spectral Type string
138 */
139 QString sptype(void) const;
140
141 /** Returns just the first character of the spectral type string. */
142 char spchar() const;
143
144 /**
145 * Returns the genetive name of the star.
146 * @return genetive name of the star
147 */
148 QString gname(bool useGreekChars = true) const;
149
150 /**
151 * Returns the greek letter portion of the star's genetive name.
152 * Returns empty string if star has no genetive name defined.
153 * @return greek letter portion of genetive name
154 */
155 QString greekLetter(bool useGreekChars = true) const;
156
157 /** @return the genitive form of the star's constellation. */
158 QString constell(void) const;
159
160 /**
161 * Determine the current coordinates (RA, Dec) from the catalog
162 * coordinates (RA0, Dec0), accounting for both precession and nutation.
163 *
164 * @param num pointer to KSNumbers object containing current values of
165 * time-dependent variables.
166 * @param includePlanets does nothing in this implementation (see KSPlanetBase::updateCoords()).
167 * @param lat does nothing in this implementation (see KSPlanetBase::updateCoords()).
168 * @param LST does nothing in this implementation (see KSPlanetBase::updateCoords()).
169 * @param forceRecompute defines whether the data should be recomputed forcefully.
170 */
171 void updateCoords(const KSNumbers *num, bool includePlanets = true, const CachingDms *lat = nullptr,
172 const CachingDms *LST = nullptr, bool forceRecompute = false) override;
173
174 /**
175 * @short Fills ra and dec with the coordinates of the star with the proper
176 * motion correction but without precision and its friends. It is used
177 * in StarComponent to re-index all the stars.
178 * @note In the Hipparcos catalog, from which most of the proper
179 * motion data in KStars is obtained, the RA correction already
180 * has the cos(delta) factor incorporated into it. See
181 * https://heasarc.gsfc.nasa.gov/W3Browse/all/hipparcos.html
182 *
183 * @return true if we changed the coordinates, false otherwise
184 * NOTE: ra and dec both in degrees.
185 */
186 bool getIndexCoords(const double julianMillenia, CachingDms &ra, CachingDms &dec) const;
187 bool getIndexCoords(const double julianMillenia, double *ra, double *dec) const;
188 inline bool getIndexCoords(const KSNumbers *num, CachingDms &ra, CachingDms &dec) const {
189 return getIndexCoords(num->julianMillenia(), ra, dec);
190 }
191 inline bool getIndexCoords(const KSNumbers *num, double *ra, double *dec) const {
192 return getIndexCoords(num->julianMillenia(), ra, dec);
193 }
194
195 /** @short added for JIT updates from both StarComponent and ConstellationLines */
196 void JITupdate();
197
198 /** @short returns the magnitude of the proper motion correction in milliarcsec/year */
199 inline double pmMagnitude() const
200 {
201 return sqrt(pmRA() * pmRA() + pmDec() * pmDec());
202 }
203
204 /**
205 * @short returns the square of the magnitude of the proper motion correction in (milliarcsec/year)^2
206 * @note In the Hipparcos catalog, from which most of the proper
207 * motion data in KStars is obtained, the RA correction already
208 * has the cos(delta) factor incorporated into it. See
209 * https://heasarc.gsfc.nasa.gov/W3Browse/all/hipparcos.html
210 * @note This method is faster when the square root need not be taken
211 */
212 inline double pmMagnitudeSquared() const
213 {
214 return (pmRA() * pmRA() + pmDec() * pmDec());
215 }
216
217 /**
218 * @short Set the Ra and Dec components of the star's proper motion, in milliarcsec/year.
219 * Note that the RA component should already have been multiplied by cos(dec).
220 * @param pmra the new RA proper motion
221 * @param pmdec the new Dec proper motion
222 */
223 inline void setProperMotion(double pmra, double pmdec)
224 {
225 PM_RA = pmra;
226 PM_Dec = pmdec;
227 }
228
229 /** @return the RA component of the star's proper motion, in mas/yr (multiplied by cos(dec)) */
230 inline double pmRA() const { return PM_RA; }
231
232 /** @return the Dec component of the star's proper motion, in mas/yr */
233 inline double pmDec() const { return PM_Dec; }
234
235 /** @short set the star's parallax angle, in milliarcsec */
236 inline void setParallax(double plx) { Parallax = plx; }
237
238 /** @return the star's parallax angle, in milliarcsec */
239 inline double parallax() const { return Parallax; }
240
241 /** @return the star's distance from the Sun in parsecs, as computed from the parallax. */
242 inline double distance() const { return 1000. / parallax(); }
243
244 /**
245 * @short set the star's multiplicity flag (i.e., is it a binary or multiple star?)
246 * @param m true if binary/multiple star system
247 */
248 inline void setMultiple(bool m) { Multiplicity = m; }
249
250 /** @return whether the star is a binary or multiple starobject */
251 inline bool isMultiple() const { return Multiplicity; }
252
253 /** @return the star's HD index */
254 inline int getHDIndex() const { return HD; }
255
256 /**
257 * @short set the star's variability flag
258 *
259 * @param v true if star is variable
260 */
261 inline void setVariable(bool v) { Variability = v; }
262
263 /** @return whether the star is a binary or multiple starobject */
264 inline bool isVariable() const { return Variability; }
265
266 /** @short returns the name, the magnitude or both. */
267 QString nameLabel(bool drawName, bool drawMag) const;
268
269 QString labelString() const override;
270
271 /**
272 * @return the pixel distance for offseting the star's name label
273 * This takes the zoom level and the star's brightness into account.
274 */
275 double labelOffset() const override;
276
277 /** @return the Visual magnitude of the star */
278 inline float getVMag() const { return V; }
279
280 /** @return the blue magnitude of the star */
281 inline float getBMag() const { return B; }
282
283 /**
284 * @return the B - V color index of the star, or a nonsense number
285 * larger than 30 if it's not well defined
286 */
287 inline float getBVIndex() const { return ((B < 30.0 && V < 30.0) ? B - V : 99.9); }
288
289 void initPopupMenu(KSPopupMenu *pmenu) override;
290
291 quint64 updateID { 0 };
292 quint64 updateNumID { 0 };
293
294#ifdef PROFILE_UPDATECOORDS
295 static double updateCoordsCpuTime;
296 static unsigned int starsUpdated;
297#endif
298
299 protected:
300 // DEBUG EDIT. For testing proper motion, uncomment this, and related blocks
301 // See starobject.cpp for further info.
302 // static QVector<SkyPoint *> Trail;
303 // bool testStar;
304 // END DEBUG
305
306 private:
307 double PM_RA { 0 };
308 double PM_Dec { 0 };
309 double Parallax { 0 };
310 bool Multiplicity { false };
311 bool Variability { false };
312 char SpType[2];
313 int HD { 0 };
314 // B and V magnitudes, separately. NOTE 1) This is kept separate from mag for a reason.
315 // See init( const DeepStarData *); 2) This applies only to deep stars at the moment
316 float B { 0 };
317 float V { 0 };
318};
a dms subclass that caches its sine and cosine values every time the angle is changed.
Definition cachingdms.h:19
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
double julianMillenia() const
Definition ksnumbers.h:94
The KStars Popup Menu.
Definition kspopupmenu.h:35
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
QString name2(void) const
Definition skyobject.h:156
qint64 UID
Type for Unique object IDenticator.
Definition skyobject.h:49
const CachingDms & dec() const
Definition skypoint.h:269
const CachingDms & ra() const
Definition skypoint.h:263
This is a subclass of SkyObject.
Definition starobject.h:33
UID getUID() const override
Return UID for object.
QString constell(void) const
static double reindexInterval(double pm)
returns the reindex interval (in centuries!) for the given magnitude of proper motion (in milliarcsec...
StarObject * clone() const override
Create copy of object.
QString labelString() const override
QString name(void) const override
If star is unnamed return "star" otherwise return the name.
Definition starobject.h:130
QString nameLabel(bool drawName, bool drawMag) const
returns the name, the magnitude or both.
double pmDec() const
Definition starobject.h:233
void setParallax(double plx)
set the star's parallax angle, in milliarcsec
Definition starobject.h:236
void initPopupMenu(KSPopupMenu *pmenu) override
Initialize the popup menut.
QString greekLetter(bool useGreekChars=true) const
Returns the greek letter portion of the star's genetive name.
float getBMag() const
Definition starobject.h:281
void updateCoords(const KSNumbers *num, bool includePlanets=true, const CachingDms *lat=nullptr, const CachingDms *LST=nullptr, bool forceRecompute=false) override
Determine the current coordinates (RA, Dec) from the catalog coordinates (RA0, Dec0),...
void setMultiple(bool m)
set the star's multiplicity flag (i.e., is it a binary or multiple star?)
Definition starobject.h:248
QString longname(void) const override
If star is unnamed return "star" otherwise return the longname.
Definition starobject.h:133
bool hasLatinName() const
Definition starobject.h:123
double labelOffset() const override
void JITupdate()
added for JIT updates from both StarComponent and ConstellationLines
double distance() const
Definition starobject.h:242
void setNames(const QString &name, const QString &name2)
Sets the name, genetive name, and long name.
double pmRA() const
Definition starobject.h:230
StarObject(dms r=dms(0.0), dms d=dms(0.0), float m=0.0, const QString &n=QString(), const QString &n2=QString(), const QString &sptype="--", double pmra=0.0, double pmdec=0.0, double par=0.0, bool mult=false, bool var=false, int hd=0)
Constructor.
float getVMag() const
Definition starobject.h:278
float getBVIndex() const
Definition starobject.h:287
double pmMagnitudeSquared() const
returns the square of the magnitude of the proper motion correction in (milliarcsec/year)^2
Definition starobject.h:212
char spchar() const
Returns just the first character of the spectral type string.
int getHDIndex() const
Definition starobject.h:254
bool isMultiple() const
Definition starobject.h:251
double pmMagnitude() const
returns the magnitude of the proper motion correction in milliarcsec/year
Definition starobject.h:199
bool getIndexCoords(const double julianMillenia, CachingDms &ra, CachingDms &dec) const
Fills ra and dec with the coordinates of the star with the proper motion correction but without preci...
void setProperMotion(double pmra, double pmdec)
Set the Ra and Dec components of the star's proper motion, in milliarcsec/year.
Definition starobject.h:223
void setVariable(bool v)
set the star's variability flag
Definition starobject.h:261
double parallax() const
Definition starobject.h:239
bool isVariable() const
Definition starobject.h:264
QString sptype(void) const
Returns entire spectral type string.
bool hasName() const
Definition starobject.h:120
void init(const StarData *stardata)
Initializes a StarObject to given data.
QString gname(bool useGreekChars=true) const
Returns the genetive name of the star.
~StarObject() override=default
Destructor.
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
bool isEmpty() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
A 16-byte structure that holds star data for really faint stars.
A 32-byte Structure that holds star data.
Definition stardata.h:18
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.