1 /* 2 SPDX-FileCopyrightText: 2004 Jasem Mutlaq 3 SPDX-FileCopyrightText: 2020 Eric Dejouhanet <eric.dejouhanet@gmail.com> 4 5 SPDX-License-Identifier: GPL-2.0-or-later 6 7 Some code fragments were adapted from Peter Kirchgessner's FITS plugin 8 SPDX-FileCopyrightText: Peter Kirchgessner <http://members.aol.com/pkirchg> 9 */ 10 11 #pragma once 12 13 #include <QObject> 14 #include <QHash> 15 #include <QStandardItem> 16 #include <QFuture> 17 18 #include "fitsdata.h" 19 20 class FITSData; 21 22 class Edge 23 { 24 public: 25 virtual ~Edge() = default; 26 float x {0}; 27 float y {0}; 28 int val {0}; 29 int scanned {0}; 30 float width {0}; 31 float HFR {-1}; 32 float sum {0}; 33 float numPixels {0}; 34 float ellipticity {0}; 35 }; 36 37 class BahtinovEdge : public Edge 38 { 39 public: 40 virtual ~BahtinovEdge() = default; 41 QVector<QLineF> line; 42 QPointF offset; 43 }; 44 45 class FITSStarDetector : public QObject 46 { 47 Q_OBJECT 48 49 public: 50 /** @brief Instantiate a detector for a FITS data file. 51 */ FITSStarDetector(FITSData * data)52 explicit FITSStarDetector(FITSData *data): QObject(), m_ImageData(data) {}; 53 54 /** @brief Find sources in the parent FITS data file. 55 * @param starCenters is the list of sources to append to. 56 * @param boundary is the rectangle in which to find sources, by default the full frame. 57 * @return The number of sources detected by the procedure. 58 */ 59 virtual QFuture<bool> findSources(QRect const &boundary = QRect()) = 0; 60 61 /** @brief Configure the detection method. 62 * @param setting is the name of a detection setting. 63 * @param value is the value of the detection setting identified by 'setting'. 64 * @return The detector as a chain to call the overridden findSources. 65 */ 66 virtual void configure(const QString &key, const QVariant &value); 67 setSettings(const QVariantMap & settings)68 void setSettings(const QVariantMap &settings) 69 { 70 m_Settings = settings; 71 } 72 QVariant getValue(const QString &key, QVariant defaultValue = QVariant()) const; 73 74 /** @brief Helper to configure the detection method from a data model. 75 * @param settings is the list of key/value pairs for the method to use settings from. 76 * @note Data model 'settings' is considered a key/value list, using column 1 text as case-insensitive keys and column 2 data as values. 77 * @return The detector as a chain to call the overridden findSources. 78 */ 79 //void configure(QStandardItemModel const &settings); 80 81 protected: 82 FITSData *m_ImageData {nullptr}; 83 QVariantMap m_Settings; 84 }; 85 86