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

core/StelApp.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2006 Fabien Chereau
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef _STELAPP_HPP_
00021 #define _STELAPP_HPP_
00022 
00023 #include <QString>
00024 #include <QVariant>
00025 #include <QObject>
00026 #include <QFile>
00027 
00028 // Predeclaration of some classes
00029 class StelCore;
00030 class SkyLocalizer;
00031 class StelTextureMgr;
00032 class StelObjectMgr;
00033 class StelLocaleMgr;
00034 class StelModuleMgr;
00035 class StelSkyCultureMgr;
00036 class QStringList;
00037 class StelLoadingBar;
00038 class QSettings;
00039 class QNetworkAccessManager;
00040 class StelStyle;
00041 class QTime;
00042 class StelLocationMgr;
00043 class StelSkyLayerMgr;
00044 class StelAudioMgr;
00045 class QNetworkReply;
00046 class StelGuiBase;
00047 
00059 class StelApp : public QObject
00060 {
00061     Q_OBJECT
00062 
00063 public:
00064     friend class StelAppGraphicsWidget;
00065 
00073     StelApp(QObject* parent=NULL);
00074 
00076     virtual ~StelApp();
00077 
00079     void init(QSettings* conf);
00080 
00082     void initPlugIns();
00083 
00086     static StelApp& getInstance() {Q_ASSERT(singleton); return *singleton;}
00087 
00090     StelModuleMgr& getModuleMgr() {return *moduleMgr;}
00091 
00094     StelLocaleMgr& getLocaleMgr() {return *localeMgr;}
00095 
00098     StelSkyCultureMgr& getSkyCultureMgr() {return *skyCultureMgr;}
00099 
00102     StelTextureMgr& getTextureManager() {return *textureMgr;}
00103 
00106     StelLocationMgr& getLocationMgr() {return *planetLocationMgr;}
00107 
00110     StelObjectMgr& getStelObjectMgr() {return *stelObjectMgr;}
00111 
00114     StelSkyLayerMgr& getSkyImageMgr() {return *skyImageMgr;}
00115 
00117     StelAudioMgr* getStelAudioMgr() {return audioMgr;}
00118 
00122     StelCore* getCore() {return core;}
00123 
00126     StelLoadingBar* getStelLoadingBar() {return loadingBar;}
00127 
00129     QNetworkAccessManager* getNetworkAccessManager() {return networkAccessManager;}
00130 
00132     void updateI18n();
00133 
00135     void updateSkyCulture();
00136 
00138     QSettings* getSettings() {return confSettings;}
00139 
00141     const StelStyle* getCurrentStelStyle() {return currentStelStyle;}
00142 
00144     void update(double deltaTime);
00145 
00148     void draw();
00149 
00154     bool drawPartial();
00155 
00157     void glWindowHasBeenResized(float x, float y, float w, float h);
00158 
00160     StelGuiBase* getGui() const {return stelGui;}
00163     void setGui(StelGuiBase* b) {stelGui=b;}
00164 
00166     static void makeMainGLContextCurrent();
00167 
00168     static void initStatic();
00169 
00171     bool getUseGLShaders() const {return useGLShaders;}
00172 
00174     // Scriptable methods
00175 public slots:
00176 
00178     void setVisionModeNight(bool);
00180     bool getVisionModeNight() const {return flagNightVision;}
00181 
00184     float getFps() const {return fps;}
00185 
00187     static double getTotalRunTime();
00188 
00191     void reportFileDownloadFinished(QNetworkReply* reply);
00192 
00193 private:
00194 
00196     void handleClick(class QMouseEvent* event);
00198     void handleWheel(class QWheelEvent* event);
00200     void handleMove(int x, int y, Qt::MouseButtons b);
00202     void handleKeys(class QKeyEvent* event);
00203 
00205     void setColorScheme(const QString& section);
00206 
00207 
00208     // The StelApp singleton
00209     static StelApp* singleton;
00210 
00211     // The associated StelCore instance
00212     StelCore* core;
00213 
00214     // Module manager for the application
00215     StelModuleMgr* moduleMgr;
00216 
00217     // Locale manager for the application
00218     StelLocaleMgr* localeMgr;
00219 
00220     // Sky cultures manager for the application
00221     StelSkyCultureMgr* skyCultureMgr;
00222 
00223     // Textures manager for the application
00224     StelTextureMgr* textureMgr;
00225 
00226     // Manager for all the StelObjects of the program
00227     StelObjectMgr* stelObjectMgr;
00228 
00229     // Manager for the list of observer locations on planets
00230     StelLocationMgr* planetLocationMgr;
00231 
00232     // Main network manager used for the program
00233     QNetworkAccessManager* networkAccessManager;
00234 
00235     // The audio manager.  Must execute in the main thread.
00236     StelAudioMgr* audioMgr;
00237 
00238     // The main loading bar
00239     StelLoadingBar* loadingBar;
00240 
00241     // Currently used StelStyle
00242     StelStyle* currentStelStyle;
00243 
00244     StelSkyLayerMgr* skyImageMgr;
00245 
00246     StelGuiBase* stelGui;
00247 
00248     float fps;
00249     int frame;
00250     double timefr, timeBase;        // Used for fps counter
00251 
00253     bool flagNightVision;
00254 
00256     bool useGLShaders;
00257 
00258     QSettings* confSettings;
00259 
00260     // Define whether the StelApp instance has completed initialization
00261     bool initialized;
00262 
00263     static QTime* qtime;
00264 
00265     // Temporary variables used to store the last gl window resize
00266     // if the core was not yet initialized
00267     int saveProjW;
00268     int saveProjH;
00269 
00271     int nbDownloadedFiles;
00273     qint64 totalDownloadedSize;
00274 
00276     int nbUsedCache;
00278     qint64 totalUsedCacheSize;
00279 
00281     int drawState;
00282 };
00283 
00284 #endif // _STELAPP_HPP_

Generated on Mon Mar 22 09:55:37 2010 for Stellarium by  doxygen 1.5.5