1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4// W A R N I N G
5// -------------
6//
7// This file is not part of the Qt Chart API. It exists purely as an
8// implementation detail. This header file may change from version to
9// version without notice, or even be removed.
10//
11// We mean it.
12
13#ifndef ABSTRACTDOMAIN_H
14#define ABSTRACTDOMAIN_H
15#include <QtCharts/QChartGlobal>
16#include <QtCharts/private/qchartglobal_p.h>
17#include <QtCore/QRectF>
18#include <QtCore/QSizeF>
19#include <QtCore/QDebug>
20#include <QtCore/QObject>
21
22QT_BEGIN_NAMESPACE
23
24class QAbstractAxis;
25
26class Q_CHARTS_PRIVATE_EXPORT AbstractDomain: public QObject
27{
28 Q_OBJECT
29public:
30 enum DomainType { UndefinedDomain,
31 XYDomain,
32 XLogYDomain,
33 LogXYDomain,
34 LogXLogYDomain,
35 XYPolarDomain,
36 XLogYPolarDomain,
37 LogXYPolarDomain,
38 LogXLogYPolarDomain };
39public:
40 explicit AbstractDomain(QObject *object = 0);
41 virtual ~AbstractDomain();
42
43 virtual void setSize(const QSizeF &size);
44 QSizeF size() const;
45
46 virtual DomainType type() = 0;
47
48 virtual void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) = 0;
49 void setRangeX(qreal min, qreal max);
50 void setRangeY(qreal min, qreal max);
51 void setMinX(qreal min);
52 void setMaxX(qreal max);
53 void setMinY(qreal min);
54 void setMaxY(qreal max);
55
56 qreal minX() const { return m_minX; }
57 qreal maxX() const { return m_maxX; }
58 qreal minY() const { return m_minY; }
59 qreal maxY() const { return m_maxY; }
60
61 qreal spanX() const;
62 qreal spanY() const;
63 bool isEmpty() const;
64
65 void blockRangeSignals(bool block);
66 bool rangeSignalsBlocked() const { return m_signalsBlocked; }
67
68 void zoomReset();
69 void storeZoomReset();
70 bool isZoomed() { return m_zoomed; }
71
72 friend bool Q_AUTOTEST_EXPORT operator== (const AbstractDomain &domain1, const AbstractDomain &domain2);
73 friend bool Q_AUTOTEST_EXPORT operator!= (const AbstractDomain &domain1, const AbstractDomain &domain2);
74 friend QDebug Q_AUTOTEST_EXPORT operator<<(QDebug dbg, const AbstractDomain &domain);
75
76 virtual void zoomIn(const QRectF &rect) = 0;
77 virtual void zoomOut(const QRectF &rect) = 0;
78 virtual void move(qreal dx, qreal dy) = 0;
79
80 virtual QPointF calculateGeometryPoint(const QPointF &point, bool &ok) const = 0;
81 virtual QPointF calculateDomainPoint(const QPointF &point) const = 0;
82 virtual QList<QPointF> calculateGeometryPoints(const QList<QPointF> &list) const = 0;
83
84 virtual bool attachAxis(QAbstractAxis *axis);
85 virtual bool detachAxis(QAbstractAxis *axis);
86
87 static void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount);
88 static qreal niceNumber(qreal x, bool ceiling);
89
90 void setReverseX(bool reverse) { m_reverseX = reverse; }
91 void setReverseY(bool reverse) { m_reverseY = reverse; }
92
93 bool isReverseX() const { return m_reverseX; }
94 bool isReverseY() const { return m_reverseY; }
95
96Q_SIGNALS:
97 void updated();
98 void rangeHorizontalChanged(qreal min, qreal max);
99 void rangeVerticalChanged(qreal min, qreal max);
100
101public Q_SLOTS:
102 void handleVerticalAxisRangeChanged(qreal min,qreal max);
103 void handleHorizontalAxisRangeChanged(qreal min,qreal max);
104 void handleReverseXChanged(bool reverse);
105 void handleReverseYChanged(bool reverse);
106
107protected:
108 void adjustLogDomainRanges(qreal &min, qreal &max);
109 QRectF fixZoomRect(const QRectF &rect);
110
111 qreal m_minX;
112 qreal m_maxX;
113 qreal m_minY;
114 qreal m_maxY;
115 QSizeF m_size;
116 bool m_signalsBlocked;
117 bool m_zoomed;
118 qreal m_zoomResetMinX;
119 qreal m_zoomResetMaxX;
120 qreal m_zoomResetMinY;
121 qreal m_zoomResetMaxY;
122 bool m_reverseX;
123 bool m_reverseY;
124};
125
126QT_END_NAMESPACE
127
128#endif // ABSTRACTDOMAIN_H
129

source code of qtcharts/src/charts/domain/abstractdomain_p.h