• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 4853788370

pending completion
4853788370

push

github

Alexander V. Wolf
Special patch for John Simple

3 of 3 new or added lines in 3 files covered. (100.0%)

14729 of 125046 relevant lines covered (11.78%)

20166.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/plugins/Scenery3d/src/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 "StelFader.hpp"
33
#include "StelProgressController.hpp"
34

35
#include "SceneInfo.hpp"
36
#include "S3DEnum.hpp"
37

38
class S3DRenderer;
39
class Scenery3dDialog;
40
class StoredViewDialog;
41
class QSettings;
42
class StelButton;
43
class S3DScene;
44

45
Q_DECLARE_LOGGING_CATEGORY(scenery3d)
46

47
/*! @defgroup scenery3D 3D Sceneries plug-in
48
@{
49
3D foreground renderer. Walk around, find and avoid obstructions in
50
your garden, find and demonstrate possible astronomical alignments
51
in temples, see shadows on sundials etc.
52

53
To move around, press Ctrl+cursor keys. To lift eye height, use Ctrl+PgUp/PgDn.
54
Movement speed is linked to field of view (i.e. zoom in for fine adjustments).
55
You can even keep moving by releasing Ctrl before cursor key.
56

57
Development of this plugin was in parts supported by the Austrian
58
Science Fund (FWF) project ASTROSIM (P 21208-G19).
59
More: http://astrosim.univie.ac.at/
60
@}
61
*/
62

63
//! @class Scenery3d
64
//! @ingroup scenery3D
65
//! Main class of the 3D Sceneries plug-in.
66
//! @authors Georg Zotti, Simon Parzer, Peter Neubauer, Andrei Borza, Florian Schaukowitsch
67

