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     StelLocationMgr& getLocationMgr() {return *planetLocationMgr;}
00114     
00117     StelObjectMgr& getStelObjectMgr() {return *stelObjectMgr;}
00118     
00121     StelSkyImageMgr& getSkyImageMgr() {return *skyImageMgr;}
00122     
00125     StelFileMgr& getFileMgr() {return *stelFileMgr;}
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();
00181     static QString getApplicationVersion();
00182     
00184     void setVisionModeNight(bool);
00186     bool getVisionModeNight() const {return flagNightVision;}
00187 
00193     void setMinFps(float m) {minfps=m; emit(minFpsChanged());}
00195     float getMinFps() {return minfps;}
00198     void setMaxFps(float m) {maxfps = m;}
00200     float getMaxFps() {return maxfps;}
00201     
00204     float getFps() const {return fps;}
00205 
00207     static double getTotalRunTime();
00208 
00211     void reportFileDownloadFinished(QNetworkReply* reply);
00212     
00213 signals:
00214     void minFpsChanged();
00215     
00216 private:
00218     void update(double deltaTime);
00219 
00222     void draw();
00223     
00225     void handleClick(class QMouseEvent* event);
00227     void handleWheel(class QWheelEvent* event);
00229     void handleMove(int x, int y, Qt::MouseButtons b);
00231     void handleKeys(class QKeyEvent* event);
00232 
00234     void glWindowHasBeenResized(int w, int h);
00235 
00237     void setColorScheme(const QString& section);
00238     
00245     void setConfigFile(const QString& configName, bool restoreDefaults=false);
00246     
00250     void copyDefaultConfigFile();
00251 
00253     QStringList* argList;
00254     
00260     bool argsGetOption(QStringList* args, QString shortOpt, QString longOpt);
00261     
00289     template<class T>
00290             T argsGetOptionWithArg(QStringList* args, QString shortOpt, QString longOpt, T defaultValue);
00291     
00312     int argsGetYesNoOption(QStringList* args, QString shortOpt, QString longOpt, int defaultValue);
00313     
00318     void parseCLIArgsPreConfig(void);   
00319 
00323     void parseCLIArgsPostConfig();
00324     
00326     void setupLog();
00327     
00330     static void writeLog(QString msg);
00331 
00332     // The StelApp singleton
00333     static StelApp* singleton;
00334 
00335     // The associated StelCore instance
00336     StelCore* core;
00337 
00338     // Module manager for the application
00339     StelModuleMgr* moduleMgr;
00340     
00341     // Font manager for the application
00342     StelFontMgr* fontManager;
00343     
00344     // Locale manager for the application
00345     StelLocaleMgr* localeMgr;
00346     
00347     // Sky cultures manager for the application
00348     StelSkyCultureMgr* skyCultureMgr;
00349     
00350     // Textures manager for the application
00351     StelTextureMgr* textureMgr;
00352     
00353     // Manager for all the StelObjects of the program
00354     StelObjectMgr* stelObjectMgr;
00355 
00356     // Manager for the list of observer locations on planets
00357     StelLocationMgr* planetLocationMgr;
00358     
00360     StelFileMgr* stelFileMgr;
00361     
00362     // Main network manager used for the program
00363     QNetworkAccessManager* networkAccessManager;
00364 
00365     // The audio manager.  Must execute in the main thread.
00366     StelAudioMgr* audioMgr;
00367     
00368     // The script manager based on Qt script engine
00369     StelScriptMgr* scriptMgr;
00370     
00371     // The main loading bar
00372     StelLoadingBar* loadingBar;
00373     
00374     // Currently used StelStyle
00375     StelStyle* currentStelStyle;
00376     
00377     // Download manager that uses networkAccessManager
00378     StelDownloadMgr* downloadMgr;
00379     
00380     StelSkyImageMgr* skyImageMgr;
00381     
00382     float fps;
00384     float minfps;
00386     float maxfps;
00387     
00388     int frame;
00389     double timefr, timeBase;        // Used for fps counter
00390     
00392     bool flagNightVision;
00393     
00394     QString configFile;
00395     QString startupScript;
00396     QSettings* confSettings;
00397     
00398     // Define whether the StelApp instance has completed initialization
00399     bool initialized;
00400     
00401     static QTime* qtime;
00402     
00403     // Temporary variables used to store the last gl window resize
00404     // if the core was not yet initialized
00405     int saveProjW;
00406     int saveProjH;
00407     
00409     int nbDownloadedFiles;
00411     qint64 totalDownloadedSize;
00412     
00414     int nbUsedCache;
00416     qint64 totalUsedCacheSize;
00417     
00418     static QFile logFile;
00419     static QString log;
00420 };
00421 
00422 #endif // _STELAPP_HPP_

Generated on Mon Mar 9 16:16:15 2009 for Stellarium by  doxygen 1.5.5