Kstars

fitstab.h
1 /*
2  SPDX-FileCopyrightText: 2012 Jasem Mutlaq <[email protected]>
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 <QFuture>
19 #include <QPointer>
20 #include <QListWidget>
21 #include <QLabel>
22 #include <QPushButton>
23 #include <QSlider>
24 
25 #include <memory>
26 
27 class FITSHistogramEditor;
28 class FITSView;
29 class FITSViewer;
30 class FITSData;
31 
32 /**
33  * @brief The FITSTab class holds information on the current view (drawing area) in addition to the undo/redo stacks
34  * and status of current document (clean or dirty). It also creates the corresponding histogram associated with the
35  * image data that is stored in the FITSView class.
36  * @author Jasem Mutlaq
37  */
38 class FITSTab : public QWidget
39 {
40  Q_OBJECT
41  public:
42  explicit FITSTab(FITSViewer *parent);
43  virtual ~FITSTab() override;
44 
45  enum
46  {
47  STAT_WIDTH,
48  STAT_HEIGHT,
49  STAT_BITPIX,
50  STAT_HFR,
51  STAT_MIN,
52  STAT_MAX,
53  STAT_MEAN,
54  STAT_MEDIAN,
55  STAT_STDDEV
56  };
57 
58  void clearRecentFITS();
59  void selectRecentFITS(int i);
60  void loadFile(const QUrl &imageURL, FITSMode mode = FITS_NORMAL, FITSScale filter = FITS_NONE);
61  bool loadData(const QSharedPointer<FITSData> &data, FITSMode mode = FITS_NORMAL, FITSScale filter = FITS_NONE);
62 
63  bool saveImage(const QString &filename);
64 
65  inline QUndoStack *getUndoStack()
66  {
67  return undoStack;
68  }
69  inline QUrl *getCurrentURL()
70  {
71  return &currentURL;
72  }
73  inline const QSharedPointer<FITSView> &getView()
74  {
75  return m_View;
76  }
77  inline QPointer<FITSHistogramEditor> getHistogram()
78  {
79  return m_HistogramEditor;
80  }
81  inline QPointer<FITSViewer> getViewer()
82  {
83  return viewer;
84  }
85 
86  bool saveFile();
87  bool saveFileAs();
88  void copyFITS();
89  void loadFITSHeader();
90  void headerFITS();
91  void histoFITS();
92  void statFITS();
93 
94  void setUID(int newID)
95  {
96  uid = newID;
97  }
98  int getUID()
99  {
100  return uid;
101  }
102 
103  void saveUnsaved();
104  void tabPositionUpdated();
105  void selectGuideStar();
106 
107  QString getPreviewText() const;
108  void setPreviewText(const QString &value);
109  bool shouldComputeHFR() const;
110 
111  public slots:
112  void modifyFITSState(bool clean = true, const QUrl &imageURL = QUrl());
113  void ZoomIn();
114  void ZoomOut();
115  void ZoomDefault();
116  void evaluateStats();
117  protected:
118  virtual void closeEvent(QCloseEvent *ev) override;
119 
120  private:
121  bool setupView(FITSMode mode, FITSScale filter);
122 
123  QHBoxLayout* setupStretchBar();
124  void setStretchUIValues(bool adjustSliders);
125  void rescaleShadows();
126  void rescaleMidtones();
127 
128  void processData();
129 
130  /** Ask user whether he wants to save changes and save if he do. */
131 
132  /// The FITSTools Toolbox
133  QPointer<QToolBox> fitsTools;
134  /// The Splitter for th FITSTools Toolbox
135  QPointer<QSplitter> fitsSplitter;
136  /// The FITS Header Panel
137  QPointer<QDialog> fitsHeaderDialog;
138  Ui::fitsHeaderDialog header;
139  /// The Statistics Panel
140  QPointer<QDialog> statWidget;
141  Ui::statForm stat;
142  /// FITS Histogram
143  QPointer<FITSHistogramEditor> m_HistogramEditor;
144  QPointer<FITSViewer> viewer;
145 
146  QPointer<QListWidget> recentImages;
147 
148  /// FITS image object
150 
151  /// History for undo/redo
152  QUndoStack *undoStack { nullptr };
153  /// FITS File name and path
154  QUrl currentURL;
155 
156  bool mDirty { false };
157  QString previewText;
158  int uid { 0 };
159 
160  // Stretch bar widgets
161  std::unique_ptr<QLabel> shadowsLabel, midtonesLabel, highlightsLabel;
162  std::unique_ptr<QLabel> shadowsVal, midtonesVal, highlightsVal;
163  std::unique_ptr<QSlider> shadowsSlider, midtonesSlider, highlightsSlider;
164  std::unique_ptr<QPushButton> stretchButton, autoButton;
165  float maxShadows {0.5}, maxMidtones {0.5}, maxHighlights {1.0};
166 
167  //QFuture<void> histogramFuture;
168 
169  signals:
170  void debayerToggled(bool);
171  void newStatus(const QString &msg, FITSBar id);
172  void changeStatus(bool clean, const QUrl &imageUrl);
173  void loaded();
174  void failed(const QString &errorMessage);
175 };
Q_OBJECTQ_OBJECT
KCALUTILS_EXPORT QString errorMessage(const KCalendarCore::Exception &exception)
The FITSTab class holds information on the current view (drawing area) in addition to the undo/redo s...
Definition: fitstab.h:38
Primary window to view monochrome and color FITS images. The FITSviewer can open multiple images each...
Definition: fitsviewer.h:48
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Aug 13 2022 04:01:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.