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

Stellarium / stellarium / 15670918640

16 Jun 2025 02:08AM UTC coverage: 11.775% (-0.2%) from 11.931%
15670918640

push

github

alex-w
Updated data

14700 of 124846 relevant lines covered (11.77%)

18324.52 hits per line

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

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

19
#ifndef STELSKYLAYERMGR_HPP
20
#define STELSKYLAYERMGR_HPP
21

22
#include "StelModule.hpp"
23
#include "StelSkyLayer.hpp"
24

25
#include <QString>
26
#include <QStringList>
27
#include <QMap>
28

29
class StelCore;
30
class StelSkyImageTile;
31

32
//! Manage the sky background images, including DSS and deep sky objects images.
33
//! Drawn after Milky Way, but before Zodiacal Light.
34
//! It is not intended to be used to "overdraw" images into the foreground without a concept of surface magnitude.
35

36
class StelSkyLayerMgr : public StelModule
37
{
38
        Q_OBJECT
39
        Q_PROPERTY(bool flagShow READ getFlagShow WRITE setFlagShow NOTIFY flagShowChanged)
40

41
public:
42
        StelSkyLayerMgr();
43
        ~StelSkyLayerMgr() override;
44

45
        ///////////////////////////////////////////////////////////////////////////
46
        // Methods defined in the StelModule class
47
        //! Initialize
48
        void init() override;
49

50
        //! Draws sky background
51
        void draw(StelCore* core) override;
52

53
        //! Determines the order in which the various modules are drawn.
54
        double getCallOrder(StelModuleActionName actionName) const override;
55

56
        ///////////////////////////////////////////////////////////////////////////
57
        // Other specific methods
58
        //! Add a new layer.
59
        //! @param l the layer to insert.
60
        //! @param keyHint a hint on which key to use for later referencing the image.
61
        //! @param show defined whether the layer should be shown by default
62
        //! @return the reference key to use when accessing this layer later on.
63
        QString insertSkyLayer(StelSkyLayerP l, const QString& keyHint=QString(), bool show=true);
64

65
        //! Remove a layer.
66
        void removeSkyLayer(StelSkyLayerP l);
67

68
        //! Get the list of all the currently loaded layers.
69
        QMap<QString, StelSkyLayerP> getAllSkyLayers() const;
70

71
        StelSkyLayerP getSkyLayer(const QString& key) const;
72

73
        //! Get whether Sky Background should be displayed
74
        bool getFlagShow() const {return flagShow;}
×
75

76
        //! Store the information needed for a graphical element layer.
77
        class SkyLayerElem
78
        {
79
        public:
80
                SkyLayerElem(StelSkyLayerP t, bool show=true);
81
                ~SkyLayerElem();
82
                StelSkyLayerP layer;
83
                class StelProgressController* progressBar;
84
                bool show;
85
        };
86

87
        //! Map image key/layer
88
        QMap<QString, SkyLayerElem*> allSkyLayers;
89

90
public slots:
91
        ///////////////////////////////////////////////////////////////////////////
92
        // Properties setters and getters
93
        //! Set whether Sky Background should be displayed
94
        void setFlagShow(bool b) {if (flagShow !=b) { flagShow = b; StelApp::immediateSave("astro/flag_nebula_display_no_texture", !b); emit flagShowChanged(b);}}
×
95
        //! Load an image from a file into a quad described with 4 corner coordinates.
96
        //! The corners are always given in counterclockwise from top-left, also for azaltimuthal images.
97
        //! This should not be called directly from scripts because it is not thread safe.
98
        //! Instead use the similarly named function in the core scripting object.
99
        //! @param id a string identifier for the image
100
        //! @param filename the name of the image file to load.  Will be
101
        //! searched for using StelFileMgr, so partial names are fine.
102
        //! @param lon0 right ascension/longitude/azimuth of top-left corner 0 in degrees
103
        //! @param lat0 declination/latitude/altitude of corner 0 in degrees
104
        //! @param lon1 right ascension/longitude/azimuth of bottom-left corner 1 in degrees
105
        //! @param lat1 declination/latitude/altitude of corner 1 in degrees
106
        //! @param lon2 right ascension/longitude/azimuth of bottom-right corner 2 in degrees
107
        //! @param lat2 declination/latitude/altitude of corner 2 in degrees
108
        //! @param lon3 right ascension/longitude/azimuth of top-right corner 3 in degrees
109
        //! @param lat3 declination/latitude/altitude of corner 3 in degrees
110
        //! @param minRes the minimum resolution setting for the image
111
        //! @param maxBright the maximum brightness setting for the image
112
        //! @param visible initial visibility setting
113
        //! @param frameType Coordinate frame type
114
        //! @param withAberration the image shall undergo aberration effects. Else it is really fixed to the frame. This flag is only used for images linked to FrameJ2000.
115
        //! @param decimateBy allow texture reduction on loading, useful on very limited hardware.
116
        //! @note frameType has been added 2017-03. Use loadSkyImage(... , StelCore::FrameJ2000) for the previous behaviour!
117
        //! @note For frameType=AzAlt, azimuth currently is counted from South towards East.
118
        //! @bug Some image are not visible close to screen center, only when in the corners.
119
        bool loadSkyImage(const QString& id, const QString& filename,
120
                                          double long0, double lat0,
121
                                          double long1, double lat1,
122
                                          double long2, double lat2,
123
                                          double long3, double lat3,
124
                                          double minRes, double maxBright, bool visible, StelCore::FrameType frameType=StelCore::FrameJ2000, bool withAberration=true, int decimateBy=1);
125

126
        //! Decide to show or not to show a layer by its ID.
127
        //! @param id the id of the layer whose status is to be changed.
128
        //! @param b the new shown value:
129
        //! - true means the specified image will be shown.
130
        //! - false means the specified image will not be shown.
131
        void showLayer(const QString& id, bool b);
132
        //! Get the current shown status of a specified image.
133
        //! @param id the ID of the image whose status is desired.
134
        //! @return the current shown status of the specified image:
135
        //! - true means the specified image is currently shown.
136
        //! - false means the specified image is currently not shown.
137
        bool getShowLayer(const QString& id) const;
138

139
        ///////////////////////////////////////////////////////////////////////////
140
        // Other slots
141
        //! Add a new SkyImage from its URI (URL or local file name).
142
        //! The image is owned by the manager and will be destroyed at the end of the program
143
        //! or when removeSkyImage is called with the same URI
144
        //! @param uri the local file or the URL where the JSON image description is located.
145
        //! @param keyHint a hint on which key to use for later referencing the image.
146
        //! @param show defined whether the image should be shown by default.
147
        //! @param decimateBy Allow image size reduction (e.g., 2...8) on very limited hardware
148
        //! @return the reference key to use when accessing this image later on.
149
        QString insertSkyImage(const QString& uri, const QString& keyHint=QString(), bool show=true, int decimateBy=1);
150

151
        //! Remove a sky layer from the list.
152
        //! Note: this is not thread safe, and so should not be used directly
153
        //! from scripts - use the similarly named function in the core
154
        //! scripting API object to delete SkyLayers.
155
        //! @param key the reference key (id) generated by insertSkyImage.
156
        void removeSkyLayer(const QString& key);
157

158
        //! Return the list of all the layer currently loaded.
159
        QStringList getAllKeys() const {return allSkyLayers.keys();}
×
160

161
signals:
162
        void flagShowChanged(bool b);
163
        void collectionLoaded();
164

165
private slots:
166
        //! Called when loading of data started or stopped for one collection
167
        //! @param b true if data loading started, false if finished
168
        void loadingStateChanged(bool b);
169

170
        //! Called when the percentage of loading tiles/tiles to be displayed changed for one collection
171
        //! @param percentage the percentage of loaded data
172
        void percentLoadedChanged(int percentage);
173

174
        //! Load the textures from the default nebula collection
175
        //! @param decimateBy allow texture size decimation (division) by this factor (for very weak hardware)
176
        void loadCollection(int decimateBy=1);
177

178
private:
179
        SkyLayerElem* skyLayerElemForLayer(const StelSkyLayer*);
180

181
        QString keyForLayer(const StelSkyLayer*);
182

183
        // Whether to draw at all
184
        bool flagShow;
185
};
186

187
#endif // STELSKYLAYERMGR_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