68
//! Main class of the module, inherits from StelModule.
69
//! Manages initialization, provides an interface to change Scenery3d properties and handles user input
70
class Scenery3d : public StelModule
71
{
72
        Q_OBJECT
73

74
        // toggle to switch it off completely.
75
        Q_PROPERTY(bool enableScene                  READ getEnableScene            WRITE setEnableScene           NOTIFY enableSceneChanged)
76
        Q_PROPERTY(bool enablePixelLighting          READ getEnablePixelLighting    WRITE setEnablePixelLighting   NOTIFY enablePixelLightingChanged)
77
        Q_PROPERTY(bool enableShadows                READ getEnableShadows          WRITE setEnableShadows         NOTIFY enableShadowsChanged)
78
        Q_PROPERTY(bool useSimpleShadows             READ getUseSimpleShadows       WRITE setUseSimpleShadows      NOTIFY useSimpleShadowsChanged)
79
        Q_PROPERTY(bool enableBumps                  READ getEnableBumps            WRITE setEnableBumps           NOTIFY enableBumpsChanged)
80
        Q_PROPERTY(S3DEnum::ShadowFilterQuality shadowFilterQuality READ getShadowFilterQuality WRITE setShadowFilterQuality NOTIFY shadowFilterQualityChanged)
81
        Q_PROPERTY(bool enablePCSS                   READ getEnablePCSS             WRITE setEnablePCSS            NOTIFY enablePCSSChanged)
82
        Q_PROPERTY(S3DEnum::CubemappingMode cubemappingMode READ getCubemappingMode WRITE setCubemappingMode       NOTIFY cubemappingModeChanged)
83
        Q_PROPERTY(bool useFullCubemapShadows        READ getUseFullCubemapShadows  WRITE setUseFullCubemapShadows NOTIFY useFullCubemapShadowsChanged)
84
        Q_PROPERTY(bool enableDebugInfo              READ getEnableDebugInfo        WRITE setEnableDebugInfo       NOTIFY enableDebugInfoChanged)
85
        Q_PROPERTY(bool enableLocationInfo           READ getEnableLocationInfo     WRITE setEnableLocationInfo    NOTIFY enableLocationInfoChanged)
86
        Q_PROPERTY(bool forceHorizonPolyline         READ getForceHorizonPolyline   WRITE setForceHorizonPolyline  NOTIFY forceHorizonPolylineChanged)
87
        Q_PROPERTY(bool enableTorchLight             READ getEnableTorchLight       WRITE setEnableTorchLight      NOTIFY enableTorchLightChanged)
88
        Q_PROPERTY(float torchStrength               READ getTorchStrength          WRITE setTorchStrength         NOTIFY torchStrengthChanged)
89
        Q_PROPERTY(float torchRange                  READ getTorchRange             WRITE setTorchRange            NOTIFY torchRangeChanged)
90
        Q_PROPERTY(bool enableLazyDrawing            READ getEnableLazyDrawing      WRITE setEnableLazyDrawing     NOTIFY enableLazyDrawingChanged)
91
        Q_PROPERTY(double lazyDrawingInterval        READ getLazyDrawingInterval    WRITE setLazyDrawingInterval   NOTIFY lazyDrawingIntervalChanged)
92
        Q_PROPERTY(bool onlyDominantFaceWhenMoving   READ getOnlyDominantFaceWhenMoving    WRITE setOnlyDominantFaceWhenMoving   NOTIFY onlyDominantFaceWhenMovingChanged)
93
        Q_PROPERTY(bool secondDominantFaceWhenMoving READ getSecondDominantFaceWhenMoving  WRITE setSecondDominantFaceWhenMoving NOTIFY secondDominantFaceWhenMovingChanged)
94
        Q_PROPERTY(uint cubemapSize                  READ getCubemapSize            WRITE setCubemapSize   NOTIFY cubemapSizeChanged)
95
        Q_PROPERTY(uint shadowmapSize                READ getShadowmapSize          WRITE setShadowmapSize NOTIFY shadowmapSizeChanged)
96
        Q_PROPERTY(QString currentSceneID            READ getCurrentSceneID         NOTIFY currentSceneIDChanged STORED false)
97
        Q_PROPERTY(QString loadingSceneID            READ getLoadingSceneID         NOTIFY loadingSceneIDChanged STORED false)
98

99
        //these properties are only valid after init() has been called
100
        Q_PROPERTY(bool isGeometryShaderSupported    READ getIsGeometryShaderSupported)
101
        Q_PROPERTY(bool areShadowsSupported          READ getAreShadowsSupported)
102
        Q_PROPERTY(bool isShadowFilteringSupported   READ getIsShadowFilteringSupported)
103
        Q_PROPERTY(bool isANGLE                      READ getIsANGLE)
104
        Q_PROPERTY(uint maximumFramebufferSize       READ getMaximumFramebufferSize)
105

106
public:
107
    Scenery3d();
108
    virtual ~Scenery3d() Q_DECL_OVERRIDE;
109

110
    //StelModule members
111
    virtual void init() Q_DECL_OVERRIDE;
112
    virtual void deinit() Q_DECL_OVERRIDE;
113
    virtual void draw(StelCore* core) Q_DECL_OVERRIDE;
114
    virtual void update(double deltaTime) Q_DECL_OVERRIDE;
115
    virtual double getCallOrder(StelModuleActionName actionName) const Q_DECL_OVERRIDE;
116
    virtual bool configureGui(bool show) Q_DECL_OVERRIDE;
117
    //! Walk/Fly Navigation with Ctrl+Cursor and Ctrl+PgUp/Dn keys.
118
    //! Pressing Ctrl-Alt: 5x, Ctrl-Shift: 10x speedup; Ctrl-Shift-Alt: 50x!
119
    //! To allow fine control, zoom in.
120
    //! If you release Ctrl key while pressing cursor key, movement will continue.
121
    virtual void handleKeys(QKeyEvent* e) Q_DECL_OVERRIDE;
122

123
    //! Sends the progressReport() signal, which eventually updates the progress bar. Can be called from another thread.
124
    void updateProgress(const QString& str, int val, int min, int max) const;
125
signals:
126
    void enableSceneChanged(const bool val);
127
    void enablePixelLightingChanged(const bool val);
128
    void enableShadowsChanged(const bool val);
129
    void useSimpleShadowsChanged(const bool val);
130
    void enableBumpsChanged(const bool val);
131
    void shadowFilterQualityChanged(const S3DEnum::ShadowFilterQuality val);
132
    void enablePCSSChanged(const bool val);
133
    void cubemappingModeChanged(const S3DEnum::CubemappingMode val);
134
    void useFullCubemapShadowsChanged(const bool val);
135
    void enableDebugInfoChanged(const bool val);
136
    void enableLocationInfoChanged(const bool val);
137
    void forceHorizonPolylineChanged(const bool val);
138
    void enableTorchLightChanged(const bool val);
139
    void torchStrengthChanged(const float val);
140
    void torchRangeChanged(const float val);
141
    void enableLazyDrawingChanged(const bool val);
142
    void lazyDrawingIntervalChanged(const double val);
143
    void onlyDominantFaceWhenMovingChanged(const bool val);
144
    void secondDominantFaceWhenMovingChanged(const bool val);
145
    void cubemapSizeChanged(const uint val);
146
    void shadowmapSizeChanged(const uint val);
147

148
    void currentSceneChanged(const SceneInfo& sceneInfo);
149
    void currentSceneIDChanged(const QString& sceneID);
150
    void loadingSceneIDChanged(const QString& sceneID);
151

152
    //! This signal is emitted from another thread than this QObject belongs to, so use QueuedConnection.
153
    void progressReport(const QString& str, int val, int min, int max) const; // ignore clazy warning here.
154

155
public slots:
156
    //! Performs a relative translation of the viewer's position.
157
    //! The values should usually be given pre-adjusted with the delta time.
158
    //! Does nothing if no scene is currently loaded.
159
    //!
160
    //! The first component specifies movement in the "right" direction, the second
161
    //! component in the "forward" direction, and the last value
162
    //! is used to adjust the height offset of the viewer (he is still
163
    //! positioned according to the heightmap).
164
    void relativeMove(const Vec3d& move);
165

166
    //! Clears the shader cache, forcing a reload of shaders on use
167
    void reloadShaders();
168

169
    //! Display text message on screen, fade out automatically
170
    void showMessage(const QString& message);
171

172
    //! Shows the stored view dialog
173
    void showStoredViewDialog();
174

175
    //! Enables/Disables the plugin
176
    void setEnableScene(const bool val);
177
    bool getEnableScene() const {return flagEnabled; }
×
178

179
    void setEnablePixelLighting(const bool val);
180
    bool getEnablePixelLighting(void) const;
181

182
    //! Use this to set/get the enableShadows flag.
183
    //! If set to true, shadow mapping is enabled for the 3D scene.
184
    void setEnableShadows(const bool enableShadows);
185
    bool getEnableShadows(void) const;
186

187
    //! If true, only 1 shadow cascade is used, giving a speedup
188
    void setUseSimpleShadows(const bool simpleShadows);
189
    bool getUseSimpleShadows() const;
190

191
    //! Use this to set/get the enableBumps flag.
192
    //! If set to true, bump mapping is enabled for the 3D scene.
193
    void setEnableBumps(const bool enableBumps);
194
    bool getEnableBumps(void) const;
195

196
    //! Returns the current shadow filter quality.
197
    S3DEnum::ShadowFilterQuality getShadowFilterQuality(void) const;
198
    //! Sets the shadow filter quality
199
    void setShadowFilterQuality(const S3DEnum::ShadowFilterQuality val);
200

201
    void setEnablePCSS(const bool val);
202
    bool getEnablePCSS() const;
203

204
    //! Returns the current cubemapping mode
205
    S3DEnum::CubemappingMode getCubemappingMode(void) const;
206
    //! Sets the cubemapping mode
207
    void setCubemappingMode(const S3DEnum::CubemappingMode val);
208

209
    bool getUseFullCubemapShadows() const;
210
    void setUseFullCubemapShadows(const bool useFullCubemapShadows);
211

212
    //! Set to true to show some rendering debug information
213
    void setEnableDebugInfo(const bool debugEnabled);
214
    bool getEnableDebugInfo() const;
215

216
    //! Set to true to show the current standing positin as text on screen.
217
    void setEnableLocationInfo(const bool enableLocationInfo);
218
    bool getEnableLocationInfo() const;
219

220
    //! Set the overdrawing of a landscape (horizon) polygon after the 3D scenery.
221
    //! This shows the difference (error) between our planar (tangential plane) modelling and effects of earth curvature.
222
    //! The landscape has to include such a polygon, of course.
223
    void setForceHorizonPolyline(const bool forcePolyline);
224
    bool getForceHorizonPolyline() const;
225

226
    //! Set to true to add an additional light source centered at the current position, useful in night scenes.
227
    void setEnableTorchLight(const bool enableTorchLight);
228
    bool getEnableTorchLight() const;
229

230
    //! Sets the strength of the additional illumination that can be toggled when pressing a button.
231
    void setTorchStrength(const float torchStrength);
232
    float getTorchStrength() const;
233

234
    //! Sets the range of the torchlight.
235
    void setTorchRange(const float torchRange);
236
    float getTorchRange() const;
237

238
    //! Sets the state of the cubemap lazy-drawing mode
239
    void setEnableLazyDrawing(const bool val);
240
    bool getEnableLazyDrawing() const;
241

242
    //! When true, only the face which currently is most dominantly visible is updated while moving.
243
    void setOnlyDominantFaceWhenMoving(const bool val);
244
    bool getOnlyDominantFaceWhenMoving() const;
245

246
    void setSecondDominantFaceWhenMoving(const bool val);
247
    bool getSecondDominantFaceWhenMoving() const;
248

249
    //! Forces a redraw of the cubemap
250
    void forceCubemapRedraw();
251

252
    //! Sets the interval for cubemap lazy-drawing mode
253
    void setLazyDrawingInterval(const double val);
254
    double getLazyDrawingInterval() const;
255

256
    //! Sets the size used for cubemap rendering.
257
    //! For best compatibility and performance, this should be a power of 2.
258
    void setCubemapSize(const uint val);
259
    uint getCubemapSize() const;
260

261
    //! Sets the size used for shadowmap rendering.
262
    //! For best compatibility and performance, this should be a power of 2.
263
    void setShadowmapSize(const uint val);
264
    uint getShadowmapSize() const;
265

266
    //these properties are only valid after init() has been called
267
    bool getIsGeometryShaderSupported() const;
268
    bool getAreShadowsSupported() const;
269
    bool getIsShadowFilteringSupported() const;
270
    bool getIsANGLE() const;
271
    uint getMaximumFramebufferSize() const;
272

273
    //! Gets the SceneInfo of the scene that is currently being displayed.
274
    //! Check SceneInfo::isValid to determine if a scene is displayed.
275
    SceneInfo getCurrentScene() const;
276

277
    //! Returns the ID of the currently loaded scene, or an null string if nothing is displayed.
278
    QString getCurrentSceneID() const;
279

280
    //! Returns the ID of the currently loading scene, or null if nothing is being loaded
281
    QString getLoadingSceneID() const;
282

283
    //! Gets the SceneInfo of the scene that is currently in the process of being loaded.
284
    //! Check SceneInfo::isValid to determine if a scene is loaded.
285
    SceneInfo getLoadingScene() const { return currentLoadScene; }
×
286

287
    //! This starts the scene loading process. This is asynchronous, this method returns after metadata loading.
288
    //! @param name a valid scene name
289
    //! @return The loaded SceneInfo. Check SceneInfo::isValid to make sure loading was successful.
290
    SceneInfo loadScenery3dByName(const QString& name);
291
    //! This starts the scene loading process. This is asynchronous, this method returns after metadata loading.
292
    //! @param id a valid scene id/folder path
293
    //! @return The loaded SceneInfo. Check SceneInfo::isValid to make sure loading was successful.
294
    SceneInfo loadScenery3dByID(const QString& id);
295

296
    QString getDefaultScenery3dID() const { return defaultScenery3dID; }
×
297
    void setDefaultScenery3dID(const QString& id);
298

299
    //! Changes the current view to the given view. JD is updated only if view contains valid data and setDate is true
300
    void setView(const StoredView& view, const bool setDate);
301
    //! Returns a StoredView that represents the current observer position + view direction.
302
    //! Label and description are empty.
303
    StoredView getCurrentView();
304

305
private slots:
306
    void clearMessage();
307
    void loadSceneCompleted();
308
    void progressReceive(const QString& str, int val, int min, int max);
309
    void loadScene(const SceneInfo& scene);
310

311
private:
312
    //! Loads config values from app settings
313
    void loadConfig();
314
    //! Creates all actions required by the plugin
315
    void createActions();
316
    //! Creates the toolbar buttons of the plugin
317
    void createToolbarButtons() const;
318

319
    //! This is run asynchronously in a background thread, performing the actual scene loading
320
    S3DScene *loadSceneBackground(const SceneInfo &scene) const;
321

322
    // the other "main" objects
323
    S3DRenderer* renderer;
324
    Scenery3dDialog* scenery3dDialog;
325
    StoredViewDialog* storedViewDialog;
326

327
    QSettings* conf;
328
    QString defaultScenery3dID;
329
    bool flagEnabled;
330
    bool cleanedUp;
331

332
    Vec3d movementKeyInput;
333

334
    StelCore* core;
335
    StelMovementMgr* mvMgr;
336
    StelCore::ProjectionType oldProjectionType;
337

338
    //screen messages (taken largely from AngleMeasure as of 2012-01-21)
339
    LinearFader messageFader;
340
    QTimer* messageTimer;
341
    Vec3f textColor;
342
    QFont font;
343
    QString currentMessage;
344
    bool forceHorizonPolyline; // if true, the LandscapeMgr is called after scene rendering to repeat rendering the landscape polygon, if one has been defined in the current Landscape.
345

346
    volatile bool loadCancel;
347
    StelProgressController* progressBar;
348
    SceneInfo currentLoadScene;
349
    S3DScene* currentScene;
350
    QFutureWatcher<S3DScene*> currentLoadFuture;
351
};
352

353

354
#include <QObject>
355
#include "StelPluginInterface.hpp"
356

357
//! This class is used by Qt to manage a plug-in interface
358
class Scenery3dStelPluginInterface : public QObject, public StelPluginInterface
359
{
360
        Q_OBJECT
361
        Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
362
        Q_INTERFACES(StelPluginInterface)
363
public:
364
        virtual StelModule* getStelModule() const Q_DECL_OVERRIDE;
365
        virtual StelPluginInfo getPluginInfo() const Q_DECL_OVERRIDE;
366
        virtual QObjectList getExtensionList() const Q_DECL_OVERRIDE;
367
};
368

369

370
#endif // SCENERY3D_HPP
371

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc