| 1 | // Copyright (C) 2023 The Qt Company Ltd. | 
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only | 
| 3 |  | 
| 4 | #ifndef QTGRAPHS_QABSTRACTAXIS_H | 
| 5 | #define QTGRAPHS_QABSTRACTAXIS_H | 
| 6 |  | 
| 7 | #include <QtCore/qobject.h> | 
| 8 | #include <QtCore/qvariant.h> | 
| 9 | #include <QtGraphs/qgraphsglobal.h> | 
| 10 | #include <QtGui/qcolor.h> | 
| 11 | #include <QtGui/qfont.h> | 
| 12 | #include <QtQml/qqmlcomponent.h> | 
| 13 | #include <QtQml/qqmlengine.h> | 
| 14 |  | 
| 15 | QT_BEGIN_NAMESPACE | 
| 16 |  | 
| 17 | class QAbstractAxisPrivate; | 
| 18 |  | 
| 19 | class Q_GRAPHS_EXPORT QAbstractAxis : public QObject | 
| 20 | { | 
| 21 |     Q_OBJECT | 
| 22 |     Q_CLASSINFO("RegisterEnumClassesUnscoped" , "false" ) | 
| 23 |     //visibility | 
| 24 |     Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) | 
| 25 |     Q_PROPERTY( | 
| 26 |         bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged FINAL) | 
| 27 |     //labels | 
| 28 |     Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY | 
| 29 |                    labelsVisibleChanged FINAL) | 
| 30 |     Q_PROPERTY( | 
| 31 |         qreal labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged FINAL) | 
| 32 |     Q_PROPERTY(QQmlComponent *labelDelegate READ labelDelegate | 
| 33 |                        WRITE setLabelDelegate NOTIFY labelDelegateChanged FINAL) | 
| 34 |     //grid | 
| 35 |     Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible NOTIFY | 
| 36 |                    gridVisibleChanged FINAL) | 
| 37 |     Q_PROPERTY(bool subGridVisible READ isSubGridVisible WRITE setSubGridVisible | 
| 38 |                    NOTIFY subGridVisibleChanged FINAL) | 
| 39 |     //title | 
| 40 |     Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged FINAL) | 
| 41 |     Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged FINAL) | 
| 42 |     Q_PROPERTY(bool titleVisible READ isTitleVisible WRITE setTitleVisible NOTIFY | 
| 43 |                    titleVisibleChanged FINAL) | 
| 44 |     Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont NOTIFY titleFontChanged FINAL) | 
| 45 |     QML_FOREIGN(QAbstractAxis) | 
| 46 |     QML_UNCREATABLE("" ) | 
| 47 |     QML_NAMED_ELEMENT(AbstractAxis) | 
| 48 |     Q_DECLARE_PRIVATE(QAbstractAxis) | 
| 49 |  | 
| 50 | public: | 
| 51 |     enum class AxisType { | 
| 52 |         Value, | 
| 53 |         BarCategory, | 
| 54 |         DateTime, | 
| 55 |     }; | 
| 56 |     Q_ENUM(AxisType) | 
| 57 |  | 
| 58 | protected: | 
| 59 |     explicit QAbstractAxis(QAbstractAxisPrivate &dd, QObject *parent = nullptr); | 
| 60 |  | 
| 61 | public: | 
| 62 |     ~QAbstractAxis() override; | 
| 63 |  | 
| 64 |     virtual AxisType type() const = 0; | 
| 65 |  | 
| 66 |     //visibility handling | 
| 67 |     bool isVisible() const; | 
| 68 |     void setVisible(bool visible = true); | 
| 69 |     void show(); | 
| 70 |     void hide(); | 
| 71 |  | 
| 72 |     //arrow handling | 
| 73 |     bool isLineVisible() const; | 
| 74 |     void setLineVisible(bool visible = true); | 
| 75 |  | 
| 76 |     //grid handling | 
| 77 |     bool isGridVisible() const; | 
| 78 |     void setGridVisible(bool visible = true); | 
| 79 |     bool isSubGridVisible() const; | 
| 80 |     void setSubGridVisible(bool visible = true); | 
| 81 |  | 
| 82 |     //labels handling | 
| 83 |     bool labelsVisible() const; | 
| 84 |     void setLabelsVisible(bool visible = true); | 
| 85 |     void setLabelsAngle(qreal angle); | 
| 86 |     qreal labelsAngle() const; | 
| 87 |     QQmlComponent *labelDelegate() const; | 
| 88 |     void setLabelDelegate(QQmlComponent *newLabelDelegate); | 
| 89 |  | 
| 90 |     //title handling | 
| 91 |     bool isTitleVisible() const; | 
| 92 |     void setTitleVisible(bool visible = true); | 
| 93 |     void setTitleColor(QColor color); | 
| 94 |     QColor titleColor() const; | 
| 95 |     void setTitleFont(const QFont &font); | 
| 96 |     QFont titleFont() const; | 
| 97 |     void setTitleText(const QString &title); | 
| 98 |     QString titleText() const; | 
| 99 |  | 
| 100 |     //range handling | 
| 101 |     void setMin(const QVariant &min); | 
| 102 |     void setMax(const QVariant &max); | 
| 103 |     void setRange(const QVariant &min, const QVariant &max); | 
| 104 |  | 
| 105 | Q_SIGNALS: | 
| 106 |     void visibleChanged(bool visible); | 
| 107 |     void lineVisibleChanged(bool visible); | 
| 108 |     void labelsVisibleChanged(bool visible); | 
| 109 |     void labelsAngleChanged(qreal angle); | 
| 110 |     void labelDelegateChanged(); | 
| 111 |     void gridVisibleChanged(bool visible); | 
| 112 |     void subGridVisibleChanged(bool visible); | 
| 113 |     void titleTextChanged(const QString &title); | 
| 114 |     void titleColorChanged(QColor color); | 
| 115 |     void titleVisibleChanged(bool visible); | 
| 116 |     void titleFontChanged(const QFont &font); | 
| 117 |     void update(); | 
| 118 |     void rangeChanged(qreal min, qreal max); | 
| 119 |  | 
| 120 | private: | 
| 121 |     friend class QGraphsView; | 
| 122 |     Q_DISABLE_COPY(QAbstractAxis) | 
| 123 | }; | 
| 124 |  | 
| 125 | QT_END_NAMESPACE | 
| 126 |  | 
| 127 | #endif // QTGRAPHS_QABSTRACTAXIS_H | 
| 128 |  |