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

0001 /*
0002     File                 : XYIntegrationCurve.h
0003     Project              : LabPlot
0004     Description          : A xy-curve defined by an integration
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2016-2021 Stefan Gerlach <stefan.gerlach@uni.kn>
0007     SPDX-FileCopyrightText: 2017 Alexander Semke <alexander.semke@web.de>
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #ifndef XYINTEGRATIONCURVE_H
0012 #define XYINTEGRATIONCURVE_H
0013 
0014 #include "backend/worksheet/plots/cartesian/XYAnalysisCurve.h"
0015 extern "C" {
0016 #include "backend/nsl/nsl_int.h"
0017 }
0018 
0019 class XYIntegrationCurvePrivate;
0020 
0021 class XYIntegrationCurve : public XYAnalysisCurve {
0022     Q_OBJECT
0023 
0024 public:
0025     struct IntegrationData {
0026         IntegrationData(){};
0027 
0028         nsl_int_method_type method{nsl_int_method_trapezoid}; // method for integration
0029         bool absolute{false}; // absolute area?
0030         bool autoRange{true}; // use all data?
0031         // TODO: use Range
0032         QVector<double> xRange{0, 0}; // x range for integration
0033     };
0034     struct IntegrationResult : public XYAnalysisCurve::Result {
0035         IntegrationResult(){};
0036 
0037         double value{0.0}; // final result of integration
0038     };
0039 
0040     explicit XYIntegrationCurve(const QString& name);
0041     ~XYIntegrationCurve() override;
0042 
0043     void recalculate() override;
0044     virtual const XYAnalysisCurve::Result& result() const override;
0045     QIcon icon() const override;
0046     void save(QXmlStreamWriter*) const override;
0047     bool load(XmlStreamReader*, bool preview) override;
0048 
0049     CLASS_D_ACCESSOR_DECL(IntegrationData, integrationData, IntegrationData)
0050     const IntegrationResult& integrationResult() const;
0051 
0052     typedef XYIntegrationCurvePrivate Private;
0053 
0054 protected:
0055     XYIntegrationCurve(const QString& name, XYIntegrationCurvePrivate* dd);
0056 
0057 private:
0058     Q_DECLARE_PRIVATE(XYIntegrationCurve)
0059 
0060 Q_SIGNALS:
0061     void integrationDataChanged(const XYIntegrationCurve::IntegrationData&);
0062 };
0063 
0064 #endif