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

Stellarium / stellarium / 13260145531

11 Feb 2025 09:41AM UTC coverage: 12.127% (+0.03%) from 12.101%
13260145531

Pull #3751

github

10110111
Restore deleted additional SC files
Pull Request #3751: Switch skycultures to the new format

14613 of 120497 relevant lines covered (12.13%)

18620.19 hits per line

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

0.0
/src/core/modules/LandscapeMgr.hpp
1
/*
2
 * Stellarium
3
 * Copyright (C) 2006 Fabien Chereau
4
 * Copyright (C) 2010 Bogdan Marinov (add/remove landscapes feature)
5
 * Copyright (C) 2012 Timothy Reaves
6
 *
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
20
 */
21

22
#ifndef LANDSCAPEMGR_HPP
23
#define LANDSCAPEMGR_HPP
24

25
#include "StelModule.hpp"
26
#include "StelUtils.hpp"
27
#include "Landscape.hpp"
28
#include "Skylight.hpp"
29

30
#include <memory>
31
#include <QMap>
32
#include <QStringList>
33
#include <QCache>
34

35
class Atmosphere;
36
class QSettings;
37
class QTimer;
38

39

40
//! @class Cardinals manages the display of cardinal points
41
class Cardinals
42
{
43
        Q_GADGET
44
public:
45
        enum CompassDirection
46
        {
47
                // Cardinals (4-wind compass rose)
48
                dN        =  1,        // north
49
                dS        =  2,        // south
50
                dE        =  3,        // east
51
                dW        =  4,        // west
52
                // Intercardinals (or ordinals) (8-wind compass rose)
53
                dNE        =  5,        // northeast
54
                dSE        =  6,        // southeast
55
                dNW        =  7,        // northwest
56
                dSW        =  8,        // southwest
57
                // Secondary Intercardinals (16-wind compass rose)
58
                dNNE        =  9,        // north-northeast
59
                dENE        = 10,        // east-northeast
60
                dESE        = 11,        // east-southeast
61
                dSSE        = 12,        // south-southeast
62
                dSSW        = 13,        // south-southwest
63
                dWSW        = 14,        // west-southwest
64
                dWNW        = 15,        // west-northwest
65
                dNNW        = 16,        // north-northwest
66
                // Tertiary Intercardinals (32-wind compass rose)
67
                dNbE        = 17,        // north by east
68
                dNEbN        = 18,        // northeast by north
69
                dNEbE        = 19,        // northeast by east
70
                dEbN        = 20,        // east by north
71
                dEbS        = 21,        // east by south
72
                dSEbE        = 22,        // southeast by east
73
                dSEbS        = 23,        // southeast by south
74
                dSbE        = 24,        // south by east
75
                dSbW        = 25,        // south by west
76
                dSWbS        = 26,        // southwest by south
77
                dSWbW        = 27,        // southwest by west
78
                dWbS        = 28,        // west by south
79
                dWbN        = 29,        // west by north
80
                dNWbW        = 30,        // northwest by west
81
                dNWbN        = 31,        // northwest by north
82
                dNbW        = 32        // north by west
83
        };
84
        Q_ENUM(CompassDirection)
85

86
        Cardinals();
87
        virtual ~Cardinals();
88
        void draw(const StelCore* core, double latitude) const;
89
        void setColor(const Vec3f& c) {color = c;}
×
90
        Vec3f getColor() const {return color;}
×
91
        void updateI18n();
92
        void update(double deltaTime);
93
        void setFadeDuration(float duration);
94
        void setFlagShowCardinals(bool b) { fader4WCR = b; StelApp::immediateSave("viewing/flag_cardinal_points", b);}
95
        bool getFlagShowCardinals() const { return fader4WCR; }
×
96

97
        void setFlagShow4WCRLabels(bool b) { fader4WCR = b; StelApp::immediateSave("viewing/flag_cardinal_points", b);}
×
98
        bool getFlagShow4WCRLabels() const { return fader4WCR; }
×
99
        void setFlagShow8WCRLabels(bool b) { fader8WCR = b; StelApp::immediateSave("viewing/flag_ordinal_points", b);}
×
100
        bool getFlagShow8WCRLabels() const { return fader8WCR; }
×
101
        void setFlagShow16WCRLabels(bool b) { fader16WCR = b; StelApp::immediateSave("viewing/flag_16wcr_points", b);}
×
102
        bool getFlagShow16WCRLabels() const { return fader16WCR; }
×
103
        void setFlagShow32WCRLabels(bool b) { fader32WCR = b; StelApp::immediateSave("viewing/flag_32wcr_points", b);}
×
104
        bool getFlagShow32WCRLabels() const { return fader32WCR; }
×
105
private:
106
        class StelPropertyMgr* propMgr;
107
        QFont font4WCR, font8WCR, font16WCR, font32WCR;
108
        Vec3f color;
109
        static constexpr float q8 = M_SQRT2*0.5f; // dimension for intercardinals
110
        static const float sp8, cp8, s1p16, c1p16, s3p16, c3p16; // dimensions for 2nd/3rd intercardinals
111
        static const QMap<Cardinals::CompassDirection, Vec3f> rose4winds, rose8winds, rose16winds, rose32winds;
112
        QMap<Cardinals::CompassDirection, QString> labels;
113
        LinearFader fader4WCR, fader8WCR, fader16WCR, fader32WCR;
114
        int screenFontSize;
115
};
116

