Stellarium 0.12.2
StarMgr.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2002 Fabien Chereau
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STARMGR_HPP_
21 #define _STARMGR_HPP_
22 
23 #include <QFont>
24 #include <QVariantMap>
25 #include "StelFader.hpp"
26 #include "StelObjectModule.hpp"
27 #include "StelProjectorType.hpp"
28 
29 class StelObject;
30 class StelToneReproducer;
31 class StelProjector;
32 class QSettings;
33 
34 namespace BigStarCatalogExtension {
35  class ZoneArray;
36  struct HipIndexStruct;
37 }
38 
39 static const int RCMAG_TABLE_SIZE = 4096;
40 
41 typedef struct
42 {
43  QString designation;
44  QString vtype;
45  float maxmag;
46  int mflag;
47  float minmag;
48  QString photosys;
49  double epoch;
50  double period;
51  int Mm;
52  QString stype;
53 } varstar;
54 
78 class StarMgr : public StelObjectModule
79 {
80  Q_OBJECT
81 
82 public:
83  StarMgr(void);
84  ~StarMgr(void);
85 
87  // Methods defined in the StelModule class
95  virtual void init();
96 
98  virtual void draw(StelCore* core, class StelRenderer* renderer);
99 
102  virtual void update(double deltaTime) {labelsFader.update((int)(deltaTime*1000)); starsFader.update((int)(deltaTime*1000));}
103 
105  virtual double getCallOrder(StelModuleActionName actionName) const;
106 
108  // Methods defined in StelObjectManager class
110  virtual QList<StelObjectP > searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
111 
115  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
116 
119  virtual StelObjectP searchByName(const QString& name) const;
120 
125  virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5) const;
130  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5) const;
131  // empty, as there's too much stars for displaying at once
132  virtual QStringList listAllObjects(bool inEnglish) const { Q_UNUSED(inEnglish) return QStringList(); }
133  virtual QString getName() const { return "Stars"; }
134 
135 public slots:
137  // Methods callable from script and GUI
139  void setLabelColor(const Vec3f& c) {labelColor = c;}
141  Vec3f getLabelColor(void) const {return labelColor;}
142 
144  void setFlagStars(bool b) {starsFader=b;}
146  bool getFlagStars(void) const {return starsFader==true;}
147 
149  void setFlagLabels(bool b) {labelsFader=b;}
151  bool getFlagLabels(void) const {return labelsFader==true;}
152 
156  void setLabelsAmount(float a) {labelsAmount=a;}
159  float getLabelsAmount(void) const {return labelsAmount;}
160 
162  void setFontSize(double newFontSize);
163 
165  static void setFlagSciNames(bool f) {flagSciNames = f;}
166  static bool getFlagSciNames(void) {return flagSciNames;}
167 
168 public:
170  // Other methods
175  StelObjectP searchHP(int hip) const;
176 
179  static QString getCommonName(int hip);
180 
183  static QString getSciName(int hip);
184 
187  static QString getGCVSName(int hip);
188 
191  static QString getGCVSVariabilityType(int hip);
192 
195  static float getGCVSMaxMagnitude(int hip);
196 
199  static int getGCVSMagnitudeFlag(int hip);
200 
203  static float getGCVSMinMagnitude(int hip);
204 
207  static QString getGCVSPhotometricSystem(int hip);
208 
211  static double getGCVSEpoch(int hip);
212 
215  static double getGCVSPeriod(int hip);
216 
219  static int getGCVSMM(int hip);
220 
221  static QString convertToSpectralType(int index);
222  static QString convertToComponentIds(int index);
223 
224  QVariantList getCatalogsDescription() const {return catalogsDescription;}
225 
229  bool checkAndLoadCatalog(QVariantMap m);
230 
231 private slots:
232  void setStelStyle(const QString& section);
234  void updateI18n();
235 
239  void updateSkyCulture(const QString& skyCultureDir);
240 
241 private:
242 
243  void setCheckFlag(const QString& catalogId, bool b);
244 
245  void copyDefaultConfigFile();
246 
250  int loadCommonNames(const QString& commonNameFile);
251 
255  void loadSciNames(const QString& sciNameFile);
256 
259  void loadGCVS(const QString& GCVSFile);
260 
262  // TODO: add a non-lame description - what is the purpose of the max search level?
263  int getMaxSearchLevel() const;
264 
266  void loadData(QVariantMap starsConfigFile);
267 
269  void drawPointer(class StelRenderer* renderer, StelProjectorP projector, const StelCore* core);
270 
271  LinearFader labelsFader;
272  LinearFader starsFader;
273 
274  bool flagStarName;
275  float labelsAmount;
276  bool gravityLabel;
277 
278  int maxGeodesicGridLevel;
279  int lastMaxSearchLevel;
280  typedef QHash<int,BigStarCatalogExtension::ZoneArray*> ZoneArrayMap;
281  ZoneArrayMap zoneArrays; // index is the grid level
282  static void initTriangleFunc(int lev, int index,
283  const Vec3f &c0,
284  const Vec3f &c1,
285  const Vec3f &c2,
286  void *context)
287  {
288  reinterpret_cast<StarMgr*>(context)->initTriangle(lev, index, c0, c1, c2);
289  }
290 
291  void initTriangle(int lev, int index,
292  const Vec3f &c0,
293  const Vec3f &c1,
294  const Vec3f &c2);
295 
296  BigStarCatalogExtension::HipIndexStruct *hipIndex; // array of hiparcos stars
297 
298  static QHash<int, QString> commonNamesMap;
299  static QHash<int, QString> commonNamesMapI18n;
300  static QMap<QString, int> commonNamesIndexI18n;
301  static QMap<QString, int> commonNamesIndex;
302 
303  static QHash<int, QString> sciNamesMapI18n;
304  static QMap<QString, int> sciNamesIndexI18n;
305 
306  static QHash<int, varstar> varStarsMapI18n;
307  static QMap<QString, int> varStarsIndexI18n;
308 
309  QFont starFont;
310  static bool flagSciNames;
311  Vec3f labelColor;
312 
313  class StelTextureNew* texPointer; // The selection pointer texture
314 
315  class StelObjectMgr* objectMgr;
316 
317  QString starConfigFileFullPath;
318  QVariantMap starSettings;
319  QVariantList catalogsDescription;
320 };
321 
322 
323 #endif // _STARMGR_HPP_
324