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 #ifdef __OpenBSD__
00040 #include <unistd.h>
00041 #endif
00042
00043
00044 #ifndef MAP_NORESERVE
00045 # ifdef MAP_AUTORESRV
00046 # if (defined(__sgi) && defined(_COMPILER_VERSION))
00047 # define MAP_NORESERVE MAP_AUTORESRV
00048 # endif
00049 # else
00050 # define MAP_NORESERVE 0
00051 # endif
00052 #endif
00053
00054 namespace BigStarCatalogExtension
00055 {
00056
00057 #define NR_OF_HIP 120416
00058 #define FILE_MAGIC 0x835f040a
00059 #define FILE_MAGIC_OTHER_ENDIAN 0x0a045f83
00060 #define FILE_MAGIC_NATIVE 0x835f040b
00061 #define MAX_MAJOR_FILE_VERSION 0
00062
00066 struct HipIndexStruct
00067 {
00068 const SpecialZoneArray<Star1> *a;
00069 const SpecialZoneData<Star1> *z;
00070 const Star1 *s;
00071 };
00072
00078 class ZoneArray
00079 {
00080 public:
00087 static ZoneArray *create(const QString &extended_file_name, bool use_mmap);
00088 virtual ~ZoneArray()
00089 {
00090 nr_of_zones = 0;
00091 }
00092
00094 unsigned int getNrOfStars() const { return nr_of_stars; }
00095
00097 virtual void updateHipIndex(HipIndexStruct hipIndex[]) const {Q_UNUSED(hipIndex);}
00098
00100 virtual void searchAround(const StelCore* core, 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 Vec3f &c0,
00115 const Vec3f &c1,
00116 const Vec3f &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 float star_position_scale;
00135
00136 protected:
00139 static bool readFile(QFile& file, void *data, qint64 size);
00140
00142 ZoneArray(const QString& fname, QFile* file, int level, int mag_min, int mag_range, int mag_steps);
00143 unsigned int nr_of_zones;
00144 unsigned int nr_of_stars;
00145 ZoneData *zones;
00146 QFile* file;
00147 };
00148
00154 template<class Star>
00155 class SpecialZoneArray : public ZoneArray
00156 {
00157 public:
00166 SpecialZoneArray(QFile* file,bool byte_swap,bool use_mmap,int level,int mag_min,
00167 int mag_range,int mag_steps);
00168 ~SpecialZoneArray(void);
00169 protected:
00171 SpecialZoneData<Star> *getZones(void) const
00172 {
00173 return static_cast<SpecialZoneData<Star>*>(zones);
00174 }
00175
00184 void draw(StelPainter* sPainter, int index,bool is_inside,
00185 const float *rcmag_table, StelCore* core,
00186 unsigned int maxMagStarName,float names_brightness) const;
00187
00188 void scaleAxis(void);
00189 void searchAround(const StelCore* core, int index,const Vec3d &v,double cosLimFov,
00190 QList<StelObjectP > &result);
00191
00192 Star *stars;
00193 private:
00194 uchar *mmap_start;
00195 };
00196
00200 class HipZoneArray : public SpecialZoneArray<Star1>
00201 {
00202 public:
00203 HipZoneArray(QFile* file,bool byte_swap,bool use_mmap,
00204 int level,int mag_min,int mag_range,int mag_steps)
00205 : SpecialZoneArray<Star1>(file,byte_swap,use_mmap,level,
00206 mag_min,mag_range,mag_steps) {}
00207
00210 void updateHipIndex(HipIndexStruct hipIndex[]) const;
00211 };
00212
00213 }
00214
00215 #endif // _ZONEARRAY_HPP_