Kstars

fitstab.h
1/*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "fitscommon.h"
10
11#include <QUndoStack>
12#include <QSplitter>
13#include <QToolBox>
14#include <QUrl>
15#include <QWidget>
16#include "ui_fitsheaderdialog.h"
17#include "ui_statform.h"
18#include "ui_platesolve.h"
19#include <QFuture>
20#include <QPointer>
21#include <QListWidget>
22#include <QLabel>
23#include <QPushButton>
24#include <memory>
25#include "ekos/auxiliary/solverutils.h"
26#include <KConfigDialog>
27
28class FITSHistogramEditor;
29class FITSView;
30class FITSViewer;
31class FITSData;
32class FITSStretchUI;
33
34namespace Ekos
35{
36class StellarSolverProfileEditor;
37}
38
39/**
40 * @brief The FITSTab class holds information on the current view (drawing area) in addition to the undo/redo stacks
41 * and status of current document (clean or dirty). It also creates the corresponding histogram associated with the
42 * image data that is stored in the FITSView class.
43 * @author Jasem Mutlaq
44 */
45class FITSTab : public QWidget
46{
48 public:
49 explicit FITSTab(FITSViewer *parent);
50 virtual ~FITSTab() override;
51
52 enum
53 {
54 STAT_WIDTH,
55 STAT_HEIGHT,
56 STAT_BITPIX,
57 STAT_HFR,
58 STAT_MIN,
59 STAT_MAX,
60 STAT_MEAN,
61 STAT_MEDIAN,
62 STAT_STDDEV
63 };
64
65 void clearRecentFITS();
66 void selectRecentFITS(int i);
67 void loadFile(const QUrl &imageURL, FITSMode mode = FITS_NORMAL, FITSScale filter = FITS_NONE);
68 bool loadData(const QSharedPointer<FITSData> &data, FITSMode mode = FITS_NORMAL, FITSScale filter = FITS_NONE);
69
70 // Methods to setup and control blinking--loading a directory of images one-by-one
71 // into a single tab.
72 void initBlink(const QList<QString> &filenames)
73 {
74 m_BlinkFilenames = filenames;
75 }
76 const QList<QString> &blinkFilenames() const
77 {
78 return m_BlinkFilenames;
79 }
80 int blinkUpto() const
81 {
82 return m_BlinkIndex;
83 };
84 void setBlinkUpto(int index)
85 {
86 if (index >= 0 && index < m_BlinkFilenames.size())
87 m_BlinkIndex = index;
88 };
89
90 bool saveImage(const QString &filename);
91
92 inline QUndoStack *getUndoStack()
93 {
94 return undoStack;
95 }
96 inline QUrl *getCurrentURL()
97 {
98 return &currentURL;
99 }
100 inline const QSharedPointer<FITSView> &getView()
101 {
102 return m_View;
103 }
104 inline QPointer<FITSHistogramEditor> getHistogram()
105 {
106 return m_HistogramEditor;
107 }
108 inline QPointer<FITSViewer> getViewer()
109 {
110 return viewer;
111 }
112
113 bool saveFile();
114 bool saveFileAs();
115 void copyFITS();
116 void loadFITSHeader();
117 void headerFITS();
118 void histoFITS();
119 void statFITS();
120
121 Q_SCRIPTABLE void setStretchValues(double shadows, double midtones, double highlights);
122 Q_SCRIPTABLE void setAutoStretch();
123
124 void setUID(int newID)
125 {
126 uid = newID;
127 }
128 int getUID()
129 {
130 return uid;
131 }
132
133 void saveUnsaved();
134 void tabPositionUpdated();
135 void selectGuideStar();
136
137 QString getPreviewText() const;
138 void setPreviewText(const QString &value);
139 bool shouldComputeHFR() const;
140
141 public slots:
142 void modifyFITSState(bool clean = true, const QUrl &imageURL = QUrl());
143 void ZoomIn();
144 void ZoomOut();
145 void ZoomDefault();
146 void displayStats(bool roi = false);
147 void extractImage();
148 void solveImage();
149 protected:
150 virtual void closeEvent(QCloseEvent *ev) override;
151
152 private:
153 bool setupView(FITSMode mode, FITSScale filter);
154 void processData();
155 void imageSolved(bool success);
156
157 /** Ask user whether he wants to save changes and save if he do. */
158
159 /// The FITSTools Toolbox
160 QPointer<QToolBox> fitsTools;
161 /// The Splitter for th FITSTools Toolbox
162 QPointer<QSplitter> fitsSplitter;
163 /// The FITS Header Panel
164 QPointer<QDialog> fitsHeaderDialog;
165 Ui::fitsHeaderDialog header;
166 /// The Statistics Panel
167 QPointer<QDialog> statWidget;
168 Ui::statForm stat;
169 /// The Plate Solving UI
170 QPointer<QDialog> m_PlateSolveWidget;
171 Ui::PlateSolveUI m_PlateSolveUI;
172 /// FITS Histogram
173 QPointer<FITSHistogramEditor> m_HistogramEditor;
175
176 QPointer<QListWidget> recentImages;
177
178 /// FITS image object
180
181 /// History for undo/redo
182 QUndoStack *undoStack { nullptr };
183 /// FITS File name and path
184 QUrl currentURL;
185
186 bool mDirty { false };
187 QString previewText;
188 int uid { 0 };
189
190 std::unique_ptr<FITSStretchUI> stretchUI;
191
192 // Used for solving an image.
193 void setupSolver(bool extractOnly = false);
194 void solverDone(bool timedOut, bool success, const FITSImage::Solution &solution, double elapsedSeconds);
195 void extractorDone(bool timedOut, bool success, const FITSImage::Solution &solution, double elapsedSeconds);
196 void initSolverUI();
197 void setupProfiles(int profileIndex);
198 int getProfileIndex(int moduleIndex);
199 void setProfileIndex(int moduleIndex, int profileIndex);
200
201
203
204 QList<QString> m_BlinkFilenames;
205 int m_BlinkIndex { 0 };
206
207 // The StellarSolverProfileEditor is shared among all tabs of all FITS Viewers.
208 // They all edit the same (align) profiles.
209 static QPointer<Ekos::StellarSolverProfileEditor> m_ProfileEditor;
210 static QPointer<KConfigDialog> m_EditorDialog;
211 static QPointer<KPageWidgetItem> m_ProfileEditorPage;
212
213 signals:
214 void debayerToggled(bool);
215 void newStatus(const QString &msg, FITSBar id);
216 void changeStatus(bool clean, const QUrl &imageUrl);
217 void loaded();
218 void updated();
219 void failed(const QString &errorMessage);
220};
The FITSTab class holds information on the current view (drawing area) in addition to the undo/redo s...
Definition fitstab.h:46
Primary window to view monochrome and color FITS images.
Definition fitsviewer.h:50
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:79
qsizetype size() const const
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:59:52 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.