Stellarium 0.11.4
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., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, 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 #ifdef __OpenBSD__
00040 #include <unistd.h>
00041 #endif
00042 
00043 // Patch by Rainer Canavan for compilation on irix with mipspro compiler part 1
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 } // namespace BigStarCatalogExtension
00214 
00215 #endif // _ZONEARRAY_HPP_
Generated on Sat Aug 25 22:13:29 2012 for Stellarium by  doxygen 1.6.3