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

modules/ZoneArray.hpp

00001 /*
00002  * The big star catalogue extension to Stellarium:
00003  * Author and Copyright: Johannes Gajdosik, 2006, 2007
00004  * The implementation of SpecialZoneArray<Star>::draw is based on
00005  * Stellarium, Copyright (C) 2002 Fabien Chereau,
00006  * and therefore has shared copyright.
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License
00010  * as published by the Free Software Foundation; either version 2
00011  * of the License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00021  */
00022 
00023 #ifndef _ZONEARRAY_HPP_
00024 #define _ZONEARRAY_HPP_
00025 
00026 #include <QString>
00027 #include <QFile>
00028 #include <QDebug>
00029 
00030 #include "ZoneData.hpp"
00031 #include "Star.hpp"
00032 
00033 #include "StelLoadingBar.hpp"
00034 #include "StelApp.hpp"
00035 #include "StelCore.hpp"
00036 #include "StelSkyDrawer.hpp"
00037 #include "StarMgr.hpp"
00038 #include "bytes.h"
00039 
00040 #include "StelPainter.hpp"
00041 
00042 // Patch by Rainer Canavan for compilation on irix with mipspro compiler part 1
00043 #ifndef MAP_NORESERVE
00044 #  ifdef MAP_AUTORESRV
00045 #    if (defined(__sgi) && defined(_COMPILER_VERSION))
00046 #      define MAP_NORESERVE MAP_AUTORESRV
00047 #    endif
00048 #  else
00049 #    define MAP_NORESERVE 0
00050 #  endif
00051 #endif
00052 
00053 namespace BigStarCatalogExtension
00054 {
00055 
00056 #define NR_OF_HIP 120416
00057 #define FILE_MAGIC 0x835f040a
00058 #define FILE_MAGIC_OTHER_ENDIAN 0x0a045f83
00059 #define FILE_MAGIC_NATIVE 0x835f040b
00060 #define MAX_MAJOR_FILE_VERSION 0
00061 
00065 struct HipIndexStruct
00066 {
00067     const SpecialZoneArray<Star1> *a;
00068     const SpecialZoneData<Star1> *z;
00069     const Star1 *s;
00070 };
00071 
00077 class ZoneArray
00078 {
00079 public:
00087     static ZoneArray *create(const QString &extended_file_name,
00088                              bool use_mmap,
00089                              StelLoadingBar &lb);
00090     virtual ~ZoneArray(void)
00091     {
00092         nr_of_zones = 0;
00093     }
00094     
00096     unsigned int getNrOfStars(void) const { return nr_of_stars; }
00097     
00099     virtual void updateHipIndex(HipIndexStruct hipIndex[]) const {}
00100     
00102     virtual void searchAround(const StelNavigator* nav, int index,const Vec3d &v,double cosLimFov,
00103                               QList<StelObjectP > &result) = 0;
00104     
00106     virtual void draw(int index,bool is_inside,
00107                       const float *rcmag_table, StelCore* core,
00108                       unsigned int maxMagStarName,float names_brightness,
00109                       StelFont *starFont) const = 0;
00110     
00113     bool isInitialized(void) const { return (nr_of_zones>0); }
00114     
00116     void initTriangle(int index,
00117                       const Vec3d &c0,
00118                       const Vec3d &c1,
00119                       const Vec3d &c2);
00120     virtual void scaleAxis(void) = 0;
00121     
00123     const QString fname;
00124     
00126     const int level;
00127     
00129     const int mag_min;
00130     
00132     const int mag_range;
00133     
00135     const int mag_steps;
00136     
00137     double star_position_scale;
00138 protected:
00141     static bool readFileWithStelLoadingBar(QFile& file, void *data,
00142                            qint64 size,StelLoadingBar &lb);
00143     
00145     ZoneArray(const QString& fname, QFile* file, int level, int mag_min,
00146           int mag_range, int mag_steps);
00147     unsigned int nr_of_zones;
00148     unsigned int nr_of_stars;
00149     ZoneData *zones;
00150     QFile* file;
00151 };
00152 
00158 template<class Star>
00159 class SpecialZoneArray : public ZoneArray
00160 {
00161 public:
00171     SpecialZoneArray(QFile* file,bool byte_swap,bool use_mmap,
00172                      StelLoadingBar &lb,int level,int mag_min,
00173              int mag_range,int mag_steps);
00174     ~SpecialZoneArray(void);
00175 protected:
00177     SpecialZoneData<Star> *getZones(void) const
00178     {
00179         return static_cast<SpecialZoneData<Star>*>(zones);
00180     }
00181     
00190     void draw(int index,bool is_inside,
00191               const float *rcmag_table, StelCore* core,
00192               unsigned int maxMagStarName,float names_brightness,
00193               StelFont *starFont) const;
00194     
00195     void scaleAxis(void);
00196     void searchAround(const StelNavigator* nav, int index,const Vec3d &v,double cosLimFov,
00197                       QList<StelObjectP > &result);
00198     
00199     Star *stars;
00200 private:
00201     uchar *mmap_start;
00202 #ifdef WIN32
00203     HANDLE mapping_handle;
00204 #endif
00205 };
00206 
00210 class HipZoneArray : public SpecialZoneArray<Star1>
00211 {
00212 public:
00213     HipZoneArray(QFile* file,bool byte_swap,bool use_mmap,StelLoadingBar &lb,
00214            int level,int mag_min,int mag_range,int mag_steps)
00215             : SpecialZoneArray<Star1>(file,byte_swap,use_mmap,lb,level,
00216                                       mag_min,mag_range,mag_steps) {}
00217     
00220     void updateHipIndex(HipIndexStruct hipIndex[]) const;
00221 };
00222 
00223 } // namespace BigStarCatalogExtension
00224 
00225 #endif // _ZONEARRAY_HPP_

Generated on Mon Mar 9 16:16:16 2009 for Stellarium by  doxygen 1.5.5