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

core/StelCore.hpp

00001 /*
00002  * Copyright (C) 2003 Fabien Chereau
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  */
00018 
00019 #ifndef _STELCORE_HPP_
00020 #define _STELCORE_HPP_
00021 
00022 #include "StelProjector.hpp"
00023 #include "StelProjectorType.hpp"
00024 #include <QString>
00025 #include <QStringList>
00026 
00027 class StelNavigator;
00028 class StelToneReproducer;
00029 class StelSkyDrawer;
00030 class StelGeodesicGrid;
00031 class StelMovementMgr;
00032 
00042 class StelCore : public QObject
00043 {
00044     Q_OBJECT
00045     Q_ENUMS(ProjectionType);
00046 
00047 public:
00050     enum FrameType
00051     {
00052         FrameAltAz,                   
00053         FrameHeliocentricEcliptic,    
00054         FrameObservercentricEcliptic, 
00055         FrameEquinoxEqu,              
00056 
00057         FrameJ2000,                   
00058 
00059         FrameGalactic                 
00060     };
00061 
00063     enum ProjectionType
00064     {
00065         ProjectionPerspective,    
00066         ProjectionEqualArea,      
00067         ProjectionStereographic,  
00068         ProjectionFisheye,        
00069         ProjectionHammer,         
00070         ProjectionCylinder,       
00071         ProjectionMercator,       
00072         ProjectionOrthographic    
00073     };
00074 
00075     StelCore();
00076     virtual ~StelCore();
00077 
00079     void init();
00080 
00083     void update(double deltaTime);
00084 
00086     void windowHasBeenResized(float x, float y, float width, float height);
00087 
00089     void preDraw();
00090 
00092     void postDraw();
00093 
00096     StelProjectorP getProjection2d() const;
00097 
00101     StelProjectorP getProjection(FrameType frameType, ProjectionType projType=(ProjectionType)1000) const;
00102 
00106     StelProjectorP getProjection(const Mat4d& modelViewMat, ProjectionType projType=(ProjectionType)1000) const;
00107 
00109     StelNavigator* getNavigator() {return navigation;}
00111     const StelNavigator* getNavigator() const {return navigation;}
00112 
00114     StelToneReproducer* getToneReproducer() {return toneConverter;}
00116     const StelToneReproducer* getToneReproducer() const {return toneConverter;}
00117 
00119     StelSkyDrawer* getSkyDrawer() {return skyDrawer;}
00121     const StelSkyDrawer* getSkyDrawer() const {return skyDrawer;}
00122 
00124     const StelGeodesicGrid* getGeodesicGrid(int maxLevel) const;
00125 
00127     StelMovementMgr* getMovementMgr() {return movementMgr;}
00129     const StelMovementMgr* getMovementMgr() const {return movementMgr;}
00130 
00132     void setClippingPlanes(double znear, double zfar) {currentProjectorParams.zNear=znear;currentProjectorParams.zFar=zfar;}
00134     void getClippingPlanes(double* zn, double* zf) const {*zn = currentProjectorParams.zNear; *zf = currentProjectorParams.zFar;}
00135 
00137     QString projectionTypeKeyToNameI18n(const QString& key) const;
00138 
00140     QString projectionNameI18nToTypeKey(const QString& nameI18n) const;
00141 
00143     StelProjector::StelProjectorParams getCurrentStelProjectorParams() const {return currentProjectorParams;}
00145     void setCurrentStelProjectorParams(const StelProjector::StelProjectorParams& newParams) {currentProjectorParams=newParams;}
00146 
00147 public slots:
00149     void setCurrentProjectionType(ProjectionType type);
00150     ProjectionType getCurrentProjectionType() const {return currentProjectionType;}
00151 
00153     QString getCurrentProjectionTypeKey(void) const;
00155     void setCurrentProjectionTypeKey(QString type);
00156 
00158     QStringList getAllProjectionTypeKeys() const;
00159 
00161     void setMaskType(StelProjector::StelProjectorMaskType m) {currentProjectorParams.maskType = m; }
00162 
00165     void setFlagGravityLabels(bool gravity) { currentProjectorParams.gravityLabels = gravity; }
00167     void setDefautAngleForGravityText(float a) { currentProjectorParams.defautAngleForGravityText = a; }
00170     void setFlipHorz(bool flip) {currentProjectorParams.flipHorz = flip;}
00173     void setFlipVert(bool flip) {currentProjectorParams.flipVert = flip;}
00176     bool getFlipHorz(void) const {return currentProjectorParams.flipHorz;}
00179     bool getFlipVert(void) const {return currentProjectorParams.flipVert;}
00180 
00181 private:
00182     StelNavigator* navigation;          // Manage all navigation parameters, coordinate transformations etc..
00183     StelToneReproducer* toneConverter;      // Tones conversion between stellarium world and display device
00184     StelSkyDrawer* skyDrawer;
00185     StelMovementMgr* movementMgr;       // Manage vision movements
00186 
00187     // Manage geodesic grid
00188     mutable StelGeodesicGrid* geodesicGrid;
00189 
00190     // The currently used projection type
00191     ProjectionType currentProjectionType;
00192 
00193     // Parameters to use when creating new instances of StelProjector
00194     StelProjector::StelProjectorParams currentProjectorParams;
00195 };
00196 
00197 #endif // _STELCORE_HPP_