Stellarium  0.16.1
Scenery3d.hpp
1 /*
2  * Stellarium Scenery3d Plug-in
3  *
4  * Copyright (C) 2011 Simon Parzer, Peter Neubauer, Georg Zotti, Andrei Borza
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19  */
20 
21 #ifndef _SCENERY3D_HPP_
22 #define _SCENERY3D_HPP_
23 
24 #include <QMap>
25 #include <QStringList>
26 #include <QFont>
27 #include <QtConcurrent>
28 
29 #include "StelCore.hpp"
30 #include "StelPluginInterface.hpp"
31 #include "StelModule.hpp"
32 #include "StelUtils.hpp"
33 #include "StelFader.hpp"
34 #include "StelActionMgr.hpp"
35 #include "StelProgressController.hpp"
36 
37 #include "SceneInfo.hpp"
38 #include "S3DEnum.hpp"
39 
40 class S3DRenderer;
41 class Scenery3dDialog;
42 class StoredViewDialog;
43 class QSettings;
44 class StelButton;
45 class S3DScene;
46 
47 Q_DECLARE_LOGGING_CATEGORY(scenery3d)
48 
49 class Scenery3d : public StelModule
52 {
53  Q_OBJECT
54 
55  // toggle to switch it off completely.
56  Q_PROPERTY(bool enableScene READ getEnableScene WRITE setEnableScene NOTIFY enableSceneChanged)
57  Q_PROPERTY(bool enablePixelLighting READ getEnablePixelLighting WRITE setEnablePixelLighting NOTIFY enablePixelLightingChanged)
58  Q_PROPERTY(bool enableShadows READ getEnableShadows WRITE setEnableShadows NOTIFY enableShadowsChanged)
59  Q_PROPERTY(bool useSimpleShadows READ getUseSimpleShadows WRITE setUseSimpleShadows NOTIFY useSimpleShadowsChanged)
60  Q_PROPERTY(bool enableBumps READ getEnableBumps WRITE setEnableBumps NOTIFY enableBumpsChanged)
61  Q_PROPERTY(S3DEnum::ShadowFilterQuality shadowFilterQuality READ getShadowFilterQuality WRITE setShadowFilterQuality NOTIFY shadowFilterQualityChanged)
62  Q_PROPERTY(bool enablePCSS READ getEnablePCSS WRITE setEnablePCSS NOTIFY enablePCSSChanged)
63  Q_PROPERTY(S3DEnum::CubemappingMode cubemappingMode READ getCubemappingMode WRITE setCubemappingMode NOTIFY cubemappingModeChanged)
64  Q_PROPERTY(bool useFullCubemapShadows READ getUseFullCubemapShadows WRITE setUseFullCubemapShadows NOTIFY useFullCubemapShadowsChanged)
65  Q_PROPERTY(bool enableDebugInfo READ getEnableDebugInfo WRITE setEnableDebugInfo NOTIFY enableDebugInfoChanged)
66  Q_PROPERTY(bool enableLocationInfo READ getEnableLocationInfo WRITE setEnableLocationInfo NOTIFY enableLocationInfoChanged)
67  Q_PROPERTY(bool enableTorchLight READ getEnableTorchLight WRITE setEnableTorchLight NOTIFY enableTorchLightChanged)
68  Q_PROPERTY(float torchStrength READ getTorchStrength WRITE setTorchStrength NOTIFY torchStrengthChanged)
69  Q_PROPERTY(float torchRange READ getTorchRange WRITE setTorchRange NOTIFY torchRangeChanged)
70  Q_PROPERTY(bool enableLazyDrawing READ getEnableLazyDrawing WRITE setEnableLazyDrawing NOTIFY enableLazyDrawingChanged)
71  Q_PROPERTY(double lazyDrawingInterval READ getLazyDrawingInterval WRITE setLazyDrawingInterval NOTIFY lazyDrawingIntervalChanged)
72  Q_PROPERTY(bool onlyDominantFaceWhenMoving READ getOnlyDominantFaceWhenMoving WRITE setOnlyDominantFaceWhenMoving NOTIFY onlyDominantFaceWhenMovingChanged)
73  Q_PROPERTY(bool secondDominantFaceWhenMoving READ getSecondDominantFaceWhenMoving WRITE setSecondDominantFaceWhenMoving NOTIFY secondDominantFaceWhenMovingChanged)
74  Q_PROPERTY(uint cubemapSize READ getCubemapSize WRITE setCubemapSize NOTIFY cubemapSizeChanged)
75  Q_PROPERTY(uint shadowmapSize READ getShadowmapSize WRITE setShadowmapSize NOTIFY shadowmapSizeChanged)
76  Q_PROPERTY(QString currentSceneID READ getCurrentSceneID NOTIFY currentSceneIDChanged STORED false)
77  Q_PROPERTY(QString loadingSceneID READ getLoadingSceneID NOTIFY loadingSceneIDChanged STORED false)
78 
79  //these properties are only valid after init() has been called
80  Q_PROPERTY(bool isGeometryShaderSupported READ getIsGeometryShaderSupported)
81  Q_PROPERTY(bool areShadowsSupported READ getAreShadowsSupported)
82  Q_PROPERTY(bool isShadowFilteringSupported READ getIsShadowFilteringSupported)
83  Q_PROPERTY(bool isANGLE READ getIsANGLE)
84  Q_PROPERTY(uint maximumFramebufferSize READ getMaximumFramebufferSize)
85 
86 public:
87  Scenery3d();
88  virtual ~Scenery3d();
89 
90  //StelModule members
91  virtual void init();
92  virtual void deinit();
93  virtual void draw(StelCore* core);
94  virtual void update(double deltaTime);
95  virtual double getCallOrder(StelModuleActionName actionName) const;
96  virtual bool configureGui(bool show);
101  virtual void handleKeys(QKeyEvent* e);
102 
104  void updateProgress(const QString& str, int val, int min, int max) const;
105 signals:
106  void enableSceneChanged(const bool val);
107  void enablePixelLightingChanged(const bool val);
108  void enableShadowsChanged(const bool val);
109  void useSimpleShadowsChanged(const bool val);
110  void enableBumpsChanged(const bool val);
111  void shadowFilterQualityChanged(const S3DEnum::ShadowFilterQuality val);
112  void enablePCSSChanged(const bool val);
113  void cubemappingModeChanged(const S3DEnum::CubemappingMode val);
114  void useFullCubemapShadowsChanged(const bool val);
115  void enableDebugInfoChanged(const bool val);
116  void enableLocationInfoChanged(const bool val);
117  void enableTorchLightChanged(const bool val);
118  void torchStrengthChanged(const float val);
119  void torchRangeChanged(const float val);
120  void enableLazyDrawingChanged(const bool val);
121  void lazyDrawingIntervalChanged(const double val);
122  void onlyDominantFaceWhenMovingChanged(const bool val);
123  void secondDominantFaceWhenMovingChanged(const bool val);
124  void cubemapSizeChanged(const uint val);
125  void shadowmapSizeChanged(const uint val);
126 
127  void currentSceneChanged(const SceneInfo& sceneInfo);
128  void currentSceneIDChanged(const QString& sceneID);
129  void loadingSceneIDChanged(const QString& sceneID);
130 
132  void progressReport(const QString& str, int val, int min, int max) const;
133 
134 public slots:
143  void relativeMove(const Vec3d& move);
144 
146  void reloadShaders();
147 
149  void showMessage(const QString& message);
150 
152  void showStoredViewDialog();
153 
155  void setEnableScene(const bool val);
156  bool getEnableScene() const {return flagEnabled; }
157 
158  void setEnablePixelLighting(const bool val);
159  bool getEnablePixelLighting(void) const;
160 
163  void setEnableShadows(const bool enableShadows);
164  bool getEnableShadows(void) const;
165 
167  void setUseSimpleShadows(const bool simpleShadows);
168  bool getUseSimpleShadows() const;
169 
172  void setEnableBumps(const bool enableBumps);
173  bool getEnableBumps(void) const;
174 
176  S3DEnum::ShadowFilterQuality getShadowFilterQuality(void) const;
178  void setShadowFilterQuality(const S3DEnum::ShadowFilterQuality val);
179 
180  void setEnablePCSS(const bool val);
181  bool getEnablePCSS() const;
182 
184  S3DEnum::CubemappingMode getCubemappingMode(void) const;
186  void setCubemappingMode(const S3DEnum::CubemappingMode val);
187 
188  bool getUseFullCubemapShadows() const;
189  void setUseFullCubemapShadows(const bool useFullCubemapShadows);
190 
192  void setEnableDebugInfo(const bool debugEnabled);
193  bool getEnableDebugInfo() const;
194 
196  void setEnableLocationInfo(const bool enableLocationInfo);
197  bool getEnableLocationInfo() const;
198 
200  void setEnableTorchLight(const bool enableTorchLight);
201  bool getEnableTorchLight() const;
202 
204  void setTorchStrength(const float torchStrength);
205  float getTorchStrength() const;
206 
208  void setTorchRange(const float torchRange);
209  float getTorchRange() const;
210 
212  void setEnableLazyDrawing(const bool val);
213  bool getEnableLazyDrawing() const;
214 
216  void setOnlyDominantFaceWhenMoving(const bool val);
217  bool getOnlyDominantFaceWhenMoving() const;
218 
219  void setSecondDominantFaceWhenMoving(const bool val);
220  bool getSecondDominantFaceWhenMoving() const;
221 
223  void forceCubemapRedraw();
224 
226  void setLazyDrawingInterval(const double val);
227  double getLazyDrawingInterval() const;
228 
231  void setCubemapSize(const uint val);
232  uint getCubemapSize() const;
233 
236  void setShadowmapSize(const uint val);
237  uint getShadowmapSize() const;
238 
239  //these properties are only valid after init() has been called
240  bool getIsGeometryShaderSupported() const;
241  bool getAreShadowsSupported() const;
242  bool getIsShadowFilteringSupported() const;
243  bool getIsANGLE() const;
244  uint getMaximumFramebufferSize() const;
245 
248  SceneInfo getCurrentScene() const;
249 
251  QString getCurrentSceneID() const;
252 
254  QString getLoadingSceneID() const;
255 
258  SceneInfo getLoadingScene() const { return currentLoadScene; }
259 
263  SceneInfo loadScenery3dByName(const QString& name);
267  SceneInfo loadScenery3dByID(const QString& id);
268 
269  QString getDefaultScenery3dID() const { return defaultScenery3dID; }
270  void setDefaultScenery3dID(const QString& id);
271 
273  void setView(const StoredView& view, const bool setDate);
276  StoredView getCurrentView();
277 
278 private slots:
279  void clearMessage();
280  void loadSceneCompleted();
281  void progressReceive(const QString& str, int val, int min, int max);
282  void loadScene(const SceneInfo& scene);
283 
284 private:
286  void loadConfig();
288  void createActions();
290  void createToolbarButtons() const;
291 
293  S3DScene *loadSceneBackground(const SceneInfo &scene) const;
294 
295  // the other "main" objects
296  S3DRenderer* renderer;
297  Scenery3dDialog* scenery3dDialog;
298  StoredViewDialog* storedViewDialog;
299 
300  QSettings* conf;
301  QString defaultScenery3dID;
302  bool flagEnabled;
303  bool cleanedUp;
304 
305  Vec3d movementKeyInput;
306 
307  StelCore* core;
308  StelMovementMgr* mvMgr;
309  StelCore::ProjectionType oldProjectionType;
310 
311  //screen messages (taken largely from AngleMeasure as of 2012-01-21)
312  LinearFader messageFader;
313  QTimer* messageTimer;
314  Vec3f textColor;
315  QFont font;
316  QString currentMessage;
317 
318  volatile bool loadCancel;
319  StelProgressController* progressBar;
320  SceneInfo currentLoadScene;
321  S3DScene* currentScene;
322  QFutureWatcher<S3DScene*> currentLoadFuture;
323 };
324 
325 
326 #include <QObject>
327 #include "StelPluginInterface.hpp"
328 
330 class Scenery3dStelPluginInterface : public QObject, public StelPluginInterface
331 {
332  Q_OBJECT
333  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
334  Q_INTERFACES(StelPluginInterface)
335 public:
336  virtual StelModule* getStelModule() const;
337  virtual StelPluginInfo getPluginInfo() const;
338  virtual QObjectList getExtensionList() const;
339 };
340 
341 
342 #endif // _SCENERY3D_HPP_
343 
Define the interface to implement when creating a plugin.
virtual QObjectList getExtensionList() const
A mechanism to provide abitrary QObjects to the StelModuleMgr.
Contains all the metadata necessary for a Scenery3d scene, and can be loaded from special ...
Definition: SceneInfo.hpp:37
virtual StelModule * getStelModule() const
Get the instance of StelModule to include in the list of standard StelModule.
Implementation of StelFader which implements a linear transition.
Definition: StelFader.hpp:77
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
Manages the head movements and zoom operations.
Main class of the module, inherits from StelModule.
Definition: Scenery3d.hpp:51
Scenery3d renderer class.
Definition: S3DRenderer.hpp:48
ShadowFilterQuality
Contains different shadow filter settings.
Definition: S3DEnum.hpp:46
A Button Graphicsitem for use in Stellarium&#39;s graphic widgets.
ProjectionType
Available projection types.
Definition: StelCore.hpp:86
CubemappingMode
Determines the method used for cubemap creation.
Definition: S3DEnum.hpp:35
virtual StelPluginInfo getPluginInfo() const
Get information about the plugin.
Maintain the state of a progress bar.
A templatized 3d vector compatible with openGL.
Definition: VecMath.hpp:33
A structure which stores a specific view position, view direction and FOV, together with a textual de...
Definition: SceneInfo.hpp:158
SceneInfo getLoadingScene() const
Gets the SceneInfo of the scene that is currently in the process of being loaded. ...
Definition: Scenery3d.hpp:258
This class is used by Qt to manage a plug-in interface.
Definition: Scenery3d.hpp:330
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49
Contains information about a Stellarium plugin.