File indexing completed on 2025-01-26 03:34:16

0001 /*
0002     File                 : XYConvolutionCurve.h
0003     Project              : LabPlot
0004     Description          : A xy-curve defined by a convolution
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2018 Stefan Gerlach <stefan.gerlach@uni.kn>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef XYCONVOLUTIONCURVE_H
0011 #define XYCONVOLUTIONCURVE_H
0012 
0013 #include "backend/worksheet/plots/cartesian/XYAnalysisCurve.h"
0014 
0015 extern "C" {
0016 #include "backend/nsl/nsl_conv.h"
0017 }
0018 
0019 class XYConvolutionCurvePrivate;
0020 
0021 class XYConvolutionCurve : public XYAnalysisCurve {
0022     Q_OBJECT
0023 
0024 public:
0025     struct ConvolutionData {
0026         ConvolutionData(){};
0027 
0028         double samplingInterval{1.}; // sampling interval used when no x-axis is present
0029         nsl_conv_kernel_type kernel{nsl_conv_kernel_avg}; // kernel to use when no response selected
0030         size_t kernelSize{2}; // size of kernel
0031         nsl_conv_direction_type direction{nsl_conv_direction_forward}; // forward (convolution) or backward (deconvolution)
0032         nsl_conv_type_type type{nsl_conv_type_linear}; // linear or circular
0033         nsl_conv_method_type method{nsl_conv_method_auto}; // how to calculate convolution (auto, direct or FFT method)
0034         nsl_conv_norm_type normalize{nsl_conv_norm_none}; // normalization of response
0035         nsl_conv_wrap_type wrap{nsl_conv_wrap_none}; // wrap response
0036         bool autoRange{true}; // use all data?
0037         // TODO: use Range
0038         QVector<double> xRange{0., 0.}; // x range for convolution
0039     };
0040     typedef XYAnalysisCurve::Result ConvolutionResult;
0041     virtual const XYAnalysisCurve::Result& result() const override;
0042 
0043     explicit XYConvolutionCurve(const QString& name);
0044     ~XYConvolutionCurve() override;
0045 
0046     void recalculate() override;
0047     QIcon icon() const override;
0048     void save(QXmlStreamWriter*) const override;
0049     bool load(XmlStreamReader*, bool preview) override;
0050 
0051     CLASS_D_ACCESSOR_DECL(ConvolutionData, convolutionData, ConvolutionData)
0052     const ConvolutionResult& convolutionResult() const;
0053 
0054     typedef XYConvolutionCurvePrivate Private;
0055 
0056 protected:
0057     XYConvolutionCurve(const QString& name, XYConvolutionCurvePrivate* dd);
0058 
0059 private:
0060     Q_DECLARE_PRIVATE(XYConvolutionCurve)
0061 
0062 Q_SIGNALS:
0063     void convolutionDataChanged(const XYConvolutionCurve::ConvolutionData&);
0064 };
0065 
0066 #endif