Stellarium 0.13.0
StelCore.hpp
1 /*
2  * Copyright (C) 2003 Fabien Chereau
3  * Copyright (C) 2012 Matthew Gates
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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STELCORE_HPP_
21 #define _STELCORE_HPP_
22 
23 #include "StelProjector.hpp"
24 #include "StelProjectorType.hpp"
25 #include "StelLocation.hpp"
26 #include "StelSkyDrawer.hpp"
27 #include <QString>
28 #include <QStringList>
29 #include <QTime>
30 
31 class StelToneReproducer;
32 class StelSkyDrawer;
33 class StelGeodesicGrid;
34 class StelMovementMgr;
35 class StelObserver;
36 
46 class StelCore : public QObject
47 {
48  Q_OBJECT
49  Q_ENUMS(ProjectionType)
50  Q_ENUMS(DeltaTAlgorithm)
51  Q_PROPERTY(bool flipHorz READ getFlipHorz WRITE setFlipHorz)
52  Q_PROPERTY(bool flipVert READ getFlipVert WRITE setFlipVert)
53 
54 public:
57  enum FrameType
58  {
59  FrameUninitialized,
60  FrameAltAz,
61  FrameHeliocentricEcliptic,
62  FrameObservercentricEcliptic,
63  FrameEquinoxEqu,
64  FrameJ2000,
66  FrameGalactic
68  };
69 
72  enum ProjectionType
73  {
74  ProjectionPerspective,
75  ProjectionEqualArea,
76  ProjectionStereographic,
77  ProjectionFisheye,
78  ProjectionHammer,
79  ProjectionCylinder,
80  ProjectionMercator,
81  ProjectionOrthographic
82  };
83 
86  enum RefractionMode
87  {
88  RefractionAuto,
89  RefractionOn,
90  RefractionOff
91  };
92 
95  enum DeltaTAlgorithm
96  {
97  WithoutCorrection,
98  Schoch,
99  Clemence,
100  IAU,
101  AstronomicalEphemeris,
102  TuckermanGoldstine,
103  MullerStephenson,
104  Stephenson1978,
105  SchmadelZech1979,
106  MorrisonStephenson1982,
107  StephensonMorrison1984,
108  StephensonHoulden,
109  Espenak,
110  Borkowski,
111  SchmadelZech1988,
112  ChaprontTouze,
113  StephensonMorrison1995,
114  Stephenson1997,
115  ChaprontMeeus,
116  JPLHorizons,
117  MeeusSimons,
118  MontenbruckPfleger,
119  ReingoldDershowitz,
120  MorrisonStephenson2004,
121  Reijs,
122  EspenakMeeus,
123  Banjevic,
124  IslamSadiqQureshi,
125  Custom
126  };
127 
128  StelCore();
129  virtual ~StelCore();
130 
132  void init();
133 
136  void update(double deltaTime);
137 
139  void windowHasBeenResized(float x, float y, float width, float height);
140 
142  void preDraw();
143 
145  void postDraw();
146 
149  StelProjectorP getProjection2d() const;
150 
153  StelProjectorP getProjection(FrameType frameType, RefractionMode refractionMode=RefractionAuto) const;
154 
157  StelProjectorP getProjection(StelProjector::ModelViewTranformP modelViewTransform, ProjectionType projType=(ProjectionType)1000) const;
158 
160  StelToneReproducer* getToneReproducer();
162  const StelToneReproducer* getToneReproducer() const;
163 
165  StelSkyDrawer* getSkyDrawer();
167  const StelSkyDrawer* getSkyDrawer() const;
168 
170  const StelGeodesicGrid* getGeodesicGrid(int maxLevel) const;
171 
173  StelMovementMgr* getMovementMgr();
175  const StelMovementMgr* getMovementMgr() const;
176 
178  void setClippingPlanes(double znear, double zfar);
180  void getClippingPlanes(double* zn, double* zf) const;
181 
183  QString projectionTypeKeyToNameI18n(const QString& key) const;
184 
186  QString projectionNameI18nToTypeKey(const QString& nameI18n) const;
187 
189  StelProjector::StelProjectorParams getCurrentStelProjectorParams() const;
191  void setCurrentStelProjectorParams(const StelProjector::StelProjectorParams& newParams);
192 
194  void lookAtJ2000(const Vec3d& pos, const Vec3d& up);
195 
196  Vec3d altAzToEquinoxEqu(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
197  Vec3d equinoxEquToAltAz(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
198  Vec3d altAzToJ2000(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
199  Vec3d j2000ToAltAz(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
200  void j2000ToAltAzInPlaceNoRefraction(Vec3f* v) const {v->transfo4d(matJ2000ToAltAz);}
201  Vec3d galacticToJ2000(const Vec3d& v) const;
202  Vec3d equinoxEquToJ2000(const Vec3d& v) const;
203  Vec3d j2000ToEquinoxEqu(const Vec3d& v) const;
204  Vec3d j2000ToGalactic(const Vec3d& v) const;
205 
207  Vec3d heliocentricEclipticToAltAz(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
208 
210  Vec3d heliocentricEclipticToEquinoxEqu(const Vec3d& v) const;
213  Vec3d heliocentricEclipticToEarthPosEquinoxEqu(const Vec3d& v) const;
214 
216  StelProjector::ModelViewTranformP getHeliocentricEclipticModelViewTransform(RefractionMode refMode=RefractionAuto) const;
217 
219  StelProjector::ModelViewTranformP getObservercentricEclipticModelViewTransform(RefractionMode refMode=RefractionAuto) const;
220 
222  StelProjector::ModelViewTranformP getEquinoxEquModelViewTransform(RefractionMode refMode=RefractionAuto) const;
223 
225  StelProjector::ModelViewTranformP getAltAzModelViewTransform(RefractionMode refMode=RefractionAuto) const;
226 
228  StelProjector::ModelViewTranformP getJ2000ModelViewTransform(RefractionMode refMode=RefractionAuto) const;
229 
231  StelProjector::ModelViewTranformP getGalacticModelViewTransform(RefractionMode refMode=RefractionAuto) const;
232 
234  static const Mat4d matJ2000ToVsop87;
236  static const Mat4d matVsop87ToJ2000;
238  static const Mat4d matJ2000ToGalactic;
240  static const Mat4d matGalacticToJ2000;
241 
243  Vec3d getObserverHeliocentricEclipticPos() const;
244 
246  const StelLocation& getCurrentLocation() const;
247 
248  const QSharedPointer<class Planet> getCurrentPlanet() const;
249 
250  SphericalCap getVisibleSkyArea() const;
251 
257  void moveObserverTo(const StelLocation& target, double duration=1., double durationIfPlanetChange=1.);
258 
259  // Conversion in standar Julian time format
260  static const double JD_SECOND;
261  static const double JD_MINUTE;
262  static const double JD_HOUR;
263  static const double JD_DAY;
264  static const double ONE_OVER_JD_SECOND;
265 
268  double getLocalSiderealTime() const;
269 
271  double getLocalSiderealDayLength() const;
272 
274  double getLocalSiderealYearLength() const;
275 
277  QString getStartupTimeMode();
278  void setStartupTimeMode(const QString& s);
279 
284  double getDeltaT(double jDay) const;
285 
290  QString getCurrentDeltaTAlgorithmValidRange(double jDay, QString* marker) const;
291 
292 public slots:
294  void setCurrentProjectionType(ProjectionType type);
295  ProjectionType getCurrentProjectionType() const;
296 
298  QString getCurrentProjectionTypeKey(void) const;
300  void setCurrentProjectionTypeKey(QString type);
301 
303  QStringList getAllProjectionTypeKeys() const;
304 
306  void setCurrentDeltaTAlgorithm(DeltaTAlgorithm algorithm) { currentDeltaTAlgorithm=algorithm; }
308  DeltaTAlgorithm getCurrentDeltaTAlgorithm() const { return currentDeltaTAlgorithm; }
310  QString getCurrentDeltaTAlgorithmDescription(void) const;
312  QString getCurrentDeltaTAlgorithmKey(void) const;
314  void setCurrentDeltaTAlgorithmKey(QString type);
315 
318 
321  void setFlagGravityLabels(bool gravity);
323  void setDefautAngleForGravityText(float a);
326  void setFlipHorz(bool flip);
329  void setFlipVert(bool flip);
332  bool getFlipHorz(void) const;
335  bool getFlipVert(void) const;
336 
338  QString getDefaultLocationID() const;
340  void setDefaultLocationID(const QString& id);
344  void returnToHome();
345 
347  void setJDay(double JD);
349  double getJDay() const;
350 
352  void setMJDay(double MJD);
354  double getMJDay() const;
355 
357  double getPresetSkyTime() const;
359  void setPresetSkyTime(double d);
360 
362  void setTimeRate(double ts);
364  double getTimeRate() const;
365 
367  void increaseTimeSpeed();
369  void decreaseTimeSpeed();
371  void increaseTimeSpeedLess();
373  void decreaseTimeSpeedLess();
374 
376  void setZeroTimeSpeed();
378  void setRealTimeSpeed();
380  void toggleRealTimeSpeed();
382  bool getRealTimeSpeed() const;
383 
385  void setTimeNow();
387  void setTodayTime(const QTime& target);
389  bool getIsTimeNow() const;
390 
392  QTime getInitTodayTime(void);
394  void setInitTodayTime(const QTime& t);
396  void setPresetSkyTime(QDateTime dt);
397 
399  void addHour();
401  void addDay();
403  void addWeek();
404 
407  void addSiderealDay();
410  void addSiderealWeek();
414  void addSiderealMonth();
418  void addSiderealYear();
422  void addSiderealCentury();
423 
425  void subtractHour();
427  void subtractDay();
429  void subtractWeek();
430 
433  void subtractSiderealDay();
436  void subtractSiderealWeek();
440  void subtractSiderealMonth();
444  void subtractSiderealYear();
449 
451  void addSynodicMonth();
452 
454  void addDraconicYear();
456  void addDraconicMonth();
457 
459  void addAnomalisticMonth();
460 
462  void addTropicalMonth();
464  void addTropicalYear();
466  void addTropicalCentury();
467 
469  void subtractSynodicMonth();
470 
472  void subtractDraconicYear();
474  void subtractDraconicMonth();
475 
478 
480  void subtractTropicalMonth();
482  void subtractTropicalYear();
485 
488  void addSolarDays(double d);
492  void addSiderealDays(double d);
493 
496  void moveObserverToSelected();
497 
500  void setDeltaTCustomYear(float y) { deltaTCustomYear=y; }
503  void setDeltaTCustomNDot(float v) { deltaTCustomNDot=v; }
506  void setDeltaTCustomEquationCoefficients(Vec3f c) { deltaTCustomEquationCoeff=c; }
507 
509  float getDeltaTCustomYear() const { return deltaTCustomYear; }
511  float getDeltaTCustomNDot() const { return deltaTCustomNDot; }
513  Vec3f getDeltaTCustomEquationCoefficients() const { return deltaTCustomEquationCoeff; }
514 
515 signals:
519  void timeRateChanged(double rate);
520 
521 private:
522  StelToneReproducer* toneConverter; // Tones conversion between stellarium world and display device
523  StelSkyDrawer* skyDrawer;
524  StelMovementMgr* movementMgr; // Manage vision movements
525 
526  // Manage geodesic grid
527  mutable StelGeodesicGrid* geodesicGrid;
528 
529  // The currently used projection type
530  ProjectionType currentProjectionType;
531 
532  // The currentrly used time correction (DeltaT)
533  DeltaTAlgorithm currentDeltaTAlgorithm;
534 
535  // Parameters to use when creating new instances of StelProjector
536  StelProjector::StelProjectorParams currentProjectorParams;
537 
538  void updateTransformMatrices();
539  void updateTime(double deltaTime);
540  void resetSync();
541 
542  // Matrices used for every coordinate transfo
543  Mat4d matHeliocentricEclipticToAltAz; // Transform from heliocentric ecliptic (Vsop87) to observer-centric altazimuthal coordinate
544  Mat4d matAltAzToHeliocentricEcliptic; // Transform from observer-centric altazimuthal coordinate to heliocentric ecliptic (Vsop87)
545  Mat4d matAltAzToEquinoxEqu; // Transform from observer-centric altazimuthal coordinate to Earth Equatorial
546  Mat4d matEquinoxEquToAltAz; // Transform from observer-centric altazimuthal coordinate to Earth Equatorial
547  Mat4d matHeliocentricEclipticToEquinoxEqu; // Transform from heliocentric ecliptic (Vsop87) to earth equatorial coordinate
548  Mat4d matEquinoxEquToJ2000;
549  Mat4d matJ2000ToEquinoxEqu;
550  Mat4d matJ2000ToAltAz;
551 
552  Mat4d matAltAzModelView; // Modelview matrix for observer-centric altazimuthal drawing
553  Mat4d invertMatAltAzModelView; // Inverted modelview matrix for observer-centric altazimuthal drawing
554 
555  // Position variables
556  StelObserver* position;
557  // The ID of the default startup location
558  QString defaultLocationID;
559 
560  // Time variables
561  double timeSpeed; // Positive : forward, Negative : Backward, 1 = 1sec/sec
562  double JDay; // Curent time in Julian day
563  double presetSkyTime;
564  QTime initTodayTime;
565  QString startupTimeMode;
566  double secondsOfLastJDayUpdate; // Time in seconds when the time rate or time last changed
567  double JDayOfLastJDayUpdate; // JDay when the time rate or time last changed
568 
569  // Variables for custom equation of Delta-T
570  Vec3f deltaTCustomEquationCoeff;
571  float deltaTCustomNDot;
572  float deltaTCustomYear;
573 
574 };
575 
576 #endif // _STELCORE_HPP_
void setTimeRate(double ts)
Set time speed in JDay/sec.
Store the informations for a location on a planet.
void setPresetSkyTime(double d)
Set the preset sky time from a JD.
void subtractSiderealYear()
Subtract one sidereal year to the simulation time.
void setCurrentProjectionType(ProjectionType type)
Set the current ProjectionType to use.
double getJDay() const
Get the current date in Julian Day.
void subtractTropicalYear()
Subtract one mean tropical year to the simulation time.
void timeRateChanged(double rate)
This signal is emitted when the time rate has changed.
void addWeek()
Add one [Earth, solar] week to the current simulation time.
DeltaTAlgorithm getCurrentDeltaTAlgorithm() const
Get the current algorithm for time correction (DeltaT)
Definition: StelCore.hpp:308
Provide a set of methods used to draw sky objects taking into account eyes adaptation, zoom level, instrument model and artificially set magnitude limits.
void addSiderealDay()
Add one sidereal day to the simulation time.
QStringList getAllProjectionTypeKeys() const
Get the list of all the available projections.
void returnToDefaultLocation()
Return to the default location.
StelProjectorMaskType
Define viewport mask types.
void setInitTodayTime(const QTime &t)
set the initial "today time" from the config file
bool getFlipHorz(void) const
Get the state of the horizontal flip.
Vec3f getDeltaTCustomEquationCoefficients() const
Get coefficients for custom equation for calculation of Delta-T.
Definition: StelCore.hpp:513
void decreaseTimeSpeed()
Decrease the time speed.
void addSiderealWeek()
Add one sidereal week (7 sidereal days) to the simulation time.
void subtractDraconicMonth()
Subtract one draconic month to the simulation time.
void subtractDay()
Subtract one [Earth, solar] day to the current simulation time.
double getMJDay() const
Get the current date in Modified Julian Day.
void setFlipVert(bool flip)
Set the vertical flip status.
void subtractTropicalCentury()
Subtract one mean tropical century to the simulation time.
A SphericalCap is defined by a direction and an aperture.
void subtractSiderealMonth()
Subtract one sidereal month (1/12 of sidereal year) to the simulation time.
QString getCurrentDeltaTAlgorithmDescription(void) const
Get description of the current algorithm for time correction.
void addDay()
Add one [Earth, solar] day to the current simulation time.
void setCurrentDeltaTAlgorithmKey(QString type)
Set the current algorithm to use from its key.
void addTropicalCentury()
Add one mean tropical century to the simulation time.
void setCurrentDeltaTAlgorithm(DeltaTAlgorithm algorithm)
Set the current algorithm for time correction (DeltaT)
Definition: StelCore.hpp:306
void setRealTimeSpeed()
Set real time speed, i.e. 1 sec/sec.
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
void setDefautAngleForGravityText(float a)
Set the offset rotation angle in degree to apply to gravity text (only if gravityLabels is set to fal...
void addSynodicMonth()
Add one synodic month to the simulation time.
Grid of triangles (zones) on the sphere with radius 1, generated by subdividing the icosahedron...
void addHour()
Add one [Earth, solar] hour to the current simulation time.
float getDeltaTCustomNDot() const
Get n-dot for custom equation for calculation of Delta-T.
Definition: StelCore.hpp:511
void addTropicalYear()
Add one mean tropical year to the simulation time.
QSharedPointer< StelProjector > StelProjectorP
Shared pointer on a StelProjector instance (implement reference counting)
void setFlagGravityLabels(bool gravity)
Set the flag with decides whether to arrage labels so that they are aligned with the bottom of a 2d s...
void subtractSynodicMonth()
Subtract one synodic month to the simulation time.
QString getCurrentDeltaTAlgorithmKey(void) const
Get the current algorithm used by the DeltaT.
Manages the head movements and zoom operations.
Converts tones in function of the eye adaptation to luminance.
void addSiderealYear()
Add one sidereal year to the simulation time.
void decreaseTimeSpeedLess()
Decrease the time speed but not as much as with decreaseTimeSpeed()
float getDeltaTCustomYear() const
Get year for custom equation for calculation of Delta-T.
Definition: StelCore.hpp:509
void addDraconicYear()
Add one draconic year to the simulation time.
void toggleRealTimeSpeed()
Set real time speed or pause simulation if we are already in realtime speed.
void setTodayTime(const QTime &target)
Set the time to some value, leaving the day the same.
Should be renamed as PlanetBasedObserver and derive from a more generical StelObserver class...
bool getFlipVert(void) const
Get the state of the vertical flip.
void returnToHome()
Return to the default location and set default landscape with atmosphere and fog effects.
void subtractWeek()
Subtract one [Earth, solar] week to the current simulation time.
void moveObserverToSelected()
Move the observer to the selected object.
double getPresetSkyTime() const
Return the preset sky time in JD.
void setFlipHorz(bool flip)
Set the horizontal flip status.
void setMaskType(StelProjector::StelProjectorMaskType m)
Set the mask type.
void setJDay(double JD)
Set the current date in Julian Day.
void addSiderealDays(double d)
Add a number of sidereal days to the current simulation time, based on the observer body's rotational...
void setZeroTimeSpeed()
Set time speed to 0, i.e. freeze the passage of simulation time.
bool getIsTimeNow() const
Get whether the current stellarium time is the real world time.
void setTimeNow()
Set stellarium time to current real world time.
void addAnomalisticMonth()
Add one anomalistic month to the simulation time.
void subtractSiderealWeek()
Subtract one sidereal week (7 sidereal days) to the simulation time.
void addTropicalMonth()
Add one mean tropical month to the simulation time.
void subtractAnomalisticMonth()
Subtract one anomalistic month to the simulation time.
void setDeltaTCustomEquationCoefficients(Vec3f c)
Set coefficients for custom equation for calculation of Delta-T.
Definition: StelCore.hpp:506
QSharedPointer< ModelViewTranform > ModelViewTranformP
Shared pointer on a ModelViewTranform instance (implement reference counting)
QTime getInitTodayTime(void)
get the initial "today time" from the config file
void addDraconicMonth()
Add one draconic month to the simulation time.
void addSiderealCentury()
Add one sidereal century (100 sidereal years) to the simulation time.
void subtractTropicalMonth()
Subtract one mean tropical month to the simulation time.
void addSiderealMonth()
Add one sidereal month (1/12 of sidereal year) to the simulation time.
void subtractDraconicYear()
Subtract one draconic year to the simulation time.
void setDeltaTCustomYear(float y)
Set year for custom equation for calculation of Delta-T.
Definition: StelCore.hpp:500
double getTimeRate() const
Get time speed in JDay/sec.
Define the StelProjectorP type.
Contains all the param needed to initialize a StelProjector.
QString getCurrentProjectionTypeKey(void) const
Get the current Mapping used by the Projection.
void subtractSiderealCentury()
Subtract one sidereal century (100 sidereal years) to the simulation time.
void increaseTimeSpeed()
Increase the time speed.
void addSolarDays(double d)
Add a number of Earth Solar days to the current simulation time.
void setCurrentProjectionTypeKey(QString type)
Set the current ProjectionType to use from its key.
void setDefaultLocationID(const QString &id)
Set the location to use by default at startup.
void setMJDay(double MJD)
Set the current date in Modified Julian Day.
void setDeltaTCustomNDot(float v)
Set n-dot for custom equation for calculation of Delta-T.
Definition: StelCore.hpp:503
void increaseTimeSpeedLess()
Increase the time speed, but not as much as with increaseTimeSpeed()
void subtractSiderealDay()
Subtract one sidereal day to the simulation time.
void locationChanged(StelLocation)
This signal is emitted when the observer location has changed.
void subtractHour()
Subtract one [Earth, solar] hour to the current simulation time.
bool getRealTimeSpeed() const
Get whether it is real time speed, i.e. 1 sec/sec.
QString getDefaultLocationID() const
Get the location used by default at startup.