Stellarium 0.15.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
51  READ getFlagLabels
52  WRITE setFlagLabels)
53  Q_PROPERTY(bool orbitsDisplayed
54  READ getFlagOrbits
55  WRITE setFlagOrbits)
56  Q_PROPERTY(bool trailsDisplayed
57  READ getFlagTrails
58  WRITE setFlagTrails)
59  Q_PROPERTY(bool planetsDisplayed
60  READ getFlagPlanets
61  WRITE setFlagPlanets)
62 
63 public:
64  SolarSystem();
65  virtual ~SolarSystem();
66 
68  // Methods defined in the StelModule class
74  virtual void init();
75 
76  virtual void deinit();
77 
82  virtual void draw(StelCore *core);
83 
86  virtual void update(double deltaTime);
87 
89  virtual double getCallOrder(StelModuleActionName actionName) const;
90 
92  // Methods defined in StelObjectManager class
101  virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
102 
106  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
107 
111  virtual StelObjectP searchByName(const QString& name) const;
112 
120  virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
128  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
129  virtual QStringList listAllObjects(bool inEnglish) const { Q_UNUSED(inEnglish) return QStringList(); }
130  virtual QStringList listAllObjectsByType(const QString& objType, bool inEnglish) const;
131  virtual QString getName() const { return "Solar System"; }
132 
133 public slots:
135  // Method callable from script and GUI
136  // Properties setters and getters
138  void setFlagPlanets(bool b);
140  bool getFlagPlanets() const;
141 
143  void setFlagTrails(bool b);
145  bool getFlagTrails() const;
146 
148  void setFlagHints(bool b);
150  bool getFlagHints() const;
151 
153  void setFlagLabels(bool b);
155  bool getFlagLabels() const;
156 
160  void setLabelsAmount(float a) {labelsAmount=a;}
163  float getLabelsAmount(void) const {return labelsAmount;}
164 
166  void setFlagOrbits(bool b);
168  bool getFlagOrbits() const {return flagOrbits;}
169 
171  void setFlagPointers(bool b) { flagPointer=b; }
173  bool getFlagPointers() const {return flagPointer;}
174 
176  void setFlagLightTravelTime(bool b);
179  bool getFlagLightTravelTime(void) const {return flagLightTravelTime;}
180 
183  void setFontSize(float newFontSize);
184 
191  void setLabelsColor(const Vec3f& c);
194  const Vec3f& getLabelsColor(void) const;
195 
202  void setOrbitsColor(const Vec3f& c);
205  Vec3f getOrbitsColor(void) const;
206 
213  void setTrailsColor(const Vec3f& c) {trailColor=c;}
216  Vec3f getTrailsColor() const {return trailColor;}
217 
224  void setPointersColor(const Vec3f& c) {pointerColor=c;}
227  Vec3f getPointersColor() const {return pointerColor;}
228 
230  void setFlagMoonScale(bool b);
232  bool getFlagMoonScale(void) const {return flagMoonScale;}
233 
235  void setMoonScale(double f);
237  float getMoonScale(void) const {return moonScale;}
238 
240  void updateI18n();
241 
246  float getPlanetVMagnitude(QString planetName, bool withExtinction=false) const;
247 
251  QString getPlanetType(QString planetName) const;
252 
256  double getDistanceToPlanet(QString planetName) const;
257 
261  double getElongationForPlanet(QString planetName) const;
262 
266  double getPhaseAngleForPlanet(QString planetName) const;
267 
271  float getPhaseForPlanet(QString planetName) const;
272 
286  void setApparentMagnitudeAlgorithmOnEarth(QString algorithm);
287 
290  QString getApparentMagnitudeAlgorithmOnEarth() const;
291 
293  void setFlagNativeNames(bool b);
295  bool getFlagNativeNames(void) const;
296 
298  void setFlagTranslatedNames(bool b);
300  bool getFlagTranslatedNames(void) const;
301 
303  void setFlagIsolatedTrails(bool b);
305  bool getFlagIsolatedTrails(void) const;
306 
308  void setFlagIsolatedOrbits(bool b);
310  bool getFlagIsolatedOrbits(void) const;
311 
313  void setFlagCustomGrsSettings(bool b);
316 
319  void setCustomGrsLongitude(int longitude);
322  int getCustomGrsLongitude();
323 
326  void setCustomGrsDrift(double drift);
328  double getCustomGrsDrift();
329 
332  void setCustomGrsJD(double JD);
334  double getCustomGrsJD();
335 
336 public:
338  // Other public methods
342  PlanetP searchByEnglishName(QString planetEnglishName) const;
343 
345  PlanetP getSun() const {return sun;}
346 
348  PlanetP getEarth() const {return earth;}
349 
351  PlanetP getMoon() const {return moon;}
352 
354  bool nearLunarEclipse();
355 
357  QStringList getAllPlanetEnglishNames() const;
358 
360  QStringList getAllPlanetLocalizedNames() const;
361 
363  void reloadPlanets();
364 
366  double getEclipseFactor(const StelCore *core) const;
367 
371  void computePositions(double dateJDE, const Vec3d& observerPos = Vec3d(0.));
372 
374  const QList<PlanetP>& getAllPlanets() const {return systemPlanets;}
375 
376 private slots:
378  void selectedObjectChange(StelModule::StelModuleSelectAction action);
379 
383  void updateSkyCulture(const QString& skyCultureDir);
384 
385 private:
391  StelObjectP search(Vec3d v, const StelCore* core) const;
392 
395  void computeTransMatrices(double dateJDE, const Vec3d& observerPos = Vec3d(0.));
396 
398  void drawPointer(const StelCore* core);
399 
404  void loadPlanets();
405 
407  bool loadPlanets(const QString& filePath);
408 
409  void recreateTrails();
410 
412  void setFlagPermanentOrbits(bool b);
413 
415  int shadowPlanetCount;
416  PlanetP sun;
417  PlanetP moon;
418  PlanetP earth;
419 
422  void setSelected(const QString& englishName);
424  void setSelected(PlanetP obj);
426  PlanetP getSelected(void) const {return selected;}
428  PlanetP selected;
429 
430  // Moon scale value
431  bool flagMoonScale;
432  float moonScale;
433 
434  QFont planetNameFont;
435 
437  float labelsAmount;
438 
440  QList<PlanetP> systemPlanets;
441 
442  // Master settings
443  bool flagOrbits;
444  bool flagLightTravelTime;
445 
447  StelTextureSP texPointer;
448  StelTextureSP texCircle; // The symbolic circle texture
449 
450  bool flagShow;
451  bool flagPointer;
452  bool flagNativeNames;
453  bool flagTranslatedNames;
454  bool flagIsolatedTrails;
455  bool flagIsolatedOrbits;
456 
457  class TrailGroup* allTrails;
458  StelGui* gui;
459  QSettings* conf;
460  LinearFader trailFader;
461  Vec3f trailColor;
462  Vec3f pointerColor;
463 
464  QHash<QString, QString> planetNativeNamesMap;
465 
466  QList<Orbit*> orbits; // Pointers on created elliptical orbits
467 };
468 
469 
470 #endif // _SOLARSYSTEM_HPP_
double getElongationForPlanet(QString planetName) const
Get elongation for Solar system bodies from scripts.
void setLabelsAmount(float a)
Set the amount of planet labels.
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'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's moon is scaled or not.
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)
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.
float getLabelsAmount(void) const
Get the amount of planet labels.
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
virtual QStringList listMatchingObjectsI18n(const QString &objPrefix, int maxNbItem=5, bool useStartOfWords=false) const
Find objects by translated name prefix.
PlanetP getMoon() const
Get the Planet object pointer for Earth'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)
void setPointersColor(const Vec3f &c)
Set the color used to draw planet pointers.
Vec3f getPointersColor() const
Get the current color used to draw planet pointers.
float getMoonScale(void) const
Get the display scaling factor for Earth's oon.
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 setFlagPointers(bool b)
Set flag which determines if planet pointers are drawn or hidden.
void setApparentMagnitudeAlgorithmOnEarth(QString algorithm)
Set the algorithm for computation of apparent magnitudes for planets in case observer on the Earth...
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. ...
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.
void setOrbitsColor(const Vec3f &c)
Set the color used to draw planet orbit lines.
This StelObjectModule derivative is used to model SolarSystem bodies.
Definition: SolarSystem.hpp:47
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'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 ...
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 planet 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:117
bool getFlagPointers() const
Get the current value of the flag which determines if planet pointers are drawn or hidden...
virtual QStringList listMatchingObjects(const QString &objPrefix, int maxNbItem=5, bool useStartOfWords=false) const
Find objects by translated name prefix.
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:109
void setTrailsColor(const Vec3f &c)
Set the color used to draw planet trails lines.
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'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...
Main class for the GUI based on QGraphicView.
Definition: StelGui.hpp:53
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)
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.
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.