Stellarium 0.90.0
SolarSystem.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2002 Fabien Chereau
4  * Copyright (c) 2010 Bogdan Marinov
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19  */
20 
21 #ifndef _SOLARSYSTEM_HPP_
22 #define _SOLARSYSTEM_HPP_
23 //sun is already defined in Sun C/Solaris
24 #if defined(sun)
25 #undef sun
26 #endif
27 
28 #include "StelObjectModule.hpp"
29 #include "StelTextureTypes.hpp"
30 #include "Planet.hpp"
31 #include "StelGui.hpp"
32 
33 #include <QFont>
34 
35 class Orbit;
36 class StelTranslator;
37 class StelObject;
38 class StelCore;
39 class StelProjector;
40 class QSettings;
41 
42 typedef QSharedPointer<Planet> PlanetP;
43 
48 {
49  Q_OBJECT
50  Q_PROPERTY(bool labelsDisplayed // This is a "forwarding property" which sets labeling into all planets.
51  READ getFlagLabels
52  WRITE setFlagLabels
53  NOTIFY labelsDisplayedChanged)
54  Q_PROPERTY(bool flagOrbits // was bool orbitsDisplayed
55  READ getFlagOrbits
56  WRITE setFlagOrbits
57  NOTIFY flagOrbitsChanged)
58  Q_PROPERTY(bool trailsDisplayed
59  READ getFlagTrails
60  WRITE setFlagTrails
61  NOTIFY trailsDisplayedChanged)
62  Q_PROPERTY(bool flagHints // was bool hintsDisplayed. This is a "forwarding property" only, without own variable.
63  READ getFlagHints
64  WRITE setFlagHints
65  NOTIFY flagHintsChanged)
66  Q_PROPERTY(bool flagPointer // was bool pointersDisplayed
67  READ getFlagPointer
68  WRITE setFlagPointer
69  NOTIFY flagPointerChanged)
70  Q_PROPERTY(bool flagNativeNames // was bool nativeNamesDisplayed
72  WRITE setFlagNativeNames
73  NOTIFY flagNativeNamesChanged)
74  Q_PROPERTY(bool flagTranslatedNames
77  NOTIFY flagTranslatedNamesChanged)
78 
79  //StelProperties
80  Q_PROPERTY(bool planetsDisplayed
81  READ getFlagPlanets
82  WRITE setFlagPlanets
83  NOTIFY flagPlanetsDisplayedChanged
84  )
85  Q_PROPERTY(bool flagIsolatedOrbits
88  NOTIFY flagIsolatedOrbitsChanged
89  )
90  Q_PROPERTY(bool flagIsolatedTrails
93  NOTIFY flagIsolatedTrailsChanged
94  )
95  Q_PROPERTY(bool flagLightTravelTime
98  NOTIFY flagLightTravelTimeChanged
99  )
100  Q_PROPERTY(bool flagMoonScale
101  READ getFlagMoonScale
102  WRITE setFlagMoonScale
103  NOTIFY flagMoonScaleChanged
104  )
105  Q_PROPERTY(double moonScale
106  READ getMoonScale
107  WRITE setMoonScale
108  NOTIFY moonScaleChanged
109  )
110  Q_PROPERTY(double labelsAmount
111  READ getLabelsAmount
112  WRITE setLabelsAmount
113  NOTIFY labelsAmountChanged
114  )
115  Q_PROPERTY(bool ephemerisMarkersDisplayed
116  READ getFlagEphemerisMarkers
117  WRITE setFlagEphemerisMarkers
118  NOTIFY ephemerisMarkersChanged
119  )
120  Q_PROPERTY(bool ephemerisDatesDisplayed
121  READ getFlagEphemerisDates
122  WRITE setFlagEphemerisDates
123  NOTIFY ephemerisDatesChanged
124  )
125 
126  Q_PROPERTY(bool flagCustomGrsSettings
129  NOTIFY flagCustomGrsSettingsChanged
130  )
131  Q_PROPERTY(int customGrsLongitude
134  NOTIFY customGrsLongitudeChanged
135  )
136  Q_PROPERTY(double customGrsDrift
137  READ getCustomGrsDrift
138  WRITE setCustomGrsDrift
139  NOTIFY customGrsDriftChanged
140  )
141  Q_PROPERTY(double customGrsJD
142  READ getCustomGrsJD
143  WRITE setCustomGrsJD
144  NOTIFY customGrsJDChanged
145  )
146 public:
147  SolarSystem();
148  virtual ~SolarSystem();
149 
151  // Methods defined in the StelModule class
157  virtual void init();
158 
159  virtual void deinit();
160 
165  virtual void draw(StelCore *core);
166 
169  virtual void update(double deltaTime);
170 
172  virtual double getCallOrder(StelModuleActionName actionName) const;
173 
175  // Methods defined in StelObjectManager class
184  virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
185 
189  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
190 
194  virtual StelObjectP searchByName(const QString& name) const;
195 
196  virtual QStringList listAllObjects(bool inEnglish) const;
197  virtual QStringList listAllObjectsByType(const QString& objType, bool inEnglish) const;
198  virtual QString getName() const { return "Solar System"; }
199 
200 public slots:
202  // Method callable from script and GUI
203  // Properties setters and getters
205  void setFlagPlanets(bool b);
207  bool getFlagPlanets() const;
208 
210  void setFlagTrails(bool b);
212  bool getFlagTrails() const;
213 
215  void setFlagHints(bool b);
217  bool getFlagHints() const;
218 
220  void setFlagLabels(bool b);
222  bool getFlagLabels() const;
223 
227  void setLabelsAmount(double a) {if(a!=labelsAmount) {labelsAmount=a; emit labelsAmountChanged(a);}}
230  double getLabelsAmount(void) const {return labelsAmount;}
231 
233  void setFlagOrbits(bool b);
235  bool getFlagOrbits() const {return flagOrbits;}
236 
238  void setFlagPointer(bool b) { if (b!=flagPointer) { flagPointer=b; emit flagPointerChanged(b); }}
240  bool getFlagPointer() const { return flagPointer;}
241 
243  void setFlagLightTravelTime(bool b);
246  bool getFlagLightTravelTime(void) const {return flagLightTravelTime;}
247 
250  void setFontSize(float newFontSize);
251 
258  void setLabelsColor(const Vec3f& c);
261  const Vec3f& getLabelsColor(void) const;
262 
269  void setOrbitsColor(const Vec3f& c);
272  Vec3f getOrbitsColor(void) const;
273 
280  void setPlanetsOrbitsColor(const Vec3f& c);
283  Vec3f getPlanetsOrbitsColor(void) const;
284 
291  void setAsteroidsOrbitsColor(const Vec3f& c);
294  Vec3f getAsteroidsOrbitsColor(void) const;
295 
302  void setCometsOrbitsColor(const Vec3f& c);
305  Vec3f getCometsOrbitsColor(void) const;
306 
313  void setTrailsColor(const Vec3f& c) {trailColor=c;}
316  Vec3f getTrailsColor() const {return trailColor;}
317 
324  void setPointerColor(const Vec3f& c) {pointerColor=c;}
327  Vec3f getPointerColor() const {return pointerColor;}
328 
330  void setFlagMoonScale(bool b);
332  bool getFlagMoonScale(void) const {return flagMoonScale;}
333 
335  void setMoonScale(double f);
337  double getMoonScale(void) const {return moonScale;}
338 
340  void updateI18n();
341 
346  float getPlanetVMagnitude(QString planetName, bool withExtinction=false) const;
347 
351  QString getPlanetType(QString planetName) const;
352 
356  double getDistanceToPlanet(QString planetName) const;
357 
361  double getElongationForPlanet(QString planetName) const;
362 
366  double getPhaseAngleForPlanet(QString planetName) const;
367 
371  float getPhaseForPlanet(QString planetName) const;
372 
386  void setApparentMagnitudeAlgorithmOnEarth(QString algorithm);
387 
390  QString getApparentMagnitudeAlgorithmOnEarth() const;
391 
393  void setFlagNativeNames(bool b);
395  bool getFlagNativeNames(void) const;
396 
398  void setFlagTranslatedNames(bool b);
400  bool getFlagTranslatedNames(void) const;
401 
403  void setFlagIsolatedTrails(bool b);
405  bool getFlagIsolatedTrails(void) const;
406 
408  void setFlagIsolatedOrbits(bool b);
410  bool getFlagIsolatedOrbits(void) const;
411 
413  void setFlagCustomGrsSettings(bool b);
416 
419  void setCustomGrsLongitude(int longitude);
422  int getCustomGrsLongitude();
423 
426  void setCustomGrsDrift(double drift);
428  double getCustomGrsDrift();
429 
432  // TODO (GZ): Clarify whether this is JD or rather JDE?
433  void setCustomGrsJD(double JD);
435  double getCustomGrsJD();
436 
439  QStringList getObjectsList(QString objType="all") const;
440 
441 signals:
442  void labelsDisplayedChanged(bool b);
443  void flagOrbitsChanged(bool b);
444  void flagHintsChanged(bool b);
445  void trailsDisplayedChanged(bool b);
446  void flagPointerChanged(bool b);
447  void flagNativeNamesChanged(bool b);
448  void flagTranslatedNamesChanged(bool b);
449  void flagPlanetsDisplayedChanged(bool b);
450  void flagIsolatedOrbitsChanged(bool b);
451  void flagIsolatedTrailsChanged(bool b);
452  void flagLightTravelTimeChanged(bool b);
453  void flagMoonScaleChanged(bool b);
454  void moonScaleChanged(double f);
455  void labelsAmountChanged(double f);
456  void ephemerisMarkersChanged(bool b);
457  void ephemerisDatesChanged(bool b);
458  void flagCustomGrsSettingsChanged(bool b);
459  void customGrsLongitudeChanged(int l);
460  void customGrsDriftChanged(double drift);
461  void customGrsJDChanged(double JD);
462 
463 public:
465  // Other public methods
469  PlanetP searchByEnglishName(QString planetEnglishName) const;
470 
472  PlanetP getSun() const {return sun;}
473 
475  PlanetP getEarth() const {return earth;}
476 
478  PlanetP getMoon() const {return moon;}
479 
481  bool nearLunarEclipse();
482 
484  QStringList getAllPlanetEnglishNames() const;
485 
487  QStringList getAllPlanetLocalizedNames() const;
488 
490  void reloadPlanets();
491 
493  double getEclipseFactor(const StelCore *core) const;
494 
498  void computePositions(double dateJDE, const Vec3d& observerPos = Vec3d(0.));
499 
501  const QList<PlanetP>& getAllPlanets() const {return systemPlanets;}
502 
503 private slots:
505  void selectedObjectChange(StelModule::StelModuleSelectAction action);
506 
510  void updateSkyCulture(const QString& skyCultureDir);
511 
512  void setFlagEphemerisMarkers(bool b);
513  bool getFlagEphemerisMarkers() const;
514 
515  void setFlagEphemerisDates(bool b);
516  bool getFlagEphemerisDates() const;
517 
518 private:
524  StelObjectP search(Vec3d v, const StelCore* core) const;
525 
528  void computeTransMatrices(double dateJDE, const Vec3d& observerPos = Vec3d(0.));
529 
531  void drawPointer(const StelCore* core);
532 
537  void loadPlanets();
538 
540  bool loadPlanets(const QString& filePath);
541 
542  void recreateTrails();
543 
545  void setFlagPermanentOrbits(bool b);
546 
548  int shadowPlanetCount;
549  PlanetP sun;
550  PlanetP moon;
551  PlanetP earth;
552 
555  void setSelected(const QString& englishName);
557  void setSelected(PlanetP obj);
559  PlanetP getSelected(void) const {return selected;}
561  PlanetP selected;
562 
563  // Moon scale value
564  bool flagMoonScale;
565  double moonScale;
566 
567  QFont planetNameFont;
568 
570  double labelsAmount;
571 
573  QList<PlanetP> systemPlanets;
574 
575  // Master settings
576  bool flagOrbits;
577  bool flagLightTravelTime;
578 
580  StelTextureSP texPointer;
581  StelTextureSP texCircle; // The symbolic circle texture
582 
583  bool flagShow;
584  bool flagPointer; // show red cross selection pointer?
585  bool flagNativeNames; // show native names?
586  bool flagTranslatedNames; // show translated names?
587  bool flagIsolatedTrails;
588  bool flagIsolatedOrbits;
589  bool ephemerisMarkersDisplayed;
590  bool ephemerisDatesDisplayed;
591 
592  class TrailGroup* allTrails;
593  StelGui* gui;
594  QSettings* conf;
595  LinearFader trailFader;
596  Vec3f trailColor;
597  Vec3f pointerColor;
598 
599  QHash<QString, QString> planetNativeNamesMap;
600 
601  QList<Orbit*> orbits; // Pointers on created elliptical orbits
602 };
603 
604 
605 #endif // _SOLARSYSTEM_HPP_
double getElongationForPlanet(QString planetName) const
Get elongation for Solar system bodies from scripts.
void setPointerColor(const Vec3f &c)
Set the color used to draw planet pointers.
Vec3f getPlanetsOrbitsColor(void) const
Get the current color used to draw planet and their moons orbit lines.
float getPhaseForPlanet(QString planetName) const
Get phase for Solar system bodies from scripts.
bool getFlagTranslatedNames(void) const
Get the current value of the flag which enables showing translated names for planets or not...
Definition: Orbit.hpp:22
virtual void update(double deltaTime)
Update time-varying components.
QStringList getAllPlanetEnglishNames() const
Get the list of all the planet english names.
void setFlagOrbits(bool b)
Set flag which determines if planet orbits are drawn or hidden.
bool getFlagMoonScale(void) const
Get the current value of the flag which determines if Earth&#39;s moon is scaled or not.
QString getApparentMagnitudeAlgorithmOnEarth() const
Get the algorithm used for computation of apparent magnitudes for planets in case observer on the Ear...
virtual double getCallOrder(StelModuleActionName actionName) const
Used to determine what order to draw the various StelModules.
void setFlagMoonScale(bool b)
Set flag which determines if Earth&#39;s moon is scaled or not.
Vec3f getPointerColor() const
Get the current color used to draw planet pointers.
void setFlagIsolatedOrbits(bool b)
Set flag which enabled the showing of isolated orbits for selected objects only or not...
PlanetP getSun() const
Get the Planet object pointer for the Sun.
PlanetP getEarth() const
Get the Planet object pointer for the Earth.
Class used to translate strings to any language.
Implementation of StelFader which implements a linear transition.
Definition: StelFader.hpp:77
double getCustomGrsDrift()
Get speed of annual drift for Great Red Spot (System II is used)
double getLabelsAmount(void) const
Get the amount of planet labels.
The base abstract class for sky objects used in Stellarium like Stars, Planets, Constellations etc...
Definition: StelObject.hpp:36
void reloadPlanets()
Reload the planets.
Define the StelTextureSP type.
bool getFlagCustomGrsSettings()
Get the current value of the flag which determines if custom settings for Great Red Spot on Jupiter i...
bool nearLunarEclipse()
Determine if a lunar eclipse is close at hand?
double getCustomGrsJD()
Get initial JD for calculation of position of Great Red Spot.
int getCustomGrsLongitude()
Get longitude of Great Red Spot (System II is used)
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
PlanetP getMoon() const
Get the Planet object pointer for Earth&#39;s moon.
void computePositions(double dateJDE, const Vec3d &observerPos=Vec3d(0.))
Compute the position and transform matrix for every element of the solar system.
bool getFlagTrails() const
Get the current value of the flag which determines if planet trails are drawn or hidden.
void setFlagHints(bool b)
Set flag which determines if planet hints are drawn or hidden along labels.
void setCustomGrsLongitude(int longitude)
Set longitude of Great Red Spot (System II is used)
bool getFlagLightTravelTime(void) const
Get the current value of the flag which determines if light travel time calculation is used or not...
void setFlagLabels(bool b)
Set flag which determines if planet labels are drawn or hidden.
void setAsteroidsOrbitsColor(const Vec3f &c)
Set the color used to draw minor planet orbit lines.
void setApparentMagnitudeAlgorithmOnEarth(QString algorithm)
Set the algorithm for computation of apparent magnitudes for planets in case observer on the Earth...
Vec3f getAsteroidsOrbitsColor(void) const
Get the current color used to draw minor planet orbit lines.
bool getFlagLabels() const
Get the current value of the flag which determines if planet labels are drawn or hidden.
bool getFlagPlanets() const
Get the current value of the flag which determines if planet are drawn or hidden. ...
Vec3f getCometsOrbitsColor(void) const
Get the current color used to draw comet orbit lines.
Specialization of StelModule which manages a collection of StelObject.
virtual QList< StelObjectP > searchAround(const Vec3d &v, double limitFov, const StelCore *core) const
Search for SolarSystem objects in some area around a point.
const QList< PlanetP > & getAllPlanets() const
Get the list of all the bodies of the solar system.
QStringList getObjectsList(QString objType="all") const
Get list of objects by type.
void setOrbitsColor(const Vec3f &c)
Set the color used to draw solar system object orbit lines.
This StelObjectModule derivative is used to model SolarSystem bodies.
Definition: SolarSystem.hpp:47
void setFlagPointer(bool b)
Set flag which determines if the planet pointer (red cross) is drawn or hidden on a selected planet...
virtual QStringList listAllObjects(bool inEnglish) const
List all StelObjects.
void setFlagIsolatedTrails(bool b)
Set flag which enabled the showing of isolated trails for selected objects only or not...
Vec3f getTrailsColor() const
Get the current color used to draw planet trails lines.
void setFlagCustomGrsSettings(bool b)
Set flag which determines if custom settings is using for Great Red Spot on Jupiter.
double getEclipseFactor(const StelCore *core) const
Determines relative amount of sun visible from the observer&#39;s position.
Provide the main interface to all operations of projecting coordinates from sky to screen...
bool getFlagIsolatedTrails(void) const
Get the current value of the flag which enables showing of isolated trails for selected objects only ...
double getMoonScale(void) const
Get the display scaling factor for Earth&#39;s moon.
bool getFlagIsolatedOrbits(void) const
Get the current value of the flag which enables showing of isolated orbits for selected objects only ...
void setFlagTranslatedNames(bool b)
Set flag which enable use translated names for planets or not.
double getDistanceToPlanet(QString planetName) const
Get distance to Solar system bodies from scripts.
QStringList getAllPlanetLocalizedNames() const
Get the list of all the planet localized names.
Vec3f getOrbitsColor(void) const
Get the current color used to draw solar system object orbit lines.
double getPhaseAngleForPlanet(QString planetName) const
Get phase angle for Solar system bodies from scripts.
virtual void init()
Initialize the SolarSystem.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
virtual StelObjectP searchByNameI18n(const QString &nameI18n) const
Search for a SolarSystem object based on the localised name.
void setLabelsColor(const Vec3f &c)
Set the color used to draw planet labels.
bool getFlagNativeNames(void) const
Get the current value of the flag which enables showing native names for planets or not...
void setFlagNativeNames(bool b)
Set flag which enable use native names for planets or not.
StelModuleSelectAction
Enum used when selecting objects to define whether to add to, replace, or remove from the existing se...
Definition: StelModule.hpp:111
double labelsAmount
The amount of planets labels (between 0 and 10).
void setTrailsColor(const Vec3f &c)
Set the color used to draw planet trails lines.
void setLabelsAmount(double a)
Set the amount of planet labels.
void setFontSize(float newFontSize)
Set planet names font size.
bool getFlagOrbits() const
Get the current value of the flag which determines if planet orbits are drawn or hidden.
void setMoonScale(double f)
Set the display scaling factor for Earth&#39;s moon.
void updateI18n()
Translate names. (public so that SolarSystemEditor can call it).
virtual void deinit()
Called before the module will be delete, and before the openGL context is suppressed.
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
bool getFlagHints() const
Get the current value of the flag which determines if planet hints are drawn or hidden along labels...
virtual QStringList listAllObjectsByType(const QString &objType, bool inEnglish) const
List all StelObjects by type.
Main class for the GUI based on QGraphicView.
Definition: StelGui.hpp:53
void setCometsOrbitsColor(const Vec3f &c)
Set the color used to draw comet orbit lines.
void setFlagPlanets(bool b)
Set flag which determines if planets are drawn or hidden.
QString getPlanetType(QString planetName) const
Get type for Solar system bodies from scripts.
float getPlanetVMagnitude(QString planetName, bool withExtinction=false) const
Get the V magnitude for Solar system bodies from scripts.
void setCustomGrsDrift(double drift)
Set speed of annual drift for Great Red Spot (System II is used)
bool getFlagPointer() const
Get the current value of the flag which determines if planet pointers are drawn or hidden...
void setCustomGrsJD(double JD)
Set initial JD for calculation of position of Great Red Spot.
const Vec3f & getLabelsColor(void) const
Get the current color used to draw planet labels.
void setFlagTrails(bool b)
Set flag which determines if planet trails are drawn or hidden.
void setFlagLightTravelTime(bool b)
Set flag which determines if the light travel time calculation is used or not.
PlanetP searchByEnglishName(QString planetEnglishName) const
Get a pointer to a Planet object.
void setPlanetsOrbitsColor(const Vec3f &c)
Set the color used to draw planet and their moons orbit lines.
virtual void draw(StelCore *core)
Draw SolarSystem objects (planets).
virtual StelObjectP searchByName(const QString &name) const
Search for a SolarSystem object based on the English name.