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

KDE's Doxygen guidelines are available online.