Kstars

fitsviewer.h
1 /*
2  SPDX-FileCopyrightText: 2004 Jasem Mutlaq <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 
6  Some code fragments were adapted from Peter Kirchgessner's FITS plugin
7  SPDX-FileCopyrightText: Peter Kirchgessner <http://members.aol.com/pkirchg>
8 */
9 
10 #pragma once
11 
12 #include "fitscommon.h"
13 
14 #include <KLed>
15 #include <KXmlGui/KXmlGuiWindow>
16 #include <KActionMenu>
17 
18 #include <QLabel>
19 #include <QList>
20 #include <QMap>
21 #include <QUrl>
22 
23 #ifdef WIN32
24 // avoid compiler warning when windows.h is included after fitsio.h
25 #include <windows.h>
26 #endif
27 
28 #include <fitsio.h>
29 
30 class QCloseEvent;
31 class QUndoGroup;
32 
33 class QTabWidget;
34 
35 class FITSDebayer;
36 class FITSTab;
37 class FITSView;
38 class FITSData;
39 
40 /**
41  * @class FITSViewer
42  * @short Primary window to view monochrome and color FITS images.
43  * The FITSviewer can open multiple images each in a separate. It supports simple filters, histogram transforms, flip and rotation operations, and star detection.
44  *
45  * @author Jasem Mutlaq
46  * @version 1.0
47  */
48 class FITSViewer : public KXmlGuiWindow
49 {
50  Q_OBJECT
51 
52  public:
53  /** Constructor. */
54  explicit FITSViewer(QWidget *parent);
55  ~FITSViewer() override;
56 
57  void loadFile(const QUrl &imageName, FITSMode mode = FITS_NORMAL, FITSScale filter = FITS_NONE,
58  const QString &previewText = QString());
59 
60  bool loadData(const QSharedPointer<FITSData> &data, const QUrl &imageName, int *tab_uid,
61  FITSMode mode = FITS_NORMAL, FITSScale filter = FITS_NONE,
62  const QString &previewText = QString());
63 
64  void updateFile(const QUrl &imageName, int fitsUID, FITSScale filter = FITS_NONE);
65  bool updateData(const QSharedPointer<FITSData> &data, const QUrl &imageName, int fitsUID, int *tab_uid,
66  FITSScale filter = FITS_NONE, FITSMode mode = FITS_UNKNOWN);
67  bool removeFITS(int fitsUID);
68 
69  bool isStarsMarked()
70  {
71  return markStars;
72  }
73 
74  bool empty() const
75  {
76  return fitsTabs.empty();
77  }
78  QList<FITSTab *> getTabs()
79  {
80  return fitsTabs;
81  }
82  bool getView(int fitsUID, QSharedPointer<FITSView> &view);
83  bool getCurrentView(QSharedPointer<FITSView> &view);
84 
85  static QStringList filterTypes;
86 
87  protected:
88  void closeEvent(QCloseEvent *) override;
89  void hideEvent(QHideEvent *) override;
90  void showEvent(QShowEvent *) override;
91 
92  public slots:
93  void changeAlwaysOnTop(Qt::ApplicationState state);
94  void openFile();
95  void saveFile();
96  void saveFileAs();
97  void copyFITS();
98  void statFITS();
99  void toggleSelectionMode();
100  void headerFITS();
101  void debayerFITS();
102  void histoFITS();
103  void tabFocusUpdated(int currentIndex);
104  void updateStatusBar(const QString &msg, FITSBar id);
105  void ZoomIn();
106  void ZoomOut();
107  void ZoomDefault();
108  void ZoomToFit();
109  void updateAction(const QString &name, bool enable);
110  void updateTabStatus(bool clean, const QUrl &imageURL);
111  void closeTab(int index);
112  void toggleStars();
113  void toggleCrossHair();
114  void toggleClipping();
115  void toggleEQGrid();
116  void toggleObjects();
117  void togglePixelGrid();
118  void toggle3DGraph();
119  void starProfileButtonOff();
120  void centerTelescope();
121  void updateWCSFunctions();
122  void applyFilter(int ftype);
123  void rotateCW();
124  void rotateCCW();
125  void flipHorizontal();
126  void flipVertical();
127  void setDebayerAction(bool);
128  void updateScopeButton();
129  void ROIFixedSize(int s);
130  void customROIInputWindow();
131 
132 
133  private:
134  void updateButtonStatus(const QString &action, const QString &item, bool showing);
135  // Shared utilites between the standard and "FromData" addFITS and updateFITS.
136  bool addFITSCommon(FITSTab *tab, const QUrl &imageName,
137  FITSMode mode, const QString &previewText);
138  bool updateFITSCommon(FITSTab *tab, const QUrl &imageName);
139 
140  QTabWidget *fitsTabWidget { nullptr };
141  QUndoGroup *undoGroup { nullptr };
142  FITSDebayer *debayerDialog { nullptr };
143  KLed led;
144  QLabel fitsPosition, fitsValue, fitsResolution, fitsZoom, fitsWCS, fitsHFR, fitsClip;
145  QAction *saveFileAction { nullptr };
146  QAction *saveFileAsAction { nullptr };
147  QList<FITSTab *> fitsTabs;
148  int fitsID { 0 };
149  bool markStars { false };
150  QMap<int, FITSTab *> fitsMap;
151  QUrl lastURL;
152  KActionMenu *roiActionMenu { nullptr };
153  KActionMenu* roiMenu { nullptr };
154 
155  signals:
156  void trackingStarSelected(int x, int y);
157  void loaded(int tabUID);
158  void closed(int tabUID);
159  void failed(const QString &errorMessage);
160 };
Q_OBJECTQ_OBJECT
KCALUTILS_EXPORT QString errorMessage(const KCalendarCore::Exception &exception)
bool empty() const const
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
FITSViewer(QWidget *parent)
Constructor.
Definition: fitsviewer.cpp:44
QAction * action(const char *name) const
void centerTelescope()
This method either enables or disables the scope mouse mode so you can slew your scope to coordinates...
void updateWCSFunctions()
This is a method that either enables or disables the WCS based features in the Current View.
Definition: fitsviewer.cpp:950
ApplicationState
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Aug 9 2022 04:06:02 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.