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

core/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 "StelCore.hpp"
00034 #include "StelSkyDrawer.hpp"
00035 #include "StarMgr.hpp"
00036 
00037 #include "StelPainter.hpp"
00038 
00039 // Patch by Rainer Canavan for compilation on irix with mipspro compiler part 1
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 } // namespace BigStarCatalogExtension
00210 
00211 #endif // _ZONEARRAY_HPP_

Generated on Wed Jun 2 13:11:13 2010 for Stellarium by  doxygen 1.5.5