1 /* 2 SPDX-FileCopyrightText: 2004 Jasem Mutlaq <mutlaqja@ikarustech.com> 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 17 #include <QLabel> 18 #include <QList> 19 #include <QMap> 20 #include <QUrl> 21 22 #ifdef WIN32 23 // avoid compiler warning when windows.h is included after fitsio.h 24 #include <windows.h> 25 #endif 26 27 #include <fitsio.h> 28 29 class QCloseEvent; 30 class QUndoGroup; 31 32 class QTabWidget; 33 34 class FITSDebayer; 35 class FITSTab; 36 class FITSView; 37 class FITSData; 38 39 /** 40 * @class FITSViewer 41 * @short Primary window to view monochrome and color FITS images. 42 * The FITSviewer can open multiple images each in a separate. It supports simple filters, histogram transforms, flip and rotation operations, and star detection. 43 * 44 * @author Jasem Mutlaq 45 * @version 1.0 46 */ 47 class FITSViewer : public KXmlGuiWindow 48 { 49 Q_OBJECT 50 51 public: 52 /** Constructor. */ 53 explicit FITSViewer(QWidget *parent); 54 ~FITSViewer(); 55 56 void loadFile(const QUrl &imageName, FITSMode mode = FITS_NORMAL, FITSScale filter = FITS_NONE, 57 const QString &previewText = QString(), bool silent = true); 58 59 bool loadData(const QSharedPointer<FITSData> &data, const QUrl &imageName, int *tab_uid, 60 FITSMode mode = FITS_NORMAL, FITSScale filter = FITS_NONE, 61 const QString &previewText = QString()); 62 63 void updateFile(const QUrl &imageName, int fitsUID, FITSScale filter = FITS_NONE, bool silent = true); 64 bool updateData(const QSharedPointer<FITSData> &data, const QUrl &imageName, int fitsUID, int *tab_uid, 65 FITSScale filter = FITS_NONE); 66 bool removeFITS(int fitsUID); 67 isStarsMarked()68 bool isStarsMarked() 69 { 70 return markStars; 71 } 72 empty()73 bool empty() const 74 { 75 return fitsTabs.empty(); 76 } getTabs()77 QList<FITSTab *> getTabs() 78 { 79 return fitsTabs; 80 } 81 FITSView *getView(int fitsUID); 82 FITSView *getCurrentView(); 83 84 static QStringList filterTypes; 85 86 protected: 87 void closeEvent(QCloseEvent *) override; 88 void hideEvent(QHideEvent *) override; 89 void showEvent(QShowEvent *) override; 90 91 public slots: 92 void changeAlwaysOnTop(Qt::ApplicationState state); 93 void openFile(); 94 void saveFile(); 95 void saveFileAs(); 96 void copyFITS(); 97 void statFITS(); 98 void headerFITS(); 99 void debayerFITS(); 100 void histoFITS(); 101 void tabFocusUpdated(int currentIndex); 102 void updateStatusBar(const QString &msg, FITSBar id); 103 void ZoomIn(); 104 void ZoomOut(); 105 void ZoomDefault(); 106 void ZoomToFit(); 107 void updateAction(const QString &name, bool enable); 108 void updateTabStatus(bool clean, const QUrl &imageURL); 109 void closeTab(int index); 110 void toggleStars(); 111 void toggleCrossHair(); 112 void toggleClipping(); 113 void toggleEQGrid(); 114 void toggleObjects(); 115 void togglePixelGrid(); 116 void toggle3DGraph(); 117 void starProfileButtonOff(); 118 void centerTelescope(); 119 void updateWCSFunctions(); 120 void applyFilter(int ftype); 121 void rotateCW(); 122 void rotateCCW(); 123 void flipHorizontal(); 124 void flipVertical(); 125 void setDebayerAction(bool); 126 void updateScopeButton(); 127 128 private: 129 void updateButtonStatus(const QString &action, const QString &item, bool showing); 130 // Shared utilites between the standard and "FromData" addFITS and updateFITS. 131 bool addFITSCommon(FITSTab *tab, const QUrl &imageName, 132 FITSMode mode, const QString &previewText); 133 bool updateFITSCommon(FITSTab *tab, const QUrl &imageName); 134 135 QTabWidget *fitsTabWidget { nullptr }; 136 QUndoGroup *undoGroup { nullptr }; 137 FITSDebayer *debayerDialog { nullptr }; 138 KLed led; 139 QLabel fitsPosition, fitsValue, fitsResolution, fitsZoom, fitsWCS, fitsHFR; 140 QAction *saveFileAction { nullptr }; 141 QAction *saveFileAsAction { nullptr }; 142 QList<FITSTab *> fitsTabs; 143 int fitsID { 0 }; 144 bool markStars { false }; 145 QMap<int, FITSTab *> fitsMap; 146 QUrl lastURL; 147 148 signals: 149 void trackingStarSelected(int x, int y); 150 void loaded(int tabUID); 151 void closed(int tabUID); 152 //void terminated(); 153 void failed(); 154 }; 155