Stellarium 0.11.4
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);
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;      // Tones conversion between stellarium world and display device
00380     StelSkyDrawer* skyDrawer;
00381     StelMovementMgr* movementMgr;       // Manage vision movements
00382 
00383     // Manage geodesic grid
00384     mutable StelGeodesicGrid* geodesicGrid;
00385 
00386     // The currently used projection type
00387     ProjectionType currentProjectionType;
00388 
00389     // Parameters to use when creating new instances of StelProjector
00390     StelProjector::StelProjectorParams currentProjectorParams;
00391 
00392     void updateTransformMatrices();
00393     void updateTime(double deltaTime);
00394 
00395     // Matrices used for every coordinate transfo
00396     Mat4d matHeliocentricEclipticToAltAz;      // Transform from heliocentric ecliptic (Vsop87) to observer-centric altazimuthal coordinate
00397     Mat4d matAltAzToHeliocentricEcliptic;      // Transform from observer-centric altazimuthal coordinate to heliocentric ecliptic (Vsop87)
00398     Mat4d matAltAzToEquinoxEqu;                // Transform from observer-centric altazimuthal coordinate to Earth Equatorial
00399     Mat4d matEquinoxEquToAltAz;                // Transform from observer-centric altazimuthal coordinate to Earth Equatorial
00400     Mat4d matHeliocentricEclipticToEquinoxEqu; // Transform from heliocentric ecliptic (Vsop87) to earth equatorial coordinate
00401     Mat4d matEquinoxEquToJ2000;
00402     Mat4d matJ2000ToEquinoxEqu;
00403     Mat4d matJ2000ToAltAz;
00404 
00405     Mat4d matAltAzModelView;           // Modelview matrix for observer-centric altazimuthal drawing
00406     Mat4d invertMatAltAzModelView;     // Inverted modelview matrix for observer-centric altazimuthal drawing
00407 
00408     // Position variables
00409     StelObserver* position;
00410     // The ID of the default startup location
00411     QString defaultLocationID;
00412 
00413     // Time variables
00414     double timeSpeed;                  // Positive : forward, Negative : Backward, 1 = 1sec/sec
00415     double JDay;                       // Curent time in Julian day
00416     double presetSkyTime;
00417     QTime initTodayTime;
00418     QString startupTimeMode;
00419 };
00420 
00421 #endif // _STELCORE_HPP_
Generated on Sat Aug 25 22:13:29 2012 for Stellarium by  doxygen 1.6.3