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

Stellarium / stellarium / 3996069357

pending completion
3996069357

push

github

Ruslan Kabatsayev
Shorten some lines

5 of 5 new or added lines in 1 file covered. (100.0%)

14663 of 124076 relevant lines covered (11.82%)

22035.13 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() Q_DECL_OVERRIDE;
44

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

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

53
        //! Determines the order in which the various modules are drawn.
54
        virtual double getCallOrder(StelModuleActionName actionName) const Q_DECL_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
public slots:
77
        ///////////////////////////////////////////////////////////////////////////
78
        // Properties setters and getters
79
        //! Set whether Sky Background should be displayed
80
        void setFlagShow(bool b) {if (flagShow !=b) { flagShow = b; emit flagShowChanged(b);}}
×
81
        //! Load an image from a file into a quad described with 4 corner coordinates.
82
        //! The corners are always given in counterclockwise from top-left, also for azaltimuthal images.
83
        //! This should not be called directly from scripts because it is not thread safe.
84
        //! Instead use the similarly named function in the core scripting object.
85
        //! @param id a string identifier for the image
86
        //! @param filename the name of the image file to load.  Will be
87
        //! searched for using StelFileMgr, so partial names are fine.
88
        //! @param lon0 right ascension/longitude/azimuth of top-left corner 0 in degrees
89
        //! @param lat0 declination/latitude/altitude of corner 0 in degrees
90
        //! @param lon1 right ascension/longitude/azimuth of bottom-left corner 1 in degrees
91
        //! @param lat1 declination/latitude/altitude of corner 1 in degrees
92
        //! @param lon2 right ascension/longitude/azimuth of bottom-right corner 2 in degrees
93
        //! @param lat2 declination/latitude/altitude of corner 2 in degrees
94
        //! @param lon3 right ascension/longitude/azimuth of top-right corner 3 in degrees
95
        //! @param lat3 declination/latitude/altitude of corner 3 in degrees
96
        //! @param minRes the minimum resolution setting for the image
97
        //! @param maxBright the maximum brightness setting for the image
98
        //! @param visible initial visibility setting
99
        //! @param frameType Coordinate frame type
100
        //! @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.
101
        //! @param decimateBy allow texture reduction on loading, useful on very limited hardware.
102
        //! @note frameType has been added 2017-03. Use loadSkyImage(... , StelCore::FrameJ2000) for the previous behaviour!
103
        //! @note For frameType=AzAlt, azimuth currently is counted from South towards East.
104
        //! @bug Some image are not visible close to screen center, only when in the corners.
105
        bool loadSkyImage(const QString& id, const QString& filename,
106
                                          double long0, double lat0,
107
                                          double long1, double lat1,
108
                                          double long2, double lat2,
109
                                          double long3, double lat3,
110
                                          double minRes, double maxBright, bool visible, StelCore::FrameType frameType=StelCore::FrameJ2000, bool withAberration=true, int decimateBy=1);
111

112
        //! Decide to show or not to show a layer by its ID.
113
        //! @param id the id of the layer whose status is to be changed.
114
        //! @param b the new shown value:
115
        //! - true means the specified image will be shown.
116
        //! - false means the specified image will not be shown.
117
        void showLayer(const QString& id, bool b);
118
        //! Get the current shown status of a specified image.
119
        //! @param id the ID of the image whose status is desired.
120
        //! @return the current shown status of the specified image:
121
        //! - true means the specified image is currently shown.
122
        //! - false means the specified image is currently not shown.
123
        bool getShowLayer(const QString& id) const;
124

125
        ///////////////////////////////////////////////////////////////////////////
126
        // Other slots
127
        //! Add a new SkyImage from its URI (URL or local file name).
128
        //! The image is owned by the manager and will be destroyed at the end of the program
129
        //! or when removeSkyImage is called with the same URI
130
        //! @param uri the local file or the URL where the JSON image description is located.
131
        //! @param keyHint a hint on which key to use for later referencing the image.
132
        //! @param show defined whether the image should be shown by default.
133
        //! @param decimateBy Allow image size reduction (e.g., 2...8) on very limited hardware
134
        //! @return the reference key to use when accessing this image later on.
135
        QString insertSkyImage(const QString& uri, const QString& keyHint=QString(), bool show=true, int decimateBy=1);
136

137
        //! Remove a sky layer from the list.
138
        //! Note: this is not thread safe, and so should not be used directly
139
        //! from scripts - use the similarly named function in the core
140
        //! scripting API object to delete SkyLayers.
141
        //! @param key the reference key (id) generated by insertSkyImage.
142
        void removeSkyLayer(const QString& key);
143

144
        //! Return the list of all the layer currently loaded.
145
        QStringList getAllKeys() const {return allSkyLayers.keys();}
×
146

147
signals:
148
        void flagShowChanged(bool b);
149

150
private slots:
151
        //! Called when loading of data started or stopped for one collection
152
        //! @param b true if data loading started, false if finished
153
        void loadingStateChanged(bool b);
154

155
        //! Called when the percentage of loading tiles/tiles to be displayed changed for one collection
156
        //! @param percentage the percentage of loaded data
157
        void percentLoadedChanged(int percentage);
158

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

163
private:
164
        //! Store the information needed for a graphical element layer.
165
        class SkyLayerElem
166
        {
167
        public:
168
                SkyLayerElem(StelSkyLayerP t, bool show=true);
169
                ~SkyLayerElem();
170
                StelSkyLayerP layer;
171
                class StelProgressController* progressBar;
172
                bool show;
173
        };
174

175
        SkyLayerElem* skyLayerElemForLayer(const StelSkyLayer*);
176

177
        QString keyForLayer(const StelSkyLayer*);
178

179
        //! Map image key/layer
180
        QMap<QString, SkyLayerElem*> allSkyLayers;
181

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

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