Stellarium 0.11.4
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., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, 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 "StelCore.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 StelCore* core) const
00078     {
00079         static const double d2000 = 2451545.0;
00080         Vec3f v;
00081         s->getJ2000Pos(z, (M_PI/180.)*(0.0001/3600.) * ((core->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.0, 0.0) : StelSkyDrawer::indexToColor(s->bV);
00087     }
00088     float getVMagnitude(const StelCore* core, bool withExtinction=false) const
00089     {
00090         float extinctionMag=0.0; // track magnitude loss
00091         if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere())
00092         {
00093         double alt=getAltAzPosApparent(core)[2];
00094         core->getSkyDrawer()->getExtinction().forward(&alt, &extinctionMag);
00095         }
00096 
00097         return 0.001f*a->mag_min + s->mag*(0.001f*a->mag_range)/a->mag_steps  + extinctionMag;
00098     }
00099     float getSelectPriority(const StelCore* core) const {return getVMagnitude(core, false);}
00100     float getBV(void) const {return s->getBV();}
00101     QString getEnglishName(void) const {return QString();}
00102     QString getNameI18n(void) const {return s->getNameI18n();}
00103     virtual double getAngularSize(const StelCore*) const {return 0.;}
00104 protected:
00105     const SpecialZoneArray<Star> *const a;
00106     const SpecialZoneData<Star> *const z;
00107     const Star *const s;
00108 };
00109 
00110 
00111 class StarWrapper1 : public StarWrapper<Star1>
00112 {
00113 public:
00114     StarWrapper1(const SpecialZoneArray<Star1> *a,
00115         const SpecialZoneData<Star1> *z,
00116         const Star1 *s) : StarWrapper<Star1>(a,z,s) {;}
00117 
00132     QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
00133     QString getEnglishName(void) const;
00134 };
00135 
00136 class StarWrapper2 : public StarWrapper<Star2>
00137 {
00138 public:
00139     StarWrapper2(const SpecialZoneArray<Star2> *a,
00140                const SpecialZoneData<Star2> *z,
00141                const Star2 *s) : StarWrapper<Star2>(a,z,s) {;}
00142 };
00143 
00144 class StarWrapper3 : public StarWrapper<Star3>
00145 {
00146 public:
00147     StarWrapper3(const SpecialZoneArray<Star3> *a,
00148                const SpecialZoneData<Star3> *z,
00149                const Star3 *s) : StarWrapper<Star3>(a,z,s) {;}
00150 };
00151 
00152 } // namespace BigStarCatalogExtension
00153 
00154 #endif // _STARWRAPPER_HPP_
Generated on Sat Aug 25 22:13:29 2012 for Stellarium by  doxygen 1.6.3