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 
72  virtual void deinit();
73 
78  virtual void draw(StelCore *core);
79 
82  virtual void update(double deltaTime);
83 
85  virtual double getCallOrder(StelModuleActionName actionName) const;
86 
88  // Methods defined in StelObjectManager class
97  virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
98 
102  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
103 
107  virtual StelObjectP searchByName(const QString& name) const;
108 
116  virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
124  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
125  virtual QStringList listAllObjects(bool inEnglish) const;
126  virtual QString getName() const { return "Solar System"; }
127 
128 public slots:
130  // Method callable from script and GUI
131  // Properties setters and getters
133  void setFlagPlanets(bool b);
135  bool getFlagPlanets() const;
136 
138  void setFlagTrails(bool b);
140  bool getFlagTrails() const;
141 
143  void setFlagHints(bool b);
145  bool getFlagHints() const;
146 
148  void setFlagLabels(bool b);
150  bool getFlagLabels() const;
151 
155  void setLabelsAmount(float a) {labelsAmount=a;}
158  float getLabelsAmount(void) const {return labelsAmount;}
159 
161  void setFlagOrbits(bool b);
163  bool getFlagOrbits() const {return flagOrbits;}
164 
166  void setFlagMarkers(bool b) { flagMarker=b; }
168  bool getFlagMarkers() const {return flagMarker;}
169 
171  void setFlagLightTravelTime(bool b);
174  bool getFlagLightTravelTime(void) const {return flagLightTravelTime;}
175 
177  void setFontSize(float newFontSize);
178 
185  void setLabelsColor(const Vec3f& c);
187  const Vec3f& getLabelsColor(void) const;
188 
195  void setOrbitsColor(const Vec3f& c);
197  Vec3f getOrbitsColor(void) const;
198 
205  void setTrailsColor(const Vec3f& c) {trailColor=c;}
207  Vec3f getTrailsColor() const {return trailColor;}
208 
215  void setPointersColor(const Vec3f& c) {pointerColor=c;}
217  Vec3f getPointersColor() const {return pointerColor;}
218 
220  void setFlagMoonScale(bool b);
222  bool getFlagMoonScale(void) const {return flagMoonScale;}
223 
225  void setMoonScale(double f);
227  float getMoonScale(void) const {return moonScale;}
228 
230  void updateI18n();
231 
236  float getPlanetVMagnitude(QString planetName) const;
237 
241  double getDistanceToPlanet(QString planetName) const;
242 
246  double getElongationForPlanet(QString planetName) const;
247 
251  double getPhaseAngleForPlanet(QString planetName) const;
252 
256  float getPhaseForPlanet(QString planetName) const;
257 
258 public:
260  // Other public methods
264  PlanetP searchByEnglishName(QString planetEnglishName) const;
265 
267  PlanetP getSun() const {return sun;}
268 
270  PlanetP getEarth() const {return earth;}
271 
273  PlanetP getMoon() const {return moon;}
274 
276  bool nearLunarEclipse();
277 
279  QStringList getAllPlanetEnglishNames() const;
280 
282  QStringList getAllPlanetLocalizedNames() const;
283 
285  void reloadPlanets();
286 
288  // DEPRECATED
294  QString getPlanetHashString();
295 
300  void computePositions(double date, const Vec3d& observerPos = Vec3d(0.));
301 
304  const QList<PlanetP>& getAllPlanets() const {return systemPlanets;}
305 
306 private slots:
308  void selectedObjectChange(StelModule::StelModuleSelectAction action);
309 
311  void setStelStyle(const QString& section);
312 
313 
314 private:
320  StelObjectP search(Vec3d v, const StelCore* core) const;
321 
324  void computeTransMatrices(double date, const Vec3d& observerPos = Vec3d(0.));
325 
327  void drawPointer(const StelCore* core);
328 
333  void loadPlanets();
334 
336  bool loadPlanets(const QString& filePath);
337 
338  void recreateTrails();
339 
340 
342  int shadowPlanetCount;
343  PlanetP sun;
344  PlanetP moon;
345  PlanetP earth;
346 
349  void setSelected(const QString& englishName);
351  void setSelected(PlanetP obj);
353  PlanetP getSelected(void) const {return selected;}
355  PlanetP selected;
356 
357  // Moon scale value
358  bool flagMoonScale;
359  float moonScale;
360 
361  QFont planetNameFont;
362 
364  float labelsAmount;
365 
367  QList<PlanetP> systemPlanets;
368 
369  // Master settings
370  bool flagOrbits;
371  bool flagLightTravelTime;
372 
374  StelTextureSP texPointer;
375 
376  bool flagShow;
377  bool flagMarker;
378 
379  class TrailGroup* allTrails;
380  LinearFader trailFader;
381  Vec3f trailColor;
382  Vec3f pointerColor;
383 
385  // DEPRECATED
387  QList<Orbit*> orbits; // Pointers on created elliptical orbits
388 };
389 
390 
391 #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.
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.
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.
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:79
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 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...
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.
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.
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.
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:46
Vec3f getTrailsColor() const
Get the current color used to draw planet trails lines.
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...
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:119
void setFlagMarkers(bool b)
Set flag which determines if planet markers 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 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:111
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...
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.