Stellarium 0.13.1
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 <QVector>
26 #include "StelFader.hpp"
27 #include "StelObjectModule.hpp"
28 #include "StelTextureTypes.hpp"
29 #include "StelProjectorType.hpp"
30 
31 class StelObject;
32 class StelToneReproducer;
33 class StelProjector;
34 class StelPainter;
35 class QSettings;
36 
37 class ZoneArray;
38 struct HipIndexStruct;
39 
40 static const int RCMAG_TABLE_SIZE = 4096;
41 
42 typedef struct
43 {
44  QString designation;
45  QString vtype;
46  float maxmag;
47  int mflag;
48  float min1mag;
49  float min2mag;
50  QString photosys;
51  double epoch;
52  double period;
53  int Mm;
54  QString stype;
55 } varstar;
56 
80 class StarMgr : public StelObjectModule
81 {
82  Q_OBJECT
83  Q_PROPERTY(bool flagStarsDisplayed
84  READ getFlagStars
85  WRITE setFlagStars
86  NOTIFY starsDisplayedChanged)
87  Q_PROPERTY(bool flagLabelsDisplayed
88  READ getFlagLabels
89  WRITE setFlagLabels
90  NOTIFY starLabelsDisplayedChanged)
91 
92 public:
93  StarMgr(void);
94  ~StarMgr(void);
95 
97  // Methods defined in the StelModule class
105  virtual void init();
106 
108  virtual void draw(StelCore* core);
109 
112  virtual void update(double deltaTime) {labelsFader.update((int)(deltaTime*1000)); starsFader.update((int)(deltaTime*1000));}
113 
115  virtual double getCallOrder(StelModuleActionName actionName) const;
116 
118  // Methods defined in StelObjectManager class
120  virtual QList<StelObjectP > searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
121 
125  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
126 
129  virtual StelObjectP searchByName(const QString& name) const;
130 
136  virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
142  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
144  virtual QStringList listAllObjects(bool inEnglish) const;
145  virtual QString getName() const { return "Stars"; }
146 
147 public slots:
149  // Methods callable from script and GUI
156  void setLabelColor(const Vec3f& c) {labelColor = c;}
158  Vec3f getLabelColor(void) const {return labelColor;}
159 
161  void setFlagStars(bool b) {starsFader=b;}
163  bool getFlagStars(void) const {return starsFader==true;}
164 
166  void setFlagLabels(bool b) {labelsFader=b;}
168  bool getFlagLabels(void) const {return labelsFader==true;}
169 
173  void setLabelsAmount(float a) {labelsAmount=a;}
176  float getLabelsAmount(void) const {return labelsAmount;}
177 
179  void setFontSize(float newFontSize);
180 
182  static void setFlagSciNames(bool f) {flagSciNames = f;}
183  static bool getFlagSciNames(void) {return flagSciNames;}
184 
185 public:
187  // Other methods
192  StelObjectP searchHP(int hip) const;
193 
198  static QString getCommonName(int hip);
199 
204  static QString getSciName(int hip);
205 
210  static QString getSciAdditionalName(int hip);
211 
216  static QString getGcvsName(int hip);
217 
222  static QString getCommonEnglishName(int hip);
223 
228  static QString getGcvsVariabilityType(int hip);
229 
234  static float getGcvsMaxMagnitude(int hip);
235 
240  static int getGcvsMagnitudeFlag(int hip);
241 
247  static float getGcvsMinMagnitude(int hip, bool firstMinimumFlag=true);
248 
253  static QString getGcvsPhotometricSystem(int hip);
254 
259  static double getGcvsEpoch(int hip);
260 
265  static double getGcvsPeriod(int hip);
266 
271  static int getGcvsMM(int hip);
272 
273  static QString convertToSpectralType(int index);
274  static QString convertToComponentIds(int index);
275 
276  QVariantList getCatalogsDescription() const {return catalogsDescription;}
277 
281  bool checkAndLoadCatalog(const QVariantMap& m);
282 
283 private slots:
284  void setStelStyle(const QString& section);
286  void updateI18n();
287 
291  void updateSkyCulture(const QString& skyCultureDir);
292 
293 signals:
294  void starLabelsDisplayedChanged(const bool displayed);
295  void starsDisplayedChanged(const bool displayed);
296 
297 private:
298 
299  void setCheckFlag(const QString& catalogId, bool b);
300 
301  void copyDefaultConfigFile();
302 
307  int loadCommonNames(const QString& commonNameFile);
308 
312  void loadSciNames(const QString& sciNameFile);
313 
316  void loadGcvs(const QString& GcvsFile);
317 
319  // TODO: add a non-lame description - what is the purpose of the max search level?
320  int getMaxSearchLevel() const;
321 
323  void loadData(QVariantMap starsConfigFile);
324 
326  void drawPointer(StelPainter& sPainter, const StelCore* core);
327 
328  LinearFader labelsFader;
329  LinearFader starsFader;
330 
331  bool flagStarName;
332  float labelsAmount;
333  bool gravityLabel;
334 
335  int maxGeodesicGridLevel;
336  int lastMaxSearchLevel;
337 
338  // A ZoneArray per grid level
339  QVector<ZoneArray*> gridLevels;
340  static void initTriangleFunc(int lev, int index,
341  const Vec3f &c0,
342  const Vec3f &c1,
343  const Vec3f &c2,
344  void *context)
345  {
346  reinterpret_cast<StarMgr*>(context)->initTriangle(lev, index, c0, c1, c2);
347  }
348 
349  void initTriangle(int lev, int index,
350  const Vec3f &c0,
351  const Vec3f &c1,
352  const Vec3f &c2);
353 
354  HipIndexStruct *hipIndex; // array of hiparcos stars
355 
356  static QHash<int, QString> commonNamesMap;
357  static QHash<int, QString> commonNamesMapI18n;
358  static QMap<QString, int> commonNamesIndexI18n;
359  static QMap<QString, int> commonNamesIndex;
360 
361  static QHash<int, QString> sciNamesMapI18n;
362  static QMap<QString, int> sciNamesIndexI18n;
363 
364  static QHash<int, QString> sciAdditionalNamesMapI18n;
365  static QMap<QString, int> sciAdditionalNamesIndexI18n;
366 
367  static QHash<int, varstar> varStarsMapI18n;
368  static QMap<QString, int> varStarsIndexI18n;
369 
370  QFont starFont;
371  static bool flagSciNames;
372  Vec3f labelColor;
373 
374  StelTextureSP texPointer; // The selection pointer texture
375 
376  class StelObjectMgr* objectMgr;
377 
378  QString starConfigFileFullPath;
379  QVariantMap starSettings;
380  QVariantList catalogsDescription;
381 };
382 
383 
384 #endif // _STARMGR_HPP_
385 
static QString getSciName(int hip)
Get the (translated) scientific name for a star with a specified Hipparcos catalogue number...
static double getGcvsEpoch(int hip)
Get Epoch for maximum light for a variable star with a specified Hipparcos catalogue number...
bool getFlagStars(void) const
Get display flag for Stars.
Definition: StarMgr.hpp:163
static int getGcvsMM(int hip)
Get the rising time or duration of eclipse for a variable star with a specified Hipparcos catalogue n...
int Mm
Period of the variable star (days)
Definition: StarMgr.hpp:53
StelObjectP searchHP(int hip) const
Search by Hipparcos catalogue number.
double epoch
The photometric system for magnitudes.
Definition: StarMgr.hpp:51
Container for Hipparcos information.
Definition: ZoneArray.hpp:64
virtual void init()
Initialize the StarMgr.
float min2mag
First minimum magnitude or amplitude.
Definition: StarMgr.hpp:49
float min1mag
Magnitude flag code.
Definition: StarMgr.hpp:48
virtual StelObjectP searchByName(const QString &name) const
Return the matching star if exists or NULL.
Implementation of StelFader which implements a linear transition.
Definition: StelFader.hpp:79
float maxmag
Type of variability.
Definition: StarMgr.hpp:46
The base abstract class for sky objects used in Stellarium like Stars, Planets, Constellations etc...
Definition: StelObject.hpp:36
static QString getSciAdditionalName(int hip)
Get the (translated) additional scientific name for a star with a specified Hipparcos catalogue numbe...
Define the StelTextureSP type.
Vec3f getLabelColor(void) const
Get the current color used to label bright stars.
Definition: StarMgr.hpp:158
double period
Epoch for maximum light (Julian days)
Definition: StarMgr.hpp:52
QString vtype
GCVS designation.
Definition: StarMgr.hpp:45
Manages all ZoneData structures of a given StelGeodesicGrid level.
Definition: ZoneArray.hpp:76
static float getGcvsMaxMagnitude(int hip)
Get the magnitude at maximum brightness for a variable star with a specified Hipparcos catalogue numb...
virtual QStringList listMatchingObjects(const QString &objPrefix, int maxNbItem=5, bool useStartOfWords=false) const
Find and return the list of at most maxNbItem objects auto-completing the passed object English name...
static double getGcvsPeriod(int hip)
Get the period for a variable star with a specified Hipparcos catalogue number.
void setLabelColor(const Vec3f &c)
Set the color used to label bright stars.
Definition: StarMgr.hpp:156
QString stype
Rising time or duration of eclipse (%)
Definition: StarMgr.hpp:54
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
bool getFlagLabels(void) const
Get display flag for Star names (labels).
Definition: StarMgr.hpp:168
void setFlagStars(bool b)
Set display flag for Stars.
Definition: StarMgr.hpp:161
static int getGcvsMagnitudeFlag(int hip)
Get the magnitude flag code for a variable star with a specified Hipparcos catalogue number...
Specialization of StelModule which manages a collection of StelObject.
virtual void draw(StelCore *core)
Draw the stars and the star selection indicator if necessary.
void setFontSize(float newFontSize)
Define font size to use for star names display.
bool checkAndLoadCatalog(const QVariantMap &m)
Try to load the given catalog, even if it is marched as unchecked.
void setLabelsAmount(float a)
Set the amount of star labels.
Definition: StarMgr.hpp:173
Converts tones in function of the eye adaptation to luminance.
virtual QStringList listMatchingObjectsI18n(const QString &objPrefix, int maxNbItem=5, bool useStartOfWords=false) const
Find and return the list of at most maxNbItem objects auto-completing the passed object I18n name...
float getLabelsAmount(void) const
Get the amount of star labels.
Definition: StarMgr.hpp:176
Provides functions for performing openGL drawing operations.
Definition: StelPainter.hpp:40
Provide the main interface to all operations of projecting coordinates from sky to screen...
virtual QList< StelObjectP > searchAround(const Vec3d &v, double limitFov, const StelCore *core) const
Return a list containing the stars located inside the limFov circle around position v...
virtual void update(double deltaTime)
Update any time-dependent features.
Definition: StarMgr.hpp:112
Stores the star catalogue data.
Definition: StarMgr.hpp:80
static QString getGcvsVariabilityType(int hip)
Get the type of variability for a variable star with a specified Hipparcos catalogue number...
Manage the selection and queries on one or more StelObjects.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:119
static float getGcvsMinMagnitude(int hip, bool firstMinimumFlag=true)
Get the minimum magnitude or amplitude for a variable star with a specified Hipparcos catalogue numbe...
virtual QStringList listAllObjects(bool inEnglish) const
static QString getGcvsName(int hip)
Get the (translated) scientific name for a variable star with a specified Hipparcos catalogue number...
int mflag
Magnitude at maximum brightness.
Definition: StarMgr.hpp:47
static QString getCommonName(int hip)
Get the (translated) common name for a star with a specified Hipparcos catalogue number.
Define the StelProjectorP type.
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
void setFlagLabels(bool b)
Set display flag for Star names (labels).
Definition: StarMgr.hpp:166
virtual double getCallOrder(StelModuleActionName actionName) const
Used to determine the order in which the various StelModules are drawn.
static void setFlagSciNames(bool f)
Show scientific or catalog names on stars without common names.
Definition: StarMgr.hpp:182
virtual StelObjectP searchByNameI18n(const QString &nameI18n) const
Return the matching Stars object's pointer if exists or NULL.
QString photosys
Second minimum magnitude or amplitude.
Definition: StarMgr.hpp:50
static QString getCommonEnglishName(int hip)
Get the (English) common name for a star with a specified Hipparcos catalogue number.
static QString getGcvsPhotometricSystem(int hip)
Get the photometric system for a variable star with a specified Hipparcos catalogue number...