![]() |
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure |
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 #include "StelLocation.hpp" 00025 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 00047 class StelNavigator : public QObject 00048 { 00049 Q_OBJECT 00050 Q_PROPERTY(double timeRate READ getTimeRate WRITE setTimeRate) 00051 00052 public: 00053 // Create and initialise to default a navigation context 00054 StelNavigator(); 00055 ~StelNavigator(); 00056 00057 void init(); 00058 00059 void updateTime(double deltaTime); 00060 void updateTransformMatrices(void); 00061 00063 void lookAtJ2000(const Vec3d& pos, const Vec3d& up); 00064 00066 const StelLocation& getCurrentLocation() const; 00067 00073 void moveObserverTo(const StelLocation& target, double duration=1., double durationIfPlanetChange=1.); 00074 00077 double getLocalSideralTime() const; 00078 00080 double getLocalSideralDayLength() const; 00081 00083 Vec3d getObserverHeliocentricEclipticPos() const; 00084 00085 00086 Vec3d altAzToEquinoxEqu(const Vec3d& v) const {return matAltAzToEquinoxEqu*v;} 00087 Vec3d equinoxEquToAltAz(const Vec3d& v) const {return matEquinoxEquToAltAz*v;} 00088 Vec3d equinoxEquToJ2000(const Vec3d& v) const {return matEquinoxEquToJ2000*v;} 00089 Vec3d altAzToJ2000(const Vec3d& v) const {return matEquinoxEquToJ2000*matAltAzToEquinoxEqu*v;} 00090 Vec3d galacticToJ2000(const Vec3d& v) const {return matGalacticToJ2000*v;} 00091 Vec3d j2000ToEquinoxEqu(const Vec3d& v) const {return matJ2000ToEquinoxEqu*v;} 00092 Vec3d j2000ToAltAz(const Vec3d& v) const {return matJ2000ToAltAz*v;} 00093 Vec3d j2000ToGalactic(const Vec3d& v) const {return matJ2000ToGalactic*v;} 00095 Vec3d heliocentricEclipticToAltAz(const Vec3d& v) const {return matHeliocentricEclipticToAltAz*v;} 00097 Vec3d heliocentricEclipticToEquinoxEqu(const Vec3d& v) const {return matHeliocentricEclipticToEquinoxEqu*v;} 00100 Vec3d heliocentricEclipticToEarthPosEquinoxEqu(const Vec3d& v) const {return matAltAzToEquinoxEqu*matHeliocentricEclipticToAltAz*v;} 00101 00103 const Mat4d getHeliocentricEclipticModelViewMat() const {return matAltAzModelView*matHeliocentricEclipticToAltAz;} 00105 const Mat4d getObservercentricEclipticModelViewMat() const {return matAltAzModelView*matJ2000ToAltAz*matVsop87ToJ2000;} 00107 const Mat4d getEquinoxEquModelViewMat() const {return matAltAzModelView*matEquinoxEquToAltAz;} 00109 const Mat4d& getAltAzModelViewMat() const {return matAltAzModelView;} 00111 const Mat4d getJ2000ModelViewMat() const {return matAltAzModelView*matEquinoxEquToAltAz*matJ2000ToEquinoxEqu;} 00113 const Mat4d getGalacticModelViewMat() const {return getJ2000ModelViewMat()*matGalacticToJ2000;} 00114 00116 double getPresetSkyTime() const {return presetSkyTime;} 00118 void setPresetSkyTime(double d) {presetSkyTime=d;} 00119 00121 QString getStartupTimeMode() {return startupTimeMode;} 00122 void setStartupTimeMode(const QString& s); 00123 00125 static const Mat4d matJ2000ToVsop87; 00127 static const Mat4d matVsop87ToJ2000; 00129 static const Mat4d matJ2000ToGalactic; 00131 static const Mat4d matGalacticToJ2000; 00132 00133 public slots: 00135 void setJDay(double JD) {JDay=JD;} 00137 double getJDay() const {return JDay;} 00138 00140 void setTimeRate(double ts) {timeSpeed=ts; emit timeRateChanged(timeSpeed);} 00142 double getTimeRate() const {return timeSpeed;} 00143 00145 void increaseTimeSpeed(); 00147 void decreaseTimeSpeed(); 00149 void increaseTimeSpeedLess(); 00151 void decreaseTimeSpeedLess(); 00152 00154 void setZeroTimeSpeed() {setTimeRate(0);} 00156 void setRealTimeSpeed() {setTimeRate(JD_SECOND);} 00158 void toggleRealTimeSpeed() {(!getRealTimeSpeed()) ? setRealTimeSpeed() : setZeroTimeSpeed();} 00160 bool getRealTimeSpeed() const {return (fabs(timeSpeed-JD_SECOND)<0.0000001);} 00161 00163 void setTimeNow(); 00165 void setTodayTime(const QTime& target); 00167 bool getIsTimeNow() const; 00168 00170 QTime getInitTodayTime(void) {return initTodayTime;} 00172 void setInitTodayTime(const QTime& t) {initTodayTime=t;} 00174 void setPresetSkyTime(QDateTime dt); 00175 00177 void addHour() {addSolarDays(0.04166666666666666667);} 00179 void addDay() {addSolarDays(1.0);} 00181 void addWeek() {addSolarDays(7.0);} 00182 00185 void addSiderealDay() {addSiderealDays(1.0);} 00188 void addSiderealWeek() {addSiderealDays(7.0);} 00189 00191 void subtractHour() {addSolarDays(-0.04166666666666666667);} 00193 void subtractDay() {addSolarDays(-1.0);} 00195 void subtractWeek() {addSolarDays(-7.0);} 00196 00199 void subtractSiderealDay() {addSiderealDays(-1.0);} 00202 void subtractSiderealWeek() {addSiderealDays(-7.0);} 00203 00206 void addSolarDays(double d); 00210 void addSiderealDays(double d); 00211 00214 void moveObserverToSelected(); 00215 00217 QString getDefaultLocationID() const {return defaultLocationID;} 00219 void setDefaultLocationID(const QString& id); 00220 00221 signals: 00223 void locationChanged(StelLocation); 00225 void timeRateChanged(double rate); 00226 00227 private: 00228 // Matrices used for every coordinate transfo 00229 Mat4d matHeliocentricEclipticToAltAz; // Transform from heliocentric ecliptic (Vsop87) to observer-centric altazimuthal coordinate 00230 Mat4d matAltAzToHeliocentricEcliptic; // Transform from observer-centric altazimuthal coordinate to heliocentric ecliptic (Vsop87) 00231 Mat4d matAltAzToEquinoxEqu; // Transform from observer-centric altazimuthal coordinate to Earth Equatorial 00232 Mat4d matEquinoxEquToAltAz; // Transform from observer-centric altazimuthal coordinate to Earth Equatorial 00233 Mat4d matHeliocentricEclipticToEquinoxEqu;// Transform from heliocentric ecliptic (Vsop87) to earth equatorial coordinate 00234 Mat4d matEquinoxEquToJ2000; 00235 Mat4d matJ2000ToEquinoxEqu; 00236 Mat4d matJ2000ToAltAz; 00237 00238 Mat4d matAltAzModelView; // Modelview matrix for observer-centric altazimuthal drawing 00239 00240 // Time variable 00241 double timeSpeed; // Positive : forward, Negative : Backward, 1 = 1sec/sec 00242 double JDay; // Curent time in Julian day 00243 00244 double presetSkyTime; 00245 QTime initTodayTime; 00246 QString startupTimeMode; 00247 00248 // The ID of the default startup location 00249 QString defaultLocationID; 00250 00251 // Position variables 00252 StelObserver* position; 00253 }; 00254 00255 #endif // _STELNAVIGATOR_HPP_