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

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         FrameUninitialized,           
00057         FrameAltAz,                   
00058         FrameHeliocentricEcliptic,    
00059         FrameObservercentricEcliptic, 
00060         FrameEquinoxEqu,              
00061 
00062         FrameJ2000,                   
00063 
00064         FrameGalactic                 
00065     };
00066 
00068     enum ProjectionType
00069     {
00070         ProjectionPerspective,    
00071         ProjectionEqualArea,      
00072         ProjectionStereographic,  
00073         ProjectionFisheye,        
00074         ProjectionHammer,         
00075         ProjectionCylinder,       
00076         ProjectionMercator,       
00077         ProjectionOrthographic    
00078     };
00079 
00081     enum RefractionMode
00082     {
00083         RefractionAuto,         
00084         RefractionOn,           
00085         RefractionOff           
00086     };
00087 
00088     StelCore();
00089     virtual ~StelCore();
00090 
00092     void init(class StelRenderer* renderer);
00093 
00096     void update(double deltaTime);
00097 
00099     void windowHasBeenResized(float x, float y, float width, float height);
00100 
00102     void preDraw();
00103 
00105     void postDraw(StelRenderer* renderer);
00106 
00109     StelProjectorP getProjection2d() const;
00110 
00113     StelProjectorP getProjection(FrameType frameType, RefractionMode refractionMode=RefractionAuto) const;
00114 
00117     StelProjectorP getProjection(StelProjector::ModelViewTranformP modelViewTransform, ProjectionType projType=(ProjectionType)1000) const;
00118 
00120     StelToneReproducer* getToneReproducer();
00122     const StelToneReproducer* getToneReproducer() const;
00123 
00125     StelSkyDrawer* getSkyDrawer();
00127     const StelSkyDrawer* getSkyDrawer() const;
00128 
00130     const StelGeodesicGrid* getGeodesicGrid(int maxLevel) const;
00131 
00133     StelMovementMgr* getMovementMgr();
00135     const StelMovementMgr* getMovementMgr() const;
00136 
00138     void setClippingPlanes(double znear, double zfar);
00140     void getClippingPlanes(double* zn, double* zf) const;
00141 
00143     QString projectionTypeKeyToNameI18n(const QString& key) const;
00144 
00146     QString projectionNameI18nToTypeKey(const QString& nameI18n) const;
00147 
00149     StelProjector::StelProjectorParams getCurrentStelProjectorParams() const;
00151     void setCurrentStelProjectorParams(const StelProjector::StelProjectorParams& newParams);
00152 
00154     void lookAtJ2000(const Vec3d& pos, const Vec3d& up);
00155 
00156     Vec3d altAzToEquinoxEqu(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
00157     Vec3d equinoxEquToAltAz(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
00158     Vec3d altAzToJ2000(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
00159     Vec3d j2000ToAltAz(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
00160     Vec3d galacticToJ2000(const Vec3d& v) const;
00161     Vec3d equinoxEquToJ2000(const Vec3d& v) const;
00162     Vec3d j2000ToEquinoxEqu(const Vec3d& v) const;
00163     Vec3d j2000ToGalactic(const Vec3d& v) const;
00164 
00166     Vec3d heliocentricEclipticToAltAz(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
00167 
00169     Vec3d heliocentricEclipticToEquinoxEqu(const Vec3d& v) const;
00172     Vec3d heliocentricEclipticToEarthPosEquinoxEqu(const Vec3d& v) const;
00173 
00175     StelProjector::ModelViewTranformP getHeliocentricEclipticModelViewTransform(RefractionMode refMode=RefractionAuto) const;
00176 
00178     StelProjector::ModelViewTranformP getObservercentricEclipticModelViewTransform(RefractionMode refMode=RefractionAuto) const;
00179 
00181     StelProjector::ModelViewTranformP getEquinoxEquModelViewTransform(RefractionMode refMode=RefractionAuto) const;
00182 
00184     StelProjector::ModelViewTranformP getAltAzModelViewTransform(RefractionMode refMode=RefractionAuto) const;
00185 
00187     StelProjector::ModelViewTranformP getJ2000ModelViewTransform(RefractionMode refMode=RefractionAuto) const;
00188 
00190     StelProjector::ModelViewTranformP getGalacticModelViewTransform(RefractionMode refMode=RefractionAuto) const;
00191 
00193     static const Mat4d matJ2000ToVsop87;
00195     static const Mat4d matVsop87ToJ2000;
00197     static const Mat4d matJ2000ToGalactic;
00199     static const Mat4d matGalacticToJ2000;
00200 
00202     Vec3d getObserverHeliocentricEclipticPos() const;
00203 
00205     const StelLocation& getCurrentLocation() const;
00206 
00207     const QSharedPointer<class Planet> getCurrentPlanet() const;
00208 
00214     void moveObserverTo(const StelLocation& target, double duration=1., double durationIfPlanetChange=1.);
00215 
00216     // Conversion in standar Julian time format
00217     static const double JD_SECOND;
00218     static const double JD_MINUTE;
00219     static const double JD_HOUR;
00220     static const double JD_DAY;
00221 
00224     double getLocalSideralTime() const;
00225 
00227     double getLocalSideralDayLength() const;
00228 
00230     QString getStartupTimeMode();
00231     void setStartupTimeMode(const QString& s);
00232 
00233 public slots:
00235     void setCurrentProjectionType(ProjectionType type);
00236     ProjectionType getCurrentProjectionType() const;
00237 
00239     QString getCurrentProjectionTypeKey(void) const;
00241     void setCurrentProjectionTypeKey(QString type);
00242 
00244     QStringList getAllProjectionTypeKeys() const;
00245 
00247     void setMaskType(StelProjector::StelProjectorMaskType m);
00248 
00251     void setFlagGravityLabels(bool gravity);
00253     void setDefautAngleForGravityText(float a);
00256     void setFlipHorz(bool flip);
00259     void setFlipVert(bool flip);
00262     bool getFlipHorz(void) const;
00265     bool getFlipVert(void) const;
00266 
00268     QString getDefaultLocationID() const;
00270     void setDefaultLocationID(const QString& id);
00272     void returnToDefaultLocation();
00274     void returnToHome();
00275 
00277     void setJDay(double JD);
00279     double getJDay() const;
00280 
00282     double getPresetSkyTime() const;
00284     void setPresetSkyTime(double d);
00285 
00287     void setTimeRate(double ts);
00289     double getTimeRate() const;
00290 
00292     void increaseTimeSpeed();
00294     void decreaseTimeSpeed();
00296     void increaseTimeSpeedLess();
00298     void decreaseTimeSpeedLess();
00299 
00301     void setZeroTimeSpeed();
00303     void setRealTimeSpeed();
00305     void toggleRealTimeSpeed();
00307     bool getRealTimeSpeed() const;
00308 
00310     void setTimeNow();
00312     void setTodayTime(const QTime& target);
00314     bool getIsTimeNow() const;
00315 
00317     QTime getInitTodayTime(void);
00319     void setInitTodayTime(const QTime& t);
00321     void setPresetSkyTime(QDateTime dt);
00322 
00324     void addHour();
00326     void addDay();
00328     void addWeek();
00329 
00332     void addSiderealDay();
00335     void addSiderealWeek();
00339     void addSiderealMonth();
00343     void addSiderealYear();
00347     void addSiderealCentury();
00348 
00350     void subtractHour();
00352     void subtractDay();
00354     void subtractWeek();
00355 
00358     void subtractSiderealDay();
00361     void subtractSiderealWeek();
00365     void subtractSiderealMonth();
00369     void subtractSiderealYear();
00373     void subtractSiderealCentury();
00374 
00376     void addSynodicMonth();
00377 
00379     void addDraconicYear();
00381     void addDraconicMonth();
00382 
00384     void addAnomalisticMonth();
00385 
00387     void addTropicalMonth();
00389     void addTropicalYear();
00391     void addTropicalCentury();
00392 
00394     void subtractSynodicMonth();
00395 
00397     void subtractDraconicYear();
00399     void subtractDraconicMonth();
00400 
00402     void subtractAnomalisticMonth();
00403 
00405     void subtractTropicalMonth();
00407     void subtractTropicalYear();
00409     void subtractTropicalCentury();
00410 
00413     void addSolarDays(double d);
00417     void addSiderealDays(double d);
00418 
00421     void moveObserverToSelected();
00422 
00423 signals:
00425     void locationChanged(StelLocation);
00427     void timeRateChanged(double rate);
00428 
00429 private:
00430     StelToneReproducer* toneConverter;      // Tones conversion between stellarium world and display device
00431     StelSkyDrawer* skyDrawer;
00432     StelMovementMgr* movementMgr;       // Manage vision movements
00433 
00434     // Manage geodesic grid
00435     mutable StelGeodesicGrid* geodesicGrid;
00436 
00437     // The currently used projection type
00438     ProjectionType currentProjectionType;
00439 
00440     // Parameters to use when creating new instances of StelProjector
00441     StelProjector::StelProjectorParams currentProjectorParams;
00442 
00443     void updateTransformMatrices();
00444     void updateTime(double deltaTime);
00445 
00446     // Matrices used for every coordinate transfo
00447     Mat4d matHeliocentricEclipticToAltAz;      // Transform from heliocentric ecliptic (Vsop87) to observer-centric altazimuthal coordinate
00448     Mat4d matAltAzToHeliocentricEcliptic;      // Transform from observer-centric altazimuthal coordinate to heliocentric ecliptic (Vsop87)
00449     Mat4d matAltAzToEquinoxEqu;                // Transform from observer-centric altazimuthal coordinate to Earth Equatorial
00450     Mat4d matEquinoxEquToAltAz;                // Transform from observer-centric altazimuthal coordinate to Earth Equatorial
00451     Mat4d matHeliocentricEclipticToEquinoxEqu; // Transform from heliocentric ecliptic (Vsop87) to earth equatorial coordinate
00452     Mat4d matEquinoxEquToJ2000;
00453     Mat4d matJ2000ToEquinoxEqu;
00454     Mat4d matJ2000ToAltAz;
00455 
00456     Mat4d matAltAzModelView;           // Modelview matrix for observer-centric altazimuthal drawing
00457     Mat4d invertMatAltAzModelView;     // Inverted modelview matrix for observer-centric altazimuthal drawing
00458 
00459     // Position variables
00460     StelObserver* position;
00461     // The ID of the default startup location
00462     QString defaultLocationID;
00463 
00464     // Time variables
00465     double timeSpeed;                  // Positive : forward, Negative : Backward, 1 = 1sec/sec
00466     double JDay;                       // Curent time in Julian day
00467     double presetSkyTime;
00468     QTime initTodayTime;
00469     QString startupTimeMode;
00470 };
00471 
00472 #endif // _STELCORE_HPP_
Generated on Thu Jan 31 14:05:40 2013 for Stellarium by  doxygen 1.6.3