00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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 "StelCore.hpp"
00035 #include "StelSkyDrawer.hpp"
00036 #include "StarMgr.hpp"
00037
00038 #include "StelPainter.hpp"
00039
00040
00041 #ifndef MAP_NORESERVE
00042 # ifdef MAP_AUTORESRV
00043 # if (defined(__sgi) && defined(_COMPILER_VERSION))
00044 # define MAP_NORESERVE MAP_AUTORESRV
00045 # endif
00046 # else
00047 # define MAP_NORESERVE 0
00048 # endif
00049 #endif
00050
00051 namespace BigStarCatalogExtension
00052 {
00053
00054 #define NR_OF_HIP 120416
00055 #define FILE_MAGIC 0x835f040a
00056 #define FILE_MAGIC_OTHER_ENDIAN 0x0a045f83
00057 #define FILE_MAGIC_NATIVE 0x835f040b
00058 #define MAX_MAJOR_FILE_VERSION 0
00059
00063 struct HipIndexStruct
00064 {
00065 const SpecialZoneArray<Star1> *a;
00066 const SpecialZoneData<Star1> *z;
00067 const Star1 *s;
00068 };
00069
00075 class ZoneArray
00076 {
00077 public:
00085 static ZoneArray *create(const QString &extended_file_name,
00086 bool use_mmap,
00087 StelLoadingBar* lb);
00088 virtual ~ZoneArray(void)
00089 {
00090 nr_of_zones = 0;
00091 }
00092
00094 unsigned int getNrOfStars(void) const { return nr_of_stars; }
00095
00097 virtual void updateHipIndex(HipIndexStruct hipIndex[]) const {}
00098
00100 virtual void searchAround(const StelNavigator* nav, int index,const Vec3d &v,double cosLimFov,
00101 QList<StelObjectP > &result) = 0;
00102
00104 virtual void draw(StelPainter* sPainter, int index,bool is_inside,
00105 const float *rcmag_table, StelCore* core,
00106 unsigned int maxMagStarName,float names_brightness) const = 0;
00107
00110 bool isInitialized(void) const { return (nr_of_zones>0); }
00111
00113 void initTriangle(int index,
00114 const Vec3d &c0,
00115 const Vec3d &c1,
00116 const Vec3d &c2);
00117 virtual void scaleAxis(void) = 0;
00118
00120 const QString fname;
00121
00123 const int level;
00124
00126 const int mag_min;
00127
00129 const int mag_range;
00130
00132 const int mag_steps;
00133
00134 double star_position_scale;
00135 protected:
00138 static bool readFileWithStelLoadingBar(QFile& file, void *data,
00139 qint64 size,StelLoadingBar* lb);
00140
00142 ZoneArray(const QString& fname, QFile* file, int level, int mag_min,
00143 int mag_range, int mag_steps);
00144 unsigned int nr_of_zones;
00145 unsigned int nr_of_stars;
00146 ZoneData *zones;
00147 QFile* file;
00148 };
00149
00155 template<class Star>
00156 class SpecialZoneArray : public ZoneArray
00157 {
00158 public:
00168 SpecialZoneArray(QFile* file,bool byte_swap,bool use_mmap,
00169 StelLoadingBar*lb,int level,int mag_min,
00170 int mag_range,int mag_steps);
00171 ~SpecialZoneArray(void);
00172 protected:
00174 SpecialZoneData<Star> *getZones(void) const
00175 {
00176 return static_cast<SpecialZoneData<Star>*>(zones);
00177 }
00178
00187 void draw(StelPainter* sPainter, int index,bool is_inside,
00188 const float *rcmag_table, StelCore* core,
00189 unsigned int maxMagStarName,float names_brightness) const;
00190
00191 void scaleAxis(void);
00192 void searchAround(const StelNavigator* nav, int index,const Vec3d &v,double cosLimFov,
00193 QList<StelObjectP > &result);
00194
00195 Star *stars;
00196 private:
00197 uchar *mmap_start;
00198 };
00199
00203 class HipZoneArray : public SpecialZoneArray<Star1>
00204 {
00205 public:
00206 HipZoneArray(QFile* file,bool byte_swap,bool use_mmap,StelLoadingBar* lb,
00207 int level,int mag_min,int mag_range,int mag_steps)
00208 : SpecialZoneArray<Star1>(file,byte_swap,use_mmap,lb,level,
00209 mag_min,mag_range,mag_steps) {}
00210
00213 void updateHipIndex(HipIndexStruct hipIndex[]) const;
00214 };
00215
00216 }
00217
00218 #endif // _ZONEARRAY_HPP_