| 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 | // W A R N I N G |
| 31 | // ------------- |
| 32 | // |
| 33 | // This file is not part of the Qt Chart API. It exists purely as an |
| 34 | // implementation detail. This header file may change from version to |
| 35 | // version without notice, or even be removed. |
| 36 | // |
| 37 | // We mean it. |
| 38 | |
| 39 | #ifndef ABSTRACTDOMAIN_H |
| 40 | #define ABSTRACTDOMAIN_H |
| 41 | #include <QtCharts/QChartGlobal> |
| 42 | #include <QtCharts/private/qchartglobal_p.h> |
| 43 | #include <QtCore/QRectF> |
| 44 | #include <QtCore/QSizeF> |
| 45 | #include <QtCore/QDebug> |
| 46 | |
| 47 | QT_CHARTS_BEGIN_NAMESPACE |
| 48 | |
| 49 | class QAbstractAxis; |
| 50 | |
| 51 | class Q_CHARTS_PRIVATE_EXPORT AbstractDomain: public QObject |
| 52 | { |
| 53 | Q_OBJECT |
| 54 | public: |
| 55 | enum DomainType { UndefinedDomain, |
| 56 | XYDomain, |
| 57 | XLogYDomain, |
| 58 | LogXYDomain, |
| 59 | LogXLogYDomain, |
| 60 | XYPolarDomain, |
| 61 | XLogYPolarDomain, |
| 62 | LogXYPolarDomain, |
| 63 | LogXLogYPolarDomain }; |
| 64 | public: |
| 65 | explicit AbstractDomain(QObject *object = 0); |
| 66 | virtual ~AbstractDomain(); |
| 67 | |
| 68 | virtual void setSize(const QSizeF &size); |
| 69 | QSizeF size() const; |
| 70 | |
| 71 | virtual DomainType type() = 0; |
| 72 | |
| 73 | virtual void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) = 0; |
| 74 | void setRangeX(qreal min, qreal max); |
| 75 | void setRangeY(qreal min, qreal max); |
| 76 | void setMinX(qreal min); |
| 77 | void setMaxX(qreal max); |
| 78 | void setMinY(qreal min); |
| 79 | void setMaxY(qreal max); |
| 80 | |
| 81 | qreal minX() const { return m_minX; } |
| 82 | qreal maxX() const { return m_maxX; } |
| 83 | qreal minY() const { return m_minY; } |
| 84 | qreal maxY() const { return m_maxY; } |
| 85 | |
| 86 | qreal spanX() const; |
| 87 | qreal spanY() const; |
| 88 | bool isEmpty() const; |
| 89 | |
| 90 | void blockRangeSignals(bool block); |
| 91 | bool rangeSignalsBlocked() const { return m_signalsBlocked; } |
| 92 | |
| 93 | void zoomReset(); |
| 94 | void storeZoomReset(); |
| 95 | bool isZoomed() { return m_zoomed; } |
| 96 | |
| 97 | friend bool Q_AUTOTEST_EXPORT operator== (const AbstractDomain &domain1, const AbstractDomain &domain2); |
| 98 | friend bool Q_AUTOTEST_EXPORT operator!= (const AbstractDomain &domain1, const AbstractDomain &domain2); |
| 99 | friend QDebug Q_AUTOTEST_EXPORT operator<<(QDebug dbg, const AbstractDomain &domain); |
| 100 | |
| 101 | virtual void zoomIn(const QRectF &rect) = 0; |
| 102 | virtual void zoomOut(const QRectF &rect) = 0; |
| 103 | virtual void move(qreal dx, qreal dy) = 0; |
| 104 | |
| 105 | virtual QPointF calculateGeometryPoint(const QPointF &point, bool &ok) const = 0; |
| 106 | virtual QPointF calculateDomainPoint(const QPointF &point) const = 0; |
| 107 | virtual QVector<QPointF> calculateGeometryPoints(const QVector<QPointF> &vector) const = 0; |
| 108 | |
| 109 | virtual bool attachAxis(QAbstractAxis *axis); |
| 110 | virtual bool detachAxis(QAbstractAxis *axis); |
| 111 | |
| 112 | static void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount); |
| 113 | static qreal niceNumber(qreal x, bool ceiling); |
| 114 | |
| 115 | void setReverseX(bool reverse) { m_reverseX = reverse; } |
| 116 | void setReverseY(bool reverse) { m_reverseY = reverse; } |
| 117 | |
| 118 | bool isReverseX() const { return m_reverseX; } |
| 119 | bool isReverseY() const { return m_reverseY; } |
| 120 | |
| 121 | Q_SIGNALS: |
| 122 | void updated(); |
| 123 | void rangeHorizontalChanged(qreal min, qreal max); |
| 124 | void rangeVerticalChanged(qreal min, qreal max); |
| 125 | |
| 126 | public Q_SLOTS: |
| 127 | void handleVerticalAxisRangeChanged(qreal min,qreal max); |
| 128 | void handleHorizontalAxisRangeChanged(qreal min,qreal max); |
| 129 | void handleReverseXChanged(bool reverse); |
| 130 | void handleReverseYChanged(bool reverse); |
| 131 | |
| 132 | protected: |
| 133 | void adjustLogDomainRanges(qreal &min, qreal &max); |
| 134 | QRectF fixZoomRect(const QRectF &rect); |
| 135 | |
| 136 | qreal m_minX; |
| 137 | qreal m_maxX; |
| 138 | qreal m_minY; |
| 139 | qreal m_maxY; |
| 140 | QSizeF m_size; |
| 141 | bool m_signalsBlocked; |
| 142 | bool m_zoomed; |
| 143 | qreal m_zoomResetMinX; |
| 144 | qreal m_zoomResetMaxX; |
| 145 | qreal m_zoomResetMinY; |
| 146 | qreal m_zoomResetMaxY; |
| 147 | bool m_reverseX; |
| 148 | bool m_reverseY; |
| 149 | }; |
| 150 | |
| 151 | QT_CHARTS_END_NAMESPACE |
| 152 | |
| 153 | #endif // ABSTRACTDOMAIN_H |
| 154 | |