File indexing completed on 2024-04-28 11:24:23
0001 /* 0002 SPDX-FileCopyrightText: 2004 Jasem Mutlaq 0003 SPDX-FileCopyrightText: 2020 Eric Dejouhanet <eric.dejouhanet@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 0007 Some code fragments were adapted from Peter Kirchgessner's FITS plugin 0008 SPDX-FileCopyrightText: Peter Kirchgessner <http://members.aol.com/pkirchg> 0009 */ 0010 0011 #pragma once 0012 0013 #include <QObject> 0014 #include <QHash> 0015 #include <QStandardItem> 0016 #include <QFuture> 0017 0018 class FITSData; 0019 0020 class Edge 0021 { 0022 public: 0023 virtual ~Edge() = default; 0024 void invalidate() 0025 { 0026 x = y = val = HFR = -1; 0027 } 0028 float x {0}; 0029 float y {0}; 0030 int val {0}; 0031 int scanned {0}; 0032 float width {0}; 0033 float HFR {-1}; 0034 float sum {0}; 0035 float numPixels {0}; 0036 float ellipticity {0}; 0037 }; 0038 0039 class BahtinovEdge : public Edge 0040 { 0041 public: 0042 virtual ~BahtinovEdge() = default; 0043 QVector<QLineF> line; 0044 QPointF offset; 0045 }; 0046 0047 class FITSStarDetector : public QObject 0048 { 0049 Q_OBJECT 0050 0051 public: 0052 /** @brief Instantiate a detector for a FITS data file. 0053 */ 0054 explicit FITSStarDetector(FITSData *data): QObject(), m_ImageData(data) {}; 0055 0056 /** @brief Find sources in the parent FITS data file. 0057 * @param starCenters is the list of sources to append to. 0058 * @param boundary is the rectangle in which to find sources, by default the full frame. 0059 * @return The number of sources detected by the procedure. 0060 */ 0061 virtual QFuture<bool> findSources(QRect const &boundary = QRect()) = 0; 0062 0063 /** @brief Configure the detection method. 0064 * @param setting is the name of a detection setting. 0065 * @param value is the value of the detection setting identified by 'setting'. 0066 * @return The detector as a chain to call the overridden findSources. 0067 */ 0068 virtual void configure(const QString &key, const QVariant &value); 0069 0070 void setSettings(const QVariantMap &settings) 0071 { 0072 m_Settings = settings; 0073 } 0074 QVariant getValue(const QString &key, QVariant defaultValue = QVariant()) const; 0075 0076 /** @brief Helper to configure the detection method from a data model. 0077 * @param settings is the list of key/value pairs for the method to use settings from. 0078 * @note Data model 'settings' is considered a key/value list, using column 1 text as case-insensitive keys and column 2 data as values. 0079 * @return The detector as a chain to call the overridden findSources. 0080 */ 0081 //void configure(QStandardItemModel const &settings); 0082 0083 protected: 0084 FITSData *m_ImageData {nullptr}; 0085 QVariantMap m_Settings; 0086 }; 0087