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

KDE's Doxygen guidelines are available online.