@@ -33,6 +33,9 | |||
|
33 | 33 | #include "qpieseries.h" |
|
34 | 34 | #include "chartitem_p.h" |
|
35 | 35 | #include "xydomain_p.h" |
|
36 | #include "xlogydomain_p.h" | |
|
37 | #include "logxydomain_p.h" | |
|
38 | #include "logxlogydomain_p.h" | |
|
36 | 39 | |
|
37 | 40 | #ifndef QT_ON_ARM |
|
38 | 41 | #include "qdatetimeaxis.h" |
@@ -52,29 +52,6 QSizeF AbstractDomain::size() const | |||
|
52 | 52 | return m_size; |
|
53 | 53 | } |
|
54 | 54 | |
|
55 | //void AbstractDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) | |
|
56 | //{ | |
|
57 | // bool axisXChanged = false; | |
|
58 | // bool axisYChanged = false; | |
|
59 | ||
|
60 | // if (!qFuzzyIsNull(m_minX - minX) || !qFuzzyIsNull(m_maxX - maxX)) { | |
|
61 | // m_minX = minX; | |
|
62 | // m_maxX = maxX; | |
|
63 | // axisXChanged = true; | |
|
64 | // emit rangeHorizontalChanged(m_minX, m_maxX); | |
|
65 | // } | |
|
66 | ||
|
67 | // if (!qFuzzyIsNull(m_minY - minY) || !qFuzzyIsNull(m_maxY - maxY)) { | |
|
68 | // m_minY = minY; | |
|
69 | // m_maxY = maxY; | |
|
70 | // axisYChanged = true; | |
|
71 | // emit rangeVerticalChanged(m_minY, m_maxY); | |
|
72 | // } | |
|
73 | ||
|
74 | // if (axisXChanged || axisYChanged) | |
|
75 | // emit updated(); | |
|
76 | //} | |
|
77 | ||
|
78 | 55 | void AbstractDomain::setRangeX(qreal min, qreal max) |
|
79 | 56 | { |
|
80 | 57 | setRange(min, max, m_minY, m_maxY); |
@@ -122,89 +99,6 bool AbstractDomain::isEmpty() const | |||
|
122 | 99 | return qFuzzyIsNull(spanX()) || qFuzzyIsNull(spanY()) || m_size.isEmpty() ; |
|
123 | 100 | } |
|
124 | 101 | |
|
125 | void AbstractDomain::zoomIn(const QRectF &rect) | |
|
126 | { | |
|
127 | qreal dx = spanX() / m_size.width(); | |
|
128 | qreal dy = spanY() / m_size.height(); | |
|
129 | ||
|
130 | qreal maxX = m_maxX; | |
|
131 | qreal minX = m_minX; | |
|
132 | qreal minY = m_minY; | |
|
133 | qreal maxY = m_maxY; | |
|
134 | ||
|
135 | maxX = minX + dx * rect.right(); | |
|
136 | minX = minX + dx * rect.left(); | |
|
137 | minY = maxY - dy * rect.bottom(); | |
|
138 | maxY = maxY - dy * rect.top(); | |
|
139 | ||
|
140 | setRange(minX, maxX, minY, maxY); | |
|
141 | } | |
|
142 | ||
|
143 | void AbstractDomain::zoomOut(const QRectF &rect) | |
|
144 | { | |
|
145 | qreal dx = spanX() / rect.width(); | |
|
146 | qreal dy = spanY() / rect.height(); | |
|
147 | ||
|
148 | qreal maxX = m_maxX; | |
|
149 | qreal minX = m_minX; | |
|
150 | qreal minY = m_minY; | |
|
151 | qreal maxY = m_maxY; | |
|
152 | ||
|
153 | minX = maxX - dx * rect.right(); | |
|
154 | maxX = minX + dx * m_size.width(); | |
|
155 | maxY = minY + dy * rect.bottom(); | |
|
156 | minY = maxY - dy * m_size.height(); | |
|
157 | ||
|
158 | setRange(minX, maxX, minY, maxY); | |
|
159 | } | |
|
160 | ||
|
161 | void AbstractDomain::move(qreal dx, qreal dy) | |
|
162 | { | |
|
163 | qreal x = spanX() / m_size.width(); | |
|
164 | qreal y = spanY() / m_size.height(); | |
|
165 | ||
|
166 | qreal maxX = m_maxX; | |
|
167 | qreal minX = m_minX; | |
|
168 | qreal minY = m_minY; | |
|
169 | qreal maxY = m_maxY; | |
|
170 | ||
|
171 | if (dx != 0) { | |
|
172 | minX = minX + x * dx; | |
|
173 | maxX = maxX + x * dx; | |
|
174 | } | |
|
175 | if (dy != 0) { | |
|
176 | minY = minY + y * dy; | |
|
177 | maxY = maxY + y * dy; | |
|
178 | } | |
|
179 | setRange(minX, maxX, minY, maxY); | |
|
180 | } | |
|
181 | ||
|
182 | //QPointF AbstractDomain::calculateGeometryPoint(const QPointF &point) const | |
|
183 | //{ | |
|
184 | // const qreal deltaX = m_size.width() / (m_maxX - m_minX); | |
|
185 | // const qreal deltaY = m_size.height() / (m_maxY - m_minY); | |
|
186 | // qreal x = (point.x() - m_minX) * deltaX; | |
|
187 | // qreal y = (point.y() - m_minY) * -deltaY + m_size.height(); | |
|
188 | // return QPointF(x, y); | |
|
189 | //} | |
|
190 | ||
|
191 | //QVector<QPointF> AbstractDomain::calculateGeometryPoints(const QList<QPointF>& vector) const | |
|
192 | //{ | |
|
193 | // const qreal deltaX = m_size.width() / (m_maxX - m_minX); | |
|
194 | // const qreal deltaY = m_size.height() / (m_maxY - m_minY); | |
|
195 | ||
|
196 | // QVector<QPointF> result; | |
|
197 | // result.resize(vector.count()); | |
|
198 | ||
|
199 | // for (int i = 0; i < vector.count(); ++i) { | |
|
200 | // qreal x = (vector[i].x() - m_minX) * deltaX; | |
|
201 | // qreal y = (vector[i].y() - m_minY) * -deltaY + m_size.height(); | |
|
202 | // result[i].setX(x); | |
|
203 | // result[i].setY(y); | |
|
204 | // } | |
|
205 | // return result; | |
|
206 | //} | |
|
207 | ||
|
208 | 102 | QPointF AbstractDomain::calculateDomainPoint(const QPointF &point) const |
|
209 | 103 | { |
|
210 | 104 | const qreal deltaX = m_size.width() / (m_maxX - m_minX); |
@@ -72,9 +72,9 public: | |||
|
72 | 72 | friend bool QTCOMMERCIALCHART_AUTOTEST_EXPORT operator!= (const AbstractDomain &domain1, const AbstractDomain &domain2); |
|
73 | 73 | friend QDebug QTCOMMERCIALCHART_AUTOTEST_EXPORT operator<<(QDebug dbg, const AbstractDomain &domain); |
|
74 | 74 | |
|
75 | void zoomIn(const QRectF &rect); | |
|
76 | void zoomOut(const QRectF &rect); | |
|
77 | void move(qreal dx, qreal dy); | |
|
75 | virtual void zoomIn(const QRectF &rect) = 0; | |
|
76 | virtual void zoomOut(const QRectF &rect) = 0; | |
|
77 | virtual void move(qreal dx, qreal dy) = 0; | |
|
78 | 78 | |
|
79 | 79 | virtual QPointF calculateGeometryPoint(const QPointF &point) const = 0; |
|
80 | 80 | virtual QPointF calculateDomainPoint(const QPointF &point) const = 0; |
@@ -68,58 +68,46 void LogXLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) | |||
|
68 | 68 | |
|
69 | 69 | void LogXLogYDomain::zoomIn(const QRectF &rect) |
|
70 | 70 | { |
|
71 | qreal dx = spanX() / m_size.width(); | |
|
72 | qreal dy = spanY() / m_size.height(); | |
|
71 | qreal newLogMinX = rect.left() * (m_logMaxX - m_logMinX) / m_size.width() + m_logMinX; | |
|
72 | qreal newLogMaxX = rect.right() * (m_logMaxX - m_logMinX) / m_size.width() + m_logMinX; | |
|
73 | qreal minX = qPow(m_logBaseX, newLogMinX); | |
|
74 | qreal maxX = qPow(m_logBaseX, newLogMaxX); | |
|
73 | 75 | |
|
74 | qreal maxX = m_maxX; | |
|
75 | qreal minX = m_minX; | |
|
76 |
qreal minY = |
|
|
77 |
qreal maxY = |
|
|
78 | ||
|
79 | maxX = minX + dx * rect.right(); | |
|
80 | minX = minX + dx * rect.left(); | |
|
81 | minY = maxY - dy * rect.bottom(); | |
|
82 | maxY = maxY - dy * rect.top(); | |
|
76 | qreal newLogMinY = m_logMaxY - rect.bottom() * (m_logMaxY - m_logMinY) / m_size.height(); | |
|
77 | qreal newLogMaxY = m_logMaxY - rect.top() * (m_logMaxY - m_logMinY) / m_size.height(); | |
|
78 | qreal minY = qPow(m_logBaseY, newLogMinY); | |
|
79 | qreal maxY = qPow(m_logBaseY, newLogMaxY); | |
|
83 | 80 | |
|
84 | 81 | setRange(minX, maxX, minY, maxY); |
|
85 | 82 | } |
|
86 | 83 | |
|
87 | 84 | void LogXLogYDomain::zoomOut(const QRectF &rect) |
|
88 | 85 | { |
|
89 |
qreal |
|
|
90 | qreal dy = spanY() / rect.height(); | |
|
91 | ||
|
92 | qreal maxX = m_maxX; | |
|
93 | qreal minX = m_minX; | |
|
94 | qreal minY = m_minY; | |
|
95 | qreal maxY = m_maxY; | |
|
96 | ||
|
97 | minX = maxX - dx * rect.right(); | |
|
98 | maxX = minX + dx * m_size.width(); | |
|
99 | maxY = minY + dy * rect.bottom(); | |
|
100 | minY = maxY - dy * m_size.height(); | |
|
86 | qreal ratioX = m_size.width()/rect.width(); | |
|
87 | qreal newLogMinX = m_logMinX - (m_logMaxX - m_logMinX) / ratioX; | |
|
88 | qreal newLogMaxX = m_logMaxX + (m_logMaxX - m_logMinX) / ratioX; | |
|
89 | qreal minX = qPow(m_logBaseX, newLogMinX); | |
|
90 | qreal maxX = qPow(m_logBaseX, newLogMaxX); | |
|
91 | ||
|
92 | qreal ratioY = m_size.height()/rect.height(); | |
|
93 | qreal newLogMinY = m_logMaxY - (m_logMaxY - m_logMinY) / ratioY; | |
|
94 | qreal newLogMaxY = m_logMaxY + (m_logMaxY - m_logMinY) / ratioY; | |
|
95 | qreal minY = qPow(m_logBaseY, newLogMinY); | |
|
96 | qreal maxY = qPow(m_logBaseY, newLogMaxY); | |
|
101 | 97 | |
|
102 | 98 | setRange(minX, maxX, minY, maxY); |
|
103 | 99 | } |
|
104 | 100 | |
|
105 | 101 | void LogXLogYDomain::move(qreal dx, qreal dy) |
|
106 | 102 | { |
|
107 |
qreal |
|
|
108 | qreal y = spanY() / m_size.height(); | |
|
103 | qreal stepX = dx * qAbs(m_logMaxX - m_logMinX) / m_size.width(); | |
|
104 | qreal minX = qPow(m_logBaseX, m_logMinX + stepX); | |
|
105 | qreal maxX = qPow(m_logBaseX, m_logMaxX + stepX); | |
|
109 | 106 | |
|
110 | qreal maxX = m_maxX; | |
|
111 | qreal minX = m_minX; | |
|
112 | qreal minY = m_minY; | |
|
113 | qreal maxY = m_maxY; | |
|
107 | qreal stepY = dy * qAbs(m_logMaxY - m_logMinY) / m_size.height(); | |
|
108 | qreal minY = qPow(m_logBaseY, m_logMinY + stepY); | |
|
109 | qreal maxY = qPow(m_logBaseY, m_logMaxY + stepY); | |
|
114 | 110 | |
|
115 | if (dx != 0) { | |
|
116 | minX = minX + x * dx; | |
|
117 | maxX = maxX + x * dx; | |
|
118 | } | |
|
119 | if (dy != 0) { | |
|
120 | minY = minY + y * dy; | |
|
121 | maxY = maxY + y * dy; | |
|
122 | } | |
|
123 | 111 | setRange(minX, maxX, minY, maxY); |
|
124 | 112 | } |
|
125 | 113 |
@@ -64,16 +64,15 void LogXYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) | |||
|
64 | 64 | |
|
65 | 65 | void LogXYDomain::zoomIn(const QRectF &rect) |
|
66 | 66 | { |
|
67 | qreal dx = spanX() / m_size.width(); | |
|
68 | qreal dy = spanY() / m_size.height(); | |
|
67 | qreal newLogMinX = rect.left() * (m_logMaxX - m_logMinX) / m_size.width() + m_logMinX; | |
|
68 | qreal newLogMaxX = rect.right() * (m_logMaxX - m_logMinX) / m_size.width() + m_logMinX; | |
|
69 | qreal minX = qPow(m_logBaseX, newLogMinX); | |
|
70 | qreal maxX = qPow(m_logBaseX, newLogMaxX); | |
|
69 | 71 | |
|
70 | qreal maxX = m_maxX; | |
|
71 | qreal minX = m_minX; | |
|
72 | qreal dy = spanY() / m_size.height(); | |
|
72 | 73 | qreal minY = m_minY; |
|
73 | 74 | qreal maxY = m_maxY; |
|
74 | 75 | |
|
75 | maxX = minX + dx * rect.right(); | |
|
76 | minX = minX + dx * rect.left(); | |
|
77 | 76 | minY = maxY - dy * rect.bottom(); |
|
78 | 77 | maxY = maxY - dy * rect.top(); |
|
79 | 78 | |
@@ -82,16 +81,16 void LogXYDomain::zoomIn(const QRectF &rect) | |||
|
82 | 81 | |
|
83 | 82 | void LogXYDomain::zoomOut(const QRectF &rect) |
|
84 | 83 | { |
|
85 |
qreal |
|
|
86 | qreal dy = spanY() / rect.height(); | |
|
84 | qreal ratioX = m_size.width()/rect.width(); | |
|
85 | qreal newLogMinX = m_logMinX - (m_logMaxX - m_logMinX) / ratioX; | |
|
86 | qreal newLogMaxX = m_logMaxX + (m_logMaxX - m_logMinX) / ratioX; | |
|
87 | qreal minX = qPow(m_logBaseX, newLogMinX); | |
|
88 | qreal maxX = qPow(m_logBaseX, newLogMaxX); | |
|
87 | 89 | |
|
88 | qreal maxX = m_maxX; | |
|
89 | qreal minX = m_minX; | |
|
90 | qreal dy = spanY() / rect.height(); | |
|
90 | 91 | qreal minY = m_minY; |
|
91 | 92 | qreal maxY = m_maxY; |
|
92 | 93 | |
|
93 | minX = maxX - dx * rect.right(); | |
|
94 | maxX = minX + dx * m_size.width(); | |
|
95 | 94 | maxY = minY + dy * rect.bottom(); |
|
96 | 95 | minY = maxY - dy * m_size.height(); |
|
97 | 96 | |
@@ -100,18 +99,14 void LogXYDomain::zoomOut(const QRectF &rect) | |||
|
100 | 99 | |
|
101 | 100 | void LogXYDomain::move(qreal dx, qreal dy) |
|
102 | 101 | { |
|
103 |
qreal |
|
|
104 | qreal y = spanY() / m_size.height(); | |
|
102 | qreal stepX = dx * qAbs(m_logMaxX - m_logMinX) / m_size.width(); | |
|
103 | qreal minX = qPow(m_logBaseX, m_logMinX + stepX); | |
|
104 | qreal maxX = qPow(m_logBaseX, m_logMaxX + stepX); | |
|
105 | 105 | |
|
106 | qreal maxX = m_maxX; | |
|
107 | qreal minX = m_minX; | |
|
106 | qreal y = spanY() / m_size.height(); | |
|
108 | 107 | qreal minY = m_minY; |
|
109 | 108 | qreal maxY = m_maxY; |
|
110 | 109 | |
|
111 | if (dx != 0) { | |
|
112 | minX = minX + x * dx; | |
|
113 | maxX = maxX + x * dx; | |
|
114 | } | |
|
115 | 110 | if (dy != 0) { |
|
116 | 111 | minY = minY + y * dy; |
|
117 | 112 | maxY = maxY + y * dy; |
@@ -64,17 +64,16 void XLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) | |||
|
64 | 64 | void XLogYDomain::zoomIn(const QRectF &rect) |
|
65 | 65 | { |
|
66 | 66 | qreal dx = spanX() / m_size.width(); |
|
67 | qreal dy = spanY() / m_size.height(); | |
|
68 | ||
|
69 | 67 | qreal maxX = m_maxX; |
|
70 | 68 | qreal minX = m_minX; |
|
71 | qreal minY = m_minY; | |
|
72 | qreal maxY = m_maxY; | |
|
73 | 69 | |
|
74 | 70 | maxX = minX + dx * rect.right(); |
|
75 | 71 | minX = minX + dx * rect.left(); |
|
76 | minY = maxY - dy * rect.bottom(); | |
|
77 | maxY = maxY - dy * rect.top(); | |
|
72 | ||
|
73 | qreal newLogMinY = m_logMaxY - rect.bottom() * (m_logMaxY - m_logMinY) / m_size.height(); | |
|
74 | qreal newLogMaxY = m_logMaxY - rect.top() * (m_logMaxY - m_logMinY) / m_size.height(); | |
|
75 | qreal minY = qPow(m_logBaseY, newLogMinY); | |
|
76 | qreal maxY = qPow(m_logBaseY, newLogMaxY); | |
|
78 | 77 | |
|
79 | 78 | setRange(minX, maxX, minY, maxY); |
|
80 | 79 | } |
@@ -82,17 +81,17 void XLogYDomain::zoomIn(const QRectF &rect) | |||
|
82 | 81 | void XLogYDomain::zoomOut(const QRectF &rect) |
|
83 | 82 | { |
|
84 | 83 | qreal dx = spanX() / rect.width(); |
|
85 | qreal dy = spanY() / rect.height(); | |
|
86 | ||
|
87 | 84 | qreal maxX = m_maxX; |
|
88 | 85 | qreal minX = m_minX; |
|
89 | qreal minY = m_minY; | |
|
90 | qreal maxY = m_maxY; | |
|
91 | 86 | |
|
92 | 87 | minX = maxX - dx * rect.right(); |
|
93 | 88 | maxX = minX + dx * m_size.width(); |
|
94 | maxY = minY + dy * rect.bottom(); | |
|
95 | minY = maxY - dy * m_size.height(); | |
|
89 | ||
|
90 | qreal ratioY = m_size.height()/rect.height(); | |
|
91 | qreal newLogMinY = m_logMaxY - (m_logMaxY - m_logMinY) / ratioY; | |
|
92 | qreal newLogMaxY = m_logMaxY + (m_logMaxY - m_logMinY) / ratioY; | |
|
93 | qreal minY = qPow(m_logBaseY, newLogMinY); | |
|
94 | qreal maxY = qPow(m_logBaseY, newLogMaxY); | |
|
96 | 95 | |
|
97 | 96 | setRange(minX, maxX, minY, maxY); |
|
98 | 97 | } |
@@ -100,21 +99,18 void XLogYDomain::zoomOut(const QRectF &rect) | |||
|
100 | 99 | void XLogYDomain::move(qreal dx, qreal dy) |
|
101 | 100 | { |
|
102 | 101 | qreal x = spanX() / m_size.width(); |
|
103 | qreal y = spanY() / m_size.height(); | |
|
104 | ||
|
105 | 102 | qreal maxX = m_maxX; |
|
106 | 103 | qreal minX = m_minX; |
|
107 | qreal minY = m_minY; | |
|
108 | qreal maxY = m_maxY; | |
|
109 | 104 | |
|
110 | 105 | if (dx != 0) { |
|
111 | 106 | minX = minX + x * dx; |
|
112 | 107 | maxX = maxX + x * dx; |
|
113 | 108 | } |
|
114 | if (dy != 0) { | |
|
115 | minY = minY + y * dy; | |
|
116 | maxY = maxY + y * dy; | |
|
117 | } | |
|
109 | ||
|
110 | qreal stepY = dy * qAbs(m_logMaxY - m_logMinY) / m_size.height(); | |
|
111 | qreal minY = qPow(m_logBaseY, m_logMinY + stepY); | |
|
112 | qreal maxY = qPow(m_logBaseY, m_logMaxY + stepY); | |
|
113 | ||
|
118 | 114 | setRange(minX, maxX, minY, maxY); |
|
119 | 115 | } |
|
120 | 116 |
General Comments 0
You need to be logged in to leave comments.
Login now