Stellarium 0.12.4
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 min1mag;
48  float min2mag;
49  QString photosys;
50  double epoch;
51  double period;
52  int Mm;
53  QString stype;
54 } varstar;
55 
79 class StarMgr : public StelObjectModule
80 {
81  Q_OBJECT
82 
83 public:
84  StarMgr(void);
85  ~StarMgr(void);
86 
88  // Methods defined in the StelModule class
96  virtual void init();
97 
99  virtual void draw(StelCore* core, class StelRenderer* renderer);
100 
103  virtual void update(double deltaTime) {labelsFader.update((int)(deltaTime*1000)); starsFader.update((int)(deltaTime*1000));}
104 
106  virtual double getCallOrder(StelModuleActionName actionName) const;
107 
109  // Methods defined in StelObjectManager class
111  virtual QList<StelObjectP > searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
112 
116  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
117 
120  virtual StelObjectP searchByName(const QString& name) const;
121 
127  virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
133  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
134  // empty, as there's too much stars for displaying at once
135  virtual QStringList listAllObjects(bool inEnglish) const { Q_UNUSED(inEnglish) return QStringList(); }
136  virtual QString getName() const { return "Stars"; }
137 
138 public slots:
140  // Methods callable from script and GUI
142  void setLabelColor(const Vec3f& c) {labelColor = c;}
144  Vec3f getLabelColor(void) const {return labelColor;}
145 
147  void setFlagStars(bool b) {starsFader=b;}
149  bool getFlagStars(void) const {return starsFader==true;}
150 
152  void setFlagLabels(bool b) {labelsFader=b;}
154  bool getFlagLabels(void) const {return labelsFader==true;}
155 
159  void setLabelsAmount(float a) {labelsAmount=a;}
162  float getLabelsAmount(void) const {return labelsAmount;}
163 
165  void setFontSize(double newFontSize);
166 
168  static void setFlagSciNames(bool f) {flagSciNames = f;}
169  static bool getFlagSciNames(void) {return flagSciNames;}
170 
171 public:
173  // Other methods
178  StelObjectP searchHP(int hip) const;
179 
182  static QString getCommonName(int hip);
183 
186  static QString getSciName(int hip);
187 
190  static QString getSciAdditionalName(int hip);
191 
194  static QString getGcvsName(int hip);
195 
198  static QString getGcvsVariabilityType(int hip);
199 
202  static float getGcvsMaxMagnitude(int hip);
203 
206  static int getGcvsMagnitudeFlag(int hip);
207 
210  static float getGcvsMinMagnitude(int hip, bool firstMinimumFlag=true);
211 
214  static QString getGcvsPhotometricSystem(int hip);
215 
218  static double getGcvsEpoch(int hip);
219 
222  static double getGcvsPeriod(int hip);
223 
226  static int getGcvsMM(int hip);
227 
228  static QString convertToSpectralType(int index);
229  static QString convertToComponentIds(int index);
230 
231  QVariantList getCatalogsDescription() const {return catalogsDescription;}
232 
236  bool checkAndLoadCatalog(QVariantMap m);
237 
238 private slots:
239  void setStelStyle(const QString& section);
241  void updateI18n();
242 
246  void updateSkyCulture(const QString& skyCultureDir);
247 
248 private:
249 
250  void setCheckFlag(const QString& catalogId, bool b);
251 
252  void copyDefaultConfigFile();
253 
257  int loadCommonNames(const QString& commonNameFile);
258 
262  void loadSciNames(const QString& sciNameFile);
263 
266  void loadGcvs(const QString& GcvsFile);
267 
269  // TODO: add a non-lame description - what is the purpose of the max search level?
270  int getMaxSearchLevel() const;
271 
273  void loadData(QVariantMap starsConfigFile);
274 
276  void drawPointer(class StelRenderer* renderer, StelProjectorP projector, const StelCore* core);
277 
278  LinearFader labelsFader;
279  LinearFader starsFader;
280 
281  bool flagStarName;
282  float labelsAmount;
283  bool gravityLabel;
284 
285  int maxGeodesicGridLevel;
286  int lastMaxSearchLevel;
287  typedef QHash<int,BigStarCatalogExtension::ZoneArray*> ZoneArrayMap;
288  ZoneArrayMap zoneArrays; // index is the grid level
289  static void initTriangleFunc(int lev, int index,
290  const Vec3f &c0,
291  const Vec3f &c1,
292  const Vec3f &c2,
293  void *context)
294  {
295  reinterpret_cast<StarMgr*>(context)->initTriangle(lev, index, c0, c1, c2);
296  }
297 
298  void initTriangle(int lev, int index,
299  const Vec3f &c0,
300  const Vec3f &c1,
301  const Vec3f &c2);
302 
303  BigStarCatalogExtension::HipIndexStruct *hipIndex; // array of hiparcos stars
304 
305  static QHash<int, QString> commonNamesMap;
306  static QHash<int, QString> commonNamesMapI18n;
307  static QMap<QString, int> commonNamesIndexI18n;
308  static QMap<QString, int> commonNamesIndex;
309 
310  static QHash<int, QString> sciNamesMapI18n;
311  static QMap<QString, int> sciNamesIndexI18n;
312 
313  static QHash<int, QString> sciAdditionalNamesMapI18n;
314  static QMap<QString, int> sciAdditionalNamesIndexI18n;
315 
316  static QHash<int, varstar> varStarsMapI18n;
317  static QMap<QString, int> varStarsIndexI18n;
318 
319  QFont starFont;
320  static bool flagSciNames;
321  Vec3f labelColor;
322 
323  class StelTextureNew* texPointer; // The selection pointer texture
324 
325  class StelObjectMgr* objectMgr;
326 
327  QString starConfigFileFullPath;
328  QVariantMap starSettings;
329  QVariantList catalogsDescription;
330 };
331 
332 
333 #endif // _STARMGR_HPP_
334