Stellarium  0.16.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 
57 typedef struct
58 {
59  QString designation;
61  float positionAngle;
62  float separation;
63 } wds;
64 
65 typedef struct
66 {
67  unsigned int sao;
68  unsigned int hd;
69  unsigned int hr;
70 
71 } crossid;
72 
73 typedef QMap<StelObjectP, float> StelACStarData;
74 
98 class StarMgr : public StelObjectModule
99 {
100  Q_OBJECT
101  Q_PROPERTY(bool flagStarsDisplayed
102  READ getFlagStars
103  WRITE setFlagStars
104  NOTIFY starsDisplayedChanged)
105  Q_PROPERTY(bool flagLabelsDisplayed
106  READ getFlagLabels
107  WRITE setFlagLabels
108  NOTIFY starLabelsDisplayedChanged)
109  Q_PROPERTY(double labelsAmount
110  READ getLabelsAmount
111  WRITE setLabelsAmount
112  NOTIFY labelsAmountChanged)
113 
114 public:
115  StarMgr(void);
116  ~StarMgr(void);
117 
119  // Methods defined in the StelModule class
127  virtual void init();
128 
130  virtual void draw(StelCore* core);
131 
134  virtual void update(double deltaTime) {labelsFader.update((int)(deltaTime*1000)); starsFader.update((int)(deltaTime*1000));}
135 
137  virtual double getCallOrder(StelModuleActionName actionName) const;
138 
140  // Methods defined in StelObjectManager class
142  virtual QList<StelObjectP > searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
143 
147  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
148 
151  virtual StelObjectP searchByName(const QString& name) const;
152 
153  virtual StelObjectP searchByID(const QString &id) const;
154 
160  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false, bool inEnglish=false) const;
162  virtual QStringList listAllObjects(bool inEnglish) const;
163  virtual QStringList listAllObjectsByType(const QString& objType, bool inEnglish) const;
164  virtual QString getName() const { return "Stars"; }
165  virtual QString getStelObjectType() const;
166 
167 public slots:
169  // Methods callable from script and GUI
176  void setLabelColor(const Vec3f& c) {labelColor = c;}
178  Vec3f getLabelColor(void) const {return labelColor;}
179 
181  void setFlagStars(bool b) {starsFader=b; emit starsDisplayedChanged(b);}
183  bool getFlagStars(void) const {return starsFader==true;}
184 
186  void setFlagLabels(bool b) {labelsFader=b; emit starLabelsDisplayedChanged(b);}
188  bool getFlagLabels(void) const {return labelsFader==true;}
189 
193  void setLabelsAmount(double a) {if(a!=labelsAmount){ labelsAmount=a; emit labelsAmountChanged(a);}}
196  double getLabelsAmount(void) const {return labelsAmount;}
197 
199  void setFontSize(float newFontSize);
200 
202  static void setFlagSciNames(bool f) {flagSciNames = f;}
203  static bool getFlagSciNames(void) {return flagSciNames;}
204 
205 public:
207  // Other methods
212  StelObjectP searchHP(int hip) const;
213 
218  static QString getCommonName(int hip);
219 
224  static QString getSciName(int hip);
225 
230  static QString getSciAdditionalName(int hip);
231 
236  static QString getGcvsName(int hip);
237 
242  static QString getWdsName(int hip);
243 
248  static QString getCommonEnglishName(int hip);
249 
254  static QString getAdditionalNames(int hip);
255 
260  static QString getAdditionalEnglishNames(int hip);
261 
266  static QString getCrossIdentificationDesignations(QString hip);
267 
272  static QString getGcvsVariabilityType(int hip);
273 
278  static float getGcvsMaxMagnitude(int hip);
279 
284  static int getGcvsMagnitudeFlag(int hip);
285 
291  static float getGcvsMinMagnitude(int hip, bool firstMinimumFlag=true);
292 
297  static QString getGcvsPhotometricSystem(int hip);
298 
303  static double getGcvsEpoch(int hip);
304 
309  static double getGcvsPeriod(int hip);
310 
315  static int getGcvsMM(int hip);
316 
321  static int getWdsLastObservation(int hip);
322 
327  static int getWdsLastPositionAngle(int hip);
328 
333  static float getWdsLastSeparation(int hip);
334 
335  static QString convertToSpectralType(int index);
336  static QString convertToComponentIds(int index);
337 
338  QVariantList getCatalogsDescription() const {return catalogsDescription;}
339 
343  bool checkAndLoadCatalog(const QVariantMap& m);
344 
346  const QList<StelObjectP>& getHipparcosStars() const { return hipparcosStars; }
347  const QList<QMap<StelObjectP, float>>& getHipparcosHighPMStars() const { return hipStarsHighPM; }
348  const QList<QMap<StelObjectP, float>>& getHipparcosDoubleStars() const { return doubleHipStars; }
349  const QList<QMap<StelObjectP, float>>& getHipparcosVariableStars() const { return variableHipStars; }
350 
351 private slots:
353  void updateI18n();
354 
358  void updateSkyCulture(const QString& skyCultureDir);
359 
360 signals:
361  void starLabelsDisplayedChanged(const bool displayed);
362  void starsDisplayedChanged(const bool displayed);
363  void labelsAmountChanged(float a);
364 
365 private:
366  void setCheckFlag(const QString& catalogId, bool b);
367 
368  void copyDefaultConfigFile();
369 
374  int loadCommonNames(const QString& commonNameFile);
375 
379  void loadSciNames(const QString& sciNameFile);
380 
383  void loadGcvs(const QString& GcvsFile);
384 
387  void loadWds(const QString& WdsFile);
388 
391  void loadCrossIdentificationData(const QString& crossIdFile);
392 
394  // TODO: add a non-lame description - what is the purpose of the max search level?
395  int getMaxSearchLevel() const;
396 
398  void loadData(QVariantMap starsConfigFile);
399 
401  void drawPointer(StelPainter& sPainter, const StelCore* core);
402 
403  void populateHipparcosLists();
404  void populateStarsDesignations();
405 
407  QList<StelObjectP> hipparcosStars;
408  QList<QMap<StelObjectP, float>> doubleHipStars, variableHipStars, hipStarsHighPM;
409 
410  LinearFader labelsFader;
411  LinearFader starsFader;
412 
413  bool flagStarName;
414  double labelsAmount;
415  bool gravityLabel;
416 
417  int maxGeodesicGridLevel;
418  int lastMaxSearchLevel;
419 
420  // A ZoneArray per grid level
421  QVector<ZoneArray*> gridLevels;
422  static void initTriangleFunc(int lev, int index,
423  const Vec3f &c0,
424  const Vec3f &c1,
425  const Vec3f &c2,
426  void *context)
427  {
428  reinterpret_cast<StarMgr*>(context)->initTriangle(lev, index, c0, c1, c2);
429  }
430 
431  void initTriangle(int lev, int index,
432  const Vec3f &c0,
433  const Vec3f &c1,
434  const Vec3f &c2);
435 
436  HipIndexStruct *hipIndex; // array of Hipparcos stars
437 
438  static QHash<int, QString> commonNamesMap; // the original names from skyculture (star_names.fab)
439  static QHash<int, QString> commonNamesMapI18n; // translated names
440  static QMap<QString, int> commonNamesIndexI18n;
441  static QMap<QString, int> commonNamesIndex;
442 
443  static QHash<int, QString> additionalNamesMap; // additional names
444  static QHash<int, QString> additionalNamesMapI18n;
445  static QMap<QString, int> additionalNamesIndex;
446  static QMap<QString, int> additionalNamesIndexI18n;
447 
448  static QHash<int, QString> sciNamesMapI18n;
449  static QMap<QString, int> sciNamesIndexI18n;
450 
451  static QHash<int, QString> sciAdditionalNamesMapI18n;
452  static QMap<QString, int> sciAdditionalNamesIndexI18n;
453 
454  static QHash<int, varstar> varStarsMapI18n;
455  static QMap<QString, int> varStarsIndexI18n;
456 
457  static QHash<int, wds> wdsStarsMapI18n;
458  static QMap<QString, int> wdsStarsIndexI18n;
459 
460  static QMap<QString, crossid> crossIdMap;
461  static QMap<int, int> saoStarsIndex;
462  static QMap<int, int> hdStarsIndex;
463  static QMap<int, int> hrStarsIndex;
464 
465  static QHash<int, QString> referenceMap;
466 
467  QFont starFont;
468  static bool flagSciNames;
469  Vec3f labelColor;
470 
471  StelTextureSP texPointer; // The selection pointer texture
472 
473  class StelObjectMgr* objectMgr;
474 
475  QString starConfigFileFullPath;
476  QVariantMap starSettings;
477  QVariantList catalogsDescription;
478 };
479 
480 
481 #endif // _STARMGR_HPP_
482 
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:183
float separation
Position Angle at date of last satisfactory observation, deg.
Definition: StarMgr.hpp:62
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
static QString getCrossIdentificationDesignations(QString hip)
Get the cross-identification designations for a star with a specified Hipparcos catalogue number...
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.
double getLabelsAmount(void) const
Get the amount of star labels.
Definition: StarMgr.hpp:196
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 Q_NULLPTR.
int observation
WDS designation.
Definition: StarMgr.hpp:60
void setLabelsAmount(double a)
Set the amount of star labels.
Definition: StarMgr.hpp:193
Implementation of StelFader which implements a linear transition.
Definition: StelFader.hpp:77
float maxmag
Type of variability.
Definition: StarMgr.hpp:46
const QList< StelObjectP > & getHipparcosStars() const
Get the list of all Hipparcos stars.
Definition: StarMgr.hpp:346
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.
virtual QStringList listAllObjectsByType(const QString &objType, bool inEnglish) const
List all StelObjects by type.
Vec3f getLabelColor(void) const
Get the current color used to label bright stars.
Definition: StarMgr.hpp:178
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...
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:176
QString stype
Rising time or duration of eclipse (%)
Definition: StarMgr.hpp:54
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
bool getFlagLabels(void) const
Get display flag for Star names (labels).
Definition: StarMgr.hpp:188
void setFlagStars(bool b)
Set display flag for Stars.
Definition: StarMgr.hpp:181
float positionAngle
Date of last satisfactory observation, yr.
Definition: StarMgr.hpp:61
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.
virtual QString getName() const
Gets a user-displayable name of the object category.
Definition: StarMgr.hpp:164
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.
Definition: StarMgr.hpp:57
Converts tones in function of the eye adaptation to luminance.
virtual StelObjectP searchByID(const QString &id) const
Return the StelObject with the given ID if exists or the empty StelObject if not found.
static QString getAdditionalEnglishNames(int hip)
Get the English additional names for a star with a specified Hipparcos catalogue number.
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...
static QString getAdditionalNames(int hip)
Get the (translated) additional names for a star with a specified Hipparcos catalogue number...
virtual void update(double deltaTime)
Update any time-dependent features.
Definition: StarMgr.hpp:134
Stores the star catalogue data.
Definition: StarMgr.hpp:98
static QString getGcvsVariabilityType(int hip)
Get the type of variability for a variable star with a specified Hipparcos catalogue number...
static int getWdsLastPositionAngle(int hip)
Get position angle at date of last satisfactory observation of double star with a Hipparcos catalogue...
Manage the selection and queries on one or more StelObjects.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
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 float getWdsLastSeparation(int hip)
Get separation angle at date of last satisfactory observation of double star with a Hipparcos catalog...
virtual QString getStelObjectType() const
Returns the name that will be returned by StelObject::getType() for the objects this module manages...
static int getWdsLastObservation(int hip)
Get year of last satisfactory observation of double star with a Hipparcos catalogue number...
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.
static QString getWdsName(int hip)
Get the (translated) scientific name for a double star with a specified Hipparcos catalogue number...
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
void setFlagLabels(bool b)
Set display flag for Star names (labels).
Definition: StarMgr.hpp:186
virtual QStringList listMatchingObjects(const QString &objPrefix, int maxNbItem=5, bool useStartOfWords=false, bool inEnglish=false) const
Find and return the list of at most maxNbItem objects auto-completing the passed object English name...
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:202
virtual StelObjectP searchByNameI18n(const QString &nameI18n) const
Return the matching Stars object&#39;s pointer if exists or Q_NULLPTR.
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...