Stellarium 0.12.3
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 
103  virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5) const;
110  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5) const;
111  virtual QStringList listAllObjects(bool inEnglish) const;
112  virtual QString getName() const { return "Solar System"; }
113 
114 public slots:
116  // Method callable from script and GUI
117  // Properties setters and getters
119  void setFlagPlanets(bool b);
121  bool getFlagPlanets() const;
122 
124  void setFlagTrails(bool b);
126  bool getFlagTrails() const;
127 
129  void setFlagHints(bool b);
131  bool getFlagHints() const;
132 
134  void setFlagLabels(bool b);
136  bool getFlagLabels() const;
137 
141  void setLabelsAmount(float a) {labelsAmount=a;}
144  float getLabelsAmount(void) const {return labelsAmount;}
145 
147  void setFlagOrbits(bool b);
149  bool getFlagOrbits() const {return flagOrbits;}
150 
152  void setFlagLightTravelTime(bool b);
155  bool getFlagLightTravelTime(void) const {return flagLightTravelTime;}
156 
158  void setFontSize(float newFontSize);
159 
161  void setLabelsColor(const Vec3f& c);
163  const Vec3f& getLabelsColor(void) const;
164 
166  void setOrbitsColor(const Vec3f& c);
168  Vec3f getOrbitsColor(void) const;
169 
171  void setTrailsColor(const Vec3f& c) {trailColor=c;}
173  Vec3f getTrailsColor() const {return trailColor;}
174 
176  void setFlagMoonScale(bool b);
178  bool getFlagMoonScale(void) const {return flagMoonScale;}
179 
181  void setMoonScale(float f);
183  float getMoonScale(void) const {return moonScale;}
184 
186  void updateI18n();
187 
192  float getPlanetVMagnitude(QString planetName, bool withExtinction=false) const;
193 
197  double getDistanceToPlanet(QString planetName) const;
198 
202  double getElongationForPlanet(QString planetName) const;
203 
207  double getPhaseAngleForPlanet(QString planetName) const;
208 
212  float getPhaseForPlanet(QString planetName) const;
213 
214 public:
216  // Other public methods
220  PlanetP searchByEnglishName(QString planetEnglishName) const;
221 
223  PlanetP getSun() const {return sun;}
224 
226  PlanetP getEarth() const {return earth;}
227 
229  PlanetP getMoon() const {return moon;}
230 
232  bool nearLunarEclipse();
233 
235  QStringList getAllPlanetEnglishNames() const;
236 
238  QStringList getAllPlanetLocalizedNames() const;
239 
241  void reloadPlanets();
242 
244  double getEclipseFactor(const StelCore *core) const;
245 
247  // DEPRECATED
253  QString getPlanetHashString();
254 
259  void computePositions(double date, const Vec3d& observerPos = Vec3d(0.));
260 
263  const QList<PlanetP>& getAllPlanets() const {return systemPlanets;}
264 
265 private slots:
267  void selectedObjectChange(StelModule::StelModuleSelectAction action);
268 
270  void setStelStyle(const QString& section);
271 
272 
273 private:
279  StelObjectP search(Vec3d v, const StelCore* core) const;
280 
283  void computeTransMatrices(double date, const Vec3d& observerPos = Vec3d(0.));
284 
289  void drawPointer(const StelCore* core, class StelRenderer* renderer);
290 
295  void loadPlanets();
296 
298  bool loadPlanets(const QString& filePath);
299 
300  void recreateTrails();
301 
303  class StelTextureNew* computeShadowInfo(StelRenderer* renderer);
304 
306  QVector<Vec4f> shadowInfoBuffer;
307 
310  QVector<Mat4d> shadowModelMatricesBuffer;
311 
313  int shadowPlanetCount;
314 
315  PlanetP sun;
316  PlanetP moon;
317  PlanetP earth;
318 
321  void setSelected(const QString& englishName);
323  void setSelected(PlanetP obj);
325  PlanetP getSelected(void) const {return selected;}
327  PlanetP selected;
328 
329  // Moon scale value
330  bool flagMoonScale;
331  float moonScale;
332 
333  QFont planetNameFont;
334 
336  float labelsAmount;
337 
339  QList<PlanetP> systemPlanets;
340 
341  // Master settings
342  bool flagOrbits;
343  bool flagLightTravelTime;
344 
346  class StelTextureNew* texPointer;
347 
348  bool flagShow;
349 
350  class TrailGroup* allTrails;
351  LinearFader trailFader;
352  Vec3f trailColor;
353 
354  Planet::SharedPlanetGraphics sharedPlanetGraphics;
355 
357  // DEPRECATED
359  QList<Orbit*> orbits; // Pointers on created elliptical orbits
360 };
361 
362 
363 #endif // _SOLARSYSTEM_HPP_