3
* Copyright (C) 2002 Fabien Chereau
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#ifndef _SOLARSYSTEM_HPP_
21
#define _SOLARSYSTEM_HPP_
22
//sun is already defined in Sun C/Solaris
28
#include "StelObjectModule.hpp"
29
#include "StelTextureTypes.hpp"
41
typedef QSharedPointer<Planet> PlanetP;
43
//! @class SolarSystem
44
//! This StelObjectModule derivative is used to model SolarSystem boies.
45
//! This includes the Major Planets, Minor Planets and Comets.
46
class SolarSystem : public StelObjectModule
52
virtual ~SolarSystem();
54
///////////////////////////////////////////////////////////////////////////
55
// Methods defined in the StelModule class
56
//! Initialize the SolarSystem.
58
//! - loading planetary body orbital and model data from data/ssystem.ini
59
//! - perform initial planet position calculation
60
//! - set display options from application settings
63
//! Draw SolarSystem objects (planets).
64
//! @param core The StelCore object.
65
//! @return The maximum squared distance in pixels that any SolarSystem object
66
//! has travelled since the last update.
67
virtual void draw(StelCore *core);
69
//! Update time-varying components.
70
//! This includes planet motion trails.
71
virtual void update(double deltaTime);
74
virtual void updateI18n();
76
//! Called when a new object is selected.
77
virtual void selectedObjectChangeCallBack(StelModuleSelectAction action=StelModule::ReplaceSelection);
79
//! Load a color scheme
80
virtual void setStelStyle(const StelStyle& style);
82
//! Used to determine what order to draw the various StelModules.
83
virtual double getCallOrder(StelModuleActionName actionName) const;
85
///////////////////////////////////////////////////////////////////////////
86
// Methods defined in StelObjectManager class
87
//! Search for SolarSystem objects in some area around a point.
88
//! @param v A vector representing a point in the sky.
89
//! @param limitFov The radius of the circle around the point v which
90
//! defines the size of the area to search.
91
//! @param core the core object
92
//! @return A STL vector of SpelObjectP (pointers) containing all SolarSystem
93
//! objects found in the specified area. This vector is not sorted by distance
95
virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
97
//! Search for a SolarSystem object based on the localised name.
98
//! @param nameI18n the case in-sensistive translated planet name.
99
//! @return a StelObjectP for the object if found, else NULL.
100
virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
102
//! Search for a SolarSystem object based on the English name.
103
//! @param name the case in-sensistive English planet name.
104
//! @return a StelObjectP for the object if found, else NULL.
105
virtual StelObjectP searchByName(const QString& name) const;
107
//! Find objects by translated name prefix.
108
//! Find and return the list of at most maxNbItem objects auto-completing
109
//! the passed object I18n name.
110
//! @param objPrefix the case insensitive first letters of the searched object.
111
//! @param maxNbItem the maximum number of returned object names.
112
//! @return a list of matching object name by order of relevance, or an empty list if nothing matches.
113
virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5) const;
116
///////////////////////////////////////////////////////////////////////////
117
// Method callable from script and GUI
118
// Properties setters and getters
119
//! Set flag which determines if planets are drawn or hidden.
120
void setFlagPlanets(bool b);
121
//! Get the current value of the flag which determines if planet are drawn or hidden.
122
bool getFlagPlanets() const;
124
//! Set flag which determines if planet trails are drawn or hidden.
125
void setFlagTrails(bool b);
126
//! Get the current value of the flag which determines if planet trails are drawn or hidden.
127
bool getFlagTrails() const;
129
//! Set flag which determines if planet hints are drawn or hidden along labels
130
void setFlagHints(bool b);
131
//! Get the current value of the flag which determines if planet hints are drawn or hidden along labels
132
bool getFlagHints() const;
134
//! Set flag which determines if planet labels are drawn or hidden.
135
void setFlagLabels(bool b);
136
//! Get the current value of the flag which determines if planet labels are drawn or hidden.
137
bool getFlagLabels() const;
139
//! Set the amount of planet labels. The real amount is also proportional with FOV.
140
//! The limit is set in function of the planets magnitude
141
//! @param a the amount between 0 and 10. 0 is no labels, 10 is maximum of labels
142
void setLabelsAmount(float a) {labelsAmount=a;}
143
//! Get the amount of planet labels. The real amount is also proportional with FOV.
144
//! @return the amount between 0 and 10. 0 is no labels, 10 is maximum of labels
145
float getLabelsAmount(void) const {return labelsAmount;}
147
//! Set flag which determines if planet orbits are drawn or hidden.
148
void setFlagOrbits(bool b);
149
//! Get the current value of the flag which determines if planet orbits are drawn or hidden.
150
bool getFlagOrbits() const {return flagOrbits;}
152
//! Set flag which determines if the light travel time calculation is used or not.
153
void setFlagLightTravelTime(bool b);
154
//! Get the current value of the flag which determines if light travel time
155
//! calculation is used or not.
156
bool getFlagLightTravelTime(void) const {return flagLightTravelTime;}
158
//! Set planet names font size.
159
void setFontSize(float newFontSize);
161
//! Set the color used to draw planet labels.
162
void setLabelsColor(const Vec3f& c);
163
//! Get the current color used to draw planet labels.
164
const Vec3f& getLabelsColor(void) const;
166
//! Set the color used to draw planet orbit lines.
167
void setOrbitsColor(const Vec3f& c);
168
//! Get the current color used to draw planet orbit lines.
169
Vec3f getOrbitsColor(void) const;
171
//! Set the color used to draw planet trails.
172
void setTrailsColor(const Vec3f& c);
173
//! Get the current color used to draw planet trails.
174
Vec3f getTrailsColor(void) const;
176
//! Set flag which determines if Earth's moon is scaled or not.
177
void setFlagMoonScale(bool b);
178
//! Get the current value of the flag which determines if Earth's moon is scaled or not.
179
bool getFlagMoonScale(void) const {return flagMoonScale;}
181
//! Set the display scaling factor for Earth's moon.
182
void setMoonScale(float f);
183
//! Get the display scaling factor for Earth's oon.
184
float getMoonScale(void) const {return moonScale;}
187
///////////////////////////////////////////////////////////////////////////
188
// Other public methods
189
//! Get a pointer to a Planet object.
190
//! @param planetEnglishName the English name of the desired planet.
191
//! @return The matching planet pointer if exists or NULL.
192
PlanetP searchByEnglishName(QString planetEnglishName) const;
194
//! Get the Planet object pointer for the Sun.
195
PlanetP getSun(void) const {return sun;}
197
//! Get the Planet object pointer for the Earth.
198
PlanetP getEarth(void) const {return earth;}
200
//! Get the Planet object pointer for Earth's moon.
201
PlanetP getMoon(void) const {return moon;}
203
//! Determine if a lunar eclipse is close at hand?
204
bool nearLunarEclipse();
206
//! Get the list of all the planet english names
207
QStringList getAllPlanetEnglishNames() const;
209
///////////////////////////////////////////////////////////////////////////////////////
211
///////////////////////////////////////////////////////////////////////////////////////
212
//! Get a hash of locale and ssystem.ini names for use with the TUI.
213
//! @return A newline delimited hash of localized:standard planet names.
214
//! Planet translated name is PARENT : NAME
215
QString getPlanetHashString();
217
//! Compute the position and transform matrix for every element of the solar system.
218
//! @param observerPos Position of the observer in heliocentric ecliptic frame (Required for light travel time computation).
219
//! @param date the date in JDay
220
void computePositions(double date, const Vec3d& observerPos = Vec3d(0.));
222
//! Get the list of all the bodies of the solar system.
223
const QList<PlanetP>& getAllPlanets() const {return systemPlanets;}
226
//! Search for SolarSystem objects which are close to the position given
227
//! in earth equatorial position.
228
//! @param v A position in earth equatorial position.
229
//! @param core the StelCore object.
230
//! @return a pointer to a StelObject if found, else NULL
231
StelObjectP search(Vec3d v, const StelCore* core) const;
233
//! Update the planet motion trails.
234
// void updateTrails(const StelNavigator* nav);
236
//! Start/stop accumulating new trail data (clear old data).
237
void startTrails(bool b);
239
//! Compute the transformation matrix for every elements of the solar system.
240
//! observerPos is needed for light travel time computation.
241
void computeTransMatrices(double date, const Vec3d& observerPos = Vec3d(0.));
243
//! Draw a nice animated pointer around the object.
244
void drawPointer(const StelCore* core);
246
//! Load planet data from a file.
253
//! Set selected planets by englishName.
254
//! @param englishName The planet name or "" to select no planet
255
void setSelected(const QString& englishName);
256
//! Set selected object from its pointer.
257
void setSelected(PlanetP obj);
258
//! Get selected object's pointer.
259
PlanetP getSelected(void) const {return selected;}
260
//! The currently selected planet.
267
QFont planetNameFont;
269
//! The amount of planets labels (between 0 and 10).
272
//! List of all the bodies of the solar system.
273
QList<PlanetP> systemPlanets;
277
bool flagLightTravelTime;
279
//! The selection pointer texture.
280
StelTextureSP texPointer;
284
//////////////////////////////////////////////////////////////////////////////////
286
//////////////////////////////////////////////////////////////////////////////////
287
PlanetP lastHomePlanet; // for tracking home planet changes for trails
288
QList<Orbit*> orbits; // Pointers on created elliptical orbits
292
#endif // _SOLARSYSTEM_HPP_