![]() |
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure |
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 00027 // Predeclaration of some classes 00028 class StelCore; 00029 class StelTextureMgr; 00030 class StelObjectMgr; 00031 class StelLocaleMgr; 00032 class StelModuleMgr; 00033 class StelSkyCultureMgr; 00034 class QSettings; 00035 class QNetworkAccessManager; 00036 class QNetworkReply; 00037 class QTime; 00038 class StelLocationMgr; 00039 class StelSkyLayerMgr; 00040 class StelAudioMgr; 00041 class StelGuiBase; 00042 00054 class StelApp : public QObject 00055 { 00056 Q_OBJECT 00057 00058 public: 00059 friend class StelAppGraphicsWidget; 00060 00066 StelApp(QObject* parent=NULL); 00067 00069 virtual ~StelApp(); 00070 00072 void init(QSettings* conf); 00073 00075 void initPlugIns(); 00076 00079 static StelApp& getInstance() {Q_ASSERT(singleton); return *singleton;} 00080 00083 StelModuleMgr& getModuleMgr() {return *moduleMgr;} 00084 00087 StelLocaleMgr& getLocaleMgr() {return *localeMgr;} 00088 00091 StelSkyCultureMgr& getSkyCultureMgr() {return *skyCultureMgr;} 00092 00095 StelTextureMgr& getTextureManager() {return *textureMgr;} 00096 00099 StelLocationMgr& getLocationMgr() {return *planetLocationMgr;} 00100 00103 StelObjectMgr& getStelObjectMgr() {return *stelObjectMgr;} 00104 00107 StelSkyLayerMgr& getSkyImageMgr() {return *skyImageMgr;} 00108 00110 StelAudioMgr* getStelAudioMgr() {return audioMgr;} 00111 00115 StelCore* getCore() {return core;} 00116 00118 QNetworkAccessManager* getNetworkAccessManager() {return networkAccessManager;} 00119 00121 void updateI18n(); 00122 00124 void updateSkyCulture(); 00125 00127 QSettings* getSettings() {return confSettings;} 00128 00130 QString getCurrentStelStyle() {return flagNightVision ? "night_color" : "color";} 00131 00133 void update(double deltaTime); 00134 00137 void draw(); 00138 00143 bool drawPartial(); 00144 00146 void glWindowHasBeenResized(float x, float y, float w, float h); 00147 00149 StelGuiBase* getGui() const {return stelGui;} 00152 void setGui(StelGuiBase* b) {stelGui=b;} 00153 00154 static void initStatic(); 00155 static void deinitStatic(); 00156 00158 bool getUseGLShaders() const {return useGLShaders;} 00159 00161 // Scriptable methods 00162 public slots: 00163 00165 void setVisionModeNight(bool); 00167 bool getVisionModeNight() const {return flagNightVision;} 00168 00171 float getFps() const {return fps;} 00172 00174 static double getTotalRunTime(); 00175 00178 void reportFileDownloadFinished(QNetworkReply* reply); 00179 00180 private: 00181 00183 void handleClick(class QMouseEvent* event); 00185 void handleWheel(class QWheelEvent* event); 00187 void handleMove(int x, int y, Qt::MouseButtons b); 00189 void handleKeys(class QKeyEvent* event); 00190 00192 void setColorScheme(const QString& section); 00193 00194 00195 // The StelApp singleton 00196 static StelApp* singleton; 00197 00198 // The associated StelCore instance 00199 StelCore* core; 00200 00201 // Module manager for the application 00202 StelModuleMgr* moduleMgr; 00203 00204 // Locale manager for the application 00205 StelLocaleMgr* localeMgr; 00206 00207 // Sky cultures manager for the application 00208 StelSkyCultureMgr* skyCultureMgr; 00209 00210 // Textures manager for the application 00211 StelTextureMgr* textureMgr; 00212 00213 // Manager for all the StelObjects of the program 00214 StelObjectMgr* stelObjectMgr; 00215 00216 // Manager for the list of observer locations on planets 00217 StelLocationMgr* planetLocationMgr; 00218 00219 // Main network manager used for the program 00220 QNetworkAccessManager* networkAccessManager; 00221 00223 void setupHttpProxy(); 00224 00225 // The audio manager. Must execute in the main thread. 00226 StelAudioMgr* audioMgr; 00227 00228 StelSkyLayerMgr* skyImageMgr; 00229 00230 StelGuiBase* stelGui; 00231 00232 float fps; 00233 int frame; 00234 double timefr, timeBase; // Used for fps counter 00235 00237 bool flagNightVision; 00238 00240 bool useGLShaders; 00241 00242 QSettings* confSettings; 00243 00244 // Define whether the StelApp instance has completed initialization 00245 bool initialized; 00246 00247 static QTime* qtime; 00248 00249 // Temporary variables used to store the last gl window resize 00250 // if the core was not yet initialized 00251 int saveProjW; 00252 int saveProjH; 00253 00255 int nbDownloadedFiles; 00257 qint64 totalDownloadedSize; 00258 00260 int nbUsedCache; 00262 qint64 totalUsedCacheSize; 00263 00265 int drawState; 00266 }; 00267 00268 #endif // _STELAPP_HPP_