00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _STELCORE_HPP_
00021 #define _STELCORE_HPP_
00022
00023 #include "StelProjector.hpp"
00024 #include "StelProjectorType.hpp"
00025 #include "StelLocation.hpp"
00026 #include "StelSkyDrawer.hpp"
00027 #include <QString>
00028 #include <QStringList>
00029 #include <QTime>
00030
00031 class StelToneReproducer;
00032 class StelSkyDrawer;
00033 class StelGeodesicGrid;
00034 class StelMovementMgr;
00035 class StelObserver;
00036
00046 class StelCore : public QObject
00047 {
00048 Q_OBJECT
00049 Q_ENUMS(ProjectionType)
00050
00051 public:
00054 enum FrameType
00055 {
00056 FrameAltAz,
00057 FrameHeliocentricEcliptic,
00058 FrameObservercentricEcliptic,
00059 FrameEquinoxEqu,
00060
00061 FrameJ2000,
00062
00063 FrameGalactic
00064 };
00065
00067 enum ProjectionType
00068 {
00069 ProjectionPerspective,
00070 ProjectionEqualArea,
00071 ProjectionStereographic,
00072 ProjectionFisheye,
00073 ProjectionHammer,
00074 ProjectionCylinder,
00075 ProjectionMercator,
00076 ProjectionOrthographic
00077 };
00078
00080 enum RefractionMode
00081 {
00082 RefractionAuto,
00083 RefractionOn,
00084 RefractionOff
00085 };
00086
00087 StelCore();
00088 virtual ~StelCore();
00089
00091 void init();
00092
00095 void update(double deltaTime);
00096
00098 void windowHasBeenResized(float x, float y, float width, float height);
00099
00101 void preDraw();
00102
00104 void postDraw();
00105
00108 StelProjectorP getProjection2d() const;
00109
00112 StelProjectorP getProjection(FrameType frameType, RefractionMode refractionMode=RefractionAuto) const;
00113
00116 StelProjectorP getProjection(StelProjector::ModelViewTranformP modelViewTransform, ProjectionType projType=(ProjectionType)1000) const;
00117
00119 StelToneReproducer* getToneReproducer();
00121 const StelToneReproducer* getToneReproducer() const;
00122
00124 StelSkyDrawer* getSkyDrawer();
00126 const StelSkyDrawer* getSkyDrawer() const;
00127
00129 const StelGeodesicGrid* getGeodesicGrid(int maxLevel) const;
00130
00132 StelMovementMgr* getMovementMgr();
00134 const StelMovementMgr* getMovementMgr() const;
00135
00137 void setClippingPlanes(double znear, double zfar);
00139 void getClippingPlanes(double* zn, double* zf) const;
00140
00142 QString projectionTypeKeyToNameI18n(const QString& key) const;
00143
00145 QString projectionNameI18nToTypeKey(const QString& nameI18n) const;
00146
00148 StelProjector::StelProjectorParams getCurrentStelProjectorParams() const;
00150 void setCurrentStelProjectorParams(const StelProjector::StelProjectorParams& newParams);
00151
00153 void lookAtJ2000(const Vec3d& pos, const Vec3d& up);
00154
00155 Vec3d altAzToEquinoxEqu(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
00156 Vec3d equinoxEquToAltAz(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
00157 Vec3d altAzToJ2000(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
00158 Vec3d j2000ToAltAz(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
00159 Vec3d galacticToJ2000(const Vec3d& v) const;
00160 Vec3d equinoxEquToJ2000(const Vec3d& v) const;
00161 Vec3d j2000ToEquinoxEqu(const Vec3d& v) const;
00162 Vec3d j2000ToGalactic(const Vec3d& v) const;
00163
00165 Vec3d heliocentricEclipticToAltAz(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
00166
00168 Vec3d heliocentricEclipticToEquinoxEqu(const Vec3d& v) const;
00171 Vec3d heliocentricEclipticToEarthPosEquinoxEqu(const Vec3d& v) const;
00172
00174 StelProjector::ModelViewTranformP getHeliocentricEclipticModelViewTransform(RefractionMode refMode=RefractionAuto) const;
00175
00177 StelProjector::ModelViewTranformP getObservercentricEclipticModelViewTransform(RefractionMode refMode=RefractionAuto) const;
00178
00180 StelProjector::ModelViewTranformP getEquinoxEquModelViewTransform(RefractionMode refMode=RefractionAuto) const;
00181
00183 StelProjector::ModelViewTranformP getAltAzModelViewTransform(RefractionMode refMode=RefractionAuto) const;
00184
00186 StelProjector::ModelViewTranformP getJ2000ModelViewTransform(RefractionMode refMode=RefractionAuto) const;
00187
00189 StelProjector::ModelViewTranformP getGalacticModelViewTransform(RefractionMode refMode=RefractionAuto) const;
00190
00192 static const Mat4d matJ2000ToVsop87;
00194 static const Mat4d matVsop87ToJ2000;
00196 static const Mat4d matJ2000ToGalactic;
00198 static const Mat4d matGalacticToJ2000;
00199
00201 Vec3d getObserverHeliocentricEclipticPos() const;
00202
00204 const StelLocation& getCurrentLocation() const;
00205
00211 void moveObserverTo(const StelLocation& target, double duration=1., double durationIfPlanetChange=1.);
00212
00213
00214 static const double JD_SECOND;
00215 static const double JD_MINUTE;
00216 static const double JD_HOUR;
00217 static const double JD_DAY;
00218
00221 double getLocalSideralTime() const;
00222
00224 double getLocalSideralDayLength() const;
00225
00227 QString getStartupTimeMode();
00228 void setStartupTimeMode(const QString& s);
00229
00230 public slots:
00232 void setCurrentProjectionType(ProjectionType type);
00233 ProjectionType getCurrentProjectionType() const;
00234
00236 QString getCurrentProjectionTypeKey(void) const;
00238 void setCurrentProjectionTypeKey(QString type);
00239
00241 QStringList getAllProjectionTypeKeys() const;
00242
00244 void setMaskType(StelProjector::StelProjectorMaskType m);
00245
00248 void setFlagGravityLabels(bool gravity);
00250 void setDefautAngleForGravityText(float a);
00253 void setFlipHorz(bool flip);
00256 void setFlipVert(bool flip);
00259 bool getFlipHorz(void) const;
00262 bool getFlipVert(void) const;
00263
00265 QString getDefaultLocationID() const;
00267 void setDefaultLocationID(const QString& id);
00269 void returnToDefaultLocation();
00271 void returnToHome();
00272
00274 void setJDay(double JD);
00276 double getJDay() const;
00277
00279 double getPresetSkyTime() const;
00281 void setPresetSkyTime(double d);
00282
00284 void setTimeRate(double ts);
00286 double getTimeRate() const;
00287
00289 void increaseTimeSpeed();
00291 void decreaseTimeSpeed();
00293 void increaseTimeSpeedLess();
00295 void decreaseTimeSpeedLess();
00296
00298 void setZeroTimeSpeed();
00300 void setRealTimeSpeed();
00302 void toggleRealTimeSpeed();
00304 bool getRealTimeSpeed() const;
00305
00307 void setTimeNow();
00309 void setTodayTime(const QTime& target);
00311 bool getIsTimeNow() const;
00312
00314 QTime getInitTodayTime(void);
00316 void setInitTodayTime(const QTime& t);
00318 void setPresetSkyTime(QDateTime dt);
00319
00321 void addHour();
00323 void addDay();
00325 void addWeek();
00326
00329 void addSiderealDay();
00332 void addSiderealWeek();
00335 void addSiderealMonth();
00338 void addSiderealYear();
00339
00341 void subtractHour();
00343 void subtractDay();
00345 void subtractWeek();
00346
00349 void subtractSiderealDay();
00352 void subtractSiderealWeek();
00355 void subtractSiderealMonth();
00358 void subtractSiderealYear();
00359
00362 void addSolarDays(double d);
00366 void addSiderealDays(double d);
00367
00370 void moveObserverToSelected();
00371
00372 signals:
00374 void locationChanged(StelLocation);
00376 void timeRateChanged(double rate);
00377
00378 private:
00379 StelToneReproducer* toneConverter;
00380 StelSkyDrawer* skyDrawer;
00381 StelMovementMgr* movementMgr;
00382
00383
00384 mutable StelGeodesicGrid* geodesicGrid;
00385
00386
00387 ProjectionType currentProjectionType;
00388
00389
00390 StelProjector::StelProjectorParams currentProjectorParams;
00391
00392 void updateTransformMatrices();
00393 void updateTime(double deltaTime);
00394
00395
00396 Mat4d matHeliocentricEclipticToAltAz;
00397 Mat4d matAltAzToHeliocentricEcliptic;
00398 Mat4d matAltAzToEquinoxEqu;
00399 Mat4d matEquinoxEquToAltAz;
00400 Mat4d matHeliocentricEclipticToEquinoxEqu;
00401 Mat4d matEquinoxEquToJ2000;
00402 Mat4d matJ2000ToEquinoxEqu;
00403 Mat4d matJ2000ToAltAz;
00404
00405 Mat4d matAltAzModelView;
00406 Mat4d invertMatAltAzModelView;
00407
00408
00409 StelObserver* position;
00410
00411 QString defaultLocationID;
00412
00413
00414 double timeSpeed;
00415 double JDay;
00416 double presetSkyTime;
00417 QTime initTodayTime;
00418 QString startupTimeMode;
00419 };
00420
00421 #endif // _STELCORE_HPP_