File indexing completed on 2025-01-26 03:34:04
0001 /* 0002 File : BarPlot.h 0003 Project : LabPlot 0004 Description : Bar Plot 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2022-2023 Alexander Semke <alexander.semke@web.de> 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #ifndef BARPLOT_H 0011 #define BARPLOT_H 0012 0013 #include "backend/worksheet/plots/cartesian/Plot.h" 0014 0015 class BarPlotPrivate; 0016 class AbstractColumn; 0017 class Background; 0018 class Line; 0019 class Value; 0020 0021 #ifdef SDK 0022 #include "labplot_export.h" 0023 class LABPLOT_EXPORT BarPlot : Plot { 0024 #else 0025 class BarPlot : public Plot { 0026 #endif 0027 Q_OBJECT 0028 0029 public: 0030 enum class Type { Grouped, Stacked, Stacked_100_Percent }; 0031 0032 explicit BarPlot(const QString&); 0033 ~BarPlot() override; 0034 0035 QIcon icon() const override; 0036 QMenu* createContextMenu() override; 0037 0038 void save(QXmlStreamWriter*) const override; 0039 bool load(XmlStreamReader*, bool preview) override; 0040 void loadThemeConfig(const KConfig&) override; 0041 0042 // general 0043 POINTER_D_ACCESSOR_DECL(const AbstractColumn, xColumn, XColumn) 0044 QString& xColumnPath() const; 0045 BASIC_D_ACCESSOR_DECL(QVector<const AbstractColumn*>, dataColumns, DataColumns) 0046 QVector<QString>& dataColumnPaths() const; 0047 BASIC_D_ACCESSOR_DECL(BarPlot::Type, type, Type) 0048 BASIC_D_ACCESSOR_DECL(BarPlot::Orientation, orientation, Orientation) 0049 BASIC_D_ACCESSOR_DECL(double, widthFactor, WidthFactor) 0050 0051 // box filling 0052 Background* backgroundAt(int) const; 0053 0054 // box border line 0055 Line* lineAt(int) const; 0056 0057 // values 0058 Value* value() const; 0059 0060 void retransform() override; 0061 void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override; 0062 0063 double minimum(CartesianCoordinateSystem::Dimension) const override; 0064 double maximum(CartesianCoordinateSystem::Dimension) const override; 0065 bool hasData() const override; 0066 bool usingColumn(const Column*) const override; 0067 void updateColumnDependencies(const AbstractColumn*) override; 0068 QColor color() const override; 0069 0070 typedef BarPlotPrivate Private; 0071 0072 protected: 0073 BarPlot(const QString& name, BarPlotPrivate* dd); 0074 0075 private: 0076 Q_DECLARE_PRIVATE(BarPlot) 0077 void init(); 0078 void initActions(); 0079 void initMenus(); 0080 0081 QAction* orientationHorizontalAction{nullptr}; 0082 QAction* orientationVerticalAction{nullptr}; 0083 QMenu* orientationMenu{nullptr}; 0084 0085 public Q_SLOTS: 0086 void recalc(); 0087 0088 private Q_SLOTS: 0089 // SLOTs for changes triggered via QActions in the context menu 0090 void orientationChangedSlot(QAction*); 0091 void dataColumnAboutToBeRemoved(const AbstractAspect*); 0092 0093 Q_SIGNALS: 0094 // General-Tab 0095 void xColumnChanged(const AbstractColumn*); 0096 void dataColumnsChanged(const QVector<const AbstractColumn*>&); 0097 void typeChanged(BarPlot::Type); 0098 void orientationChanged(BarPlot::Orientation); 0099 void widthFactorChanged(double); 0100 0101 // box border 0102 void borderPenChanged(QPen&); 0103 void borderOpacityChanged(float); 0104 }; 0105 0106 #endif