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

Stellarium / stellarium / 13149582607

03 Feb 2025 11:24AM UTC coverage: 12.101% (-0.04%) from 12.141%
13149582607

push

github

web-flow
Translate po/stellarium/stellarium.pot in zh_CN

100% translated source file: 'po/stellarium/stellarium.pot'
on 'zh_CN'.

14603 of 120671 relevant lines covered (12.1%)

18593.62 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
        void updateFontSizes();
107

108
private:
109
        class StelPropertyMgr* propMgr;
110
        QFont font4WCR, font8WCR, font16WCR, font32WCR;
111
        Vec3f color;
112
        static constexpr float q8 = M_SQRT2*0.5f; // dimension for intercardinals
113
        static const float sp8, cp8, s1p16, c1p16, s3p16, c3p16; // dimensions for 2nd/3rd intercardinals
114
        static const QMap<Cardinals::CompassDirection, Vec3f> rose4winds, rose8winds, rose16winds, rose32winds;
115
        QMap<Cardinals::CompassDirection, QString> labels;
116
        LinearFader fader4WCR, fader8WCR, fader16WCR, fader32WCR;
117
        int screenFontSize;
118
};
119

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

297
public:
298
        LandscapeMgr();
299
        ~LandscapeMgr() override;
300

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

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

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

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

327
        ///////////////////////////////////////////////////////////////////////////
328
        // Methods specific to the landscape manager
329

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

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

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

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

359
        //! 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.
360
        //! Usually there is no need to call this, the luminance is properly computed. This is a function which can be
361
        //! useful in rare cases, e.g. in scripts when you want to create images of adjacent sky regions with the same brightness setting,
362
        //! or for creation of a virtual camera which can deliberately show over- or underexposure.
363
        //! For these cases, it is advisable to first center the brightest luminary (sun or moon), call getAtmosphereAverageLuminance() and then set
364
        //! this value explicitly to freeze it during image export. To unfreeze, call this again with any negative value.
365
        void setAtmosphereAverageLuminance(const float overrideLuminance);
366

367
        //! Return a map of landscape names to landscape IDs (directory names).
368
        static QMap<QString,QString> getNameToDirMap();
369

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

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

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

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

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

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

431
        //! Get the current landscape object.
432
        Landscape* getCurrentLandscape() const { return landscape; }
×
433

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

441
        //! Return a pseudo HTML formatted string with all information on the current landscape
442
        QString getCurrentLandscapeHtmlDescription() const;
443

444
        //! Return a pseudo HTML formatted string with information from description or ini file
445
        QString getDescription() const;
446

447
        //! Get flag for displaying Landscape.
448
        bool getFlagLandscape() const;
449
        //! Set flag for displaying Landscape.
450
        void setFlagLandscape(const bool displayed);
451

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

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

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

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

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

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

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

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

537
        //! Get Cardinals Points color.
538
        Vec3f getColorCardinalPoints() const;
539
        //! Set Cardinals Points color.
540
        void setColorCardinalPoints(const Vec3f& v);
541

542
        //! Get flag for displaying Atmosphere.
543
        bool getFlagAtmosphere() const;
544
        //! Set flag for displaying Atmosphere.
545
        void setFlagAtmosphere(const bool displayed);
546

547
        QString getAtmosphereModel() const;
548
        void setAtmosphereModel(const QString& model);
549

550
        QString getAtmosphereModelPath() const;
551
        void setAtmosphereModelPath(const QString& path);
552

553
        QString getDefaultAtmosphereModelPath() const;
554

555
        bool getAtmosphereShowMySkyStoppedWithError() const;
556
        void setAtmosphereShowMySkyStoppedWithError(bool error);
557

558
        QString getAtmosphereShowMySkyStatusText() const;
559
        void setAtmosphereShowMySkyStatusText(const QString& text);
560

561
        bool getFlagAtmosphereZeroOrderScattering() const;
562
        void setFlagAtmosphereZeroOrderScattering(bool enable);
563

564
        bool getFlagAtmosphereSingleScattering() const;
565
        void setFlagAtmosphereSingleScattering(bool enable);
566

567
        bool getFlagAtmosphereMultipleScattering() const;
568
        void setFlagAtmosphereMultipleScattering(bool enable);
569

570
        int getAtmosphereEclipseSimulationQuality() const;
571
        void setAtmosphereEclipseSimulationQuality(int quality);
572

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

578
        //! Get current display intensity of atmosphere ([0..1], for smoother transitions)
579
        float getAtmosphereFadeIntensity() const;
580

581
        //! Get atmosphere fade duration in s.
582
        float getAtmosphereFadeDuration() const;
583
        //! Set atmosphere fade duration in s.
584
        void setAtmosphereFadeDuration(const float f);
585

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

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

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

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

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

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

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

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

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

685
        //! Get flag for autoselect of landscapes for planets.
686
        bool getFlagLandscapeAutoSelection() const;
687
        //! Set flag for autoselect of landscapes for planets.
688
        void setFlagLandscapeAutoSelection(bool enableAutoSelect);
689

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

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

709
        void showMessage(const QString& message);
710
        void clearMessage();
711

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

748
        //! Emitted whenever the default landscape is changed
749
        //! @param id the landscape id of the new default landscape
750
        void defaultLandscapeChanged(const QString& id);
751

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

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

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

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

793
        //! Translate labels to new language settings.
794
        void updateI18n();
795

796
        void increaseLightPollution();
797
        void reduceLightPollution();
798
        void cyclicChangeLightPollution();
799
        void createAtmosphere();
800
        void resetToFallbackAtmosphere();
801

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

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

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

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

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

832
        //! Define whether the observer location is to be updated when the landscape is updated and includes location info.
833
        bool flagLandscapeSetsLocation;
834

835
        //! Define whether on location change onto another planet a landscape for the new planet shall be loaded.
836
        bool flagLandscapeAutoSelection;
837

838
        bool flagLightPollutionFromDatabase;
839
        bool atmosphereNoScatter; //!< true to suppress actual blue-sky rendering but keep refraction & extinction
840

841
        //! control drawing of a Polygonal line, if one is defined.
842
        bool flagPolyLineDisplayedOnly;
843

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

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

860
        //! The ID of the currently loaded landscape
861
        QString currentLandscapeID;
862

863
        //! The ID of the default landscape
864
        QString defaultLandscapeID;
865

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

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

879
        //! Core current planet name, used to react to planet change.
880
        QString currentPlanetName;
881

882
        bool needToRecreateAtmosphere=false;
883
        bool atmosphereZeroOrderScatteringEnabled=false;
884
        bool atmosphereSingleScatteringEnabled=true;
885
        bool atmosphereMultipleScatteringEnabled=true;
886

887
        QString atmosphereShowMySkyStatusText;
888
        bool atmosphereShowMySkyStoppedWithError=false;
889
};
890

891
#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