Stellarium 0.12.4
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 <QFont>
29 #include "StelObjectModule.hpp"
30 #include "Planet.hpp"
31 
32 class Orbit;
33 class StelTranslator;
34 class StelObject;
35 class StelCore;
36 class StelProjector;
37 class QSettings;
38 
39 typedef QSharedPointer<Planet> PlanetP;
40 
45 {
46  Q_OBJECT
47 
48 public:
49  SolarSystem();
50  virtual ~SolarSystem();
51 
53  // Methods defined in the StelModule class
59  virtual void init();
60 
66  virtual void draw(StelCore *core, class StelRenderer* renderer);
67 
70  virtual void update(double deltaTime);
71 
73  virtual double getCallOrder(StelModuleActionName actionName) const;
74 
76  // Methods defined in StelObjectManager class
85  virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
86 
90  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
91 
95  virtual StelObjectP searchByName(const QString& name) const;
96 
104  virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
112  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
113  virtual QStringList listAllObjects(bool inEnglish) const;
114  virtual QString getName() const { return "Solar System"; }
115 
116 public slots:
118  // Method callable from script and GUI
119  // Properties setters and getters
121  void setFlagPlanets(bool b);
123  bool getFlagPlanets() const;
124 
126  void setFlagTrails(bool b);
128  bool getFlagTrails() const;
129 
131  void setFlagHints(bool b);
133  bool getFlagHints() const;
134 
136  void setFlagLabels(bool b);
138  bool getFlagLabels() const;
139 
143  void setLabelsAmount(float a) {labelsAmount=a;}
146  float getLabelsAmount(void) const {return labelsAmount;}
147 
149  void setFlagOrbits(bool b);
151  bool getFlagOrbits() const {return flagOrbits;}
152 
154  void setFlagLightTravelTime(bool b);
157  bool getFlagLightTravelTime(void) const {return flagLightTravelTime;}
158 
160  void setFontSize(float newFontSize);
161 
163  void setLabelsColor(const Vec3f& c);
165  const Vec3f& getLabelsColor(void) const;
166 
168  void setOrbitsColor(const Vec3f& c);
170  Vec3f getOrbitsColor(void) const;
171 
173  void setTrailsColor(const Vec3f& c) {trailColor=c;}
175  Vec3f getTrailsColor() const {return trailColor;}
176 
178  void setFlagMoonScale(bool b);
180  bool getFlagMoonScale(void) const {return flagMoonScale;}
181 
183  void setMoonScale(float f);
185  float getMoonScale(void) const {return moonScale;}
186 
188  void updateI18n();
189 
194  float getPlanetVMagnitude(QString planetName, bool withExtinction=false) const;
195 
199  double getDistanceToPlanet(QString planetName) const;
200 
204  double getElongationForPlanet(QString planetName) const;
205 
209  double getPhaseAngleForPlanet(QString planetName) const;
210 
214  float getPhaseForPlanet(QString planetName) const;
215 
216 public:
218  // Other public methods
222  PlanetP searchByEnglishName(QString planetEnglishName) const;
223 
225  PlanetP getSun() const {return sun;}
226 
228  PlanetP getEarth() const {return earth;}
229 
231  PlanetP getMoon() const {return moon;}
232 
234  bool nearLunarEclipse();
235 
237  QStringList getAllPlanetEnglishNames() const;
238 
240  QStringList getAllPlanetLocalizedNames() const;
241 
243  void reloadPlanets();
244 
246  double getEclipseFactor(const StelCore *core) const;
247 
249  // DEPRECATED
255  QString getPlanetHashString();
256 
261  void computePositions(double date, const Vec3d& observerPos = Vec3d(0.));
262 
265  const QList<PlanetP>& getAllPlanets() const {return systemPlanets;}
266 
267 private slots:
269  void selectedObjectChange(StelModule::StelModuleSelectAction action);
270 
272  void setStelStyle(const QString& section);
273 
274 
275 private:
281  StelObjectP search(Vec3d v, const StelCore* core) const;
282 
285  void computeTransMatrices(double date, const Vec3d& observerPos = Vec3d(0.));
286 
291  void drawPointer(const StelCore* core, class StelRenderer* renderer);
292 
297  void loadPlanets();
298 
300  bool loadPlanets(const QString& filePath);
301 
302  void recreateTrails();
303 
305  class StelTextureNew* computeShadowInfo(StelRenderer* renderer);
306 
308  QVector<Vec4f> shadowInfoBuffer;
309 
312  QVector<Mat4d> shadowModelMatricesBuffer;
313 
315  int shadowPlanetCount;
316 
317  PlanetP sun;
318  PlanetP moon;
319  PlanetP earth;
320 
323  void setSelected(const QString& englishName);
325  void setSelected(PlanetP obj);
327  PlanetP getSelected(void) const {return selected;}
329  PlanetP selected;
330 
331  // Moon scale value
332  bool flagMoonScale;
333  float moonScale;
334 
335  QFont planetNameFont;
336 
338  float labelsAmount;
339 
341  QList<PlanetP> systemPlanets;
342 
343  // Master settings
344  bool flagOrbits;
345  bool flagLightTravelTime;
346 
348  class StelTextureNew* texPointer;
349 
350  bool flagShow;
351 
352  class TrailGroup* allTrails;
353  LinearFader trailFader;
354  Vec3f trailColor;
355 
356  Planet::SharedPlanetGraphics sharedPlanetGraphics;
357 
359  // DEPRECATED
361  QList<Orbit*> orbits; // Pointers on created elliptical orbits
362 };
363 
364 
365 #endif // _SOLARSYSTEM_HPP_