| 1 | // Copyright (C) 2021 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QABSTRACTAXIS_H |
| 5 | #define QABSTRACTAXIS_H |
| 6 | |
| 7 | #include <QtCharts/QChartGlobal> |
| 8 | #include <QtGui/QPen> |
| 9 | #include <QtGui/QFont> |
| 10 | #include <QtCore/QVariant> |
| 11 | #include <QtCore/QObject> |
| 12 | |
| 13 | QT_BEGIN_NAMESPACE |
| 14 | |
| 15 | class QAbstractAxisPrivate; |
| 16 | |
| 17 | class Q_CHARTS_EXPORT QAbstractAxis : public QObject |
| 18 | { |
| 19 | Q_OBJECT |
| 20 | //visibility |
| 21 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
| 22 | //arrow |
| 23 | Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged) |
| 24 | Q_PROPERTY(QPen linePen READ linePen WRITE setLinePen NOTIFY linePenChanged) |
| 25 | Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged) |
| 26 | //labels |
| 27 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
| 28 | Q_PROPERTY(QBrush labelsBrush READ labelsBrush WRITE setLabelsBrush NOTIFY labelsBrushChanged) |
| 29 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged) |
| 30 | Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont NOTIFY labelsFontChanged) |
| 31 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) |
| 32 | Q_PROPERTY(bool labelsTruncated READ labelsTruncated NOTIFY labelsTruncatedChanged REVISION(6, 2)) |
| 33 | Q_PROPERTY(bool truncateLabels READ truncateLabels WRITE setTruncateLabels NOTIFY truncateLabelsChanged REVISION(6, 2)) |
| 34 | //grid |
| 35 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) |
| 36 | Q_PROPERTY(QPen gridLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged) |
| 37 | Q_PROPERTY(bool minorGridVisible READ isMinorGridLineVisible WRITE setMinorGridLineVisible NOTIFY minorGridVisibleChanged) |
| 38 | Q_PROPERTY(QPen minorGridLinePen READ minorGridLinePen WRITE setMinorGridLinePen NOTIFY minorGridLinePenChanged) |
| 39 | Q_PROPERTY(QColor gridLineColor READ gridLineColor WRITE setGridLineColor NOTIFY gridLineColorChanged) |
| 40 | Q_PROPERTY(QColor minorGridLineColor READ minorGridLineColor WRITE setMinorGridLineColor NOTIFY minorGridLineColorChanged) |
| 41 | //shades |
| 42 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) |
| 43 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) |
| 44 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) |
| 45 | Q_PROPERTY(QPen shadesPen READ shadesPen WRITE setShadesPen NOTIFY shadesPenChanged) |
| 46 | Q_PROPERTY(QBrush shadesBrush READ shadesBrush WRITE setShadesBrush NOTIFY shadesBrushChanged) |
| 47 | //title |
| 48 | Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged) |
| 49 | Q_PROPERTY(QBrush titleBrush READ titleBrush WRITE setTitleBrush NOTIFY titleBrushChanged) |
| 50 | Q_PROPERTY(bool titleVisible READ isTitleVisible WRITE setTitleVisible NOTIFY titleVisibleChanged) |
| 51 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont NOTIFY titleFontChanged) |
| 52 | //orientation |
| 53 | Q_PROPERTY(Qt::Orientation orientation READ orientation) |
| 54 | //alignment |
| 55 | Q_PROPERTY(Qt::Alignment alignment READ alignment) |
| 56 | Q_PROPERTY(bool reverse READ isReverse WRITE setReverse NOTIFY reverseChanged) |
| 57 | |
| 58 | public: |
| 59 | |
| 60 | enum AxisType { |
| 61 | AxisTypeNoAxis = 0x0, |
| 62 | AxisTypeValue = 0x1, |
| 63 | AxisTypeBarCategory = 0x2, |
| 64 | AxisTypeCategory = 0x4, |
| 65 | AxisTypeDateTime = 0x8, |
| 66 | AxisTypeLogValue = 0x10, |
| 67 | AxisTypeColor = 0x20 |
| 68 | }; |
| 69 | |
| 70 | Q_DECLARE_FLAGS(AxisTypes, AxisType) |
| 71 | |
| 72 | protected: |
| 73 | explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = nullptr); |
| 74 | |
| 75 | public: |
| 76 | ~QAbstractAxis(); |
| 77 | |
| 78 | virtual AxisType type() const = 0; |
| 79 | |
| 80 | //visibility handling |
| 81 | bool isVisible() const; |
| 82 | void setVisible(bool visible = true); |
| 83 | void show(); |
| 84 | void hide(); |
| 85 | |
| 86 | //arrow handling |
| 87 | bool isLineVisible() const; |
| 88 | void setLineVisible(bool visible = true); |
| 89 | void setLinePen(const QPen &pen); |
| 90 | QPen linePen() const; |
| 91 | void setLinePenColor(QColor color); |
| 92 | QColor linePenColor() const; |
| 93 | |
| 94 | //grid handling |
| 95 | bool isGridLineVisible() const; |
| 96 | void setGridLineVisible(bool visible = true); |
| 97 | void setGridLinePen(const QPen &pen); |
| 98 | QPen gridLinePen() const; |
| 99 | bool isMinorGridLineVisible() const; |
| 100 | void setMinorGridLineVisible(bool visible = true); |
| 101 | void setMinorGridLinePen(const QPen &pen); |
| 102 | QPen minorGridLinePen() const; |
| 103 | void setGridLineColor(const QColor &color); |
| 104 | QColor gridLineColor(); |
| 105 | void setMinorGridLineColor(const QColor &color); |
| 106 | QColor minorGridLineColor(); |
| 107 | |
| 108 | //labels handling |
| 109 | bool labelsVisible() const; |
| 110 | void setLabelsVisible(bool visible = true); |
| 111 | void setLabelsBrush(const QBrush &brush); |
| 112 | QBrush labelsBrush() const; |
| 113 | void setLabelsFont(const QFont &font); |
| 114 | QFont labelsFont() const; |
| 115 | void setLabelsAngle(int angle); |
| 116 | int labelsAngle() const; |
| 117 | void setLabelsColor(QColor color); |
| 118 | QColor labelsColor() const; |
| 119 | |
| 120 | //title handling |
| 121 | bool isTitleVisible() const; |
| 122 | void setTitleVisible(bool visible = true); |
| 123 | void setTitleBrush(const QBrush &brush); |
| 124 | QBrush titleBrush() const; |
| 125 | void setTitleFont(const QFont &font); |
| 126 | QFont titleFont() const; |
| 127 | void setTitleText(const QString &title); |
| 128 | QString titleText() const; |
| 129 | |
| 130 | //shades handling |
| 131 | bool shadesVisible() const; |
| 132 | void setShadesVisible(bool visible = true); |
| 133 | void setShadesPen(const QPen &pen); |
| 134 | QPen shadesPen() const; |
| 135 | void setShadesBrush(const QBrush &brush); |
| 136 | QBrush shadesBrush() const; |
| 137 | void setShadesColor(QColor color); |
| 138 | QColor shadesColor() const; |
| 139 | void setShadesBorderColor(QColor color); |
| 140 | QColor shadesBorderColor() const; |
| 141 | |
| 142 | Qt::Orientation orientation() const; |
| 143 | Qt::Alignment alignment() const; |
| 144 | |
| 145 | //range handling |
| 146 | void setMin(const QVariant &min); |
| 147 | void setMax(const QVariant &max); |
| 148 | void setRange(const QVariant &min, const QVariant &max); |
| 149 | |
| 150 | //reverse handling |
| 151 | void setReverse(bool reverse = true); |
| 152 | bool isReverse() const; |
| 153 | |
| 154 | //label editable handling |
| 155 | void setLabelsEditable(bool editable = true); |
| 156 | bool labelsEditable() const; |
| 157 | |
| 158 | bool labelsTruncated() const; |
| 159 | |
| 160 | void setTruncateLabels(bool truncateLabels = true); |
| 161 | bool truncateLabels() const; |
| 162 | |
| 163 | Q_SIGNALS: |
| 164 | void visibleChanged(bool visible); |
| 165 | void linePenChanged(const QPen &pen); |
| 166 | void lineVisibleChanged(bool visible); |
| 167 | void labelsVisibleChanged(bool visible); |
| 168 | void labelsBrushChanged(const QBrush &brush); |
| 169 | void labelsFontChanged(const QFont &pen); |
| 170 | void labelsAngleChanged(int angle); |
| 171 | void gridLinePenChanged(const QPen &pen); |
| 172 | void gridVisibleChanged(bool visible); |
| 173 | void minorGridVisibleChanged(bool visible); |
| 174 | void minorGridLinePenChanged(const QPen &pen); |
| 175 | void gridLineColorChanged(const QColor &color); |
| 176 | void minorGridLineColorChanged(const QColor &color); |
| 177 | void colorChanged(QColor color); |
| 178 | void labelsColorChanged(QColor color); |
| 179 | void titleTextChanged(const QString &title); |
| 180 | void titleBrushChanged(const QBrush &brush); |
| 181 | void titleVisibleChanged(bool visible); |
| 182 | void titleFontChanged(const QFont &font); |
| 183 | void shadesVisibleChanged(bool visible); |
| 184 | void shadesColorChanged(QColor color); |
| 185 | void shadesBorderColorChanged(QColor color); |
| 186 | void shadesPenChanged(const QPen &pen); |
| 187 | void shadesBrushChanged(const QBrush &brush); |
| 188 | void reverseChanged(bool reverse); |
| 189 | void labelsEditableChanged(bool editable); |
| 190 | Q_REVISION(6, 2) void labelsTruncatedChanged(bool labelsTruncated); |
| 191 | Q_REVISION(6, 2) void truncateLabelsChanged(bool truncateLabels); |
| 192 | |
| 193 | protected: |
| 194 | QScopedPointer<QAbstractAxisPrivate> d_ptr; |
| 195 | friend class ChartDataSet; |
| 196 | friend class ChartPresenter; |
| 197 | friend class ChartThemeManager; |
| 198 | friend class AbstractDomain; |
| 199 | friend class ChartAxisElement; |
| 200 | friend class HorizontalAxis; |
| 201 | friend class VerticalAxis; |
| 202 | friend class XYChart; |
| 203 | |
| 204 | private: |
| 205 | Q_DISABLE_COPY(QAbstractAxis) |
| 206 | }; |
| 207 | |
| 208 | QT_END_NAMESPACE |
| 209 | |
| 210 | #endif // QABSTRACTAXIS_H |
| 211 | |