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 "StelCore.hpp"
00034 #include "StelSkyDrawer.hpp"
00035 #include "StarMgr.hpp"
00036
00037 #include "StelPainter.hpp"
00038
00039
00040 #ifndef MAP_NORESERVE
00041 # ifdef MAP_AUTORESRV
00042 # if (defined(__sgi) && defined(_COMPILER_VERSION))
00043 # define MAP_NORESERVE MAP_AUTORESRV
00044 # endif
00045 # else
00046 # define MAP_NORESERVE 0
00047 # endif
00048 #endif
00049
00050 namespace BigStarCatalogExtension
00051 {
00052
00053 #define NR_OF_HIP 120416
00054 #define FILE_MAGIC 0x835f040a
00055 #define FILE_MAGIC_OTHER_ENDIAN 0x0a045f83
00056 #define FILE_MAGIC_NATIVE 0x835f040b
00057 #define MAX_MAJOR_FILE_VERSION 0
00058
00062 struct HipIndexStruct
00063 {
00064 const SpecialZoneArray<Star1> *a;
00065 const SpecialZoneData<Star1> *z;
00066 const Star1 *s;
00067 };
00068
00074 class ZoneArray
00075 {
00076 public:
00083 static ZoneArray *create(const QString &extended_file_name, bool use_mmap);
00084 virtual ~ZoneArray()
00085 {
00086 nr_of_zones = 0;
00087 }
00088
00090 unsigned int getNrOfStars() const { return nr_of_stars; }
00091
00093 virtual void updateHipIndex(HipIndexStruct hipIndex[]) const {Q_UNUSED(hipIndex);}
00094
00096 virtual void searchAround(const StelNavigator* nav, int index,const Vec3d &v,double cosLimFov,
00097 QList<StelObjectP > &result) = 0;
00098
00100 virtual void draw(StelPainter* sPainter, int index,bool is_inside,
00101 const float *rcmag_table, StelCore* core,
00102 unsigned int maxMagStarName,float names_brightness) const = 0;
00103
00106 bool isInitialized(void) const { return (nr_of_zones>0); }
00107
00109 void initTriangle(int index,
00110 const Vec3f &c0,
00111 const Vec3f &c1,
00112 const Vec3f &c2);
00113 virtual void scaleAxis(void) = 0;
00114
00116 const QString fname;
00117
00119 const int level;
00120
00122 const int mag_min;
00123
00125 const int mag_range;
00126
00128 const int mag_steps;
00129
00130 float star_position_scale;
00131
00132 protected:
00135 static bool readFile(QFile& file, void *data, qint64 size);
00136
00138 ZoneArray(const QString& fname, QFile* file, int level, int mag_min, int mag_range, int mag_steps);
00139 unsigned int nr_of_zones;
00140 unsigned int nr_of_stars;
00141 ZoneData *zones;
00142 QFile* file;
00143 };
00144
00150 template<class Star>
00151 class SpecialZoneArray : public ZoneArray
00152 {
00153 public:
00162 SpecialZoneArray(QFile* file,bool byte_swap,bool use_mmap,int level,int mag_min,
00163 int mag_range,int mag_steps);
00164 ~SpecialZoneArray(void);
00165 protected:
00167 SpecialZoneData<Star> *getZones(void) const
00168 {
00169 return static_cast<SpecialZoneData<Star>*>(zones);
00170 }
00171
00180 void draw(StelPainter* sPainter, int index,bool is_inside,
00181 const float *rcmag_table, StelCore* core,
00182 unsigned int maxMagStarName,float names_brightness) const;
00183
00184 void scaleAxis(void);
00185 void searchAround(const StelNavigator* nav, int index,const Vec3d &v,double cosLimFov,
00186 QList<StelObjectP > &result);
00187
00188 Star *stars;
00189 private:
00190 uchar *mmap_start;
00191 };
00192
00196 class HipZoneArray : public SpecialZoneArray<Star1>
00197 {
00198 public:
00199 HipZoneArray(QFile* file,bool byte_swap,bool use_mmap,
00200 int level,int mag_min,int mag_range,int mag_steps)
00201 : SpecialZoneArray<Star1>(file,byte_swap,use_mmap,level,
00202 mag_min,mag_range,mag_steps) {}
00203
00206 void updateHipIndex(HipIndexStruct hipIndex[]) const;
00207 };
00208
00209 }
00210
00211 #endif // _ZONEARRAY_HPP_