Kstars

starobject.h
1 /*
2  SPDX-FileCopyrightText: 2001 Thomas Kabelmann <[email protected]>
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 
13 #include <QString>
14 
15 struct DeepStarData;
16 class KSNumbers;
17 class KSPopupMenu;
18 struct 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  */
32 class 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 KSNumbers *num, CachingDms &ra, CachingDms &dec);
187  bool getIndexCoords(const KSNumbers *num, double *ra, double *dec);
188 
189  /** @short added for JIT updates from both StarComponent and ConstellationLines */
190  void JITupdate();
191 
192  /** @short returns the magnitude of the proper motion correction in milliarcsec/year */
193  inline double pmMagnitude() const
194  {
195  return sqrt(pmRA() * pmRA() + pmDec() * pmDec());
196  }
197 
198  /**
199  * @short returns the square of the magnitude of the proper motion correction in (milliarcsec/year)^2
200  * @note In the Hipparcos catalog, from which most of the proper
201  * motion data in KStars is obtained, the RA correction already
202  * has the cos(delta) factor incorporated into it. See
203  * https://heasarc.gsfc.nasa.gov/W3Browse/all/hipparcos.html
204  * @note This method is faster when the square root need not be taken
205  */
206  inline double pmMagnitudeSquared() const
207  {
208  return (pmRA() * pmRA() + pmDec() * pmDec());
209  }
210 
211  /**
212  * @short Set the Ra and Dec components of the star's proper motion, in milliarcsec/year.
213  * Note that the RA component should already have been multiplied by cos(dec).
214  * @param pmra the new RA proper motion
215  * @param pmdec the new Dec proper motion
216  */
217  inline void setProperMotion(double pmra, double pmdec)
218  {
219  PM_RA = pmra;
220  PM_Dec = pmdec;
221  }
222 
223  /** @return the RA component of the star's proper motion, in mas/yr (multiplied by cos(dec)) */
224  inline double pmRA() const { return PM_RA; }
225 
226  /** @return the Dec component of the star's proper motion, in mas/yr */
227  inline double pmDec() const { return PM_Dec; }
228 
229  /** @short set the star's parallax angle, in milliarcsec */
230  inline void setParallax(double plx) { Parallax = plx; }
231 
232  /** @return the star's parallax angle, in milliarcsec */
233  inline double parallax() const { return Parallax; }
234 
235  /** @return the star's distance from the Sun in parsecs, as computed from the parallax. */
236  inline double distance() const { return 1000. / parallax(); }
237 
238  /**
239  * @short set the star's multiplicity flag (i.e., is it a binary or multiple star?)
240  * @param m true if binary/multiple star system
241  */
242  inline void setMultiple(bool m) { Multiplicity = m; }
243 
244  /** @return whether the star is a binary or multiple starobject */
245  inline bool isMultiple() const { return Multiplicity; }
246 
247  /** @return the star's HD index */
248  inline int getHDIndex() const { return HD; }
249 
250  /**
251  * @short set the star's variability flag
252  *
253  * @param v true if star is variable
254  */
255  inline void setVariable(bool v) { Variability = v; }
256 
257  /** @return whether the star is a binary or multiple starobject */
258  inline bool isVariable() const { return Variability; }
259 
260  /** @short returns the name, the magnitude or both. */
261  QString nameLabel(bool drawName, bool drawMag) const;
262 
263  QString labelString() const override;
264 
265  /**
266  * @return the pixel distance for offseting the star's name label
267  * This takes the zoom level and the star's brightness into account.
268  */
269  double labelOffset() const override;
270 
271  /** @return the Visual magnitude of the star */
272  inline float getVMag() const { return V; }
273 
274  /** @return the blue magnitude of the star */
275  inline float getBMag() const { return B; }
276 
277  /**
278  * @return the B - V color index of the star, or a nonsense number
279  * larger than 30 if it's not well defined
280  */
281  inline float getBVIndex() const { return ((B < 30.0 && V < 30.0) ? B - V : 99.9); }
282 
283  void initPopupMenu(KSPopupMenu *pmenu) override;
284 
285  quint64 updateID { 0 };
286  quint64 updateNumID { 0 };
287 
288 #ifdef PROFILE_UPDATECOORDS
289  static double updateCoordsCpuTime;
290  static unsigned int starsUpdated;
291 #endif
292 
293  protected:
294  // DEBUG EDIT. For testing proper motion, uncomment this, and related blocks
295  // See starobject.cpp for further info.
296  // static QVector<SkyPoint *> Trail;
297  // bool testStar;
298  // END DEBUG
299 
300  private:
301  double PM_RA { 0 };
302  double PM_Dec { 0 };
303  double Parallax { 0 };
304  bool Multiplicity { false };
305  bool Variability { false };
306  char SpType[2];
307  int HD { 0 };
308  // B and V magnitudes, separately. NOTE 1) This is kept separate from mag for a reason.
309  // See init( const DeepStarData *); 2) This applies only to deep stars at the moment
310  float B { 0 };
311  float V { 0 };
312 };
QString greekLetter(bool useGreekChars=true) const
Returns the greek letter portion of the star's genetive name.
Definition: starobject.cpp:567
void setProperMotion(double pmra, double pmdec)
Set the Ra and Dec components of the star's proper motion, in milliarcsec/year.
Definition: starobject.h:217
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.
Definition: starobject.cpp:626
A 32-byte Structure that holds star data.
Definition: stardata.h:17
a dms subclass that caches its sine and cosine values every time the angle is changed.
Definition: cachingdms.h:18
QString labelString() const override
Definition: starobject.cpp:651
void setVariable(bool v)
set the star's variability flag
Definition: starobject.h:255
bool getIndexCoords(const KSNumbers *num, CachingDms &ra, CachingDms &dec)
Fills ra and dec with the coordinates of the star with the proper motion correction but without preci...
Definition: starobject.cpp:290
void setNames(const QString &name, const QString &name2)
Sets the name, genetive name, and long name.
Definition: starobject.cpp:231
bool isVariable() const
Definition: starobject.h:258
qint64 UID
Type for Unique object IDenticator.
Definition: skyobject.h:49
double pmMagnitude() const
returns the magnitude of the proper motion correction in milliarcsec/year
Definition: starobject.h:193
int getHDIndex() const
Definition: starobject.h:248
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),...
Definition: starobject.cpp:258
QString gname(bool useGreekChars=true) const
Returns the genetive name of the star.
Definition: starobject.cpp:559
QString longname(void) const override
If star is unnamed return "star" otherwise return the longname.
Definition: starobject.h:133
Store several time-dependent astronomical quantities.
Definition: ksnumbers.h:42
const CachingDms & dec() const
Definition: skypoint.h:269
subclass of SkyObject specialized for stars.
Definition: starobject.h:32
bool isEmpty() const const
QString sptype(void) const
Returns entire spectral type string.
Definition: starobject.cpp:549
void initPopupMenu(KSPopupMenu *pmenu) override
Initialize the popup menut.
Definition: starobject.cpp:249
double parallax() const
Definition: starobject.h:233
double pmRA() const
Definition: starobject.h:224
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.
Definition: starobject.cpp:57
~StarObject() override=default
Destructor.
void init(const StarData *stardata)
Initializes a StarObject to given data.
Definition: starobject.cpp:133
bool hasLatinName() const
Definition: starobject.h:123
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
float getBMag() const
Definition: starobject.h:275
float getBVIndex() const
Definition: starobject.h:281
char spchar() const
Returns just the first character of the spectral type string.
Definition: starobject.cpp:554
double labelOffset() const override
Definition: starobject.cpp:656
QString constell(void) const
Definition: starobject.cpp:614
const CachingDms & ra() const
Definition: skypoint.h:263
double distance() const
Definition: starobject.h:236
StarObject * clone() const override
Create copy of object.
Definition: starobject.cpp:126
A 16-byte structure that holds star data for really faint stars.
bool hasName() const
Definition: starobject.h:120
double pmMagnitudeSquared() const
returns the square of the magnitude of the proper motion correction in (milliarcsec/year)^2
Definition: starobject.h:206
bool isMultiple() const
Definition: starobject.h:245
void JITupdate()
added for JIT updates from both StarComponent and ConstellationLines
Definition: starobject.cpp:526
QString name2(void) const
Definition: skyobject.h:156
float getVMag() const
Definition: starobject.h:272
UID getUID() const override
Return UID for object.
Definition: starobject.cpp:661
void setParallax(double plx)
set the star's parallax angle, in milliarcsec
Definition: starobject.h:230
double pmDec() const
Definition: starobject.h:227
Information about an object in the sky.
Definition: skyobject.h:41
static double reindexInterval(double pm)
returns the reindex interval (in centuries!) for the given magnitude of proper motion (in milliarcsec...
Definition: starobject.cpp:46
void setMultiple(bool m)
set the star's multiplicity flag (i.e., is it a binary or multiple star?)
Definition: starobject.h:242
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Dec 1 2022 03:58:19 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.