| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 or (at your option) any later version |
| 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
| 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
| 22 | ** included in the packaging of this file. Please review the following |
| 23 | ** information to ensure the GNU General Public License requirements will |
| 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 25 | ** |
| 26 | ** $QT_END_LICENSE$ |
| 27 | ** |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | #ifndef QABSTRACTAXIS_H |
| 31 | #define QABSTRACTAXIS_H |
| 32 | |
| 33 | #include <QtCharts/QChartGlobal> |
| 34 | #include <QtGui/QPen> |
| 35 | #include <QtGui/QFont> |
| 36 | #include <QtCore/QVariant> |
| 37 | |
| 38 | QT_CHARTS_BEGIN_NAMESPACE |
| 39 | |
| 40 | class QAbstractAxisPrivate; |
| 41 | |
| 42 | class Q_CHARTS_EXPORT QAbstractAxis : public QObject |
| 43 | { |
| 44 | Q_OBJECT |
| 45 | //visibility |
| 46 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
| 47 | //arrow |
| 48 | Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged) |
| 49 | Q_PROPERTY(QPen linePen READ linePen WRITE setLinePen NOTIFY linePenChanged) |
| 50 | Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged) |
| 51 | //labels |
| 52 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
| 53 | Q_PROPERTY(QBrush labelsBrush READ labelsBrush WRITE setLabelsBrush NOTIFY labelsBrushChanged) |
| 54 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged) |
| 55 | Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont NOTIFY labelsFontChanged) |
| 56 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) |
| 57 | //grid |
| 58 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) |
| 59 | Q_PROPERTY(QPen gridLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged) |
| 60 | Q_PROPERTY(bool minorGridVisible READ isMinorGridLineVisible WRITE setMinorGridLineVisible NOTIFY minorGridVisibleChanged) |
| 61 | Q_PROPERTY(QPen minorGridLinePen READ minorGridLinePen WRITE setMinorGridLinePen NOTIFY minorGridLinePenChanged) |
| 62 | Q_PROPERTY(QColor gridLineColor READ gridLineColor WRITE setGridLineColor NOTIFY gridLineColorChanged) |
| 63 | Q_PROPERTY(QColor minorGridLineColor READ minorGridLineColor WRITE setMinorGridLineColor NOTIFY minorGridLineColorChanged) |
| 64 | //shades |
| 65 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) |
| 66 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) |
| 67 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) |
| 68 | Q_PROPERTY(QPen shadesPen READ shadesPen WRITE setShadesPen NOTIFY shadesPenChanged) |
| 69 | Q_PROPERTY(QBrush shadesBrush READ shadesBrush WRITE setShadesBrush NOTIFY shadesBrushChanged) |
| 70 | //title |
| 71 | Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged) |
| 72 | Q_PROPERTY(QBrush titleBrush READ titleBrush WRITE setTitleBrush NOTIFY titleBrushChanged) |
| 73 | Q_PROPERTY(bool titleVisible READ isTitleVisible WRITE setTitleVisible NOTIFY titleVisibleChanged) |
| 74 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont NOTIFY titleFontChanged) |
| 75 | //orientation |
| 76 | Q_PROPERTY(Qt::Orientation orientation READ orientation) |
| 77 | //aligment |
| 78 | Q_PROPERTY(Qt::Alignment alignment READ alignment) |
| 79 | Q_PROPERTY(bool reverse READ isReverse WRITE setReverse NOTIFY reverseChanged) |
| 80 | |
| 81 | public: |
| 82 | |
| 83 | enum AxisType { |
| 84 | AxisTypeNoAxis = 0x0, |
| 85 | AxisTypeValue = 0x1, |
| 86 | AxisTypeBarCategory = 0x2, |
| 87 | AxisTypeCategory = 0x4, |
| 88 | AxisTypeDateTime = 0x8, |
| 89 | AxisTypeLogValue = 0x10 |
| 90 | }; |
| 91 | |
| 92 | Q_DECLARE_FLAGS(AxisTypes, AxisType) |
| 93 | |
| 94 | protected: |
| 95 | explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = nullptr); |
| 96 | |
| 97 | public: |
| 98 | ~QAbstractAxis(); |
| 99 | |
| 100 | virtual AxisType type() const = 0; |
| 101 | |
| 102 | //visibility handling |
| 103 | bool isVisible() const; |
| 104 | void setVisible(bool visible = true); |
| 105 | void show(); |
| 106 | void hide(); |
| 107 | |
| 108 | //arrow handling |
| 109 | bool isLineVisible() const; |
| 110 | void setLineVisible(bool visible = true); |
| 111 | void setLinePen(const QPen &pen); |
| 112 | QPen linePen() const; |
| 113 | void setLinePenColor(QColor color); |
| 114 | QColor linePenColor() const; |
| 115 | |
| 116 | //grid handling |
| 117 | bool isGridLineVisible() const; |
| 118 | void setGridLineVisible(bool visible = true); |
| 119 | void setGridLinePen(const QPen &pen); |
| 120 | QPen gridLinePen() const; |
| 121 | bool isMinorGridLineVisible() const; |
| 122 | void setMinorGridLineVisible(bool visible = true); |
| 123 | void setMinorGridLinePen(const QPen &pen); |
| 124 | QPen minorGridLinePen() const; |
| 125 | void setGridLineColor(const QColor &color); |
| 126 | QColor gridLineColor(); |
| 127 | void setMinorGridLineColor(const QColor &color); |
| 128 | QColor minorGridLineColor(); |
| 129 | |
| 130 | //labels handling |
| 131 | bool labelsVisible() const; |
| 132 | void setLabelsVisible(bool visible = true); |
| 133 | void setLabelsBrush(const QBrush &brush); |
| 134 | QBrush labelsBrush() const; |
| 135 | void setLabelsFont(const QFont &font); |
| 136 | QFont labelsFont() const; |
| 137 | void setLabelsAngle(int angle); |
| 138 | int labelsAngle() const; |
| 139 | void setLabelsColor(QColor color); |
| 140 | QColor labelsColor() const; |
| 141 | |
| 142 | //title handling |
| 143 | bool isTitleVisible() const; |
| 144 | void setTitleVisible(bool visible = true); |
| 145 | void setTitleBrush(const QBrush &brush); |
| 146 | QBrush titleBrush() const; |
| 147 | void setTitleFont(const QFont &font); |
| 148 | QFont titleFont() const; |
| 149 | void setTitleText(const QString &title); |
| 150 | QString titleText() const; |
| 151 | |
| 152 | //shades handling |
| 153 | bool shadesVisible() const; |
| 154 | void setShadesVisible(bool visible = true); |
| 155 | void setShadesPen(const QPen &pen); |
| 156 | QPen shadesPen() const; |
| 157 | void setShadesBrush(const QBrush &brush); |
| 158 | QBrush shadesBrush() const; |
| 159 | void setShadesColor(QColor color); |
| 160 | QColor shadesColor() const; |
| 161 | void setShadesBorderColor(QColor color); |
| 162 | QColor shadesBorderColor() const; |
| 163 | |
| 164 | Qt::Orientation orientation() const; |
| 165 | Qt::Alignment alignment() const; |
| 166 | |
| 167 | //range handling |
| 168 | void setMin(const QVariant &min); |
| 169 | void setMax(const QVariant &max); |
| 170 | void setRange(const QVariant &min, const QVariant &max); |
| 171 | |
| 172 | //reverse handling |
| 173 | void setReverse(bool reverse = true); |
| 174 | bool isReverse() const; |
| 175 | |
| 176 | //label editable handling |
| 177 | void setLabelsEditable(bool editable = true); |
| 178 | bool labelsEditable() const; |
| 179 | |
| 180 | Q_SIGNALS: |
| 181 | void visibleChanged(bool visible); |
| 182 | void linePenChanged(const QPen &pen); |
| 183 | void lineVisibleChanged(bool visible); |
| 184 | void labelsVisibleChanged(bool visible); |
| 185 | void labelsBrushChanged(const QBrush &brush); |
| 186 | void labelsFontChanged(const QFont &pen); |
| 187 | void labelsAngleChanged(int angle); |
| 188 | void gridLinePenChanged(const QPen &pen); |
| 189 | void gridVisibleChanged(bool visible); |
| 190 | void minorGridVisibleChanged(bool visible); |
| 191 | void minorGridLinePenChanged(const QPen &pen); |
| 192 | void gridLineColorChanged(const QColor &color); |
| 193 | void minorGridLineColorChanged(const QColor &color); |
| 194 | void colorChanged(QColor color); |
| 195 | void labelsColorChanged(QColor color); |
| 196 | void titleTextChanged(const QString &title); |
| 197 | void titleBrushChanged(const QBrush &brush); |
| 198 | void titleVisibleChanged(bool visible); |
| 199 | void titleFontChanged(const QFont &font); |
| 200 | void shadesVisibleChanged(bool visible); |
| 201 | void shadesColorChanged(QColor color); |
| 202 | void shadesBorderColorChanged(QColor color); |
| 203 | void shadesPenChanged(const QPen &pen); |
| 204 | void shadesBrushChanged(const QBrush &brush); |
| 205 | void reverseChanged(bool reverse); |
| 206 | void labelsEditableChanged(bool editable); |
| 207 | |
| 208 | protected: |
| 209 | QScopedPointer<QAbstractAxisPrivate> d_ptr; |
| 210 | friend class ChartDataSet; |
| 211 | friend class ChartPresenter; |
| 212 | friend class ChartThemeManager; |
| 213 | friend class AbstractDomain; |
| 214 | friend class ChartAxisElement; |
| 215 | friend class XYChart; |
| 216 | |
| 217 | private: |
| 218 | Q_DISABLE_COPY(QAbstractAxis) |
| 219 | }; |
| 220 | |
| 221 | QT_CHARTS_END_NAMESPACE |
| 222 | |
| 223 | #endif // QABSTRACTAXIS_H |
| 224 | |