File indexing completed on 2024-05-12 03:47:56

0001 /*
0002     File                 : StatisticsSpreadsheet.h
0003     Project              : LabPlot
0004     Description          : Aspect providing a spreadsheet with the columns statistics for the parent spreadsheet
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2023 Alexander Semke <alexander.semke@web.de>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef STATISTICSSPREADSHEET_H
0011 #define STATISTICSSPREADSHEET_H
0012 
0013 #include "backend/spreadsheet/Spreadsheet.h"
0014 
0015 class StatisticsSpreadsheet : public Spreadsheet {
0016     Q_OBJECT
0017 
0018 public:
0019     explicit StatisticsSpreadsheet(Spreadsheet*, bool loading = false, AspectType type = AspectType::StatisticsSpreadsheet);
0020     ~StatisticsSpreadsheet() override;
0021 
0022     enum class Metric {
0023         Count = 0x00000001,
0024         Minimum = 0x00000002,
0025         Maximum = 0x00000004,
0026         ArithmeticMean = 0x00000008,
0027         GeometricMean = 0x00000010,
0028         HarmonicMean = 0x00000020,
0029         ContraharmonicMean = 0x00000040,
0030         Mode = 0x00000080,
0031         FirstQuartile = 0x00000100,
0032         Median = 0x00000200,
0033         ThirdQuartile = 0x00000400,
0034         IQR = 0x00000800,
0035         Percentile1 = 0x00001000,
0036         Percentile5 = 0x00002000,
0037         Percentile10 = 0x00004000,
0038         Percentile90 = 0x00008000,
0039         Percentile95 = 0x00010000,
0040         Percentile99 = 0x00020000,
0041         Trimean = 0x00040000,
0042         Variance = 0x00080000,
0043         StandardDeviation = 0x00100000,
0044         MeanDeviation = 0x00200000,
0045         MeanDeviationAroundMedian = 0x00400000,
0046         MedianDeviation = 0x00800000,
0047         Skewness = 0x01000000,
0048         Kurtosis = 0x02000000,
0049         Entropy = 0x04000000
0050     };
0051     Q_DECLARE_FLAGS(Metrics, Metric)
0052 
0053     QIcon icon() const override;
0054 
0055     Metrics metrics() const;
0056     void setMetrics(Metrics);
0057 
0058     void save(QXmlStreamWriter*) const override;
0059     bool load(XmlStreamReader*, bool preview) override;
0060 
0061 private:
0062     void init();
0063     void update();
0064 
0065     Spreadsheet* m_spreadsheet{nullptr};
0066     Metrics m_metrics;
0067     QMap<Metric, QString> m_metricNames;
0068 
0069     friend class SpreadsheetTest;
0070 };
0071 
0072 Q_DECLARE_OPERATORS_FOR_FLAGS(StatisticsSpreadsheet::Metrics)
0073 
0074 #endif