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 "ui_catalogobject.h"
21#include "ui_catalogobjecttypefilter.h"
22#include <QFuture>
23#include <QPointer>
24#include <QListWidget>
25#include <QLabel>
26#include <QPushButton>
27#include <memory>
28#include "ekos/auxiliary/solverutils.h"
29#include <KConfigDialog>
30#include <QNetworkAccessManager>
31#include <QStandardItemModel>
32
33class FITSHistogramEditor;
34class FITSView;
35class FITSViewer;
36class FITSData;
37class FITSStretchUI;
38
39namespace Ekos
40{
41class StellarSolverProfileEditor;
42}
43
44/**
45 * @brief The FITSTab class holds information on the current view (drawing area) in addition to the undo/redo stacks
46 * and status of current document (clean or dirty). It also creates the corresponding histogram associated with the
47 * image data that is stored in the FITSView class.
48 * @author Jasem Mutlaq
49 */
50class FITSTab : public QWidget
51{
53 public:
54 explicit FITSTab(FITSViewer *parent);
55 virtual ~FITSTab() override;
56
57 enum
58 {
59 STAT_WIDTH,
60 STAT_HEIGHT,
61 STAT_BITPIX,
62 STAT_HFR,
63 STAT_MIN,
64 STAT_MAX,
65 STAT_MEAN,
66 STAT_MEDIAN,
67 STAT_STDDEV
68 };
69
70 void clearRecentFITS();
71 void selectRecentFITS(int i);
72 void loadFile(const QUrl &imageURL, FITSMode mode = FITS_NORMAL, FITSScale filter = FITS_NONE);
73 bool loadData(const QSharedPointer<FITSData> &data, FITSMode mode = FITS_NORMAL, FITSScale filter = FITS_NONE);
74
75 // Methods to setup and control blinking--loading a directory of images one-by-one
76 // into a single tab.
77 void initBlink(const QList<QString> &filenames)
78 {
79 m_BlinkFilenames = filenames;
80 }
81 const QList<QString> &blinkFilenames() const
82 {
83 return m_BlinkFilenames;
84 }
85 int blinkUpto() const
86 {
87 return m_BlinkIndex;
88 };
89 void setBlinkUpto(int index)
90 {
91 if (index >= 0 && index < m_BlinkFilenames.size())
92 m_BlinkIndex = index;
93 };
94
95 bool saveImage(const QString &filename);
96
97 inline QUndoStack *getUndoStack()
98 {
99 return undoStack;
100 }
101 inline QUrl *getCurrentURL()
102 {
103 return &currentURL;
104 }
105 inline const QSharedPointer<FITSView> &getView()
106 {
107 return m_View;
108 }
109 inline QPointer<FITSHistogramEditor> getHistogram()
110 {
111 return m_HistogramEditor;
112 }
113 inline QPointer<FITSViewer> getViewer()
114 {
115 return viewer;
116 }
117
118 bool saveFile();
119 bool saveFileAs();
120 void copyFITS();
121 void loadFITSHeader();
122 void loadCatalogObjects();
123 void queriedCatalogObjects();
124 void catQueryFailed(const QString text);
125 void catReset();
126 void catHighlightChanged(const int highlight);
127 void catHighlightRow(const int row);
128 void headerFITS();
129 void histoFITS();
130 void statFITS();
131
132 Q_SCRIPTABLE void setStretchValues(double shadows, double midtones, double highlights);
133 Q_SCRIPTABLE void setAutoStretch();
134
135 void setUID(int newID)
136 {
137 uid = newID;
138 }
139 int getUID()
140 {
141 return uid;
142 }
143
144 void saveUnsaved();
145 void tabPositionUpdated();
146 void selectGuideStar();
147
148 QString getPreviewText() const;
149 void setPreviewText(const QString &value);
150 bool shouldComputeHFR() const;
151
152 public slots:
153 void modifyFITSState(bool clean = true, const QUrl &imageURL = QUrl());
154 void ZoomIn();
155 void ZoomOut();
156 void ZoomDefault();
157 void displayStats(bool roi = false);
158 void extractImage();
159 void solveImage();
160 protected:
161 virtual void closeEvent(QCloseEvent *ev) override;
162
163 private:
164 bool setupView(FITSMode mode, FITSScale filter);
165 void processData();
166 void imageSolved(bool success);
167
168 /** Ask user whether he wants to save changes and save if he do. */
169
170 /// The FITSTools Toolbox
171 QPointer<QToolBox> fitsTools;
172 /// The Splitter for th FITSTools Toolbox
173 QPointer<QSplitter> fitsSplitter;
174 /// The FITS Header Panel
175 QPointer<QDialog> fitsHeaderDialog;
176 Ui::fitsHeaderDialog header;
177 /// The Statistics Panel
178 QPointer<QDialog> statWidget;
179 Ui::statForm stat;
180 /// The Plate Solving UI
181 QPointer<QDialog> m_PlateSolveWidget;
182 Ui::PlateSolveUI m_PlateSolveUI;
183 /// Catalog Object UI
184 QPointer<QDialog> m_CatalogObjectWidget;
185 Ui::CatalogObjectUI m_CatalogObjectUI;
186 QPointer<QDialog> m_CatObjTypeFilterDialog;
187 Ui::CatalogObjectTypeFilterUI m_CatObjTypeFilterUI;
188 /// FITS Histogram
189 QPointer<FITSHistogramEditor> m_HistogramEditor;
191
192 QPointer<QListWidget> recentImages;
193
194 /// FITS image object
196
197 /// History for undo/redo
198 QUndoStack *undoStack { nullptr };
199 /// FITS File name and path
200 QUrl currentURL;
201
202 bool mDirty { false };
203 QString previewText;
204 int uid { 0 };
205
206 std::unique_ptr<FITSStretchUI> stretchUI;
207
208 // Used for solving an image.
209 void setupSolver(bool extractOnly = false);
210 void solverDone(bool timedOut, bool success, const FITSImage::Solution &solution, double elapsedSeconds);
211 void extractorDone(bool timedOut, bool success, const FITSImage::Solution &solution, double elapsedSeconds);
212 void initSolverUI();
213 void setupProfiles(int profileIndex);
214 int getProfileIndex(int moduleIndex);
215 void setProfileIndex(int moduleIndex, int profileIndex);
216
217 // Used for catalog table processing
218 typedef enum { CAT_NUM,
219 CAT_CDSPORTAL,
220 CAT_SIMBAD,
221 CAT_NED,
222 CAT_OBJECT,
223 CAT_TYPECODE,
224 CAT_TYPELABEL,
225 CAT_COORDS,
226 CAT_DISTANCE,
227 CAT_MAGNITUDE,
228 CAT_SIZE,
229 CAT_MAX_COLS
230 } CatCols;
231
232 typedef enum { CATTYPE_CODE,
233 CATTYPE_CANDCODE,
234 CATTYPE_LABEL,
235 CATTYPE_DESCRIPTION,
236 CATTYPE_COMMENTS,
237 CATTYPE_MAX_COLS
238 } CatTypeCols;
239
240 void catRowChanged(const QModelIndex &current, const QModelIndex &previous);
241 void catCellDoubleClicked(const QModelIndex &index);
242 void launchCatTypeFilterDialog();
243 void showCatObjNames(bool enabled);
244 void launchSimbad(QString name);
245 void launchCDS(QString name);
246 void launchNED(QString name);
247 void initCatalogObject();
248 void setupCatObjTypeFilter();
249 void applyTypeFilter();
250 void checkAllTypeFilter();
251 void uncheckAllTypeFilter();
252 void typeFilterItemChanged(QTreeWidgetItem *item, int column);
253 QPushButton *m_CheckAllButton;
254 QPushButton *m_UncheckAllButton;
255 int m_CatalogObjectItem { 0 };
256 QStandardItemModel m_CatObjModel;
257
259
260 QList<QString> m_BlinkFilenames;
261 int m_BlinkIndex { 0 };
262
263 // The StellarSolverProfileEditor is shared among all tabs of all FITS Viewers.
264 // They all edit the same (align) profiles.
265 static QPointer<Ekos::StellarSolverProfileEditor> m_ProfileEditor;
266 static QPointer<KConfigDialog> m_EditorDialog;
267 static QPointer<KPageWidgetItem> m_ProfileEditorPage;
268
269 signals:
270 void debayerToggled(bool);
271 void newStatus(const QString &msg, FITSBar id);
272 void changeStatus(bool clean, const QUrl &imageUrl);
273 void loaded();
274 void updated();
275 void failed(const QString &errorMessage);
276};
The FITSTab class holds information on the current view (drawing area) in addition to the undo/redo s...
Definition fitstab.h:51
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 Dec 20 2024 11:52:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.