Stellarium 0.15.2
ZoneArray.hpp
1 /*
2  * The big star catalogue extension to Stellarium:
3  * Author and Copyright: Johannes Gajdosik, 2006, 2007
4  * The implementation of SpecialZoneArray<Star>::draw is based on
5  * Stellarium, Copyright (C) 2002 Fabien Chereau,
6  * and therefore has shared copyright.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
21  */
22 
23 #ifndef _ZONEARRAY_HPP_
24 #define _ZONEARRAY_HPP_
25 
26 #include "ZoneData.hpp"
27 #include "Star.hpp"
28 
29 #include "StelCore.hpp"
30 #include "StelSkyDrawer.hpp"
31 #include "StarMgr.hpp"
32 
33 #include <QString>
34 #include <QFile>
35 #include <QDebug>
36 
37 #ifdef __OpenBSD__
38 #include <unistd.h>
39 #endif
40 
41 class StelPainter;
42 
43 // Patch by Rainer Canavan for compilation on irix with mipspro compiler part 1
44 #ifndef MAP_NORESERVE
45 # ifdef MAP_AUTORESRV
46 # if (defined(__sgi) && defined(_COMPILER_VERSION))
47 # define MAP_NORESERVE MAP_AUTORESRV
48 # endif
49 # else
50 # define MAP_NORESERVE 0
51 # endif
52 #endif
53 
54 
55 #define NR_OF_HIP 120416
56 #define FILE_MAGIC 0x835f040a
57 #define FILE_MAGIC_OTHER_ENDIAN 0x0a045f83
58 #define FILE_MAGIC_NATIVE 0x835f040b
59 #define MAX_MAJOR_FILE_VERSION 0
60 
65 {
66  const SpecialZoneArray<Star1> *a;
67  const SpecialZoneData<Star1> *z;
68  const Star1 *s;
69 };
70 
76 class ZoneArray
77 {
78 public:
85  static ZoneArray *create(const QString &extended_file_name, bool use_mmap);
86  virtual ~ZoneArray()
87  {
88  nr_of_zones = 0;
89  }
90 
92  unsigned int getNrOfStars() const { return nr_of_stars; }
93 
95  virtual void updateHipIndex(HipIndexStruct hipIndex[]) const {Q_UNUSED(hipIndex);}
96 
98  virtual void searchAround(const StelCore* core, int index,const Vec3d &v,double cosLimFov,
99  QList<StelObjectP > &result) = 0;
100 
102  virtual void draw(StelPainter* sPainter, int index,bool is_inside,
103  const RCMag* rcmag_table, int limitMagIndex, StelCore* core,
104  int maxMagStarName, float names_brightness,
105  const QVector<SphericalCap>& boundingCaps) const = 0;
106 
109  bool isInitialized(void) const { return (nr_of_zones>0); }
110 
112  void initTriangle(int index, const Vec3f &c0, const Vec3f &c1, const Vec3f &c2);
113 
114  virtual void scaleAxis() = 0;
115 
117  const QString fname;
118 
120  const int level;
121 
123  const int mag_min;
124 
126  const int mag_range;
127 
129  const int mag_steps;
130 
131  float star_position_scale;
132 
133 protected:
136  static bool readFile(QFile& file, void *data, qint64 size);
137 
139  ZoneArray(const QString& fname, QFile* file, int level, int mag_min, int mag_range, int mag_steps);
140  unsigned int nr_of_zones;
141  unsigned int nr_of_stars;
142  ZoneData *zones;
143  QFile* file;
144 };
145 
151 template<class Star>
152 class SpecialZoneArray : public ZoneArray
153 {
154 public:
163  SpecialZoneArray(QFile* file,bool byte_swap,bool use_mmap,int level,int mag_min,
164  int mag_range,int mag_steps);
165  ~SpecialZoneArray(void);
166 protected:
169  {
170  return static_cast<SpecialZoneData<Star>*>(zones);
171  }
172 
182  virtual void draw(StelPainter* sPainter, int index, bool isInsideViewport,
183  const RCMag *rcmag_table, int limitMagIndex, StelCore* core,
184  int maxMagStarName, float names_brightness,
185  const QVector<SphericalCap>& boundingCaps) const;
186 
187  virtual void scaleAxis();
188  virtual void searchAround(const StelCore* core, int index,const Vec3d &v,double cosLimFov,
189  QList<StelObjectP > &result);
190 
191  Star *stars;
192 private:
193  uchar *mmap_start;
194 };
195 
199 class HipZoneArray : public SpecialZoneArray<Star1>
200 {
201 public:
202  HipZoneArray(QFile* file,bool byte_swap,bool use_mmap,
203  int level,int mag_min,int mag_range,int mag_steps)
204  : SpecialZoneArray<Star1>(file,byte_swap,use_mmap,level,
205  mag_min,mag_range,mag_steps) {}
206 
209  void updateHipIndex(HipIndexStruct hipIndex[]) const;
210 };
211 
212 #endif // _ZONEARRAY_HPP_
const int mag_range
Range of magnitudes in this level. Units: millimags.
Definition: ZoneArray.hpp:126
Container for Hipparcos information.
Definition: ZoneArray.hpp:64
Manages all ZoneData structures of a given StelGeodesicGrid level.
Definition: ZoneArray.hpp:76
const int level
Level in StelGeodesicGrid.
Definition: ZoneArray.hpp:120
SpecialZoneData< Star > * getZones(void) const
Get an array of all SpecialZoneData objects in this catalog.
Definition: ZoneArray.hpp:168
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
bool isInitialized(void) const
Get whether or not the catalog was successfully loaded.
Definition: ZoneArray.hpp:109
Definition: Star.hpp:51
A single triangle.
Definition: ZoneData.hpp:37
Contains the 2 parameters necessary to draw a star on screen.
Provides functions for performing openGL drawing operations.
Definition: StelPainter.hpp:40
const int mag_min
Lower bound of magnitudes in this level. Units: millimag. May be negative for brightest stars...
Definition: ZoneArray.hpp:123
unsigned int getNrOfStars() const
Get the total number of stars in this catalog.
Definition: ZoneArray.hpp:92
ZoneArray of Hipparcos stars.
Definition: ZoneArray.hpp:199
const int mag_steps
Number of steps used to describe values in mag_range. Always positive. Individual stars have their ma...
Definition: ZoneArray.hpp:129
virtual void updateHipIndex(HipIndexStruct hipIndex[]) const
Dummy method that does nothing. See subclass implementation.
Definition: ZoneArray.hpp:95
const QString fname
File path of the catalog.
Definition: ZoneArray.hpp:117