Stellarium 0.13.1
StarWrapper.hpp
1 /*
2  * The big star catalogue extension to Stellarium:
3  * Author and Copyright: Johannes Gajdosik, 2006, 2007
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 _STARWRAPPER_HPP_
21 #define _STARWRAPPER_HPP_
22 
23 #include "StelObject.hpp"
24 #include "StelApp.hpp"
25 #include "StelCore.hpp"
26 #include "StarMgr.hpp"
27 #include "Star.hpp"
28 #include "StelSkyDrawer.hpp"
29 
30 #include <QString>
31 
32 template <class Star> class SpecialZoneArray;
33 template <class Star> struct SpecialZoneData;
34 
35 
44 {
45 protected:
46  StarWrapperBase(void) : ref_count(0) {;}
47  virtual ~StarWrapperBase(void) {;}
48  QString getType(void) const {return "Star";}
49 
50  QString getEnglishName(void) const {return "";}
51  QString getNameI18n(void) const = 0;
52 
63  QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
64  virtual float getBV(void) const = 0;
65 
66 private:
67  int ref_count;
68 };
69 
70 template <class Star> class StarWrapper : public StarWrapperBase
71 {
72 protected:
74  const SpecialZoneData<Star> *z,
75  const Star *s) : a(a), z(z), s(s) {;}
77  {
78  static const double d2000 = 2451545.0;
79  Vec3f v;
80  s->getJ2000Pos(z, (M_PI/180.)*(0.0001/3600.) * ((core->getJDay()-d2000)/365.25) / a->star_position_scale, v);
81  return Vec3d(v[0], v[1], v[2]);
82  }
83  Vec3f getInfoColor(void) const
84  {
85  return StelSkyDrawer::indexToColor(s->getBVIndex());
86  }
87  float getVMagnitude(const StelCore* core) const
88  {
89  Q_UNUSED(core);
90  return 0.001f*a->mag_min + s->getMag()*(0.001f*a->mag_range)/a->mag_steps;
91  }
92  float getBV(void) const {return s->getBV();}
93  QString getEnglishName(void) const {return QString();}
94  QString getNameI18n(void) const {return s->getNameI18n();}
95  virtual double getAngularSize(const StelCore*) const {return 0.;}
96 protected:
97  const SpecialZoneArray<Star> *const a;
98  const SpecialZoneData<Star> *const z;
99  const Star *const s;
100 };
101 
102 
103 class StarWrapper1 : public StarWrapper<Star1>
104 {
105 public:
107  const SpecialZoneData<Star1> *z,
108  const Star1 *s) : StarWrapper<Star1>(a,z,s) {;}
109 
123  QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
124  QString getEnglishName(void) const;
125 };
126 
127 class StarWrapper2 : public StarWrapper<Star2>
128 {
129 public:
131  const SpecialZoneData<Star2> *z,
132  const Star2 *s) : StarWrapper<Star2>(a,z,s) {;}
133 };
134 
135 class StarWrapper3 : public StarWrapper<Star3>
136 {
137 public:
139  const SpecialZoneData<Star3> *z,
140  const Star3 *s) : StarWrapper<Star3>(a,z,s) {;}
141 };
142 
143 
144 #endif // _STARWRAPPER_HPP_
static const Vec3f & indexToColor(unsigned char bV)
Convert quantized B-V index to RGB colors.
const int mag_range
Range of magnitudes in this level. Units: millimags.
Definition: ZoneArray.hpp:126
double getJDay() const
Get the current date in Julian Day.
Vec3f getInfoColor(void) const
Get a color used to display info about the object.
Definition: StarWrapper.hpp:83
Wrapper struct around ZoneData.
Definition: Star.hpp:39
Definition: Star.hpp:141
QString getNameI18n(void) const
Return translated object's name.
Definition: StarWrapper.hpp:94
The base abstract class for sky objects used in Stellarium like Stars, Planets, Constellations etc...
Definition: StelObject.hpp:36
QString getInfoString(const StelCore *core, const InfoStringGroup &flags) const
StarWrapperBase supports the following InfoStringGroup flags.
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
Definition: Star.hpp:54
QString getEnglishName(void) const
Return object's name in english.
Definition: StarWrapper.hpp:50
Definition: Star.hpp:218
const int mag_min
Lower bound of magnitudes in this level. Units: millimag. May be negative for brightest stars...
Definition: ZoneArray.hpp:123
QString getNameI18n(void) const =0
Return translated object's name.
QString getType(void) const
Return object's type. It should be the name of the class.
Definition: StarWrapper.hpp:48
virtual double getAngularSize(const StelCore *) const
Return the angular radius of a circle containing the object as seen from the observer with the circle...
Definition: StarWrapper.hpp:95
Vec3d getJ2000EquatorialPos(const StelCore *core) const
Get observer-centered equatorial coordinates at equinox J2000.
Definition: StarWrapper.hpp:76
float getVMagnitude(const StelCore *core) const
Return object's apparent V magnitude as seen from observer, without including extinction.
Definition: StarWrapper.hpp:87
QString getEnglishName(void) const
Return object's name in english.
Implements all the virtual methods in ZoneArray.
Definition: Star.hpp:38
A Star (Star1,Star2,Star3,...) cannot be a StelObject.
Definition: StarWrapper.hpp:43
const int mag_steps
Number of steps used to describe values in mag_range. Always positive. Individual stars have their ma...
Definition: ZoneArray.hpp:129
QString getEnglishName(void) const
Return object's name in english.
Definition: StarWrapper.hpp:93
QString getInfoString(const StelCore *core, const InfoStringGroup &flags) const
StarWrapper1 supports the following InfoStringGroup flags: