Home · All Namespaces · All Classes · Functions · Coding Style · 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 "fixx11h.h"
00024 #include <QString>
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 StelFontMgr;
00034 class StelLocaleMgr;
00035 class StelModuleMgr;
00036 class StelSkyCultureMgr;
00037 class StelFileMgr;
00038 class QStringList;
00039 class StelLoadingBar;
00040 class QSettings;
00041 class QNetworkAccessManager;
00042 class StelStyle;
00043 class QTime;
00044 class StelLocationMgr;
00045 class StelSkyImageMgr;
00046 class StelScriptMgr;
00047 class StelDownloadMgr;
00048 class StelAudioMgr;
00049 class QNetworkReply;
00050 
00062 class StelApp : public QObject
00063 {
00064     Q_OBJECT
00065     
00066 public:
00067     friend class StelAppGraphicsScene;
00068     
00076     StelApp(int argc, char** argv, QObject* parent=NULL);
00077 
00079     virtual ~StelApp();
00080 
00082     void init();
00083 
00085     void initPlugIns();
00086     
00089     static StelApp& getInstance() {Q_ASSERT(singleton); return *singleton;}
00090 
00093     StelModuleMgr& getModuleMgr() {return *moduleMgr;}
00094     
00097     StelLocaleMgr& getLocaleMgr() {return *localeMgr;}
00098     
00101     StelFontMgr& getFontManager() {return *fontManager;}
00102     
00105     StelSkyCultureMgr& getSkyCultureMgr() {return *skyCultureMgr;}
00106     
00109     StelTextureMgr& getTextureManager() {return *textureMgr;}
00110     
00113     StelObjectMgr& getStelObjectMgr() {return *stelObjectMgr;}
00114     
00117     StelLocationMgr& getLocationMgr() {return *planetLocationMgr;}
00118     
00121     StelFileMgr& getFileMgr() {return *stelFileMgr;}
00122     
00125     StelSkyImageMgr& getSkyImageMgr() {return *skyImageMgr;}
00126 
00127     StelAudioMgr* getStelAudioMgr() {return audioMgr;}
00128     
00130     StelScriptMgr& getScriptMgr() {return *scriptMgr;}
00131     
00133     StelDownloadMgr& getDownloadMgr() {return *downloadMgr;}
00134     
00138     StelCore* getCore() {return core;}
00139     
00142     StelLoadingBar* getStelLoadingBar() {return loadingBar;}
00143     
00145     QNetworkAccessManager* getNetworkAccessManager() {return networkAccessManager;}
00146     
00148     void updateI18n();  
00149     
00151     void updateSkyCulture();    
00152     
00155     const QString& getConfigFilePath() { return configFile; }
00156     
00158     QSettings* getSettings() {return confSettings;}
00159 
00161     const StelStyle* getCurrentStelStyle() {return currentStelStyle;}
00162     
00167     static void debugLogHandler(QtMsgType, const char*);
00168     
00170     QString getLog() { return log; }
00171     
00173     QString getStartupScript() const {return startupScript;}
00174             
00176     // Scriptable methods
00177 public slots:
00179     static QString getApplicationName();
00180     
00182     void setVisionModeNight(bool);
00184     bool getVisionModeNight() const {return flagNightVision;}
00185 
00191     void setMinFps(float m) {minfps=m; emit(minFpsChanged());}
00193     float getMinFps() {return minfps;}
00196     void setMaxFps(float m) {maxfps = m;}
00198     float getMaxFps() {return maxfps;}
00199     
00202     float getFps() const {return fps;}
00203 
00205     static double getTotalRunTime();
00206 
00209     void reportFileDownloadFinished(QNetworkReply* reply);
00210     
00211 signals:
00212     void minFpsChanged();
00213     
00214 private:
00216     void update(double deltaTime);
00217 
00220     void draw();
00221     
00223     void handleClick(class QMouseEvent* event);
00225     void handleWheel(class QWheelEvent* event);
00227     void handleMove(int x, int y, Qt::MouseButtons b);
00229     void handleKeys(class QKeyEvent* event);
00230 
00232     void glWindowHasBeenResized(int w, int h);
00233 
00235     void setColorScheme(const QString& section);
00236     
00243     void setConfigFile(const QString& configName, bool restoreDefaults=false);
00244     
00248     void copyDefaultConfigFile();
00249 
00251     QStringList* argList;
00252     
00258     bool argsGetOption(QStringList* args, QString shortOpt, QString longOpt);
00259     
00287     template<class T>
00288             T argsGetOptionWithArg(QStringList* args, QString shortOpt, QString longOpt, T defaultValue);
00289     
00310     int argsGetYesNoOption(QStringList* args, QString shortOpt, QString longOpt, int defaultValue);
00311     
00316     void parseCLIArgsPreConfig(void);   
00317 
00321     void parseCLIArgsPostConfig();
00322     
00324     void setupLog();
00325     
00328     static void writeLog(QString msg);
00329 
00330     // The StelApp singleton
00331     static StelApp* singleton;
00332 
00333     // The associated StelCore instance
00334     StelCore* core;
00335 
00336     // Module manager for the application
00337     StelModuleMgr* moduleMgr;
00338     
00339     // Font manager for the application
00340     StelFontMgr* fontManager;
00341     
00342     // Locale manager for the application
00343     StelLocaleMgr* localeMgr;
00344     
00345     // Sky cultures manager for the application
00346     StelSkyCultureMgr* skyCultureMgr;
00347     
00348     // Textures manager for the application
00349     StelTextureMgr* textureMgr;
00350     
00351     // Manager for all the StelObjects of the program
00352     StelObjectMgr* stelObjectMgr;
00353 
00354     // Manager for the list of observer locations on planets
00355     StelLocationMgr* planetLocationMgr;
00356     
00358     StelFileMgr* stelFileMgr;
00359     
00360     // Main network manager used for the program
00361     QNetworkAccessManager* networkAccessManager;
00362     
00363     // The manager for the sky images such as nebulas or background DSS
00364     StelSkyImageMgr* skyImageMgr;
00365 
00366     // The audio manager.  Must execute in the main thread.
00367     StelAudioMgr* audioMgr;
00368     
00369     // The script manager based on Qt script engine
00370     StelScriptMgr* scriptMgr;
00371     
00372     // The main loading bar
00373     StelLoadingBar* loadingBar;
00374     
00375     // Currently used StelStyle
00376     StelStyle* currentStelStyle;
00377     
00378     // Download manager that uses networkAccessManager
00379     StelDownloadMgr* downloadMgr;
00380     
00381     float fps;
00383     float minfps;
00385     float maxfps;
00386     
00387     int frame;
00388     double timefr, timeBase;        // Used for fps counter
00389     
00391     bool flagNightVision;
00392     
00393     QString configFile;
00394     QString startupScript;
00395     QSettings* confSettings;
00396     
00397     // Define whether the StelApp instance has completed initialization
00398     bool initialized;
00399     
00400     static QTime* qtime;
00401     
00402     // Temporary variables used to store the last gl window resize
00403     // if the core was not yet initialized
00404     int saveProjW;
00405     int saveProjH;
00406     
00408     int nbDownloadedFiles;
00410     qint64 totalDownloadedSize;
00411     
00413     int nbUsedCache;
00415     qint64 totalUsedCacheSize;
00416     
00417     static QFile logFile;
00418     static QString log;
00419 };
00420 
00421 #endif // _STELAPP_HPP_

Generated on Mon Feb 2 17:23:47 2009 for Stellarium by  doxygen 1.5.5