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

0001 /*
0002     File                 : KDEPlot.h
0003     Project              : LabPlot
0004     Description          : KDE-Plot
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2023 Alexander Semke <alexander.semke@web.de>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef KDEPLOT_H
0011 #define KDEPLOT_H
0012 
0013 #include "Plot.h"
0014 #include "backend/nsl/nsl_kde.h"
0015 #include "backend/nsl/nsl_sf_kernel.h"
0016 
0017 class AbstractColumn;
0018 class KDEPlotPrivate;
0019 class XYCurve;
0020 
0021 #ifdef SDK
0022 #include "labplot_export.h"
0023 class LABPLOT_EXPORT KDEPlot : public Plot {
0024 #else
0025 class KDEPlot : public Plot {
0026 #endif
0027     Q_OBJECT
0028 
0029 public:
0030     friend class KDEPlotSetDataColumnCmd;
0031 
0032     explicit KDEPlot(const QString& name);
0033     ~KDEPlot() override;
0034 
0035     void finalizeAdd() override;
0036 
0037     QIcon icon() const override;
0038 
0039     void save(QXmlStreamWriter*) const override;
0040     bool load(XmlStreamReader*, bool preview) override;
0041 
0042     void loadThemeConfig(const KConfig&) override;
0043     void saveThemeConfig(const KConfig&) override;
0044 
0045     POINTER_D_ACCESSOR_DECL(const AbstractColumn, dataColumn, DataColumn)
0046     CLASS_D_ACCESSOR_DECL(QString, dataColumnPath, DataColumnPath)
0047     BASIC_D_ACCESSOR_DECL(nsl_kernel_type, kernelType, KernelType)
0048     BASIC_D_ACCESSOR_DECL(nsl_kde_bandwidth_type, bandwidthType, BandwidthType)
0049     BASIC_D_ACCESSOR_DECL(double, bandwidth, Bandwidth)
0050 
0051     XYCurve* estimationCurve() const;
0052     XYCurve* rugCurve() const;
0053 
0054     void retransform() override;
0055     void recalc();
0056     void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override;
0057     void setVisible(bool) override;
0058 
0059     bool minMax(const CartesianCoordinateSystem::Dimension dim, const Range<int>& indexRange, Range<double>& r, bool includeErrorBars = true) const override;
0060     double minimum(CartesianCoordinateSystem::Dimension) const override;
0061     double maximum(CartesianCoordinateSystem::Dimension) const override;
0062     int gridPointsCount() const;
0063     bool hasData() const override;
0064     bool usingColumn(const Column*) const override;
0065     void updateColumnDependencies(const AbstractColumn*) override;
0066     QColor color() const override;
0067 
0068     typedef KDEPlotPrivate Private;
0069 
0070 private Q_SLOTS:
0071     void dataColumnAboutToBeRemoved(const AbstractAspect*);
0072 
0073 protected:
0074     KDEPlot(const QString& name, KDEPlotPrivate* dd);
0075 
0076 private:
0077     Q_DECLARE_PRIVATE(KDEPlot)
0078     void init();
0079     void connectDataColumn(const AbstractColumn*);
0080     QAction* navigateToAction{nullptr};
0081     bool m_menusInitialized{false};
0082 
0083 Q_SIGNALS:
0084     void linesUpdated(const KDEPlot*, const QVector<QLineF>&);
0085 
0086     // General-Tab
0087     void dataChanged(); // emitted when the actual curve data to be plotted was changed to re-adjust the plot
0088     void dataDataChanged();
0089     void dataColumnChanged(const AbstractColumn*);
0090     void kernelTypeChanged(nsl_kernel_type);
0091     void bandwidthTypeChanged(nsl_kde_bandwidth_type);
0092     void bandwidthChanged(double);
0093 };
0094 
0095 #endif