File indexing completed on 2025-01-26 03:34:15
0001 /* 0002 File : XYAnalysisCurve.h 0003 Project : LabPlot 0004 Description : Base class for all analysis curves 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2017-2021 Alexander Semke <alexander.semke@web.de> 0007 SPDX-FileCopyrightText: 2018-2022 Stefan Gerlach <stefan.gerlach@uni.kn> 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #ifndef XYANALYSISCURVE_H 0012 #define XYANALYSISCURVE_H 0013 0014 #include "backend/worksheet/plots/cartesian/XYCurve.h" 0015 0016 class XYAnalysisCurvePrivate; 0017 0018 class XYAnalysisCurve : public XYCurve { 0019 Q_OBJECT 0020 Q_ENUMS(DataSourceType) 0021 0022 public: 0023 enum class DataSourceType { Spreadsheet, Curve, Histogram }; 0024 enum class AnalysisAction { 0025 DataReduction, 0026 Differentiation, 0027 Integration, 0028 Interpolation, 0029 Smoothing, 0030 FitLinear, 0031 FitPower, 0032 FitExp1, 0033 FitExp2, 0034 FitInvExp, 0035 FitGauss, 0036 FitCauchyLorentz, 0037 FitTan, 0038 FitTanh, 0039 FitErrFunc, 0040 FitCustom, 0041 FourierFilter 0042 }; 0043 0044 struct Result { 0045 Result(){}; 0046 0047 bool available{false}; 0048 bool valid{false}; 0049 QString status; 0050 qint64 elapsedTime{0}; 0051 }; 0052 0053 ~XYAnalysisCurve() override; 0054 0055 static void copyData(QVector<double>& xData, 0056 QVector<double>& yData, 0057 const AbstractColumn* xDataColumn, 0058 const AbstractColumn* yDataColumn, 0059 double xMin, 0060 double xMax, 0061 bool avgUniqueX = false); 0062 0063 virtual void recalculate() = 0; 0064 bool resultAvailable() const; 0065 virtual const Result& result() const = 0; 0066 bool usingColumn(const Column*) const override; 0067 void updateColumnDependencies(const AbstractColumn*) override; 0068 0069 void save(QXmlStreamWriter*) const override; 0070 bool load(XmlStreamReader*, bool preview) override; 0071 0072 BASIC_D_ACCESSOR_DECL(DataSourceType, dataSourceType, DataSourceType) 0073 POINTER_D_ACCESSOR_DECL(const XYCurve, dataSourceCurve, DataSourceCurve) 0074 const QString& dataSourceCurvePath() const; 0075 0076 POINTER_D_ACCESSOR_DECL(const AbstractColumn, xDataColumn, XDataColumn) 0077 POINTER_D_ACCESSOR_DECL(const AbstractColumn, yDataColumn, YDataColumn) 0078 POINTER_D_ACCESSOR_DECL(const AbstractColumn, y2DataColumn, Y2DataColumn) // optional 0079 CLASS_D_ACCESSOR_DECL(QString, xDataColumnPath, XDataColumnPath) 0080 CLASS_D_ACCESSOR_DECL(QString, yDataColumnPath, YDataColumnPath) 0081 CLASS_D_ACCESSOR_DECL(QString, y2DataColumnPath, Y2DataColumnPath) 0082 0083 bool saveCalculations() const; 0084 0085 typedef XYAnalysisCurvePrivate Private; 0086 0087 protected: 0088 XYAnalysisCurve(const QString& name, XYAnalysisCurvePrivate*, AspectType); 0089 0090 private: 0091 Q_DECLARE_PRIVATE(XYAnalysisCurve) 0092 void init(); 0093 0094 public Q_SLOTS: 0095 void handleSourceDataChanged(); 0096 void createDataSpreadsheet(); 0097 0098 private Q_SLOTS: 0099 void xDataColumnAboutToBeRemoved(const AbstractAspect*); 0100 void yDataColumnAboutToBeRemoved(const AbstractAspect*); 0101 void y2DataColumnAboutToBeRemoved(const AbstractAspect*); 0102 void xDataColumnNameChanged(); 0103 void yDataColumnNameChanged(); 0104 void y2DataColumnNameChanged(); 0105 0106 Q_SIGNALS: 0107 void sourceDataChanged(); // emitted when the source data used in the analysis curves was changed to enable the recalculation in the dock widgets 0108 void dataSourceTypeChanged(XYAnalysisCurve::DataSourceType); 0109 void dataSourceCurveChanged(const XYCurve*); 0110 void xDataColumnChanged(const AbstractColumn*); 0111 void yDataColumnChanged(const AbstractColumn*); 0112 void y2DataColumnChanged(const AbstractColumn*); 0113 }; 0114 0115 #endif