117
//! @class LandscapeMgr
118
//! Manages all the rendering at the level of the observer's surroundings.
119
//! This includes landscape textures, fog, atmosphere and cardinal points.
120
//! I decided to put all these elements together in a single class because they are
121
//! inherently linked, especially when we start moving the observer in altitude.
122
//! \note
123
//! The Bortle scale index setting was removed from this class, because it was duplicated
124
//! from StelSkyDrawer, complicating code that changes it.
125
//! It is now only in StelSkyDrawer and can be accessed
126
//! with \link StelSkyDrawer::getBortleScaleIndex getBortleScaleIndex \endlink
127
//! and \link StelSkyDrawer::setBortleScaleIndex setBortleScaleIndex \endlink.
128
//! Slots setAtmosphereBortleLightPollution and getAtmosphereBortleLightPollution
129
//! in this class have been removed/made private.
130
//! If script access is desired, use
131
//! \link StelMainScriptAPI::getBortleScaleIndex StelMainScriptAPI::get \endlink/\link StelMainScriptAPI::setBortleScaleIndex setBortleScaleIndex \endlink
132
class LandscapeMgr : public StelModule
133
{
134
        Q_OBJECT
135
        Q_PROPERTY(bool atmosphereDisplayed
136
                   READ getFlagAtmosphere
137
                   WRITE setFlagAtmosphere
138
                   NOTIFY atmosphereDisplayedChanged)
139
        Q_PROPERTY(bool atmosphereNoScatter
140
                   READ getFlagAtmosphereNoScatter
141
                   WRITE setFlagAtmosphereNoScatter
142
                   NOTIFY atmosphereNoScatterChanged)
143
        Q_PROPERTY(QString atmosphereModel
144
                   READ getAtmosphereModel
145
                   WRITE setAtmosphereModel
146
                   NOTIFY atmosphereModelChanged)
147
        Q_PROPERTY(QString atmosphereModelPath
148
                   READ getAtmosphereModelPath
149
                   WRITE setAtmosphereModelPath
150
                   NOTIFY atmosphereModelPathChanged)
151
        Q_PROPERTY(QString defaultAtmosphereModelPath
152
                   READ getDefaultAtmosphereModelPath
153
                   SCRIPTABLE false
154
                   CONSTANT)
155
        Q_PROPERTY(bool atmosphereShowMySkyStoppedWithError
156
                   READ getAtmosphereShowMySkyStoppedWithError
157
                   WRITE setAtmosphereShowMySkyStoppedWithError
158
                   NOTIFY atmosphereStoppedWithErrorChanged)
159
        Q_PROPERTY(QString atmosphereShowMySkyStatusText
160
                   READ getAtmosphereShowMySkyStatusText
161
                   WRITE setAtmosphereShowMySkyStatusText
162
                   NOTIFY atmosphereStatusTextChanged)
163
        Q_PROPERTY(bool flagAtmosphereZeroOrderScattering
164
                   READ getFlagAtmosphereZeroOrderScattering
165
                   WRITE setFlagAtmosphereZeroOrderScattering
166
                   NOTIFY flagAtmosphereZeroOrderScatteringChanged)
167
        Q_PROPERTY(bool flagAtmosphereSingleScattering
168
                   READ getFlagAtmosphereSingleScattering
169
                   WRITE setFlagAtmosphereSingleScattering
170
                   NOTIFY flagAtmosphereSingleScatteringChanged)
171
        Q_PROPERTY(bool flagAtmosphereMultipleScattering
172
                   READ getFlagAtmosphereMultipleScattering
173
                   WRITE setFlagAtmosphereMultipleScattering
174
                   NOTIFY flagAtmosphereMultipleScatteringChanged)
175
        Q_PROPERTY(int atmosphereEclipseSimulationQuality
176
                   READ getAtmosphereEclipseSimulationQuality
177
                   WRITE setAtmosphereEclipseSimulationQuality
178
                   NOTIFY atmosphereEclipseSimulationQualityChanged)
179
        Q_PROPERTY(bool cardinalPointsDisplayed
180
                   READ getFlagCardinalPoints
181
                   WRITE setFlagCardinalPoints
182
                   NOTIFY cardinalPointsDisplayedChanged)
183
        Q_PROPERTY(bool ordinalPointsDisplayed
184
                   READ getFlagOrdinalPoints
185
                   WRITE setFlagOrdinalPoints
186
                   NOTIFY ordinalPointsDisplayedChanged)
187
        Q_PROPERTY(bool ordinal16WRPointsDisplayed
188
                   READ getFlagOrdinal16WRPoints
189
                   WRITE setFlagOrdinal16WRPoints
190
                   NOTIFY ordinal16WRPointsDisplayedChanged)
191
        Q_PROPERTY(bool ordinal32WRPointsDisplayed
192
                   READ getFlagOrdinal32WRPoints
193
                   WRITE setFlagOrdinal32WRPoints
194
                   NOTIFY ordinal32WRPointsDisplayedChanged)
195
        Q_PROPERTY(Vec3f cardinalPointsColor
196
                   READ getColorCardinalPoints
197
                   WRITE setColorCardinalPoints
198
                   NOTIFY cardinalPointsColorChanged)
199
        Q_PROPERTY(bool fogDisplayed
200
                   READ getFlagFog
201
                   WRITE setFlagFog
202
                   NOTIFY fogDisplayedChanged)
203
        Q_PROPERTY(bool landscapeDisplayed
204
                   READ getFlagLandscape
205
                   WRITE setFlagLandscape
206
                   NOTIFY landscapeDisplayedChanged)
207
        Q_PROPERTY(bool illuminationDisplayed
208
                   READ getFlagIllumination
209
                   WRITE setFlagIllumination
210
                   NOTIFY illuminationDisplayedChanged)
211
        Q_PROPERTY(bool labelsDisplayed
212
                   READ getFlagLabels
213
                   WRITE setFlagLabels
214
                   NOTIFY labelsDisplayedChanged)
215
        Q_PROPERTY(bool flagPolyLineDisplayedOnly
216
                   READ getFlagPolyLineOnlyDisplayed
217
                   WRITE setFlagPolyLineOnlyDisplayed
218
                   NOTIFY flagPolyLineOnlyDisplayedChanged)
219
        Q_PROPERTY(int polyLineThickness
220
                   READ getPolyLineThickness
221
                   WRITE setPolyLineThickness
222
                   NOTIFY polyLineThicknessChanged)
223
        Q_PROPERTY(Vec3f polyLineColor
224
                   READ getPolyLineColor
225
                   WRITE setPolyLineColor
226
                   NOTIFY polyLineColorChanged)
227
        Q_PROPERTY(bool flagUseLightPollutionFromDatabase
228
                   READ getFlagUseLightPollutionFromDatabase
229
                   WRITE setFlagUseLightPollutionFromDatabase
230
                   NOTIFY flagUseLightPollutionFromDatabaseChanged)
231
        Q_PROPERTY(bool flagLandscapeAutoSelection
232
                   READ getFlagLandscapeAutoSelection
233
                   WRITE setFlagLandscapeAutoSelection
234
                   NOTIFY flagLandscapeAutoSelectionChanged)
235
        Q_PROPERTY(bool flagLandscapeSetsLocation
236
                   READ getFlagLandscapeSetsLocation
237
                   WRITE setFlagLandscapeSetsLocation
238
                   NOTIFY flagLandscapeSetsLocationChanged)
239
        Q_PROPERTY(bool flagLandscapeUseMinimalBrightness
240
                   READ getFlagLandscapeUseMinimalBrightness
241
                   WRITE setFlagLandscapeUseMinimalBrightness
242
                   NOTIFY flagLandscapeUseMinimalBrightnessChanged)
243
        Q_PROPERTY(bool flagLandscapeSetsMinimalBrightness
244
                   READ getFlagLandscapeSetsMinimalBrightness
245
                   WRITE setFlagLandscapeSetsMinimalBrightness
246
                   NOTIFY flagLandscapeSetsMinimalBrightnessChanged)
247
        Q_PROPERTY(double defaultMinimalBrightness
248
                   READ getDefaultMinimalBrightness
249
                   WRITE setDefaultMinimalBrightness
250
                   NOTIFY defaultMinimalBrightnessChanged)
251
        Q_PROPERTY(bool flagEnvironmentAutoEnabling
252
                   READ getFlagEnvironmentAutoEnable
253
                   WRITE setFlagEnvironmentAutoEnable
254
                   NOTIFY setFlagEnvironmentAutoEnableChanged)
255
        Q_PROPERTY(QString currentLandscapeID
256
                   READ getCurrentLandscapeID
257
                   WRITE setCurrentLandscapeID
258
                   NOTIFY currentLandscapeChanged)
259
        Q_PROPERTY(QStringList allLandscapeNames
260
                   READ getAllLandscapeNames
261
                   NOTIFY landscapesChanged)
262
        Q_PROPERTY(QString currentLandscapeName
263
                   READ getCurrentLandscapeName
264
                   WRITE setCurrentLandscapeName
265
                   NOTIFY currentLandscapeChanged)
266
        Q_PROPERTY(QString currentLandscapeHtmlDescription
267
                   READ getCurrentLandscapeHtmlDescription
268
                   NOTIFY currentLandscapeChanged)
269
        Q_PROPERTY(QString defaultLandscapeID
270
                   READ getDefaultLandscapeID
271
                   WRITE setDefaultLandscapeID
272
                   NOTIFY defaultLandscapeChanged)
273
        Q_PROPERTY(int labelFontSize
274
                   READ getLabelFontSize
275
                   WRITE setLabelFontSize
276
                   NOTIFY labelFontSizeChanged)
277
        Q_PROPERTY(Vec3f labelColor
278
                   READ getLabelColor
279
                   WRITE setLabelColor
280
                   NOTIFY labelColorChanged)
281
        Q_PROPERTY(int labelAngle
282
                   READ getLabelAngle
283
                   WRITE setLabelAngle
284
                   NOTIFY labelAngleChanged)
285
        Q_PROPERTY(double landscapeTransparency
286
                   READ getLandscapeTransparency
287
                   WRITE setLandscapeTransparency
288
                   NOTIFY landscapeTransparencyChanged)
289
        Q_PROPERTY(bool flagLandscapeUseTransparency
290
                   READ getFlagLandscapeUseTransparency
291
                   WRITE setFlagLandscapeUseTransparency
292
                   NOTIFY flagLandscapeUseTransparencyChanged)
293

294
public:
295
        LandscapeMgr();
296
        ~LandscapeMgr() override;
297

298
        ///////////////////////////////////////////////////////////////////////////
299
        // Methods defined in the StelModule class
300
        //! Initialize the LandscapeManager class.
301
        //! Operations performed:
302
        //! - Load the default landscape as specified in the application configuration
303
        //! - Set up landscape-related display flags from ini parser object
304
        void init() override;
305

306
        //! Draw the atmosphere, landscape graphics, and cardinal points.
307
        void draw(StelCore* core) override;
308
        //! Draw landscape graphics and cardinal points. This only will redraw a polygonal line (if defined), the gazetteer and the Cardinal points.
309
        //! This can be called outside the usual call order, if any foreground has to be overdrawn, e.g. 3D sceneries.
310
        void drawPolylineOnly(StelCore* core);
311

312
        //! Update time-dependent state.
313
        //! Includes:
314
        //! - Landscape, atmosphere and cardinal point on/off fading.
315
        //! - Atmophere colour calculation based on location, position of sun
316
        //!   and moon.
317
        //! - updates adaptation luminescence based on visible bright objects.
318
        //! - Landscape and lightscape brightness computations based on sun position and whether atmosphere is on or off.
319
        void update(double deltaTime) override;
320

321
        //! Get the order in which this module will draw its objects relative to other modules.
322
        double getCallOrder(StelModuleActionName actionName) const override;
323

324
        ///////////////////////////////////////////////////////////////////////////
325
        // Methods specific to the landscape manager
326

327
        // Load a landscape based on a hash of parameters mirroring the landscape.ini
328
        // file and make it the current landscape.
329
        // GZ: This was declared, but not implemented(?)
330
        //bool loadLandscape(QMap<QString, QString>& param);
331

332
        //! Create a new landscape from the files which describe it.
333
        //! Reads a landscape.ini file which is passed as the first parameter, determines
334
        //! the landscape type, and creates a new object for the landscape of the proper
335
        //! type.  The load member is then called, passing both parameters.
336
        //! @param landscapeFile This is the path to a landscape.ini file.
337
        //! @param landscapeId This is the landscape ID, which is also the name of the
338
        //! directory in which the files (textures and so on) for the landscape reside.
339
        //! @return A pointer to the newly created landscape object.
340
        Landscape* createFromFile(const QString& landscapeFile, const QString& landscapeId);
341

342
        // GZ: implement StelModule's method. For test purposes only, we implement a manual transparency sampler.
343
        // TODO: comment this away for final builds. Please leave it in until this feature is finished.
344
        // virtual void handleMouseClicks(class QMouseEvent*);
345

346
public slots:
347
        ///////////////////////////////////////////////////////////////////////////
348
        // Methods callable from scripts and GUI
349
        //! Return the global landscape luminance [0..1], for being used e.g for setting eye adaptation.
350
        //! It returns 1 if atmosphere drawing is on and no eclipse underway, 0 if atmosphere is switched off.
351
        //! The actual brightness is of no concern here. You may use getAtmosphereAverageLuminance() for this.
352
        float getLuminance() const;
353
        //! return average luminance [cd/m^2] of atmosphere. Expect 10 at sunset, 6400 in daylight, >0 in dark night.
354
        float getAtmosphereAverageLuminance() const;
355

356
        //! Override autocomputed value and set average luminance [cd/m^2] of atmosphere.  This is around 10 at sunset, 6400 in daylight, >0 in dark night.
357
        //! Usually there is no need to call this, the luminance is properly computed. This is a function which can be
358
        //! useful in rare cases, e.g. in scripts when you want to create images of adjacent sky regions with the same brightness setting,
359
        //! or for creation of a virtual camera which can deliberately show over- or underexposure.
360
        //! For these cases, it is advisable to first center the brightest luminary (sun or moon), call getAtmosphereAverageLuminance() and then set
361
        //! this value explicitly to freeze it during image export. To unfreeze, call this again with any negative value.
362
        void setAtmosphereAverageLuminance(const float overrideLuminance);
363

364
        //! Return a map of landscape names to landscape IDs (directory names).
365
        static QMap<QString,QString> getNameToDirMap();
366

367
        //! Retrieve a list of the names of all the available landscapes in
368
        //! the file search path sub-directories of the landscape area
369
        //! @return the names of the landscapes, which are the values of the name parameter in the landscape.ini files
370
        QStringList getAllLandscapeNames() const;
371

372
        //! Retrieve a list of the identifiers of all the available landscapes in
373
        //! the file search path sub-directories of the landscape area
374
        //! @return the identifiers of the landscapes, which are the names of the directories containing the landscapes' files
375
        QStringList getAllLandscapeIDs() const;
376

377
        //! Retrieve a list of the identifiers of all user-installed landscapes.
378
        //! Effectively, this returns the results of getAllLandscapeIDs() without
379
        //! the landscapes specified in the #packagedLandscapeIDs list.
380
        QStringList getUserLandscapeIDs() const;
381

382
        //! Get the current landscape ID.
383
        const QString getCurrentLandscapeID() const {return currentLandscapeID;}
×
384
        //! Change the current landscape to the landscape with the ID specified.
385
        //! Emits currentLandscapeChanged() if the landscape changed (true returned)
386
        //! @param id the ID of the new landscape
387
        //! @param changeLocationDuration the duration of the transition animation
388
        //! @return false if the new landscape could not be set (e.g. no landscape of that ID was found).
389
        bool setCurrentLandscapeID(const QString& id, const double changeLocationDuration = 1.0);
390
        
391
        //! Get the current landscape name.
392
        QString getCurrentLandscapeName() const;
393
        //! Change the current landscape to the landscape with the name specified.
394
        //! Emits currentLandscapeChanged() if the landscape changed (true returned)
395
        //! @param name the name of the new landscape, as found in the landscape:name key of the landscape.ini file.
396
        //! @param changeLocationDuration the duration of the transition animation
397
        bool setCurrentLandscapeName(const QString& name, const double changeLocationDuration = 1.0);
398

399
        //! Get the current landscape or lightscape brightness (0..1)
400
        //! @param light true to retrieve the light layer brightness value.
401
        float getCurrentLandscapeBrightness(const bool light=false) const {return static_cast<float>(light? landscape->getLightscapeBrightness() : landscape->getBrightness());}
×
402

403
        //! Preload a landscape into cache.
404
        //! @param id the ID of a landscape
405
        //! @param replace true if existing landscape entry should be replaced (useful during development to reload after edit)
406
        //! @return false if landscape could not be found, or if it already existed in cache and replace was false.
407
        bool precacheLandscape(const QString& id, const bool replace=true);
408
        //! Remove a landscape from the cache of landscapes.
409
        //! @param id the ID of a landscape
410
        //! @return false if landscape could not be found
411
        bool removeCachedLandscape(const QString& id);
412
        //! Set size of the landscape cache, in MB.
413
        //! Default size is 100MB, or configured as [landscape/cache_size_mb] from config.ini.
414
        //! The landscape sizes returned in Landscape::getMemorySize() are only approximate, but include image and texture sizes.
415
        //! A big landscape may well take 150MB or more.
416
        //! On a 32bit system, keep this rather small. On 64bit with 16GB RAM and no other tasks, 4GB is no problem.
417
        //! Modern GPUs may have 4 or even 8GB of dedicated texture memory. Most of this may be filled with landscape textures.
418
        //! Example: a museum installation with 20 large (16384x2048) old_style landscapes can require up to 3.5GB. Allow 4GB cache,
419
        //! and the system will never have to load a landscape during the show when all have been preloaded.
420
        void setCacheSize(int mb) { landscapeCache.setMaxCost(mb);}
×
421
        //! Retrieve total size of cache (MB).
422
        int getCacheSize() const {return landscapeCache.maxCost();}
×
423
        //! Retrieve sum of currently used memory in cache (MB, approximate)
424
        int getCacheFilledSize() const {return landscapeCache.totalCost();}
×
425
        //! Return number of landscapes already in the cache.
426
        int getCacheCount() const {return landscapeCache.count();}
×
427

428
        //! Get the current landscape object.
429
        Landscape* getCurrentLandscape() const { return landscape; }
×
430

431
        //! Get the default landscape ID.
432
        const QString getDefaultLandscapeID() const {return defaultLandscapeID;}
×
433
        //! Change the default landscape to the landscape with the ID specified.
434
        //! @param id the ID of the landscape to use by default
435
        //! @return false if the new landscape could not be set (e.g. no landscape of that ID was found). True on success.
436
        bool setDefaultLandscapeID(const QString& id);
437

438
        //! Return a pseudo HTML formatted string with all information on the current landscape
439
        QString getCurrentLandscapeHtmlDescription() const;
440

441
        //! Return a pseudo HTML formatted string with information from description or ini file
442
        QString getDescription() const;
443

444
        //! Get flag for displaying Landscape.
445
        bool getFlagLandscape() const;
446
        //! Set flag for displaying Landscape.
447
        void setFlagLandscape(const bool displayed);
448

449
        //! Get whether the landscape is currently visible. If true, objects below landscape's limiting altitude limit can be omitted.
450
        bool getIsLandscapeFullyVisible() const;
451
        //! Get the sine of current landscape's minimal altitude. Useful to construct bounding caps.
452
        double getLandscapeSinMinAltitudeLimit() const;
453
        
454
        //! Get flag for displaying Fog.
455
        bool getFlagFog() const;
456
        //! Set flag for displaying Fog.
457
        void setFlagFog(const bool displayed);
458
        //! Get flag for displaying illumination layer
459
        bool getFlagIllumination() const;
460
        //! Set flag for displaying illumination layer
461
        void setFlagIllumination(const bool on);
462
        //! Get flag for displaying landscape labels
463
        bool getFlagLabels() const;
464
        //! Set flag for displaying landscape labels
465
        void setFlagLabels(const bool on);
466
        //! Get the fontsize for landscape labels
467
        int getLabelFontSize() const;
468
        //! Set the fontsize for landscape labels
469
        void setLabelFontSize(const int size);
470
        //! Get the rotation angle for landscape labels (degrees)
471
        int getLabelAngle() const;
472
        //! Set the rotation angle for landscape labels (degrees)
473
        void setLabelAngle(const int angleDeg);
474
        //! Get color for landscape labels
475
        Vec3f getLabelColor() const;
476
        //! Set color for landscape labels
477
        void setLabelColor(const Vec3f& c);
478

479
        //! Retrieve flag for rendering polygonal line only (if one is defined), suppressing any panorama image
480
        bool getFlagPolyLineOnlyDisplayed() const;
481
        //! Set flag for rendering polygonal line only (if one is defined), suppressing any panorama image
482
        void setFlagPolyLineOnlyDisplayed(bool b);
483
        //! Retrieve thickness for rendering polygonal line (if one is defined)
484
        int getPolyLineThickness() const;
485
        //! Set thickness for rendering polygonal line (if one is defined)
486
        void setPolyLineThickness(int thickness);
487
        //! Get color for landscape polygon
488
        Vec3f getPolyLineColor() const;
489
        //! Set color for landscape polygon
490
        void setPolyLineColor(const Vec3f& c);
491

492
        //! Return the value of the flag determining if a change of landscape will update the observer location.
493
        bool getFlagLandscapeSetsLocation() const;
494
        //! Set the value of the flag determining if a change of landscape will update the observer location.
495
        void setFlagLandscapeSetsLocation(bool b);
496

497
        //! Return the value of the flag determining if a minimal brightness should be used to keep landscape visible.
498
        bool getFlagLandscapeUseMinimalBrightness() const;
499
        //! Set the value of the flag determining if a minimal brightness should be used to keep landscape visible.
500
        void setFlagLandscapeUseMinimalBrightness(bool b);
501
        //! Return the value of the flag determining if the minimal brightness should be taken from landscape.ini
502
        bool getFlagLandscapeSetsMinimalBrightness() const;
503
        //! Sets the value of the flag determining if the minimal brightness should be taken from landscape.ini
504
        void setFlagLandscapeSetsMinimalBrightness(bool b);
505
        //! Return the minimal brightness value of the landscape
506
        double getDefaultMinimalBrightness() const;
507
        //! Set the minimal brightness value of the landscape.
508
        void setDefaultMinimalBrightness(const double b);
509
        //! Sets the value of the flag usage light pollution (and bortle index) from locations database.
510
        void setFlagUseLightPollutionFromDatabase(const bool usage);
511
        //! Return the value of flag usage light pollution (and bortle index) from locations database.
512
        bool getFlagUseLightPollutionFromDatabase() const;
513

514
        //! Get flag for displaying cardinal points (4-wind compass rose directions)
515
        bool getFlagCardinalPoints() const;
516
        //! Set flag for displaying cardinal points (4-wind compass rose directions)
517
        void setFlagCardinalPoints(const bool displayed);
518

519
        //! Get flag for displaying intercardinal (or ordinal) points (8-wind compass rose directions).
520
        bool getFlagOrdinalPoints() const;
521
        //! Set flag for displaying intercardinal (or ordinal) points (8-wind compass rose directions).
522
        void setFlagOrdinalPoints(const bool displayed);
523

524
        //! Get flag for displaying intercardinal (or ordinal) points (16-wind compass rose directions).
525
        bool getFlagOrdinal16WRPoints() const;
526
        //! Set flag for displaying intercardinal (or ordinal) points (16-wind compass rose directions).
527
        void setFlagOrdinal16WRPoints(const bool displayed);
528

529
        //! Get flag for displaying intercardinal (or ordinal) points (32-wind compass rose directions).
530
        bool getFlagOrdinal32WRPoints() const;
531
        //! Set flag for displaying intercardinal (or ordinal) points (32-wind compass rose directions).
532
        void setFlagOrdinal32WRPoints(const bool displayed);
533

534
        //! Get Cardinals Points color.
535
        Vec3f getColorCardinalPoints() const;
536
        //! Set Cardinals Points color.
537
        void setColorCardinalPoints(const Vec3f& v);
538

539
        //! Get flag for displaying Atmosphere.
540
        bool getFlagAtmosphere() const;
541
        //! Set flag for displaying Atmosphere.
542
        void setFlagAtmosphere(const bool displayed);
543

544
        QString getAtmosphereModel() const;
545
        void setAtmosphereModel(const QString& model);
546

547
        QString getAtmosphereModelPath() const;
548
        void setAtmosphereModelPath(const QString& path);
549

550
        QString getDefaultAtmosphereModelPath() const;
551

552
        bool getAtmosphereShowMySkyStoppedWithError() const;
553
        void setAtmosphereShowMySkyStoppedWithError(bool error);
554

555
        QString getAtmosphereShowMySkyStatusText() const;
556
        void setAtmosphereShowMySkyStatusText(const QString& text);
557

558
        bool getFlagAtmosphereZeroOrderScattering() const;
559
        void setFlagAtmosphereZeroOrderScattering(bool enable);
560

561
        bool getFlagAtmosphereSingleScattering() const;
562
        void setFlagAtmosphereSingleScattering(bool enable);
563

564
        bool getFlagAtmosphereMultipleScattering() const;
565
        void setFlagAtmosphereMultipleScattering(bool enable);
566

567
        int getAtmosphereEclipseSimulationQuality() const;
568
        void setAtmosphereEclipseSimulationQuality(int quality);
569

570
        //! Get flag for suppressing Atmosphere scatter (blue light) while displaying all other effects (refraction, extinction).
571
        bool getFlagAtmosphereNoScatter() const;
572
        //! Set flag for suppressing Atmosphere scatter (blue light) while displaying all other effects (refraction, extinction).
573
        void setFlagAtmosphereNoScatter(const bool displayed);
574

575
        //! Get current display intensity of atmosphere ([0..1], for smoother transitions)
576
        float getAtmosphereFadeIntensity() const;
577

578
        //! Get atmosphere fade duration in s.
579
        float getAtmosphereFadeDuration() const;
580
        //! Set atmosphere fade duration in s.
581
        void setAtmosphereFadeDuration(const float f);
582

583
        double getLandscapeTransparency() const;
584
        void setLandscapeTransparency(const double f);
585
        //! Return the value of the flag determining if a transparency should be used.
586
        bool getFlagLandscapeUseTransparency() const;
587
        //! Set the value of the flag determining if a transparency should be used.
588
        void setFlagLandscapeUseTransparency(bool b);
589

590
        //! Set a discoloration to simulate sunrise/sunset colors.
591
        void setLandscapeTint(const Vec3f &c){landscapeTint=c;}
×
592
        Vec3f getLandscapeTint() const {return landscapeTint;}
×
593

594
        /*
595
        //This method has been removed, use StelSkyDrawer::getBortleScaleIndex instead, or StelMainScriptAPI::getBortleScaleIndex in scripts
596
        //Also, if required, please use StelSkyDrawer::setBortleScaleIndex or StelMainScriptAPI::setBortleScaleIndex instead of LandscapeMgr::setAtmosphereBortleLightPollution
597
        int getAtmosphereBortleLightPollution() const;
598
        */
599

600
        //! Set the rotation of the landscape about the z-axis.
601
        //! This is intended for special uses such as when the landscape consists of
602
        //! a vehicle which might change orientation over time (e.g. a ship).
603
        //! @param d the rotation angle in degrees as an offset from the originally loaded value.
604
        void setZRotation(const float d);
605

606
        //! Install a landscape from a ZIP archive.
607
        //! This function searches for a file named "landscape.ini" in the root
608
        //! directory of the archive. If it is not found there, the function
609
        //! searches inside the topmost sub-directories (if any), but no deeper.
610
        //! If a landscape configuration file is found:
611
        //!  - if a "landscapes" directory does not exist in the user data
612
        //! directory, it is created;
613
        //!  - inside it, a sub-directory is created with the landscape identifier
614
        //! for a name;
615
        //!  - all files in the archive directory that contains the "landscape.ini"
616
        //! file are extracted to the new sub-directory of "landscapes";
617
        //!  - all sub-directories of that archive directory will be skipped along
618
        //! with any other files or directories in the archive.
619
        //!
620
        //! The landscape identifier is either:
621
        //!  - the name of the folder in the archive that contains "landscape.ini",
622
        //!  - or the first 65 (or less) characters of the archive name, if the
623
        //! "landscape.ini" file is in the nameless root directory of the archive.
624
        //!
625
        //! The landscape identifier must be unique.
626
        //! @param pathToSourceArchive path to the source archive file.
627
        //! @param display If true, the landscape will be set to be the current
628
        //! landscape after installation.
629
        //! @param forAllUsers If true, this function will try to install the
630
        //! landscape in a way that meakes it is available to all users of this
631
        //! computer. May require running Stellarium as an administrator (root)
632
        //! on some Windows or *nix systems. (NOT IMPLEMENTED!)
633
        //! @returns the installed landscape's identifier, or
634
        //! an empty string on failure.
635
        //! @todo Find a better way to pass error messages.
636
        QString installLandscapeFromArchive(QString pathToSourceArchive, const bool display = false, const bool forAllUsers = false);
637

638
        /* GZ: leaving doc without the method confuses Doxygen. Commenting out completely.
639
        //! Install a landscape from a directory.
640
        //! Expected directory structure: the name of the directory that contains
641
        //! a landscape.ini file is assumed to be the landscape ID and should be
642
        //! unique.
643
        //! This directory and all files in it will be installed, but its
644
        //! subdirectories will be skipped along with any other files or
645
        //! directories in the archive.
646
        //! @param pathToSourceLandscapeIni path to a landscape.ini file. Its parent
647
        //! directory is assumed to be the landscape source directory.
648
        //! @param display If true, the landscape will be set to be the current
649
        //! landscape after installation.
650
        //! @param forAllUsers If true, this function will try to install the
651
        //! landscape in a way that meakes it is available to all users of this
652
        //! computer. May require running Stellarium as an administrator (root)
653
        //! on some Windows or *nix systems. (NOT IMPLEMENTED!)
654
        //! @returns the installed landscape's identifier (the folder name), or
655
        //! an empty string on failure.
656
        //QString installLandscapeFromDirectory(QString pathToSourceLandscapeIni, bool display = false, bool forAllUsers = false);
657
        */
658

659
        //! This function removes a landscape from the user data directory.
660
        //! It tries to recursively delete all files in the landscape directory
661
        //! and then remove it from the list of available landscapes.
662
        //! If the function encounters any file that can't be deleted
663
        //! it aborts the operation (previously deleted files are not restored).
664
        //! Landscapes that were packaged with Stellarium can't be removed,
665
        //! thanks to the #packagedLandscapeIDs list.
666
        //! @param landscapeID an installed landscape's identifier (the folder name)
667
        //! @todo Find a better way to pass error messages.
668
        bool removeLandscape(const QString landscapeID);
669

670
        //! This function reads a landscape's name from its configuration file.
671
        //! @param landscapeID an installed landscape's identifier (the folder name)
672
        //! @returns an empty string if there is no such landscape or some other
673
        //! error occurs
674
        QString loadLandscapeName(const QString landscapeID);
675

676
        //! This function calculates and returns a landscape's disc size in bytes.
677
        //! It adds up the sizes of all files in the landscape's folder. It assumes
678
        //! that there are no sub-directories. (There shouldn't be any anyway.)
679
        //! @param landscapeID an installed landscape's identifier (the folder name)
680
        quint64 loadLandscapeSize(const QString landscapeID) const;
681

682
        //! Get flag for autoselect of landscapes for planets.
683
        bool getFlagLandscapeAutoSelection() const;
684
        //! Set flag for autoselect of landscapes for planets.
685
        void setFlagLandscapeAutoSelection(bool enableAutoSelect);
686

687
        //! Get flag for auto-enable of atmospheres and landscapes for planets.
688
        bool getFlagEnvironmentAutoEnable() const;
689
        //! Set flag for auto-enable atmosphere and landscape for planets with atmospheres in location window
690
        void setFlagEnvironmentAutoEnable(bool b);
691

692
        //! Forward opacity query to current landscape.
693
        //! @param azalt direction of view line to sample in azaltimuth coordinates.
694
        float getLandscapeOpacity(Vec3d azalt) const {return landscape->getOpacity(azalt);}
×
695
        // This variant is required for scripting!
696
        float getLandscapeOpacity(Vec3f azalt) const {return landscape->getOpacity(azalt.toVec3d());}
×
697
        //! Forward opacity query to current landscape.
698
        //! @param azimuth in degrees
699
        //! @param altitude in degrees
700
        float getLandscapeOpacity(float azimuth, float altitude) const {
×
701
                Vec3d azalt;
×
702
                StelUtils::spheToRect((180.0f-azimuth)*M_PI_180f, altitude*M_PI_180f, azalt);
×
703
                return landscape->getOpacity(azalt);
×
704
        }
705

706
        void showMessage(const QString& message);
707
        void clearMessage();
708

709
signals:
710
        void atmosphereDisplayedChanged(const bool displayed);
711
        void atmosphereModelChanged(const QString& model);
712
        void atmosphereModelPathChanged(const QString& model);
713
        void atmosphereStoppedWithErrorChanged(bool error);
714
        void atmosphereStatusTextChanged(const QString& status);
715
        void flagAtmosphereZeroOrderScatteringChanged(bool value);
716
        void flagAtmosphereSingleScatteringChanged(bool value);
717
        void flagAtmosphereMultipleScatteringChanged(bool value);
718
        void atmosphereEclipseSimulationQualityChanged(unsigned quality);
719
        void atmosphereNoScatterChanged(const bool noScatter);
720
        void cardinalPointsDisplayedChanged(const bool displayed);
721
        void ordinalPointsDisplayedChanged(const bool displayed);
722
        void ordinal16WRPointsDisplayedChanged(const bool displayed);
723
        void ordinal32WRPointsDisplayedChanged(const bool displayed);
724
        void cardinalPointsColorChanged(const Vec3f & newColor) const;
725
        void fogDisplayedChanged(const bool displayed);
726
        void landscapeDisplayedChanged(const bool displayed);
727
        void illuminationDisplayedChanged(const bool displayed);
728
        void labelsDisplayedChanged(const bool displayed);
729
        void labelFontSizeChanged(const int size);
730
        void labelColorChanged(const Vec3f &c);
731
        void labelAngleChanged(const int angleDeg);
732
        void flagPolyLineOnlyDisplayedChanged(const bool enabled);
733
        void polyLineThicknessChanged(const int thickness);
734
        void polyLineColorChanged(const Vec3f& c);
735
        void flagUseLightPollutionFromDatabaseChanged(const bool usage);
736
        void flagLandscapeAutoSelectionChanged(const bool value);
737
        void flagLandscapeSetsLocationChanged(const bool value);
738
        void flagLandscapeUseMinimalBrightnessChanged(const bool value);
739
        void flagLandscapeSetsMinimalBrightnessChanged(const bool value);
740
        void defaultMinimalBrightnessChanged(const double value);
741
        void setFlagEnvironmentAutoEnableChanged(const bool enabled);
742
        void landscapeTransparencyChanged(const double value);
743
        void flagLandscapeUseTransparencyChanged(const bool value);
744

745
        //! Emitted whenever the default landscape is changed
746
        //! @param id the landscape id of the new default landscape
747
        void defaultLandscapeChanged(const QString& id);
748

749
        //! Emitted when a landscape has been installed or un-installed.
750
        //! For example, it is used to update the list of landscapes in
751
        //! the Sky and viewing options window (the ViewDialog class)
752
        void landscapesChanged();
753

754
        //! Emitted when installLandscapeFromArchive() can't read from, write to or
755
        //! create a file or a directory.
756
        //! (A way of moving the need for translatable error messages to the GUI.)
757
        //! \param path path to the file or directory
758
        void errorUnableToOpen(QString path);
759
        //! Emitted when the file passed to installLandscapeFromArchive() is not a
760
        //! ZIP archive or does not contain a valid landscape.
761
        //! (A way of moving the need for translatable error messages to the GUI.)
762
        void errorNotArchive();
763
        //! Emitted when installLandscapeFromArchive() tries to install a landscape
764
        //! with the same name or identifier as an already installed one.
765
        //! (A way of moving the need for translatable error messages to the GUI.)
766
        //! \param nameOrID the name or the identifier of the landscape
767
        void errorNotUnique(QString nameOrID);
768
        //! Emitted when removeLandscape() is unable to remove all the files of
769
        //! a landscape.
770
        //! (A way of moving the need for translatable error messages to the GUI.)
771
        //! \param path the path to the landscape's directory
772
        void errorRemoveManually(QString path);
773

774
        //! Emitted when the current landscape was changed
775
        //! \param currentLandscapeID the ID of the new landscape
776
        //! \param currentLandscapeName the name of the new landscape
777
        void currentLandscapeChanged(QString currentLandscapeID,QString currentLandscapeName);
778

779
private slots:
780
        //! Reacts to StelCore::locationChanged.
781
        //! If flagLightPollutionFromDatabase is active,
782
        //! this applies light pollution information from the new location
783
        void onLocationChanged(const StelLocation &loc);
784
        //! To be connected to StelCore::targetLocationChanged.
785
        //! This sets landscape with landscapeID.
786
        //! If that is empty and flagLandscapeAutoSelection==true, set a landscape fitting to loc's planet.
787
        //! Does not set loc itself!
788
        void onTargetLocationChanged(const StelLocation &loc, const QString &landscapeID);
789

790
        //! Translate labels to new language settings.
791
        void updateI18n();
792

793
        void increaseLightPollution();
794
        void reduceLightPollution();
795
        void cyclicChangeLightPollution();
796
        void createAtmosphere();
797
        void resetToFallbackAtmosphere();
798

799
private:
800
        //! Get light pollution luminance level in cd/m².
801
        float getAtmosphereLightPollutionLuminance() const;
802
        //! Set light pollution luminance level in cd/m².
803
        void setAtmosphereLightPollutionLuminance(const float f);
804

805
        //! For a given landscape name, return the landscape ID.
806
        //! This takes a name of the landscape, as described in the landscape:name item in the
807
        //! landscape.ini, and returns the landscape ID which corresponds to that name.
808
        static QString nameToID(const QString& name);
809

810
        //! Returns the path to an installed landscape's directory.
811
        //! It uses StelFileMgr to look for it in the possible directories.
812
        //! @param landscapeID an installed landscape's identifier (the folder name)
813
        //! @returns an empty string, if no such landscape was found.
814
        static QString getLandscapePath(const QString landscapeID);
815

816
        Skylight skylight; // Is used by AtmospherePreetham, but must not be deleted & re-created,
817
                       // otherwise StelPropertyMgr::registerObject will break.
818
        std::unique_ptr<Atmosphere> atmosphere; // Atmosphere
819
        std::unique_ptr<Atmosphere> loadingAtmosphere; // Atmosphere that's in the process of loading
820
        Cardinals* cardinalPoints;                // Cardinals points
821
        Landscape* landscape;                        // The landscape i.e. the fog, the ground and "decor"
822
        Landscape* oldLandscape;                // Used only during transitions to newly loaded landscape.
823

824
        // Used to display error messages: e.g. when atmosphere model fails
825
        LinearFader messageFader;
826
        QString messageToShow;
827
        QTimer* messageTimer = nullptr;
828

829
        //! Define whether the observer location is to be updated when the landscape is updated and includes location info.
830
        bool flagLandscapeSetsLocation;
831

832
        //! Define whether on location change onto another planet a landscape for the new planet shall be loaded.
833
        bool flagLandscapeAutoSelection;
834

835
        bool flagLightPollutionFromDatabase;
836
        bool atmosphereNoScatter; //!< true to suppress actual blue-sky rendering but keep refraction & extinction
837

838
        //! control drawing of a Polygonal line, if one is defined.
839
        bool flagPolyLineDisplayedOnly;
840

841
        //! Indicate use of the default minimal brightness value specified in config.ini.
842
        bool flagLandscapeUseMinimalBrightness;
843
        //! A minimal brightness value to keep landscape visible.
844
        double defaultMinimalBrightness;
845
        //! Indicate use of the minimal brightness value specified in the current landscape.ini, if present.
846
        bool flagLandscapeSetsMinimalBrightness;
847
        //! Indicate auto-enable atmosphere and landscape for planets with atmospheres in location window
848
        bool flagEnvironmentAutoEnabling;
849

850
        //! Indicate use of the default transparency value specified in config.ini.
851
        bool flagLandscapeUseTransparency;
852
        //! A user-configurable transparency value to make landscape partially see-through and let objects below the horizon be visible
853
        double landscapeTransparency;
854
        //! Color tint to draw the landscape in. Can be useful for sunrise/sunset scenes.
855
        Vec3f landscapeTint;
856

857
        //! The ID of the currently loaded landscape
858
        QString currentLandscapeID;
859

860
        //! The ID of the default landscape
861
        QString defaultLandscapeID;
862

863
        //! List of the IDs of the landscapes packaged by default with Stellarium.
864
        //! (So that they can't be removed.)
865
        QStringList packagedLandscapeIDs;
866

867
        //! QCache of landscapes kept in memory for faster access, esp. when frequently switching between several big landscapes.
868
        //! Example: a 16384-size old_style landscape takes about 10 seconds to load. Kept in cache, it is back instantly.
869
        //! Of course, this requires lots of RAM and GPU texture memory, but in the age of 64bit CPUs and 4GB and more GPU
870
        //! texture memory, it is no problem to keep even 20 or more landscapes.
871
        //! This is esp. useful in a context of automated setup (museum show or such) where a list of landscapes is preloaded
872
        //! at system start (e.g. in the startup.ssc script) and then retrieved while script is running.
873
        //! The key is just the LandscapeID.
874
        QCache<QString,Landscape> landscapeCache;
875

876
        //! Core current planet name, used to react to planet change.
877
        QString currentPlanetName;
878

879
        bool needToRecreateAtmosphere=false;
880
        bool atmosphereZeroOrderScatteringEnabled=false;
881
        bool atmosphereSingleScatteringEnabled=true;
882
        bool atmosphereMultipleScatteringEnabled=true;
883

884
        QString atmosphereShowMySkyStatusText;
885
        bool atmosphereShowMySkyStoppedWithError=false;
886
};
887

888
#endif // LANDSCAPEMGR_HPP
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