Stellarium 0.12.4
StelApp.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2006 Fabien Chereau
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STELAPP_HPP_
21 #define _STELAPP_HPP_
22 
23 #include <QString>
24 #include <QVariant>
25 #include <QObject>
26 
27 // Predeclaration of some classes
28 class StelCore;
29 class StelObjectMgr;
30 class StelLocaleMgr;
31 class StelModuleMgr;
32 class StelSkyCultureMgr;
33 class StelShortcutMgr;
34 class QSettings;
35 class QNetworkAccessManager;
36 class QNetworkReply;
37 class QTime;
38 class QTimer;
39 class StelLocationMgr;
40 class StelSkyLayerMgr;
41 class StelAudioMgr;
42 class StelVideoMgr;
43 class StelGuiBase;
44 
56 class StelApp : public QObject
57 {
58  Q_OBJECT
59 
60 public:
61  friend class StelAppGraphicsWidget;
62 
68  StelApp(QObject* parent=NULL);
69 
71  virtual ~StelApp();
72 
74  void init(QSettings* conf, class StelRenderer* renderer);
75 
77  void initPlugIns();
78 
81  static StelApp& getInstance() {Q_ASSERT(singleton); return *singleton;}
82 
85  StelModuleMgr& getModuleMgr() {return *moduleMgr;}
86 
89  StelLocaleMgr& getLocaleMgr() {return *localeMgr;}
90 
93  StelSkyCultureMgr& getSkyCultureMgr() {return *skyCultureMgr;}
94 
97  StelLocationMgr& getLocationMgr() {return *planetLocationMgr;}
98 
101  StelObjectMgr& getStelObjectMgr() {return *stelObjectMgr;}
102 
103  StelSkyLayerMgr& getSkyImageMgr() {return *skyImageMgr;}
104 
106  StelAudioMgr* getStelAudioMgr() {return audioMgr;}
107 
109  StelShortcutMgr* getStelShortcutManager() {return shortcutMgr;}
110 
112  StelVideoMgr* getStelVideoMgr() {return videoMgr;}
113 
117  StelCore* getCore() {return core;}
118 
120  QNetworkAccessManager* getNetworkAccessManager() {return networkAccessManager;}
121 
123  void updateI18n();
124 
126  void updateSkyCulture();
127 
129  QSettings* getSettings() {return confSettings;}
130 
132  QString getCurrentStelStyle() {return flagNightVision ? "night_color" : "color";}
133 
135  void update(double deltaTime);
136 
141  bool drawPartial(class StelRenderer* renderer);
142 
144  void windowHasBeenResized(float x, float y, float w, float h);
145 
147  StelGuiBase* getGui() const {return stelGui;}
150  void setGui(StelGuiBase* b) {stelGui=b;}
151 
152  static void initStatic();
153  static void deinitStatic();
154 
156  bool getRenderSolarShadows() const;
157 
159  // Scriptable methods
160 public slots:
161 
163  void setRenderSolarShadows(bool);
164 
166  void setVisionModeNight(bool);
168  bool getVisionModeNight() const {return flagNightVision;}
169 
172  float getFps() const {return fps;}
173 
175  static double getTotalRunTime();
176 
179  void reportFileDownloadFinished(QNetworkReply* reply);
180 
181 signals:
182  void colorSchemeChanged(const QString&);
183  void languageChanged();
184  void skyCultureChanged(const QString&);
185 
186 private:
187 
189  void handleClick(class QMouseEvent* event);
191  void handleWheel(class QWheelEvent* event);
193  void handleMove(int x, int y, Qt::MouseButtons b);
195  void handleKeys(class QKeyEvent* event);
196 
197  // The StelApp singleton
198  static StelApp* singleton;
199 
200  // The associated StelCore instance
201  StelCore* core;
202 
203  // Module manager for the application
204  StelModuleMgr* moduleMgr;
205 
206  // Locale manager for the application
207  StelLocaleMgr* localeMgr;
208 
209  // Sky cultures manager for the application
210  StelSkyCultureMgr* skyCultureMgr;
211 
212  //Shortcuts manager for the application
213  StelShortcutMgr* shortcutMgr;
214 
215  // Manager for all the StelObjects of the program
216  StelObjectMgr* stelObjectMgr;
217 
218  // Manager for the list of observer locations on planets
219  StelLocationMgr* planetLocationMgr;
220 
221  // Main network manager used for the program
222  QNetworkAccessManager* networkAccessManager;
223 
225  void setupHttpProxy();
226 
227  // The audio manager. Must execute in the main thread.
228  StelAudioMgr* audioMgr;
229 
230  // The video manager. Must execute in the main thread.
231  StelVideoMgr* videoMgr;
232 
233  StelSkyLayerMgr* skyImageMgr;
234 
235  StelGuiBase* stelGui;
236 
237  // Used to collect wheel events
238  QTimer * wheelEventTimer;
239 
240  float fps;
241  int frame;
242  double timefr, timeBase; // Used for fps counter
243 
245  bool flagNightVision;
246 
248  bool renderSolarShadows;
249 
250  QSettings* confSettings;
251 
252  // Define whether the StelApp instance has completed initialization
253  bool initialized;
254 
255  static QTime* qtime;
256 
257  // Temporary variables used to store the last window resize
258  // if the core was not yet initialized
259  int saveProjW;
260  int saveProjH;
261 
263  int nbDownloadedFiles;
265  qint64 totalDownloadedSize;
266 
268  int nbUsedCache;
270  qint64 totalUsedCacheSize;
271 
273  int drawState;
274 };
275 
276 #endif // _STELAPP_HPP_