| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | // W A R N I N G |
| 5 | // ------------- |
| 6 | // |
| 7 | // This file is not part of the Qt Chart API. It exists purely as an |
| 8 | // implementation detail. This header file may change from version to |
| 9 | // version without notice, or even be removed. |
| 10 | // |
| 11 | // We mean it. |
| 12 | |
| 13 | #ifndef QABSTRACTBARSERIES_P_H |
| 14 | #define QABSTRACTBARSERIES_P_H |
| 15 | |
| 16 | #include <QtCharts/QAbstractBarSeries> |
| 17 | #include <private/qabstractseries_p.h> |
| 18 | #include <QtCore/QStringList> |
| 19 | #include <QtCharts/QAbstractSeries> |
| 20 | #include <QtCharts/private/qchartglobal_p.h> |
| 21 | |
| 22 | QT_BEGIN_NAMESPACE |
| 23 | |
| 24 | class QBarModelMapper; |
| 25 | class QBarCategoryAxis; |
| 26 | class QLegendMarker; |
| 27 | |
| 28 | class Q_CHARTS_EXPORT QAbstractBarSeriesPrivate : public QAbstractSeriesPrivate |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | public: |
| 32 | QAbstractBarSeriesPrivate(QAbstractBarSeries *parent); |
| 33 | int categoryCount() const; |
| 34 | |
| 35 | void setBarWidth(qreal width); |
| 36 | qreal barWidth() const; |
| 37 | |
| 38 | void setVisible(bool visible); |
| 39 | void setLabelsVisible(bool visible); |
| 40 | |
| 41 | void initializeDomain() override; |
| 42 | void initializeAxes() override; |
| 43 | void initializeAnimations(QChart::AnimationOptions options, int duration, QEasingCurve &curve) override; |
| 44 | void initializeTheme(int index, ChartTheme* theme, bool forced = false) override; |
| 45 | |
| 46 | QList<QLegendMarker*> createLegendMarkers(QLegend *legend) override; |
| 47 | |
| 48 | virtual QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const override; |
| 49 | QAbstractAxis* createDefaultAxis(Qt::Orientation orientation) const override; |
| 50 | |
| 51 | bool append(QBarSet *set); |
| 52 | bool remove(QBarSet *set); |
| 53 | bool append(const QList<QBarSet *> &sets); |
| 54 | bool remove(const QList<QBarSet *> &sets); |
| 55 | bool insert(int index, QBarSet *set); |
| 56 | |
| 57 | QBarSet *barsetAt(int index); |
| 58 | qreal min(); |
| 59 | qreal max(); |
| 60 | qreal valueAt(int set, int category); |
| 61 | qreal percentageAt(int set, int category); |
| 62 | qreal categorySum(int category); |
| 63 | qreal absoluteCategorySum(int category); |
| 64 | qreal maxCategorySum(); |
| 65 | qreal minX(); |
| 66 | qreal maxX(); |
| 67 | qreal categoryTop(int category); |
| 68 | qreal categoryBottom(int category); |
| 69 | qreal top(); |
| 70 | qreal bottom(); |
| 71 | |
| 72 | bool blockBarUpdate(); |
| 73 | |
| 74 | qreal labelsAngle() const; |
| 75 | void setVisualsDirty(bool dirty) { m_visualsDirty = dirty; } |
| 76 | bool visualsDirty() const { return m_visualsDirty; } |
| 77 | void setLabelsDirty(bool dirty) { m_labelsDirty = dirty; } |
| 78 | bool labelsDirty() const { return m_labelsDirty; } |
| 79 | |
| 80 | Q_SIGNALS: |
| 81 | void clicked(int index, QBarSet *barset); |
| 82 | void pressed(int index, QBarSet *barset); |
| 83 | void released(int index, QBarSet *barset); |
| 84 | void doubleClicked(int index, QBarSet *barset); |
| 85 | void updatedBars(); |
| 86 | void updatedLayout(); |
| 87 | void restructuredBars(); |
| 88 | void labelsVisibleChanged(bool visible); |
| 89 | void visibleChanged(); |
| 90 | void setValueChanged(int index, QBarSet *barset); |
| 91 | void setValueAdded(int index, int count, QBarSet *barset); |
| 92 | void setValueRemoved(int index, int count, QBarSet *barset); |
| 93 | |
| 94 | private Q_SLOTS: |
| 95 | void handleSetValueChange(int index); |
| 96 | void handleSetValueAdd(int index, int count); |
| 97 | void handleSetValueRemove(int index, int count); |
| 98 | |
| 99 | private: |
| 100 | void populateCategories(QBarCategoryAxis *axis); |
| 101 | |
| 102 | protected: |
| 103 | QList<QBarSet *> m_barSets; |
| 104 | qreal m_barWidth; |
| 105 | bool m_labelsVisible; |
| 106 | bool m_visible; |
| 107 | bool m_blockBarUpdate; |
| 108 | QString m_labelsFormat; |
| 109 | QAbstractBarSeries::LabelsPosition m_labelsPosition; |
| 110 | qreal m_labelsAngle; |
| 111 | int m_labelsPrecision; |
| 112 | bool m_visualsDirty; |
| 113 | bool m_labelsDirty; |
| 114 | |
| 115 | private: |
| 116 | Q_DECLARE_PUBLIC(QAbstractBarSeries) |
| 117 | friend class HorizontalBarChartItem; |
| 118 | friend class BarChartItem; |
| 119 | }; |
| 120 | |
| 121 | QT_END_NAMESPACE |
| 122 | |
| 123 | #endif // QABSTRACTBARSERIES_P_H |
| 124 | |