| 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 | #include <QtCore/qloggingcategory.h> |
| 15 | |
| 16 | QT_BEGIN_NAMESPACE |
| 17 | |
| 18 | Q_DECLARE_LOGGING_CATEGORY(lcAxis2D) |
| 19 | |
| 20 | class QAbstractAxisPrivate; |
| 21 | |
| 22 | class Q_GRAPHS_EXPORT QAbstractAxis : public QObject |
| 23 | { |
| 24 | Q_OBJECT |
| 25 | Q_CLASSINFO("RegisterEnumClassesUnscoped" , "false" ) |
| 26 | //visibility |
| 27 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) |
| 28 | Q_PROPERTY( |
| 29 | bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged FINAL) |
| 30 | //labels |
| 31 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY |
| 32 | labelsVisibleChanged FINAL) |
| 33 | Q_PROPERTY( |
| 34 | qreal labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged FINAL) |
| 35 | Q_PROPERTY(QQmlComponent *labelDelegate READ labelDelegate |
| 36 | WRITE setLabelDelegate NOTIFY labelDelegateChanged FINAL) |
| 37 | //grid |
| 38 | Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible NOTIFY |
| 39 | gridVisibleChanged FINAL) |
| 40 | Q_PROPERTY(bool subGridVisible READ isSubGridVisible WRITE setSubGridVisible |
| 41 | NOTIFY subGridVisibleChanged FINAL) |
| 42 | //title |
| 43 | Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged FINAL) |
| 44 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged FINAL) |
| 45 | Q_PROPERTY(bool titleVisible READ isTitleVisible WRITE setTitleVisible NOTIFY |
| 46 | titleVisibleChanged FINAL) |
| 47 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont NOTIFY titleFontChanged FINAL) |
| 48 | //alignment |
| 49 | Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY |
| 50 | alignmentChanged REVISION(6, 9)) |
| 51 | Q_PROPERTY(Qt::TextElideMode textElideMode READ textElideMode WRITE setTextElideMode NOTIFY |
| 52 | textElideModeChanged REVISION(6, 10)) |
| 53 | |
| 54 | QML_FOREIGN(QAbstractAxis) |
| 55 | QML_UNCREATABLE("" ) |
| 56 | QML_NAMED_ELEMENT(AbstractAxis) |
| 57 | Q_DECLARE_PRIVATE(QAbstractAxis) |
| 58 | |
| 59 | public: |
| 60 | enum class AxisType { |
| 61 | Value, |
| 62 | BarCategory, |
| 63 | DateTime, |
| 64 | }; |
| 65 | Q_ENUM(AxisType) |
| 66 | |
| 67 | protected: |
| 68 | explicit QAbstractAxis(QAbstractAxisPrivate &dd, QObject *parent = nullptr); |
| 69 | |
| 70 | public: |
| 71 | ~QAbstractAxis() override; |
| 72 | |
| 73 | virtual AxisType type() const = 0; |
| 74 | |
| 75 | //visibility handling |
| 76 | bool isVisible() const; |
| 77 | void setVisible(bool visible = true); |
| 78 | void show(); |
| 79 | void hide(); |
| 80 | |
| 81 | //arrow handling |
| 82 | bool isLineVisible() const; |
| 83 | void setLineVisible(bool visible = true); |
| 84 | |
| 85 | //grid handling |
| 86 | bool isGridVisible() const; |
| 87 | void setGridVisible(bool visible = true); |
| 88 | bool isSubGridVisible() const; |
| 89 | void setSubGridVisible(bool visible = true); |
| 90 | |
| 91 | //labels handling |
| 92 | bool labelsVisible() const; |
| 93 | void setLabelsVisible(bool visible = true); |
| 94 | void setLabelsAngle(qreal angle); |
| 95 | qreal labelsAngle() const; |
| 96 | QQmlComponent *labelDelegate() const; |
| 97 | void setLabelDelegate(QQmlComponent *newLabelDelegate); |
| 98 | |
| 99 | //title handling |
| 100 | bool isTitleVisible() const; |
| 101 | void setTitleVisible(bool visible = true); |
| 102 | void setTitleColor(QColor color); |
| 103 | QColor titleColor() const; |
| 104 | void setTitleFont(const QFont &font); |
| 105 | QFont titleFont() const; |
| 106 | void setTitleText(const QString &title); |
| 107 | QString titleText() const; |
| 108 | |
| 109 | Qt::Alignment alignment() const; |
| 110 | void setAlignment(Qt::Alignment alignment); |
| 111 | |
| 112 | Qt::TextElideMode textElideMode() const; |
| 113 | void setTextElideMode(Qt::TextElideMode elideMode); |
| 114 | |
| 115 | //range handling |
| 116 | void setMin(const QVariant &min); |
| 117 | void setMax(const QVariant &max); |
| 118 | void setRange(const QVariant &min, const QVariant &max); |
| 119 | |
| 120 | Q_SIGNALS: |
| 121 | void visibleChanged(bool visible); |
| 122 | void lineVisibleChanged(bool visible); |
| 123 | void labelsVisibleChanged(bool visible); |
| 124 | void labelsAngleChanged(qreal angle); |
| 125 | void labelDelegateChanged(); |
| 126 | void gridVisibleChanged(bool visible); |
| 127 | void subGridVisibleChanged(bool visible); |
| 128 | void titleTextChanged(const QString &title); |
| 129 | void titleColorChanged(QColor color); |
| 130 | void titleVisibleChanged(bool visible); |
| 131 | void titleFontChanged(const QFont &font); |
| 132 | Q_REVISION(6, 9) void alignmentChanged(Qt::Alignment alignment); |
| 133 | Q_REVISION(6, 10) void textElideModeChanged(Qt::TextElideMode elideMode); |
| 134 | void update(); |
| 135 | void rangeChanged(qreal min, qreal max); |
| 136 | |
| 137 | private: |
| 138 | friend class QGraphsView; |
| 139 | Q_DISABLE_COPY(QAbstractAxis) |
| 140 | }; |
| 141 | |
| 142 | QT_END_NAMESPACE |
| 143 | |
| 144 | #endif // QTGRAPHS_QABSTRACTAXIS_H |
| 145 | |