Stellarium 0.15.2
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
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  */
21 #ifndef _SCENERY3DMGR_HPP_
22 #define _SCENERY3DMGR_HPP_
24 #include <QMap>
25 #include <QStringList>
26 #include <QFont>
27 #include <QtConcurrent>
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"
37 #include "SceneInfo.hpp"
38 #include "S3DEnum.hpp"
40 class Scenery3d;
41 class Scenery3dDialog;
42 class StoredViewDialog;
43 class QSettings;
44 class StelButton;
48 class Scenery3dMgr : public StelModule
49 {
52  // toggle to switch it off completely.
53  Q_PROPERTY(bool enableScene READ getEnableScene WRITE setEnableScene NOTIFY enableSceneChanged)
54  Q_PROPERTY(bool enablePixelLighting READ getEnablePixelLighting WRITE setEnablePixelLighting NOTIFY enablePixelLightingChanged)
55  Q_PROPERTY(bool enableShadows READ getEnableShadows WRITE setEnableShadows NOTIFY enableShadowsChanged)
56  Q_PROPERTY(bool useSimpleShadows READ getUseSimpleShadows WRITE setUseSimpleShadows NOTIFY useSimpleShadowsChanged)
57  Q_PROPERTY(bool enableBumps READ getEnableBumps WRITE setEnableBumps NOTIFY enableBumpsChanged)
58  Q_PROPERTY(S3DEnum::ShadowFilterQuality shadowFilterQuality READ getShadowFilterQuality WRITE setShadowFilterQuality NOTIFY shadowFilterQualityChanged)
59  Q_PROPERTY(bool enablePCSS READ getEnablePCSS WRITE setEnablePCSS NOTIFY enablePCSSChanged)
60  Q_PROPERTY(S3DEnum::CubemappingMode cubemappingMode READ getCubemappingMode WRITE setCubemappingMode NOTIFY cubemappingModeChanged)
61  Q_PROPERTY(bool useFullCubemapShadows READ getUseFullCubemapShadows WRITE setUseFullCubemapShadows NOTIFY useFullCubemapShadowsChanged)
62  Q_PROPERTY(bool enableDebugInfo READ getEnableDebugInfo WRITE setEnableDebugInfo NOTIFY enableDebugInfoChanged)
63  Q_PROPERTY(bool enableLocationInfo READ getEnableLocationInfo WRITE setEnableLocationInfo NOTIFY enableLocationInfoChanged)
64  Q_PROPERTY(bool enableTorchLight READ getEnableTorchLight WRITE setEnableTorchLight NOTIFY enableTorchLightChanged)
65  Q_PROPERTY(float torchStrength READ getTorchStrength WRITE setTorchStrength NOTIFY torchStrengthChanged)
66  Q_PROPERTY(float torchRange READ getTorchRange WRITE setTorchRange NOTIFY torchRangeChanged)
67  Q_PROPERTY(bool enableLazyDrawing READ getEnableLazyDrawing WRITE setEnableLazyDrawing NOTIFY enableLazyDrawingChanged)
68  Q_PROPERTY(double lazyDrawingInterval READ getLazyDrawingInterval WRITE setLazyDrawingInterval NOTIFY lazyDrawingIntervalChanged)
69  Q_PROPERTY(bool onlyDominantFaceWhenMoving READ getOnlyDominantFaceWhenMoving WRITE setOnlyDominantFaceWhenMoving NOTIFY onlyDominantFaceWhenMovingChanged)
70  Q_PROPERTY(bool secondDominantFaceWhenMoving READ getSecondDominantFaceWhenMoving WRITE setSecondDominantFaceWhenMoving NOTIFY secondDominantFaceWhenMovingChanged)
71  Q_PROPERTY(uint cubemapSize READ getCubemapSize WRITE setCubemapSize NOTIFY cubemapSizeChanged)
72  Q_PROPERTY(uint shadowmapSize READ getShadowmapSize WRITE setShadowmapSize NOTIFY shadowmapSizeChanged)
74  //these properties are only valid after init() has been called
75  Q_PROPERTY(bool isGeometryShaderSupported READ getIsGeometryShaderSupported)
76  Q_PROPERTY(bool areShadowsSupported READ getAreShadowsSupported)
77  Q_PROPERTY(bool isShadowFilteringSupported READ getIsShadowFilteringSupported)
79  Q_PROPERTY(uint maximumFramebufferSize READ getMaximumFramebufferSize)
81 public:
82  Scenery3dMgr();
83  virtual ~Scenery3dMgr();
85  //StelModule members
86  virtual void init();
87  virtual void deinit();
88  virtual void draw(StelCore* core);
89  virtual void update(double deltaTime);
90  virtual double getCallOrder(StelModuleActionName actionName) const;
91  virtual bool configureGui(bool show);
92  virtual void handleKeys(QKeyEvent* e);
95  void updateProgress(const QString& str, int val, int min, int max);
96 signals:
97  void enableSceneChanged(const bool val);
98  void enablePixelLightingChanged(const bool val);
99  void enableShadowsChanged(const bool val);
100  void useSimpleShadowsChanged(const bool val);
101  void enableBumpsChanged(const bool val);
102  void shadowFilterQualityChanged(const S3DEnum::ShadowFilterQuality val);
103  void enablePCSSChanged(const bool val);
104  void cubemappingModeChanged(const S3DEnum::CubemappingMode val);
105  void useFullCubemapShadowsChanged(const bool val);
106  void enableDebugInfoChanged(const bool val);
107  void enableLocationInfoChanged(const bool val);
108  void enableTorchLightChanged(const bool val);
109  void torchStrengthChanged(const float val);
110  void torchRangeChanged(const float val);
111  void enableLazyDrawingChanged(const bool val);
112  void lazyDrawingIntervalChanged(const double val);
113  void onlyDominantFaceWhenMovingChanged(const bool val);
114  void secondDominantFaceWhenMovingChanged(const bool val);
115  void cubemapSizeChanged(const uint val);
116  void shadowmapSizeChanged(const uint val);
118  void currentSceneChanged(const SceneInfo& sceneInfo);
121  void progressReport(const QString& str, int val, int min, int max);
123 public slots:
125  void reloadShaders();
128  void showMessage(const QString& message);
131  void showStoredViewDialog();
134  void setEnableScene(const bool val);
135  bool getEnableScene() const {return flagEnabled; }
137  void setEnablePixelLighting(const bool val);
138  bool getEnablePixelLighting(void) const;
142  void setEnableShadows(const bool enableShadows);
143  bool getEnableShadows(void) const;
146  void setUseSimpleShadows(const bool simpleShadows);
147  bool getUseSimpleShadows() const;
151  void setEnableBumps(const bool enableBumps);
152  bool getEnableBumps(void) const;
159  void setEnablePCSS(const bool val);
160  bool getEnablePCSS() const;
167  bool getUseFullCubemapShadows() const;
168  void setUseFullCubemapShadows(const bool useFullCubemapShadows);
171  void setEnableDebugInfo(const bool debugEnabled);
172  bool getEnableDebugInfo() const;
175  void setEnableLocationInfo(const bool enableLocationInfo);
176  bool getEnableLocationInfo() const;
179  void setEnableTorchLight(const bool enableTorchLight);
180  bool getEnableTorchLight() const;
183  void setTorchStrength(const float torchStrength);
184  float getTorchStrength() const;
187  void setTorchRange(const float torchRange);
188  float getTorchRange() const;
191  void setEnableLazyDrawing(const bool val);
192  bool getEnableLazyDrawing() const;
195  void setOnlyDominantFaceWhenMoving(const bool val);
196  bool getOnlyDominantFaceWhenMoving() const;
198  void setSecondDominantFaceWhenMoving(const bool val);
199  bool getSecondDominantFaceWhenMoving() const;
202  void forceCubemapRedraw();
205  void setLazyDrawingInterval(const double val);
206  double getLazyDrawingInterval() const;
210  void setCubemapSize(const uint val);
211  uint getCubemapSize() const;
215  void setShadowmapSize(const uint val);
216  uint getShadowmapSize() const;
218  //these properties are only valid after init() has been called
219  bool getIsGeometryShaderSupported() const;
220  bool getAreShadowsSupported() const;
221  bool getIsShadowFilteringSupported() const;
222  bool getIsANGLE() const;
223  uint getMaximumFramebufferSize() const;
227  SceneInfo getCurrentScene() const;
231  SceneInfo getLoadingScene() const { return currentLoadScene; }
236  SceneInfo loadScenery3dByName(const QString& name);
240  SceneInfo loadScenery3dByID(const QString& id);
242  QString getDefaultScenery3dID() const { return defaultScenery3dID; }
243  void setDefaultScenery3dID(const QString& id);
246  void setView(const StoredView& view, const bool setDate);
251 private slots:
252  void clearMessage();
253  void loadSceneCompleted();
254  void progressReceive(const QString& str, int val, int min, int max);
255  void loadScene(const SceneInfo& scene);
257 private:
259  void loadConfig();
261  void createActions();
263  void createToolbarButtons() const;
266  bool loadSceneBackground();
268  // the other "main" objects
269  Scenery3d* scenery3d;
270  Scenery3dDialog* scenery3dDialog;
271  StoredViewDialog* storedViewDialog;
273  QSettings* conf;
274  QString defaultScenery3dID;
275  bool flagEnabled;
276  bool cleanedUp;
278  StelCore::ProjectionType oldProjectionType;
280  //screen messages (taken largely from AngleMeasure as of 2012-01-21)
281  LinearFader messageFader;
282  QTimer* messageTimer;
283  Vec3f textColor;
284  QFont font;
285  QString currentMessage;
287  StelProgressController* progressBar;
288  SceneInfo currentLoadScene;
289  QFutureWatcher<bool> currentLoadFuture;
290 };
293 #include <QObject>
294 #include "StelPluginInterface.hpp"
297 class Scenery3dStelPluginInterface : public QObject, public StelPluginInterface
298 {
300  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
301  Q_INTERFACES(StelPluginInterface)
302 public:
303  virtual StelModule* getStelModule() const;
304  virtual StelPluginInfo getPluginInfo() const;
305 };
308 #endif
void setEnableLocationInfo(const bool enableLocationInfo)
Set to true to show the current standing positin as text on screen.
S3DEnum::CubemappingMode getCubemappingMode(void) const
Returns the current cubemapping mode.
void setUseSimpleShadows(const bool simpleShadows)
If true, only 1 shadow cascade is used, giving a speedup.
void setCubemappingMode(const S3DEnum::CubemappingMode val)
Sets the cubemapping mode.
StoredView getCurrentView()
Returns a StoredView that represents the current observer position + view direction.
void setOnlyDominantFaceWhenMoving(const bool val)
When true, only the face which currently is most dominantly visible is updated while moving...
Define the interface to implement when creating a plugin.
void setShadowFilterQuality(const S3DEnum::ShadowFilterQuality val)
Sets the shadow filter quality.
void setLazyDrawingInterval(const double val)
Sets the interval for cubemap lazy-drawing mode.
void setEnableShadows(const bool enableShadows)
Use this to set/get the enableShadows flag.
Contains all the metadata necessary for a Scenery3d scene, and can be loaded from special ...
Definition: SceneInfo.hpp:34
void forceCubemapRedraw()
Forces a redraw of the cubemap.
Implementation of StelFader which implements a linear transition.
Definition: StelFader.hpp:77
virtual bool configureGui(bool show)
Detect or show the configuration GUI elements for the module.
void setTorchRange(const float torchRange)
Sets the range of the torchlight.
void reloadShaders()
Clears the shader cache, forcing a reload of shaders on use.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
void setEnableScene(const bool val)
Enables/Disables the plugin.
void setCubemapSize(const uint val)
Sets the size used for cubemap rendering.
S3DEnum::ShadowFilterQuality getShadowFilterQuality(void) const
Returns the current shadow filter quality.
Main class of the module, inherits from StelModule.
virtual void init()
Initialize itself.
void setEnableTorchLight(const bool enableTorchLight)
Set to true to add an additional light source centered at the current position, useful in night scene...
SceneInfo getLoadingScene() const
Gets the SceneInfo of the scene that is currently in the process of being loaded. ...
void setEnableLazyDrawing(const bool val)
Sets the state of the cubemap lazy-drawing mode.
void showStoredViewDialog()
Shows the stored view dialog.
Representation of a complete 3D scenery.
Definition: Scenery3d.hpp:45
void showMessage(const QString &message)
Display text message on screen, fade out automatically.
Contains different shadow filter settings.
Definition: S3DEnum.hpp:46
A Button Graphicsitem for use in Stellarium&#39;s graphic widgets.
void progressReport(const QString &str, int val, int min, int max)
This signal is emitted from another thread than this QObject belongs to, so use QueuedConnection.
virtual void draw(StelCore *core)
Execute all the drawing functions for this module.
virtual void deinit()
Called before the module will be delete, and before the openGL context is suppressed.
Available projection types.
Definition: StelCore.hpp:86
Determines the method used for cubemap creation.
Definition: S3DEnum.hpp:35
virtual void handleKeys(QKeyEvent *e)
Handle key events.
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
Maintain the state of a progress bar.
virtual void update(double deltaTime)
Update the module with respect to the time.
SceneInfo loadScenery3dByID(const QString &id)
This starts the scene loading process.
void setView(const StoredView &view, const bool setDate)
Changes the current view to the given view. JD is updated only if view contains valid data and setDat...
void updateProgress(const QString &str, int val, int min, int max)
Sends the progressReport() signal, which eventually updates the progress bar. Can be called from anot...
SceneInfo loadScenery3dByName(const QString &name)
This starts the scene loading process.
void setEnableDebugInfo(const bool debugEnabled)
Set to true to show some rendering debug information.
A structure which stores a specific view position, view direction and FOV, together with a textual de...
Definition: SceneInfo.hpp:152
SceneInfo getCurrentScene() const
Gets the SceneInfo of the scene that is currently being displayed.
void setEnableBumps(const bool enableBumps)
Use this to set/get the enableBumps flag.
void setTorchStrength(const float torchStrength)
Sets the strength of the additional illumination that can be toggled when pressing a button...
void setShadowmapSize(const uint val)
Sets the size used for shadowmap rendering.
virtual double getCallOrder(StelModuleActionName actionName) const
Return the value defining the order of call for the given action For example if stars.callOrder[ActionDraw] == 10 and constellation.callOrder[ActionDraw] == 11, the stars module will be drawn before the constellations.
This class is used by Qt to manage a plug-in interface.
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49
Contains information about a Stellarium plugin.