~ubuntu-branches/debian/squeeze/stellarium/squeeze

« back to all changes in this revision

Viewing changes to src/modules/SolarSystem.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Cédric Delfosse
  • Date: 2010-07-31 15:44:02 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100731154402-511dojtyt5ycuizd
Tags: 0.10.5-1
* New upstream release (Closes: #586804)
* Remove 01_fix_pow10_function_check.diff, now applied upstream
* Remove 02_remove_unknown_locale_code.diff, no more needed
* Rendering of `old_style' landscapes fixed by upstream (Closes: #581657)
* Update debian/control:
  - Bump Standards-Version from 3.8.4 to 3.9.0
  - Add libqt4-sql-sqlite to Depends (Closes: #582726)
* Update debian/copyright:
  - Fix FSF address

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Stellarium
3
 
 * Copyright (C) 2002 Fabien Chereau
4
 
 *
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.
9
 
 *
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.
14
 
 *
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.
18
 
 */
19
 
 
20
 
#ifndef _SOLARSYSTEM_HPP_
21
 
#define _SOLARSYSTEM_HPP_
22
 
//sun is already defined in Sun C/Solaris
23
 
#if defined(sun)
24
 
#undef sun
25
 
#endif
26
 
 
27
 
#include <QFont>
28
 
#include "StelObjectModule.hpp"
29
 
#include "StelTextureTypes.hpp"
30
 
#include "Planet.hpp"
31
 
 
32
 
class Orbit;
33
 
class StelLoadingBar;
34
 
class StelTranslator;
35
 
class StelObject;
36
 
class StelCore;
37
 
class StelProjector;
38
 
class StelNavigator;
39
 
class QSettings;
40
 
 
41
 
typedef QSharedPointer<Planet> PlanetP;
42
 
 
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
47
 
{
48
 
        Q_OBJECT
49
 
 
50
 
public:
51
 
        SolarSystem();
52
 
        virtual ~SolarSystem();
53
 
 
54
 
        ///////////////////////////////////////////////////////////////////////////
55
 
        // Methods defined in the StelModule class
56
 
        //! Initialize the SolarSystem.
57
 
        //! Includes:
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
61
 
        virtual void init();
62
 
 
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);
68
 
 
69
 
        //! Update time-varying components.
70
 
        //! This includes planet motion trails.
71
 
        virtual void update(double deltaTime);
72
 
 
73
 
        //! Translate names.
74
 
        virtual void updateI18n();
75
 
 
76
 
        //! Called when a new object is selected.
77
 
        virtual void selectedObjectChangeCallBack(StelModuleSelectAction action=StelModule::ReplaceSelection);
78
 
 
79
 
        //! Load a color scheme
80
 
        virtual void setStelStyle(const StelStyle& style);
81
 
 
82
 
        //! Used to determine what order to draw the various StelModules.
83
 
        virtual double getCallOrder(StelModuleActionName actionName) const;
84
 
 
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
94
 
        //! from v.
95
 
        virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
96
 
 
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;
101
 
 
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;
106
 
 
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;
114
 
 
115
 
public slots:
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;
123
 
 
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;
128
 
 
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;
133
 
 
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;
138
 
 
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;}
146
 
 
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;}
151
 
 
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;}
157
 
 
158
 
        //! Set planet names font size.
159
 
        void setFontSize(float newFontSize);
160
 
 
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;
165
 
 
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;
170
 
 
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;
175
 
 
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;}
180
 
 
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;}
185
 
 
186
 
public:
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;
193
 
 
194
 
        //! Get the Planet object pointer for the Sun.
195
 
        PlanetP getSun(void) const {return sun;}
196
 
 
197
 
        //! Get the Planet object pointer for the Earth.
198
 
        PlanetP getEarth(void) const {return earth;}
199
 
 
200
 
        //! Get the Planet object pointer for Earth's moon.
201
 
        PlanetP getMoon(void) const {return moon;}
202
 
 
203
 
        //! Determine if a lunar eclipse is close at hand?
204
 
        bool nearLunarEclipse();
205
 
 
206
 
        //! Get the list of all the planet english names
207
 
        QStringList getAllPlanetEnglishNames() const;
208
 
 
209
 
        ///////////////////////////////////////////////////////////////////////////////////////
210
 
        // DEPRECATED
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();
216
 
 
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.));
221
 
 
222
 
        //! Get the list of all the bodies of the solar system.
223
 
        const QList<PlanetP>& getAllPlanets() const {return systemPlanets;}
224
 
 
225
 
private:
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;
232
 
 
233
 
        //! Update the planet motion trails.
234
 
        // void updateTrails(const StelNavigator* nav);
235
 
 
236
 
        //! Start/stop accumulating new trail data (clear old data).
237
 
        void startTrails(bool b);
238
 
 
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.));
242
 
 
243
 
        //! Draw a nice animated pointer around the object.
244
 
        void drawPointer(const StelCore* core);
245
 
 
246
 
        //! Load planet data from a file.
247
 
        void loadPlanets();
248
 
 
249
 
        PlanetP sun;
250
 
        PlanetP moon;
251
 
        PlanetP earth;
252
 
 
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.
261
 
        PlanetP selected;
262
 
 
263
 
        // Moon scale value
264
 
        bool flagMoonScale;
265
 
        float moonScale;
266
 
 
267
 
        QFont planetNameFont;
268
 
 
269
 
        //! The amount of planets labels (between 0 and 10).
270
 
        float labelsAmount;
271
 
 
272
 
        //! List of all the bodies of the solar system.
273
 
        QList<PlanetP> systemPlanets;
274
 
 
275
 
        // Master settings
276
 
        bool flagOrbits;
277
 
        bool flagLightTravelTime;
278
 
 
279
 
        //! The selection pointer texture.
280
 
        StelTextureSP texPointer;
281
 
 
282
 
        bool flagShow;
283
 
 
284
 
        //////////////////////////////////////////////////////////////////////////////////
285
 
        // DEPRECATED
286
 
        //////////////////////////////////////////////////////////////////////////////////
287
 
        PlanetP lastHomePlanet;    // for tracking home planet changes for trails
288
 
        QList<Orbit*> orbits;           // Pointers on created elliptical orbits
289
 
};
290
 
 
291
 
 
292
 
#endif // _SOLARSYSTEM_HPP_