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
123 void setUID(int newID)
124 {
125 uid = newID;
126 }
127 int getUID()
128 {
129 return uid;
130 }
131
132 void saveUnsaved();
133 void tabPositionUpdated();
134 void selectGuideStar();
135
136 QString getPreviewText() const;
137 void setPreviewText(const QString &value);
138 bool shouldComputeHFR() const;
139
140 public slots:
141 void modifyFITSState(bool clean = true, const QUrl &imageURL = QUrl());
142 void ZoomIn();
143 void ZoomOut();
144 void ZoomDefault();
145 void displayStats(bool roi = false);
146 void extractImage();
147 void solveImage();
148 protected:
149 virtual void closeEvent(QCloseEvent *ev) override;
150
151 private:
152 bool setupView(FITSMode mode, FITSScale filter);
153 void processData();
154 void imageSolved(bool success);
155
156 /** Ask user whether he wants to save changes and save if he do. */
157
158 /// The FITSTools Toolbox
159 QPointer<QToolBox> fitsTools;
160 /// The Splitter for th FITSTools Toolbox
161 QPointer<QSplitter> fitsSplitter;
162 /// The FITS Header Panel
163 QPointer<QDialog> fitsHeaderDialog;
164 Ui::fitsHeaderDialog header;
165 /// The Statistics Panel
166 QPointer<QDialog> statWidget;
167 Ui::statForm stat;
168 /// The Plate Solving UI
169 QPointer<QDialog> m_PlateSolveWidget;
170 Ui::PlateSolveUI m_PlateSolveUI;
171 /// FITS Histogram
172 QPointer<FITSHistogramEditor> m_HistogramEditor;
174
175 QPointer<QListWidget> recentImages;
176
177 /// FITS image object
179
180 /// History for undo/redo
181 QUndoStack *undoStack { nullptr };
182 /// FITS File name and path
183 QUrl currentURL;
184
185 bool mDirty { false };
186 QString previewText;
187 int uid { 0 };
188
189 std::unique_ptr<FITSStretchUI> stretchUI;
190
191 // Used for solving an image.
192 void setupSolver(bool extractOnly = false);
193 void solverDone(bool timedOut, bool success, const FITSImage::Solution &solution, double elapsedSeconds);
194 void extractorDone(bool timedOut, bool success, const FITSImage::Solution &solution, double elapsedSeconds);
195 void initSolverUI();
196 void setupProfiles(int profileIndex);
197 int getProfileIndex(int moduleIndex);
198 void setProfileIndex(int moduleIndex, int profileIndex);
199
200
202
203 QList<QString> m_BlinkFilenames;
204 int m_BlinkIndex { 0 };
205
206 // The StellarSolverProfileEditor is shared among all tabs of all FITS Viewers.
207 // They all edit the same (align) profiles.
208 static QPointer<Ekos::StellarSolverProfileEditor> m_ProfileEditor;
209 static QPointer<KConfigDialog> m_EditorDialog;
210 static QPointer<KPageWidgetItem> m_ProfileEditorPage;
211
212 signals:
213 void debayerToggled(bool);
214 void newStatus(const QString &msg, FITSBar id);
215 void changeStatus(bool clean, const QUrl &imageUrl);
216 void loaded();
217 void updated();
218 void failed(const QString &errorMessage);
219};
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:78
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 Tue Mar 26 2024 11:19:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.