Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

core/modules/StarWrapper.hpp

00001 /*
00002  * The big star catalogue extension to Stellarium:
00003  * Author and Copyright: Johannes Gajdosik, 2006, 2007
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef _STARWRAPPER_HPP_
00021 #define _STARWRAPPER_HPP_
00022 
00023 #include <QString>
00024 #include "StelObject.hpp"
00025 #include "StelApp.hpp"
00026 #include "StelNavigator.hpp"
00027 #include "StarMgr.hpp"
00028 #include "Star.hpp"
00029 #include "StelSkyDrawer.hpp"
00030 
00031 namespace BigStarCatalogExtension {
00032 
00033 template <class Star> struct SpecialZoneArray;
00034 template <class Star> struct SpecialZoneData;
00035 
00036 
00044 class StarWrapperBase : public StelObject
00045 {
00046 protected:
00047     StarWrapperBase(void) : ref_count(0) {;}
00048     virtual ~StarWrapperBase(void) {;}
00049     QString getType(void) const {return "Star";}
00050 
00051     QString getEnglishName(void) const {return "";}
00052     QString getNameI18n(void) const = 0;
00053 
00064     QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
00065     virtual float getBV(void) const = 0;
00066 
00067 private:
00068     int ref_count;
00069 };
00070 
00071 template <class Star> class StarWrapper : public StarWrapperBase
00072 {
00073 protected:
00074     StarWrapper(const SpecialZoneArray<Star> *a,
00075         const SpecialZoneData<Star> *z,
00076         const Star *s) : a(a), z(z), s(s) {;}
00077     Vec3d getJ2000EquatorialPos(const StelNavigator* nav) const
00078     {
00079         static const double d2000 = 2451545.0;
00080         Vec3f v;
00081         s->getJ2000Pos(z, (M_PI/180.)*(0.0001/3600.) * ((nav->getJDay()-d2000)/365.25) / a->star_position_scale, v);
00082         return Vec3d(v[0], v[1], v[2]);
00083     }
00084     Vec3f getInfoColor(void) const
00085     {
00086         return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.8, 0.2, 0.2) : StelSkyDrawer::indexToColor(s->bV);
00087     }
00088     float getVMagnitude(const StelNavigator*) const
00089     {
00090         return 0.001f*a->mag_min + s->mag*(0.001f*a->mag_range)/a->mag_steps;
00091     }
00092     float getSelectPriority(const StelNavigator *nav) const {return getVMagnitude(nav);}
00093     float getBV(void) const {return s->getBV();}
00094     QString getEnglishName(void) const {return QString();}
00095     QString getNameI18n(void) const {return s->getNameI18n();}
00096     virtual double getAngularSize(const StelCore*) const {return 0.;}
00097 protected:
00098     const SpecialZoneArray<Star> *const a;
00099     const SpecialZoneData<Star> *const z;
00100     const Star *const s;
00101 };
00102 
00103 
00104 class StarWrapper1 : public StarWrapper<Star1>
00105 {
00106 public:
00107     StarWrapper1(const SpecialZoneArray<Star1> *a,
00108         const SpecialZoneData<Star1> *z,
00109         const Star1 *s) : StarWrapper<Star1>(a,z,s) {;}
00110 
00125     QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
00126     QString getEnglishName(void) const;
00127 };
00128 
00129 class StarWrapper2 : public StarWrapper<Star2>
00130 {
00131 public:
00132     StarWrapper2(const SpecialZoneArray<Star2> *a,
00133                const SpecialZoneData<Star2> *z,
00134                const Star2 *s) : StarWrapper<Star2>(a,z,s) {;}
00135 };
00136 
00137 class StarWrapper3 : public StarWrapper<Star3>
00138 {
00139 public:
00140     StarWrapper3(const SpecialZoneArray<Star3> *a,
00141                const SpecialZoneData<Star3> *z,
00142                const Star3 *s) : StarWrapper<Star3>(a,z,s) {;}
00143 };
00144 
00145 } // namespace BigStarCatalogExtension
00146 
00147 #endif // _STARWRAPPER_HPP_

Generated on Wed Jun 2 13:11:13 2010 for Stellarium by  doxygen 1.5.5