File: fileio.h

package info (click to toggle)
stellarsolver 2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,112 kB
  • sloc: ansic: 31,587; cpp: 15,103; python: 186; sh: 74; pascal: 67; perl: 9; makefile: 2
file content (106 lines) | stat: -rw-r--r-- 2,361 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef FILEIO_H
#define FILEIO_H

//Qt Includes
#include <QObject>
#include <QImageReader>
#include <QFile>
#include <QVariant>

//CFitsio Includes
#include "fitsio.h"

//KStars related includes
#include "stretch.h"
#include "math.h"
#include "dms.h"
#include "bayer.h"

//Project Includes
#include "parameters.h"
#include "structuredefinitions.h"
#include "stellarsolver/sep/sep.h"

class fileio : public QObject
{
    Q_OBJECT
public:

    /** Structure to hold FITS Header records */
    typedef struct
    {
        QString key;      /** FITS Header Key */
        QVariant value;   /** FITS Header Value */
        QString comment;  /** FITS Header Comment, if any */
    } Record;


    fileio();
    ~fileio();
    void deleteImageBuffer();
    bool logToSignal = false;
    bool loadImage(QString fileName);
    bool loadImageBufferOnly(QString fileName);
    bool loadFits(QString fileName);
    bool parseHeader();
    bool saveAsFITS(QString fileName, FITSImage::Statistic &imageStats, uint8_t *m_ImageBuffer, FITSImage::Solution solution, const QList<Record> &records, bool hasSolution);
    bool loadOtherFormat(QString fileName);
    bool checkDebayer();
    bool debayer();
    bool debayer_8bit();
    bool debayer_16bit();
    bool getSolverOptionsFromFITS();

    bool position_given = false;
    double ra;
    double dec;

    bool scale_given = false;
    double scale_low;
    double scale_high;
    SSolver::ScaleUnits scale_units;

    bool imageBufferTaken = false;
    uint8_t *getImageBuffer();

    FITSImage::Statistic getStats(){
        return stats;
    }

    const QList<Record> &getRecords() const
    {
        return m_HeaderRecords;
    }

    void setRecords(QList<Record> &records)
    {
        m_HeaderRecords = records;
    }

    QImage getRawQImage()
    {
        return rawImage;
    }

private:
    QString file;
    fitsfile *fptr { nullptr };
    FITSImage::Statistic stats;
    QList<Record> m_HeaderRecords;
    /// Generic data image buffer
    uint8_t *m_ImageBuffer { nullptr };
    /// Above buffer size in bytes
    uint32_t m_ImageBufferSize { 0 };
    bool justLoadBuffer = false;
    StretchParams stretchParams;
    BayerParams debayerParams;
    void logIssue(QString messsage);

    QImage rawImage;
    void generateQImage();

signals:
    void logOutput(QString logText);
};

#endif // FILEIO_H