Stellarium  0.16.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_TYPE;}
49  QString getID(void) const { return getEnglishName(); } //TODO: add a proper ID here (probably based on position?)
50 
51  QString getEnglishName(void) const {return "";}
52  QString getNameI18n(void) const = 0;
53 
64  QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
65  virtual float getBV(void) const = 0;
66 
67 private:
68  int ref_count;
69 };
70 
71 template <class Star> class StarWrapper : public StarWrapperBase
72 {
73 protected:
75  const SpecialZoneData<Star> *z,
76  const Star *s) : a(a), z(z), s(s) {;}
78  {
79  static const double d2000 = 2451545.0;
80  Vec3f v;
81  s->getJ2000Pos(z, (M_PI/180.)*(0.0001/3600.) * ((core->getJDE()-d2000)/365.25) / a->star_position_scale, v);
82  return Vec3d(v[0], v[1], v[2]);
83  }
84  Vec3f getInfoColor(void) const
85  {
86  return StelSkyDrawer::indexToColor(s->getBVIndex());
87  }
88  float getVMagnitude(const StelCore* core) const
89  {
90  Q_UNUSED(core);
91  return 0.001f*a->mag_min + s->getMag()*(0.001f*a->mag_range)/a->mag_steps;
92  }
93  float getBV(void) const {return s->getBV();}
94  QString getEnglishName(void) const {return QString();}
95  QString getNameI18n(void) const {return s->getNameI18n();}
96  virtual double getAngularSize(const StelCore*) const {return 0.;}
97 protected:
98  const SpecialZoneArray<Star> *const a;
99  const SpecialZoneData<Star> *const z;
100  const Star *const s;
101 };
102 
103 
104 class StarWrapper1 : public StarWrapper<Star1>
105 {
106 public:
108  const SpecialZoneData<Star1> *z,
109  const Star1 *s) : StarWrapper<Star1>(a,z,s) {;}
110 
124  QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
138  virtual QVariantMap getInfoMap(const StelCore *core) const;
139  QString getEnglishName(void) const;
140 };
141 
142 class StarWrapper2 : public StarWrapper<Star2>
143 {
144 public:
146  const SpecialZoneData<Star2> *z,
147  const Star2 *s) : StarWrapper<Star2>(a,z,s) {;}
148 };
149 
150 class StarWrapper3 : public StarWrapper<Star3>
151 {
152 public:
154  const SpecialZoneData<Star3> *z,
155  const Star3 *s) : StarWrapper<Star3>(a,z,s) {;}
156 };
157 
158 
159 #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
Vec3f getInfoColor(void) const
Get a color used to display info about the object.
Definition: StarWrapper.hpp:84
Wrapper struct around ZoneData.
Definition: Star.hpp:38
Definition: Star.hpp:146
QString getNameI18n(void) const
Return translated object&#39;s name.
Definition: StarWrapper.hpp:95
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:48
Definition: Star.hpp:53
virtual QVariantMap getInfoMap(const StelCore *core) const
Return a key/value map with data about an object&#39;s position, magnitude and so on. ...
QString getEnglishName(void) const
Return object&#39;s name in english.
Definition: StarWrapper.hpp:51
Definition: Star.hpp:223
double getJDE() const
Get the current date in Julian Day (TT).
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&#39;s name.
QString getType(void) const
Return object&#39;s type. It should be the name of the class.
Definition: StarWrapper.hpp:48
QString getID(void) const
Returns a unique identifier for this object.
Definition: StarWrapper.hpp:49
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:96
Vec3d getJ2000EquatorialPos(const StelCore *core) const
Get observer-centered equatorial coordinates at equinox J2000.
Definition: StarWrapper.hpp:77
float getVMagnitude(const StelCore *core) const
Return object&#39;s apparent V magnitude as seen from observer, without including extinction.
Definition: StarWrapper.hpp:88
Implements all the virtual methods in ZoneArray.
Definition: Star.hpp:37
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&#39;s name in english.
Definition: StarWrapper.hpp:94