StelNavigator.hpp   StelNavigator.hpp 
skipping to change at line 24 skipping to change at line 24
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#ifndef _STELNAVIGATOR_HPP_ #ifndef _STELNAVIGATOR_HPP_
#define _STELNAVIGATOR_HPP_ #define _STELNAVIGATOR_HPP_
#include "VecMath.hpp" #include "VecMath.hpp"
#include "StelLocation.hpp"
#include "fixx11h.h"
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QTime> #include <QTime>
#include <QDateTime> #include <QDateTime>
// Conversion in standar Julian time format // Conversion in standar Julian time format
#define JD_SECOND 0.000011574074074074074074 #define JD_SECOND 0.000011574074074074074074
#define JD_MINUTE 0.00069444444444444444444 #define JD_MINUTE 0.00069444444444444444444
#define JD_HOUR 0.041666666666666666666 #define JD_HOUR 0.041666666666666666666
#define JD_DAY 1. #define JD_DAY 1.
class StelObserver; class StelObserver;
class StelObject; class StelObject;
class StelLoadingBar; class StelLoadingBar;
class Planet;
class StelLocation;
//! @class StelNavigator //! @class StelNavigator
//! Manages a navigation context. This includes: //! Manages a navigation context. This includes:
//! - date/time //! - date/time
//! - viewing direction/fov //! - viewing direction/fov
//! - observer position //! - observer position
//! - coordinate changes //! - coordinate changes
class StelNavigator : public QObject class StelNavigator : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(double timeRate READ getTimeRate WRITE setTimeRate)
public: public:
enum ViewingModeType
{
ViewHorizon,
ViewEquator
};
//! Possible mount modes
enum MountMode { MountAltAzimuthal, MountEquatorial };
// Create and initialise to default a navigation context // Create and initialise to default a navigation context
StelNavigator(); StelNavigator();
~StelNavigator(); ~StelNavigator();
void init(); void init();
void updateTime(double deltaTime); void updateTime(double deltaTime);
void updateTransformMatrices(void); void updateTransformMatrices(void);
//! Set current mount type
void setMountMode(MountMode m) {setViewingMode((m==MountAltAzimuthal
) ? StelNavigator::ViewHorizon : StelNavigator::ViewEquator);}
//! Get current mount type
MountMode getMountMode(void) {return ((getViewingMode()==StelNavigat
or::ViewHorizon) ? MountAltAzimuthal : MountEquatorial);}
//! Get vision direction //! Get vision direction
const Vec3d& getEquinoxEquVisionDirection(void) const {return earthE void lookAtJ2000(const Vec3d& pos, const Vec3d& up);
quVisionDirection;}
const Vec3d& getJ2000EquVisionDirection(void) const {return J2000Equ
VisionDirection;}
const Vec3d& getAltAzVisionDirection(void) const {return altAzVision
Direction;}
void setAltAzVisionDirection(const Vec3d& _pos);
void setEquinoxEquVisionDirection(const Vec3d& _pos);
void setJ2000EquVisionDirection(const Vec3d& _pos);
//! Get the informations on the current location //! Get the informations on the current location
const StelLocation& getCurrentLocation() const; const StelLocation& getCurrentLocation() const;
//! Smoothly move the observer to the given location //! Smoothly move the observer to the given location
//! @param target the target location //! @param target the target location
//! @param duration direction of view move duration in s //! @param duration direction of view move duration in s
//! @param durationIfPlanetChange direction of view + planet travel move duration in s. //! @param durationIfPlanetChange direction of view + planet travel move duration in s.
//! This is used only if the destination planet is different from th e starting one. //! This is used only if the destination planet is different from th e starting one.
void moveObserverTo(const StelLocation& target, double duration=1., double durationIfPlanetChange=1.); void moveObserverTo(const StelLocation& target, double duration=1., double durationIfPlanetChange=1.);
//! Get the sideral time shifted by the observer longitude //! Get the sideral time shifted by the observer longitude
//! @return the locale sideral time in radian //! @return the locale sideral time in radian
double getLocalSideralTime() const; double getLocalSideralTime() const;
const Planet *getHomePlanet() const; //! Get the duration of a sideral day for the current observer in da
y.
double getLocalSideralDayLength() const;
//! Return the observer heliocentric ecliptic position //! Return the observer heliocentric ecliptic position
Vec3d getObserverHeliocentricEclipticPos() const; Vec3d getObserverHeliocentricEclipticPos() const;
//! Transform vector from altazimuthal coordinate to equatorial Vec3d altAzToEquinoxEqu(const Vec3d& v) const {return matAltAzToEqui
Vec3d altAzToEquinoxEqu(const Vec3d& v) const { return matAltAzToEqu noxEqu*v;}
inoxEqu*v; } Vec3d equinoxEquToAltAz(const Vec3d& v) const {return matEquinoxEquT
oAltAz*v;}
//! Transform vector from equatorial coordinate to altazimuthal Vec3d equinoxEquToJ2000(const Vec3d& v) const {return matEquinoxEquT
Vec3d equinoxEquToAltAz(const Vec3d& v) const { return matEquinoxEqu oJ2000*v;}
ToAltAz*v; } Vec3d altAzToJ2000(const Vec3d& v) const {return matEquinoxEquToJ200
Vec3d equinoxEquToJ2000(const Vec3d& v) const { return matEquinoxEqu 0*matAltAzToEquinoxEqu*v;}
ToJ2000*v; } Vec3d galacticToJ2000(const Vec3d& v) const {return matGalacticToJ20
Vec3d j2000ToEquinoxEqu(const Vec3d& v) const { return matJ2000ToEqu 00*v;}
inoxEqu*v; } Vec3d j2000ToEquinoxEqu(const Vec3d& v) const {return matJ2000ToEqui
Vec3d j2000ToAltAz(const Vec3d& v) const { return matJ2000ToAltAz*v; noxEqu*v;}
} Vec3d j2000ToAltAz(const Vec3d& v) const {return matJ2000ToAltAz*v;}
Vec3d j2000ToGalactic(const Vec3d& v) const {return matJ2000ToGalact
ic*v;}
//! Transform vector from heliocentric ecliptic coordinate to altazi muthal //! Transform vector from heliocentric ecliptic coordinate to altazi muthal
Vec3d heliocentricEclipticToAltAz(const Vec3d& v) const { return mat Vec3d heliocentricEclipticToAltAz(const Vec3d& v) const {return matH
HeliocentricEclipticToAltAz*v; } eliocentricEclipticToAltAz*v;}
//! Transform from heliocentric coordinate to equatorial at current equinox (for the planet where the observer stands) //! Transform from heliocentric coordinate to equatorial at current equinox (for the planet where the observer stands)
Vec3d heliocentricEclipticToEquinoxEqu(const Vec3d& v) const { retur Vec3d heliocentricEclipticToEquinoxEqu(const Vec3d& v) const {return
n matHeliocentricEclipticToEquinoxEqu*v; } matHeliocentricEclipticToEquinoxEqu*v;}
//! Transform vector from heliocentric coordinate to false equatoria l : equatorial //! Transform vector from heliocentric coordinate to false equatoria l : equatorial
//! coordinate but centered on the observer position (usefull for ob jects close to earth) //! coordinate but centered on the observer position (usefull for ob jects close to earth)
Vec3d heliocentricEclipticToEarthPosEquinoxEqu(const Vec3d& v) const { return matAltAzToEquinoxEqu*matHeliocentricEclipticToAltAz*v; } Vec3d heliocentricEclipticToEarthPosEquinoxEqu(const Vec3d& v) const {return matAltAzToEquinoxEqu*matHeliocentricEclipticToAltAz*v;}
//! Get the modelview matrix for heliocentric ecliptic (Vsop87) draw ing //! Get the modelview matrix for heliocentric ecliptic (Vsop87) draw ing
const Mat4d getHeliocentricEclipticModelViewMat(void) const {return matAltAzModelView*matHeliocentricEclipticToAltAz;} const Mat4d getHeliocentricEclipticModelViewMat() const {return matA ltAzModelView*matHeliocentricEclipticToAltAz;}
//! Get the modelview matrix for observer-centric ecliptic (Vsop87) drawing //! Get the modelview matrix for observer-centric ecliptic (Vsop87) drawing
const Mat4d getObservercentricEclipticModelViewMat(void) const {retu rn matAltAzModelView*matJ2000ToAltAz*matVsop87ToJ2000;} const Mat4d getObservercentricEclipticModelViewMat() const {return m atAltAzModelView*matJ2000ToAltAz*matVsop87ToJ2000;}
//! Get the modelview matrix for observer-centric equatorial at equi nox drawing //! Get the modelview matrix for observer-centric equatorial at equi nox drawing
const Mat4d getEquinoxEquModelViewMat(void) const {return matAltAzMo delView*matEquinoxEquToAltAz;} const Mat4d getEquinoxEquModelViewMat() const {return matAltAzModelV iew*matEquinoxEquToAltAz;}
//! Get the modelview matrix for observer-centric altazimuthal drawi ng //! Get the modelview matrix for observer-centric altazimuthal drawi ng
const Mat4d& getAltAzModelViewMat(void) const {return matAltAzModelV iew;} const Mat4d& getAltAzModelViewMat() const {return matAltAzModelView; }
//! Get the modelview matrix for observer-centric J2000 equatorial d rawing //! Get the modelview matrix for observer-centric J2000 equatorial d rawing
const Mat4d getJ2000ModelViewMat(void) const {return matAltAzModelVi const Mat4d getJ2000ModelViewMat() const {return matAltAzModelView*m
ew*matEquinoxEquToAltAz*matJ2000ToEquinoxEqu;} atEquinoxEquToAltAz*matJ2000ToEquinoxEqu;}
//! Get the modelview matrix for observer-centric Galactic equatoria
void setViewingMode(ViewingModeType viewMode); l drawing
ViewingModeType getViewingMode(void) const {return viewingMode;} const Mat4d getGalacticModelViewMat() const {return getJ2000ModelVie
wMat()*matGalacticToJ2000;}
//! Return the inital viewing direction in altazimuthal coordinates
const Vec3d& getInitViewingDirection() {return initViewPos;}
//! Return the preset sky time in JD //! Return the preset sky time in JD
double getPresetSkyTime() const {return presetSkyTime;} double getPresetSkyTime() const {return presetSkyTime;}
//! Set the preset sky time from a JD //! Set the preset sky time from a JD
void setPresetSkyTime(double d) {presetSkyTime=d;} void setPresetSkyTime(double d) {presetSkyTime=d;}
//! Return the startup mode, can be preset|Preset or anything else //! Return the startup mode, can be preset|Preset or anything else
QString getStartupTimeMode() {return startupTimeMode;} QString getStartupTimeMode() {return startupTimeMode;}
void setStartupTimeMode(const QString& s); void setStartupTimeMode(const QString& s);
//! Rotation matrix from equatorial J2000 to ecliptic (Vsop87) //! Rotation matrix from equatorial J2000 to ecliptic (Vsop87)
static const Mat4d matJ2000ToVsop87; static const Mat4d matJ2000ToVsop87;
//! Rotation matrix from ecliptic (Vsop87) to equatorial J2000 //! Rotation matrix from ecliptic (Vsop87) to equatorial J2000
static const Mat4d matVsop87ToJ2000; static const Mat4d matVsop87ToJ2000;
//! Rotation matrix from J2000 to Galactic reference frame, using FI
TS convention.
static const Mat4d matJ2000ToGalactic;
//! Rotation matrix from J2000 to Galactic reference frame, using FI
TS convention.
static const Mat4d matGalacticToJ2000;
public slots: public slots:
//! Toggle current mount mode between equatorial and altazimuthal
void toggleMountMode() {if (getMountMode()==MountAltAzimuthal) setMo
untMode(MountEquatorial); else setMountMode(MountAltAzimuthal);}
//! Define whether we should use equatorial mount or altazimuthal
void setEquatorialMount(bool b) {setMountMode(b ? MountEquatorial :
MountAltAzimuthal);}
//! Set the current date in Julian Day //! Set the current date in Julian Day
void setJDay(double JD) {JDay=JD;} void setJDay(double JD) {JDay=JD;}
//! Get the current date in Julian Day //! Get the current date in Julian Day
double getJDay() const {return JDay;} double getJDay() const {return JDay;}
//! Set time speed in JDay/sec //! Set time speed in JDay/sec
void setTimeRate(double ts) {timeSpeed=ts;} void setTimeRate(double ts) {timeSpeed=ts; emit timeRateChanged(time Speed);}
//! Get time speed in JDay/sec //! Get time speed in JDay/sec
double getTimeRate() const {return timeSpeed;} double getTimeRate() const {return timeSpeed;}
//! Increase the time speed //! Increase the time speed
void increaseTimeSpeed(); void increaseTimeSpeed();
//! Decrease the time speed //! Decrease the time speed
void decreaseTimeSpeed(); void decreaseTimeSpeed();
//! Increase the time speed, but not as much as with increaseTimeSpe
ed()
void increaseTimeSpeedLess();
//! Decrease the time speed but not as much as with decreaseTimeSpee
d()
void decreaseTimeSpeedLess();
//! Set time speed to 0, i.e. freeze the passage of simulation time //! Set time speed to 0, i.e. freeze the passage of simulation time
void setZeroTimeSpeed() {setTimeRate(0);} void setZeroTimeSpeed() {setTimeRate(0);}
//! Set real time speed, i.e. 1 sec/sec //! Set real time speed, i.e. 1 sec/sec
void setRealTimeSpeed() {setTimeRate(JD_SECOND);} void setRealTimeSpeed() {setTimeRate(JD_SECOND);}
//! Set real time speed or pause simulation if we are already in rea
ltime speed.
void toggleRealTimeSpeed() {(!getRealTimeSpeed()) ? setRealTimeSpeed
() : setZeroTimeSpeed();}
//! Get whether it is real time speed, i.e. 1 sec/sec //! Get whether it is real time speed, i.e. 1 sec/sec
bool getRealTimeSpeed() const {return (fabs(timeSpeed-JD_SECOND)<0.0 000001);} bool getRealTimeSpeed() const {return (fabs(timeSpeed-JD_SECOND)<0.0 000001);}
//! Set stellarium time to current real world time //! Set stellarium time to current real world time
void setTimeNow(); void setTimeNow();
//! Set the time to some value, leaving the day the same. //! Set the time to some value, leaving the day the same.
void setTodayTime(const QTime& target); void setTodayTime(const QTime& target);
//! Get wether the current stellarium time is the real world time //! Get whether the current stellarium time is the real world time
bool getIsTimeNow() const; bool getIsTimeNow() const;
//! get the initial "today time" from the config file //! get the initial "today time" from the config file
QTime getInitTodayTime(void) {return initTodayTime;} QTime getInitTodayTime(void) {return initTodayTime;}
//! set the initial "today time" from the config file //! set the initial "today time" from the config file
void setInitTodayTime(const QTime& t) {initTodayTime=t;} void setInitTodayTime(const QTime& t) {initTodayTime=t;}
//! Set the preset sky time from a QDateTime //! Set the preset sky time from a QDateTime
void setPresetSkyTime(QDateTime dt); void setPresetSkyTime(QDateTime dt);
//! Add one [Earth, solar] hour to the current simulation time. //! Add one [Earth, solar] hour to the current simulation time.
skipping to change at line 235 skipping to change at line 213
//! Add a number of Earth Solar days to the current simulation time //! Add a number of Earth Solar days to the current simulation time
//! @param d the decimal number of days to add (use negative values to subtract) //! @param d the decimal number of days to add (use negative values to subtract)
void addSolarDays(double d); void addSolarDays(double d);
//! Add a number of sidereal days to the current simulation time, //! Add a number of sidereal days to the current simulation time,
//! based on the observer body's rotational period. //! based on the observer body's rotational period.
//! @param d the decimal number of sidereal days to add (use negativ e values to subtract) //! @param d the decimal number of sidereal days to add (use negativ e values to subtract)
void addSiderealDays(double d); void addSiderealDays(double d);
//! Move the observer to the selected object. This will only do some thing if //! Move the observer to the selected object. This will only do some thing if
//! the selected object is of the correct type - i.e. a planet. //! the selected object is of the correct type - i.e. a planet.
void moveObserverToSelected(void); void moveObserverToSelected();
//! Get the location used by default at startup //! Get the location used by default at startup
QString getDefaultLocationID() const {return defaultLocationID;} QString getDefaultLocationID() const {return defaultLocationID;}
//! Set the location to use by default at startup //! Set the location to use by default at startup
void setDefaultLocationID(const QString& id); void setDefaultLocationID(const QString& id);
//! Sets the initial direction of view to the current altitude and a signals:
zimuth. //! This signal is emitted when the observer location has changed.
//! Note: Updates the configuration file. void locationChanged(StelLocation);
void setInitViewDirectionToCurrent(void); //! This signal is emitted when the time rate has changed
void timeRateChanged(double rate);
private: private:
//! Update the modelview matrices
void updateModelViewMat(void);
// Matrices used for every coordinate transfo // Matrices used for every coordinate transfo
Mat4d matHeliocentricEclipticToAltAz; // Transform from heliocentr ic ecliptic (Vsop87) to observer-centric altazimuthal coordinate Mat4d matHeliocentricEclipticToAltAz; // Transform from heliocentr ic ecliptic (Vsop87) to observer-centric altazimuthal coordinate
Mat4d matAltAzToHeliocentricEcliptic; // Transform from observer-c entric altazimuthal coordinate to heliocentric ecliptic (Vsop87) Mat4d matAltAzToHeliocentricEcliptic; // Transform from observer-c entric altazimuthal coordinate to heliocentric ecliptic (Vsop87)
Mat4d matAltAzToEquinoxEqu; // Transform from observer-centric altazimuthal coordinate to Earth Equatorial Mat4d matAltAzToEquinoxEqu; // Transform from observer-centric altazimuthal coordinate to Earth Equatorial
Mat4d matEquinoxEquToAltAz; // Transform from observer-centric altazimuthal coordinate to Earth Equatorial Mat4d matEquinoxEquToAltAz; // Transform from observer-centric altazimuthal coordinate to Earth Equatorial
Mat4d matHeliocentricEclipticToEquinoxEqu;// Transform from heliocen tric ecliptic (Vsop87) to earth equatorial coordinate Mat4d matHeliocentricEclipticToEquinoxEqu;// Transform from heliocen tric ecliptic (Vsop87) to earth equatorial coordinate
Mat4d matEquinoxEquToJ2000; Mat4d matEquinoxEquToJ2000;
Mat4d matJ2000ToEquinoxEqu; Mat4d matJ2000ToEquinoxEqu;
Mat4d matJ2000ToAltAz; Mat4d matJ2000ToAltAz;
Mat4d matAltAzModelView; // M odelview matrix for observer-centric altazimuthal drawing Mat4d matAltAzModelView; // M odelview matrix for observer-centric altazimuthal drawing
// Vision variables
// Viewing direction in altazimuthal and equatorial coordinates
Vec3d altAzVisionDirection, earthEquVisionDirection, J2000EquVisionD
irection;
// Time variable // Time variable
double timeSpeed; // Positive : forward, Negative : Backward, 1 = 1sec/sec double timeSpeed; // Positive : forward, Negative : Backward, 1 = 1sec/sec
double JDay; // Curent time in Julian day double JDay; // Curent time in Julian day
double presetSkyTime; double presetSkyTime;
QTime initTodayTime; QTime initTodayTime;
QString startupTimeMode; QString startupTimeMode;
// The ID of the default startup location // The ID of the default startup location
QString defaultLocationID; QString defaultLocationID;
// Position variables // Position variables
StelObserver* position; StelObserver* position;
Vec3d initViewPos; // Default viewing direction
// defines if view corrects for horizon, or uses equatorial coordina
tes
ViewingModeType viewingMode;
}; };
#endif // _STELNAVIGATOR_HPP_ #endif // _STELNAVIGATOR_HPP_
 End of changes. 28 change blocks. 
91 lines changed or deleted 60 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/