Stellarium 0.11.3
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

core/StelCore.hpp

00001 /*
00002  * Copyright (C) 2003 Fabien Chereau
00003  * Copyright (C) 2012 Matthew Gates
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., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
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     // Conversion in standar Julian time format
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);
00268 
00270     void setJDay(double JD);
00272     double getJDay() const;
00273 
00275     double getPresetSkyTime() const;
00277     void setPresetSkyTime(double d);
00278 
00280     void setTimeRate(double ts);
00282     double getTimeRate() const;
00283 
00285     void increaseTimeSpeed();
00287     void decreaseTimeSpeed();
00289     void increaseTimeSpeedLess();
00291     void decreaseTimeSpeedLess();
00292 
00294     void setZeroTimeSpeed();
00296     void setRealTimeSpeed();
00298     void toggleRealTimeSpeed();
00300     bool getRealTimeSpeed() const;
00301 
00303     void setTimeNow();
00305     void setTodayTime(const QTime& target);
00307     bool getIsTimeNow() const;
00308 
00310     QTime getInitTodayTime(void);
00312     void setInitTodayTime(const QTime& t);
00314     void setPresetSkyTime(QDateTime dt);
00315 
00317     void addHour();
00319     void addDay();
00321     void addWeek();
00322 
00325     void addSiderealDay();
00328     void addSiderealWeek();
00331     void addSiderealMonth();
00334     void addSiderealYear();
00335 
00337     void subtractHour();
00339     void subtractDay();
00341     void subtractWeek();
00342 
00345     void subtractSiderealDay();
00348     void subtractSiderealWeek();
00351     void subtractSiderealMonth();
00354     void subtractSiderealYear();
00355 
00358     void addSolarDays(double d);
00362     void addSiderealDays(double d);
00363 
00366     void moveObserverToSelected();
00367 
00368 signals:
00370     void locationChanged(StelLocation);
00372     void timeRateChanged(double rate);
00373 
00374 private:
00375     StelToneReproducer* toneConverter;      // Tones conversion between stellarium world and display device
00376     StelSkyDrawer* skyDrawer;
00377     StelMovementMgr* movementMgr;       // Manage vision movements
00378 
00379     // Manage geodesic grid
00380     mutable StelGeodesicGrid* geodesicGrid;
00381 
00382     // The currently used projection type
00383     ProjectionType currentProjectionType;
00384 
00385     // Parameters to use when creating new instances of StelProjector
00386     StelProjector::StelProjectorParams currentProjectorParams;
00387 
00388     void updateTransformMatrices();
00389     void updateTime(double deltaTime);
00390 
00391     // Matrices used for every coordinate transfo
00392     Mat4d matHeliocentricEclipticToAltAz;      // Transform from heliocentric ecliptic (Vsop87) to observer-centric altazimuthal coordinate
00393     Mat4d matAltAzToHeliocentricEcliptic;      // Transform from observer-centric altazimuthal coordinate to heliocentric ecliptic (Vsop87)
00394     Mat4d matAltAzToEquinoxEqu;                // Transform from observer-centric altazimuthal coordinate to Earth Equatorial
00395     Mat4d matEquinoxEquToAltAz;                // Transform from observer-centric altazimuthal coordinate to Earth Equatorial
00396     Mat4d matHeliocentricEclipticToEquinoxEqu; // Transform from heliocentric ecliptic (Vsop87) to earth equatorial coordinate
00397     Mat4d matEquinoxEquToJ2000;
00398     Mat4d matJ2000ToEquinoxEqu;
00399     Mat4d matJ2000ToAltAz;
00400 
00401     Mat4d matAltAzModelView;           // Modelview matrix for observer-centric altazimuthal drawing
00402     Mat4d invertMatAltAzModelView;     // Inverted modelview matrix for observer-centric altazimuthal drawing
00403 
00404     // Position variables
00405     StelObserver* position;
00406     // The ID of the default startup location
00407     QString defaultLocationID;
00408 
00409     // Time variables
00410     double timeSpeed;                  // Positive : forward, Negative : Backward, 1 = 1sec/sec
00411     double JDay;                       // Curent time in Julian day
00412     double presetSkyTime;
00413     QTime initTodayTime;
00414     QString startupTimeMode;
00415 };
00416 
00417 #endif // _STELCORE_HPP_
Generated on Thu May 31 10:37:18 2012 for Stellarium by  doxygen 1.6.3