Stellarium 0.13.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 
32 #include <QFont>
33 
34 class Orbit;
35 class StelTranslator;
36 class StelObject;
37 class StelCore;
38 class StelProjector;
39 class QSettings;
40 
41 typedef QSharedPointer<Planet> PlanetP;
42 
47 {
48  Q_OBJECT
49  Q_PROPERTY(bool labelsDisplayed
50  READ getFlagLabels
51  WRITE setFlagLabels)
52  Q_PROPERTY(bool orbitsDisplayed
53  READ getFlagOrbits
54  WRITE setFlagOrbits)
55  Q_PROPERTY(bool trailsDisplayed
56  READ getFlagTrails
57  WRITE setFlagTrails)
58 
59 public:
60  SolarSystem();
61  virtual ~SolarSystem();
62 
64  // Methods defined in the StelModule class
70  virtual void init();
71 
76  virtual void draw(StelCore *core);
77 
80  virtual void update(double deltaTime);
81 
83  virtual double getCallOrder(StelModuleActionName actionName) const;
84 
86  // Methods defined in StelObjectManager class
95  virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
96 
100  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
101 
105  virtual StelObjectP searchByName(const QString& name) const;
106 
114  virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
122  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
123  virtual QStringList listAllObjects(bool inEnglish) const;
124  virtual QString getName() const { return "Solar System"; }
125 
126 public slots:
128  // Method callable from script and GUI
129  // Properties setters and getters
131  void setFlagPlanets(bool b);
133  bool getFlagPlanets() const;
134 
136  void setFlagTrails(bool b);
138  bool getFlagTrails() const;
139 
141  void setFlagHints(bool b);
143  bool getFlagHints() const;
144 
146  void setFlagLabels(bool b);
148  bool getFlagLabels() const;
149 
153  void setLabelsAmount(float a) {labelsAmount=a;}
156  float getLabelsAmount(void) const {return labelsAmount;}
157 
159  void setFlagOrbits(bool b);
161  bool getFlagOrbits() const {return flagOrbits;}
162 
164  void setFlagMarkers(bool b) { flagMarker=b; }
166  bool getFlagMarkers() const {return flagMarker;}
167 
169  void setFlagLightTravelTime(bool b);
172  bool getFlagLightTravelTime(void) const {return flagLightTravelTime;}
173 
175  void setFontSize(float newFontSize);
176 
183  void setLabelsColor(const Vec3f& c);
185  const Vec3f& getLabelsColor(void) const;
186 
193  void setOrbitsColor(const Vec3f& c);
195  Vec3f getOrbitsColor(void) const;
196 
203  void setTrailsColor(const Vec3f& c) {trailColor=c;}
205  Vec3f getTrailsColor() const {return trailColor;}
206 
213  void setPointersColor(const Vec3f& c) {pointerColor=c;}
215  Vec3f getPointersColor() const {return pointerColor;}
216 
218  void setFlagMoonScale(bool b);
220  bool getFlagMoonScale(void) const {return flagMoonScale;}
221 
223  void setMoonScale(double f);
225  float getMoonScale(void) const {return moonScale;}
226 
228  void updateI18n();
229 
234  float getPlanetVMagnitude(QString planetName) const;
235 
239  double getDistanceToPlanet(QString planetName) const;
240 
244  double getElongationForPlanet(QString planetName) const;
245 
249  double getPhaseAngleForPlanet(QString planetName) const;
250 
254  float getPhaseForPlanet(QString planetName) const;
255 
256 public:
258  // Other public methods
262  PlanetP searchByEnglishName(QString planetEnglishName) const;
263 
265  PlanetP getSun() const {return sun;}
266 
268  PlanetP getEarth() const {return earth;}
269 
271  PlanetP getMoon() const {return moon;}
272 
274  bool nearLunarEclipse();
275 
277  QStringList getAllPlanetEnglishNames() const;
278 
280  QStringList getAllPlanetLocalizedNames() const;
281 
283  void reloadPlanets();
284 
286  // DEPRECATED
292  QString getPlanetHashString();
293 
298  void computePositions(double date, const Vec3d& observerPos = Vec3d(0.));
299 
302  const QList<PlanetP>& getAllPlanets() const {return systemPlanets;}
303 
304 private slots:
306  void selectedObjectChange(StelModule::StelModuleSelectAction action);
307 
309  void setStelStyle(const QString& section);
310 
311 
312 private:
318  StelObjectP search(Vec3d v, const StelCore* core) const;
319 
322  void computeTransMatrices(double date, const Vec3d& observerPos = Vec3d(0.));
323 
325  void drawPointer(const StelCore* core);
326 
331  void loadPlanets();
332 
334  bool loadPlanets(const QString& filePath);
335 
336  void recreateTrails();
337 
339  void computeShadowInfo();
340 
342  QVector<Vec4f> shadowInfoBuffer;
343 
346  QVector<Mat4d> shadowModelMatricesBuffer;
347 
349  int shadowPlanetCount;
350  PlanetP sun;
351  PlanetP moon;
352  PlanetP earth;
353 
356  void setSelected(const QString& englishName);
358  void setSelected(PlanetP obj);
360  PlanetP getSelected(void) const {return selected;}
362  PlanetP selected;
363 
364  // Moon scale value
365  bool flagMoonScale;
366  float moonScale;
367 
368  QFont planetNameFont;
369 
371  float labelsAmount;
372 
374  QList<PlanetP> systemPlanets;
375 
376  // Master settings
377  bool flagOrbits;
378  bool flagLightTravelTime;
379 
381  StelTextureSP texPointer;
382 
383  bool flagShow;
384  bool flagMarker;
385 
386  class TrailGroup* allTrails;
387  LinearFader trailFader;
388  Vec3f trailColor;
389  Vec3f pointerColor;
390 
392  // DEPRECATED
394  QList<Orbit*> orbits; // Pointers on created elliptical orbits
395 };
396 
397 
398 #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.
Definition: SolarSystem.hpp:153
float getPhaseForPlanet(QString planetName) const
Get phase for Solar system bodies from scripts.
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.
Definition: SolarSystem.hpp:220
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.
PlanetP getSun() const
Get the Planet object pointer for the Sun.
Definition: SolarSystem.hpp:265
PlanetP getEarth() const
Get the Planet object pointer for the Earth.
Definition: SolarSystem.hpp:268
Class used to translate strings to any language.
Definition: StelTranslator.hpp:51
Implementation of StelFader which implements a linear transition.
Definition: StelFader.hpp:79
Definition: TrailGroup.hpp:29
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.
Definition: SolarSystem.hpp:156
bool nearLunarEclipse()
Determine if a lunar eclipse is close at hand?
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
bool getFlagMarkers() const
Get the current value of the flag which determines if planet markers are drawn or hidden...
Definition: SolarSystem.hpp:166
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.
Definition: SolarSystem.hpp:271
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 setPointersColor(const Vec3f &c)
Set the color used to draw planet pointers.
Definition: SolarSystem.hpp:213
Vec3f getPointersColor() const
Get the current color used to draw planet pointers.
Definition: SolarSystem.hpp:215
float getMoonScale(void) const
Get the display scaling factor for Earth's oon.
Definition: SolarSystem.hpp:225
bool getFlagLightTravelTime(void) const
Get the current value of the flag which determines if light travel time calculation is used or not...
Definition: SolarSystem.hpp:172
void setFlagLabels(bool b)
Set flag which determines if planet labels are drawn or hidden.
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.
Definition: StelObjectModule.hpp:35
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.
Definition: SolarSystem.hpp:302
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:46
Vec3f getTrailsColor() const
Get the current color used to draw planet trails lines.
Definition: SolarSystem.hpp:205
float getPlanetVMagnitude(QString planetName) const
Get the V magnitude for Solar system bodies from scripts.
Provide the main interface to all operations of projecting coordinates from sky to screen...
Definition: StelProjector.hpp:37
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:120
void setFlagMarkers(bool b)
Set flag which determines if planet markers are drawn or hidden.
Definition: SolarSystem.hpp:164
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 computePositions(double date, const Vec3d &observerPos=Vec3d(0.))
Compute the position and transform matrix for every element of the solar system.
void setLabelsColor(const Vec3f &c)
Set the color used to draw planet labels.
StelModuleSelectAction
Enum used when selecting objects to define whether to add to, replace, or remove from the existing se...
Definition: StelModule.hpp:112
void setTrailsColor(const Vec3f &c)
Set the color used to draw planet trails lines.
Definition: SolarSystem.hpp:203
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.
Definition: SolarSystem.hpp:161
void setMoonScale(double f)
Set the display scaling factor for Earth's moon.
void updateI18n()
Translate names. (public so that SolarSystemEditor can call it).
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
Definition: StelTextureTypes.hpp:34
bool getFlagHints() const
Get the current value of the flag which determines if planet hints are drawn or hidden along labels...
void setFlagPlanets(bool b)
Set flag which determines if planets are drawn or hidden.
const Vec3f & getLabelsColor(void) const
Get the current color used to draw planet labels.
QString getPlanetHashString()
Get a hash of locale and ssystem.ini names for use with the TUI.
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.