File indexing completed on 2025-01-26 03:34:12
0001 /* 0002 File : Histogram.h 0003 Project : LabPlot 0004 Description : Histogram 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2016 Anu Mittal <anu22mittal@gmail.com> 0007 SPDX-FileCopyrightText: 2018-2024 Alexander Semke <alexander.semke@web.de> 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #ifndef HISTOGRAM_H 0012 #define HISTOGRAM_H 0013 0014 #include "backend/worksheet/plots/cartesian/Plot.h" 0015 0016 class AbstractColumn; 0017 class HistogramPrivate; 0018 class Background; 0019 class ErrorBar; 0020 class ErrorBarStyle; 0021 class Line; 0022 class Symbol; 0023 class Value; 0024 0025 #ifdef SDK 0026 #include "labplot_export.h" 0027 class LABPLOT_EXPORT Histogram : public Plot { 0028 #else 0029 class Histogram : public Plot { 0030 #endif 0031 Q_OBJECT 0032 0033 public: 0034 friend class HistogramSetDataColumnCmd; 0035 enum Type { Ordinary, Cumulative, AvgShift }; 0036 enum Orientation { Vertical, Horizontal }; 0037 enum Normalization { Count, Probability, CountDensity, ProbabilityDensity }; 0038 enum BinningMethod { ByNumber, ByWidth, SquareRoot, Rice, Sturges, Doane, Scott }; 0039 enum LineType { NoLine, Bars, Envelope, DropLines, HalfBars }; 0040 enum ValuesType { NoValues, ValuesBinEntries, ValuesCustomColumn }; 0041 enum ValuesPosition { ValuesAbove, ValuesUnder, ValuesLeft, ValuesRight }; 0042 0043 explicit Histogram(const QString& name); 0044 ~Histogram() override; 0045 0046 QIcon icon() const override; 0047 QMenu* createContextMenu() override; 0048 void save(QXmlStreamWriter*) const override; 0049 bool load(XmlStreamReader*, bool preview) override; 0050 void loadThemeConfig(const KConfig&) override; 0051 void saveThemeConfig(const KConfig&) override; 0052 0053 POINTER_D_ACCESSOR_DECL(const AbstractColumn, dataColumn, DataColumn) 0054 CLASS_D_ACCESSOR_DECL(QString, dataColumnPath, DataColumnPath) 0055 0056 BASIC_D_ACCESSOR_DECL(Histogram::Type, type, Type) 0057 BASIC_D_ACCESSOR_DECL(Histogram::Orientation, orientation, Orientation) 0058 BASIC_D_ACCESSOR_DECL(Histogram::Normalization, normalization, Normalization) 0059 BASIC_D_ACCESSOR_DECL(Histogram::BinningMethod, binningMethod, BinningMethod) 0060 BASIC_D_ACCESSOR_DECL(int, binCount, BinCount) 0061 BASIC_D_ACCESSOR_DECL(double, binWidth, BinWidth) 0062 BASIC_D_ACCESSOR_DECL(bool, autoBinRanges, AutoBinRanges) 0063 BASIC_D_ACCESSOR_DECL(double, binRangesMin, BinRangesMin) 0064 BASIC_D_ACCESSOR_DECL(double, binRangesMax, BinRangesMax) 0065 0066 Line* line() const; 0067 Background* background() const; 0068 Symbol* symbol() const; 0069 Value* value() const; 0070 0071 // error bars 0072 ErrorBar* errorBar() const; 0073 ErrorBarStyle* errorBarStyle() const; 0074 0075 // margin plots 0076 BASIC_D_ACCESSOR_DECL(bool, rugEnabled, RugEnabled) 0077 BASIC_D_ACCESSOR_DECL(double, rugOffset, RugOffset) 0078 BASIC_D_ACCESSOR_DECL(double, rugLength, RugLength) 0079 BASIC_D_ACCESSOR_DECL(double, rugWidth, RugWidth) 0080 0081 double minimum(CartesianCoordinateSystem::Dimension) const override; 0082 double maximum(CartesianCoordinateSystem::Dimension) const override; 0083 bool hasData() const override; 0084 bool usingColumn(const Column*) const override; 0085 void updateColumnDependencies(const AbstractColumn*) override; 0086 QColor color() const override; 0087 0088 const AbstractColumn* bins() const; 0089 const AbstractColumn* binValues() const; 0090 const AbstractColumn* binPDValues() const; 0091 0092 typedef WorksheetElement BaseClass; 0093 typedef HistogramPrivate Private; 0094 0095 public Q_SLOTS: 0096 void retransform() override; 0097 void recalc(); 0098 void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override; 0099 void createDataSpreadsheet(); 0100 0101 private Q_SLOTS: 0102 void updateValues(); 0103 void updateErrorBars(); 0104 0105 void dataColumnAboutToBeRemoved(const AbstractAspect*); 0106 0107 protected: 0108 Histogram(const QString& name, HistogramPrivate* dd); 0109 0110 private: 0111 Q_DECLARE_PRIVATE(Histogram) 0112 void init(); 0113 void initActions(); 0114 void connectDataColumn(const AbstractColumn*); 0115 0116 Q_SIGNALS: 0117 // General-Tab 0118 void dataDataChanged(); 0119 void dataColumnChanged(const AbstractColumn*); 0120 0121 void typeChanged(Histogram::Type); 0122 void orientationChanged(Histogram::Orientation); 0123 void normalizationChanged(Histogram::Normalization); 0124 void binningMethodChanged(Histogram::BinningMethod); 0125 void binCountChanged(int); 0126 void binWidthChanged(double); 0127 void autoBinRangesChanged(bool); 0128 void binRangesMinChanged(double); 0129 void binRangesMaxChanged(double); 0130 0131 // Margin Plots 0132 void rugEnabledChanged(bool); 0133 void rugLengthChanged(double); 0134 void rugWidthChanged(double); 0135 void rugOffsetChanged(double); 0136 }; 0137 0138 #endif