Home · All Namespaces · All Classes · Functions · Coding Style · Plugins · File Structure

core/StelNavigator.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2002 Fabien Chereau
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef _STELNAVIGATOR_HPP_
00021 #define _STELNAVIGATOR_HPP_
00022 
00023 #include "VecMath.hpp"
00024 
00025 #include "fixx11h.h"
00026 #include <QObject>
00027 #include <QString>
00028 #include <QTime>
00029 #include <QDateTime>
00030 
00031 // Conversion in standar Julian time format
00032 #define JD_SECOND 0.000011574074074074074074
00033 #define JD_MINUTE 0.00069444444444444444444
00034 #define JD_HOUR   0.041666666666666666666
00035 #define JD_DAY    1.
00036 
00037 class StelObserver;
00038 class StelObject;
00039 class StelLoadingBar;
00040 class Planet;
00041 class StelLocation;
00042 
00049 class StelNavigator : public QObject
00050 {
00051     Q_OBJECT
00052     
00053 public:
00054 
00055     enum ViewingModeType
00056     {
00057         ViewHorizon,
00058         ViewEquator
00059     };
00060     
00062     enum MountMode { MountAltAzimuthal, MountEquatorial };
00063     
00064     // Create and initialise to default a navigation context
00065     StelNavigator();
00066     ~StelNavigator();
00067 
00068     void init();
00069 
00070     void updateTime(double deltaTime);
00071     void updateTransformMatrices(void);
00072     
00074     void setMountMode(MountMode m) {setViewingMode((m==MountAltAzimuthal) ? StelNavigator::ViewHorizon : StelNavigator::ViewEquator);}
00076     MountMode getMountMode(void) {return ((getViewingMode()==StelNavigator::ViewHorizon) ? MountAltAzimuthal : MountEquatorial);}
00077 
00079     const Vec3d& getEquinoxEquVisionDirection(void) const {return earthEquVisionDirection;}
00080     const Vec3d& getJ2000EquVisionDirection(void) const {return J2000EquVisionDirection;}
00081     const Vec3d& getAltAzVisionDirection(void) const {return altAzVisionDirection;}
00082     void setAltAzVisionDirection(const Vec3d& _pos);
00083     void setEquinoxEquVisionDirection(const Vec3d& _pos);
00084     void setJ2000EquVisionDirection(const Vec3d& _pos);
00085     
00087     const StelLocation& getCurrentLocation() const;
00088     
00094     void moveObserverTo(const StelLocation& target, double duration=1., double durationIfPlanetChange=1.);
00095     
00098     double getLocalSideralTime() const;
00099     
00100     const Planet *getHomePlanet() const;
00101 
00103     Vec3d getObserverHeliocentricEclipticPos() const;
00104 
00106     Vec3d altAzToEquinoxEqu(const Vec3d& v) const { return matAltAzToEquinoxEqu*v; }
00107 
00109     Vec3d equinoxEquToAltAz(const Vec3d& v) const { return matEquinoxEquToAltAz*v; }
00110     Vec3d equinoxEquToJ2000(const Vec3d& v) const { return matEquinoxEquToJ2000*v; }
00111     Vec3d j2000ToEquinoxEqu(const Vec3d& v) const { return matJ2000ToEquinoxEqu*v; }
00112     Vec3d j2000ToAltAz(const Vec3d& v) const { return matJ2000ToAltAz*v; }
00113     
00115     Vec3d heliocentricEclipticToAltAz(const Vec3d& v) const { return matHeliocentricEclipticToAltAz*v; }
00116 
00118     Vec3d heliocentricEclipticToEquinoxEqu(const Vec3d& v) const { return matHeliocentricEclipticToEquinoxEqu*v; }
00119 
00122     Vec3d heliocentricEclipticToEarthPosEquinoxEqu(const Vec3d& v) const { return matAltAzToEquinoxEqu*matHeliocentricEclipticToAltAz*v; }
00123 
00125     const Mat4d getHeliocentricEclipticModelViewMat(void) const {return matAltAzModelView*matHeliocentricEclipticToAltAz;}
00127     const Mat4d getObservercentricEclipticModelViewMat(void) const {return matAltAzModelView*matJ2000ToAltAz*matVsop87ToJ2000;}
00129     const Mat4d getEquinoxEquModelViewMat(void) const {return matAltAzModelView*matEquinoxEquToAltAz;}
00131     const Mat4d& getAltAzModelViewMat(void) const {return matAltAzModelView;}
00133     const Mat4d getJ2000ModelViewMat(void) const {return matAltAzModelView*matEquinoxEquToAltAz*matJ2000ToEquinoxEqu;}
00134 
00135     void setViewingMode(ViewingModeType viewMode);
00136     ViewingModeType getViewingMode(void) const {return viewingMode;}
00137 
00139     const Vec3d& getInitViewingDirection() {return initViewPos;}
00140     
00142     double getPresetSkyTime() const {return presetSkyTime;}
00144     void setPresetSkyTime(double d) {presetSkyTime=d;}
00145     
00147     QString getStartupTimeMode() {return startupTimeMode;}
00148     void setStartupTimeMode(const QString& s);
00149     
00151     static const Mat4d matJ2000ToVsop87;
00153     static const Mat4d matVsop87ToJ2000;
00154     
00155 public slots:
00157     void toggleMountMode() {if (getMountMode()==MountAltAzimuthal) setMountMode(MountEquatorial); else setMountMode(MountAltAzimuthal);}
00159     void setEquatorialMount(bool b) {setMountMode(b ? MountEquatorial : MountAltAzimuthal);}
00160     
00162     void setJDay(double JD) {JDay=JD;}
00164     double getJDay() const {return JDay;}
00165     
00167     void setTimeRate(double ts) {timeSpeed=ts;}
00169     double getTimeRate() const {return timeSpeed;}
00170     
00172     void increaseTimeSpeed();
00174     void decreaseTimeSpeed();
00175     
00177     void setZeroTimeSpeed() {setTimeRate(0);}
00179     void setRealTimeSpeed() {setTimeRate(JD_SECOND);}
00181     bool getRealTimeSpeed() const {return (fabs(timeSpeed-JD_SECOND)<0.0000001);}
00182     
00184     void setTimeNow();
00186     void setTodayTime(const QTime& target);
00188     bool getIsTimeNow() const;
00189 
00191     QTime getInitTodayTime(void) {return initTodayTime;}
00193     void setInitTodayTime(const QTime& t) {initTodayTime=t;}
00195     void setPresetSkyTime(QDateTime dt);
00196 
00198     void addHour() {addSolarDays(0.04166666666666666667);}
00200     void addDay() {addSolarDays(1.0);}
00202     void addWeek() {addSolarDays(7.0);}
00203 
00206     void addSiderealDay() {addSiderealDays(1.0);}
00209     void addSiderealWeek() {addSiderealDays(7.0);}
00210 
00212     void subtractHour() {addSolarDays(-0.04166666666666666667);}
00214     void subtractDay() {addSolarDays(-1.0);}
00216     void subtractWeek() {addSolarDays(-7.0);}
00217 
00220     void subtractSiderealDay() {addSiderealDays(-1.0);}
00223     void subtractSiderealWeek() {addSiderealDays(-7.0);}
00224 
00227     void addSolarDays(double d);
00231     void addSiderealDays(double d);
00232     
00235     void moveObserverToSelected(void);
00236     
00238     QString getDefaultLocationID() const {return defaultLocationID;}
00240     void setDefaultLocationID(const QString& id);
00241     
00244     void setInitViewDirectionToCurrent(void);
00245     
00246 private:
00248     void updateModelViewMat(void);
00249     
00250     // Matrices used for every coordinate transfo
00251     Mat4d matHeliocentricEclipticToAltAz;   // Transform from heliocentric ecliptic (Vsop87) to observer-centric altazimuthal coordinate
00252     Mat4d matAltAzToHeliocentricEcliptic;   // Transform from observer-centric altazimuthal coordinate to heliocentric ecliptic (Vsop87)
00253     Mat4d matAltAzToEquinoxEqu;             // Transform from observer-centric altazimuthal coordinate to Earth Equatorial
00254     Mat4d matEquinoxEquToAltAz;             // Transform from observer-centric altazimuthal coordinate to Earth Equatorial
00255     Mat4d matHeliocentricEclipticToEquinoxEqu;// Transform from heliocentric ecliptic (Vsop87) to earth equatorial coordinate
00256     Mat4d matEquinoxEquToJ2000;
00257     Mat4d matJ2000ToEquinoxEqu;
00258     Mat4d matJ2000ToAltAz;
00259     
00260     Mat4d matAltAzModelView;                    // Modelview matrix for observer-centric altazimuthal drawing
00261 
00262     // Vision variables
00263     // Viewing direction in altazimuthal and equatorial coordinates
00264     Vec3d altAzVisionDirection, earthEquVisionDirection, J2000EquVisionDirection;
00265 
00266     // Time variable
00267     double timeSpeed;        // Positive : forward, Negative : Backward, 1 = 1sec/sec
00268     double JDay;              // Curent time in Julian day
00269 
00270     double presetSkyTime;
00271     QTime initTodayTime;
00272     QString startupTimeMode;
00273 
00274     // The ID of the default startup location
00275     QString defaultLocationID;
00276             
00277     // Position variables
00278     StelObserver* position;
00279 
00280     Vec3d initViewPos;        // Default viewing direction
00281 
00282     // defines if view corrects for horizon, or uses equatorial coordinates
00283     ViewingModeType viewingMode;
00284 };
00285 
00286 #endif // _STELNAVIGATOR_HPP_

Generated on Mon Mar 9 16:16:15 2009 for Stellarium by  doxygen 1.5.5