File indexing completed on 2024-04-14 14:08:56

0001 /*
0002     SPDX-FileCopyrightText: 2016 Akarsh Simha <akarsh@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "dms.h"
0010 
0011 #include <QImage>
0012 #include <QString>
0013 
0014 /**
0015  * @class KSDssImage
0016  * @short Provides a class to hold a DSS Image along with its metadata
0017  *
0018  * @author Akarsh Simha <akarsh@kde.org>
0019  */
0020 class KSDssImage
0021 {
0022   public:
0023     /** @short Constructor */
0024     explicit KSDssImage(const QString &fileName);
0025 
0026     /**
0027      * @struct KSDssImage::Metadata
0028      * @short Structure to hold some DSS image metadata
0029      *
0030      * @note Some fields in the structure are redundant. The methods
0031      * that fill this structure must be designed to fill in the
0032      * redundancies correctly!
0033      *
0034      */
0035     struct Metadata
0036     {
0037         /**
0038          * @enum Source
0039          * @short Contains possible sources for digitized sky-survey images
0040          */
0041         enum Source
0042         {
0043             DSS                   = 0,
0044             SDSS                  = 1,
0045             GenericInternetSource = 2
0046         };
0047 
0048         /**
0049          * @enum FileFormat
0050          * @short Contains possible file formats for images
0051          *
0052          * @note Although DSS website provides us GIF, we may convert
0053          * to PNG to incorporate metadata, since by default Qt has no
0054          * write support for GIF. Besides, PNG compresses better.
0055          *
0056          */
0057         enum FileFormat
0058         {
0059             FITS = 0,
0060             GIF  = 1,
0061             PNG  = 2
0062         };
0063 
0064         /// Used for DSS -- Indicates which version of scans to pull
0065         QString version;
0066         /// Name / identifier of the object. Added to metadata
0067         QString object;
0068         /// File format used.
0069         FileFormat format { FITS };
0070         /// DSS / SDSS -- source of the image
0071         Source src { DSS };
0072         /// Center RA (J2000.0)
0073         dms ra0;
0074         /// Center Dec (J2000.0)
0075         dms dec0;
0076         /// Height in arcminutes
0077         float height { 0 };
0078         /// Width in arcminutes
0079         float width { 0 };
0080         /// Photometric band (UBVRI...) Use "?" for unknown.
0081         char band { '?' };
0082         /// Generation for DSS images, data release for SDSS; use -1 for unknown.
0083         int gen { -1 };
0084         /// Are these data valid?
0085         bool valid { false };
0086 
0087         inline bool isValid() const
0088         {
0089             return valid; // convenience method
0090         }
0091     };
0092 
0093     inline QImage getImage() const { return m_Image; }
0094     inline KSDssImage::Metadata getMetadata() const { return m_Metadata; }
0095     inline QString getFileName() const { return m_FileName; }
0096 
0097     // TODO: Implement methods to load and read FITS image data and metadata
0098 
0099   private:
0100     // TODO: Add support for FITS
0101     QString m_FileName;
0102     QImage m_Image;
0103     Metadata m_Metadata;
0104 };