@@ -1,212 +1,212 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "splineanimation_p.h" |
|
22 | 22 | #include "splinechartitem_p.h" |
|
23 | 23 | #include <QDebug> |
|
24 | 24 | |
|
25 | 25 | Q_DECLARE_METATYPE(QVector<QPointF>) |
|
26 | 26 | Q_DECLARE_METATYPE(SplineVector) |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | SplineAnimation::SplineAnimation(SplineChartItem* item):XYAnimation(item), |
|
31 | 31 | m_item(item), |
|
32 | 32 | m_valid(false) |
|
33 | 33 | { |
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | SplineAnimation::~SplineAnimation() |
|
37 | 37 | { |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | void SplineAnimation::setup(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints, QVector<QPointF> &oldControlPoints, QVector<QPointF> &newControlPoints, int index) |
|
41 | 41 | { |
|
42 | if(newPoints.count() * 2 - 2 != newControlPoints.count() || newControlPoints.count() < 2){ | |
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
42 | if (newPoints.count() * 2 - 2 != newControlPoints.count() || newControlPoints.count() < 2) { | |
|
43 | m_valid=false; | |
|
44 | m_dirty=false; | |
|
45 | m_item->setGeometryPoints(newPoints); | |
|
46 | m_item->setControlGeometryPoints(newControlPoints); | |
|
47 | m_item->setDirty(false); | |
|
48 | m_item->updateGeometry(); | |
|
49 | return; | |
|
50 | 50 | } |
|
51 | 51 | |
|
52 | 52 | m_type = NewAnimation; |
|
53 | 53 | |
|
54 | 54 | if (state() != QAbstractAnimation::Stopped) { |
|
55 | 55 | stop(); |
|
56 | 56 | m_dirty=false; |
|
57 | 57 | } |
|
58 | 58 | |
|
59 | 59 | if(!m_dirty) { |
|
60 | 60 | m_dirty = true; |
|
61 | 61 | m_oldSpline.first = oldPoints; |
|
62 | 62 | m_oldSpline.second = oldControlPoints; |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | m_newSpline.first=newPoints; |
|
66 | 66 | m_newSpline.second=newControlPoints; |
|
67 | 67 | |
|
68 | 68 | |
|
69 | 69 | int x = m_oldSpline.first.count(); |
|
70 | 70 | int y = m_newSpline.first.count(); |
|
71 | 71 | |
|
72 | 72 | if(x - y == 1 && index >= 0 && y>0) { |
|
73 | 73 | //remove point |
|
74 | 74 | if(index>0){ |
|
75 | 75 | m_newSpline.first.insert(index, newPoints[index-1]); |
|
76 | 76 | m_newSpline.second.insert((index -1) * 2, newPoints[index-1] ); |
|
77 | 77 | m_newSpline.second.insert((index -1) * 2 + 1, newPoints[index-1]); |
|
78 | 78 | }else{ |
|
79 | 79 | m_newSpline.first.insert(index, newPoints[index]); |
|
80 | 80 | m_newSpline.second.insert(index * 2, newPoints[index] ); |
|
81 | 81 | m_newSpline.second.insert(index * 2 + 1, newPoints[index]); |
|
82 | 82 | } |
|
83 | 83 | m_index=index; |
|
84 | 84 | m_type = RemovePointAnimation; |
|
85 | 85 | } |
|
86 | 86 | |
|
87 | 87 | if(x - y == -1 && index >= 0) { |
|
88 | 88 | //add point |
|
89 | 89 | if(index>0){ |
|
90 | 90 | m_oldSpline.first.insert(index, newPoints[index-1]); |
|
91 | 91 | m_oldSpline.second.insert((index - 1) * 2, newPoints[index-1]); |
|
92 | 92 | m_oldSpline.second.insert((index - 1) * 2 + 1, newPoints[index-1]); |
|
93 | 93 | }else{ |
|
94 | 94 | m_oldSpline.first.insert(index, newPoints[index]); |
|
95 | 95 | m_oldSpline.second.insert((index - 1) * 2, newPoints[index]); |
|
96 | 96 | m_oldSpline.second.insert((index - 1) * 2 + 1, newPoints[index]); |
|
97 | 97 | } |
|
98 | 98 | m_index=index; |
|
99 | 99 | m_type = AddPointAnimation; |
|
100 | 100 | } |
|
101 | 101 | |
|
102 | 102 | x = m_oldSpline.first.count(); |
|
103 | 103 | y = m_newSpline.first.count(); |
|
104 | 104 | |
|
105 | 105 | if(x != y) |
|
106 | 106 | { |
|
107 | 107 | m_type = NewAnimation; |
|
108 | 108 | } |
|
109 | 109 | else if(m_type == NewAnimation) |
|
110 | 110 | { |
|
111 | 111 | m_type = ReplacePointAnimation; |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | |
|
115 | 115 | setKeyValueAt(0.0, qVariantFromValue(m_oldSpline)); |
|
116 | 116 | setKeyValueAt(1.0, qVariantFromValue(m_newSpline)); |
|
117 | 117 | |
|
118 | 118 | m_valid=true; |
|
119 | 119 | |
|
120 | 120 | } |
|
121 | 121 | |
|
122 | 122 | QVariant SplineAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress ) const |
|
123 | 123 | { |
|
124 | 124 | |
|
125 | 125 | SplineVector startPair = qVariantValue< SplineVector >(start); |
|
126 | 126 | SplineVector endPair = qVariantValue< SplineVector >(end); |
|
127 | 127 | SplineVector result; |
|
128 | 128 | |
|
129 | 129 | switch (animationType()) { |
|
130 | 130 | |
|
131 | 131 | case RemovePointAnimation: |
|
132 | 132 | case AddPointAnimation: |
|
133 | 133 | case ReplacePointAnimation: |
|
134 | 134 | { |
|
135 | 135 | if (startPair.first.count() != endPair.first.count()) |
|
136 | 136 | break; |
|
137 | 137 | Q_ASSERT(startPair.first.count() * 2 - 2 == startPair.second.count()); |
|
138 | 138 | Q_ASSERT(endPair.first.count() * 2 - 2 == endPair.second.count()); |
|
139 | 139 | for(int i = 0; i < endPair.first.count(); i++) { |
|
140 | 140 | qreal x = startPair.first[i].x() + ((endPair.first[i].x() - startPair.first[i].x()) * progress); |
|
141 | 141 | qreal y = startPair.first[i].y() + ((endPair.first[i].y() - startPair.first[i].y()) * progress); |
|
142 | 142 | result.first << QPointF(x,y); |
|
143 | 143 | if (i + 1 >= endPair.first.count()) |
|
144 | 144 | continue; |
|
145 | 145 | x = startPair.second[i * 2].x() + ((endPair.second[i * 2].x() - startPair.second[i * 2].x()) * progress); |
|
146 | 146 | y = startPair.second[i * 2].y() + ((endPair.second[i * 2].y() - startPair.second[i * 2].y()) * progress); |
|
147 | 147 | result.second << QPointF(x,y); |
|
148 | 148 | x = startPair.second[i * 2 + 1].x() + ((endPair.second[i * 2 + 1].x() - startPair.second[i * 2 + 1].x()) * progress); |
|
149 | 149 | y = startPair.second[i * 2 + 1].y() + ((endPair.second[i * 2 + 1].y() - startPair.second[i * 2 + 1].y()) * progress); |
|
150 | 150 | result.second << QPointF(x,y); |
|
151 | 151 | } |
|
152 | 152 | |
|
153 | 153 | } |
|
154 | 154 | break; |
|
155 | 155 | case NewAnimation: { |
|
156 | 156 | Q_ASSERT(endPair.first.count() * 2 - 2 == endPair.second.count()); |
|
157 | 157 | int count = endPair.first.count()* qBound(qreal(0), progress, qreal(1)); |
|
158 | 158 | for(int i = 0; i < count; i++) { |
|
159 | 159 | result.first << endPair.first[i]; |
|
160 | 160 | if(i + 1 == count) |
|
161 | 161 | break; |
|
162 | 162 | result.second << endPair.second[2 * i]; |
|
163 | 163 | result.second << endPair.second[2 * i + 1]; |
|
164 | 164 | } |
|
165 | 165 | } |
|
166 | 166 | break; |
|
167 | 167 | default: |
|
168 | 168 | qWarning() << "Unknown type of animation"; |
|
169 | 169 | break; |
|
170 | 170 | } |
|
171 | 171 | |
|
172 | 172 | return qVariantFromValue(result); |
|
173 | 173 | } |
|
174 | 174 | |
|
175 | 175 | void SplineAnimation::updateCurrentValue (const QVariant &value ) |
|
176 | 176 | { |
|
177 | 177 | if (state() != QAbstractAnimation::Stopped && m_valid) { //workaround |
|
178 | 178 | QPair<QVector<QPointF >, QVector<QPointF > > pair = qVariantValue< QPair< QVector<QPointF>, QVector<QPointF> > >(value); |
|
179 | 179 | m_item->setGeometryPoints(pair.first); |
|
180 | 180 | m_item->setControlGeometryPoints(pair.second); |
|
181 | 181 | m_item->updateGeometry(); |
|
182 | 182 | m_item->setDirty(true); |
|
183 | 183 | m_dirty = false; |
|
184 | 184 | } |
|
185 | 185 | } |
|
186 | 186 | |
|
187 | 187 | void SplineAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) |
|
188 | 188 | { |
|
189 | 189 | XYAnimation::updateState(newState, oldState); |
|
190 | 190 | |
|
191 | 191 | if(oldState == QAbstractAnimation::Running && newState == QAbstractAnimation::Stopped) |
|
192 | 192 | { |
|
193 | 193 | if(m_item->isDirty() && m_type==RemovePointAnimation) { |
|
194 | 194 | if(!m_newSpline.first.isEmpty()) { |
|
195 | 195 | m_newSpline.first.remove(m_index); |
|
196 | 196 | m_newSpline.second.remove((m_index-1) * 2); |
|
197 | 197 | m_newSpline.second.remove((m_index-1) * 2); |
|
198 | 198 | } |
|
199 | 199 | m_item->setGeometryPoints(m_newSpline.first); |
|
200 | 200 | m_item->setControlGeometryPoints(m_newSpline.second); |
|
201 | 201 | } |
|
202 | 202 | } |
|
203 | 203 | |
|
204 | 204 | if(oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) |
|
205 | 205 | { |
|
206 | 206 | if(!m_valid) { |
|
207 | 207 | stop(); |
|
208 | 208 | } |
|
209 | 209 | } |
|
210 | 210 | } |
|
211 | 211 | |
|
212 | 212 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,235 +1,233 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qsplineseries.h" |
|
22 | 22 | #include "qsplineseries_p.h" |
|
23 | 23 | #include "splinechartitem_p.h" |
|
24 | 24 | #include "chartdataset_p.h" |
|
25 | 25 | #include "charttheme_p.h" |
|
26 | 26 | #include "splineanimation_p.h" |
|
27 | 27 | |
|
28 | 28 | /*! |
|
29 | 29 | \class QSplineSeries |
|
30 | 30 | \brief Series type used to store data needed to draw a spline. |
|
31 | 31 | |
|
32 | 32 | QSplineSeries stores the data points along with the segment control points needed by QPainterPath to draw spline |
|
33 | 33 | Control points are automatically calculated when data changes. The algorithm computes the points so that the normal spline can be drawn. |
|
34 | 34 | |
|
35 | 35 | \image examples_splinechart.png |
|
36 | 36 | |
|
37 | 37 | Creating basic spline chart is simple: |
|
38 | 38 | \code |
|
39 | 39 | QSplineSeries* series = new QSplineSeries(); |
|
40 | 40 | series->append(0, 6); |
|
41 | 41 | series->append(2, 4); |
|
42 | 42 | ... |
|
43 | 43 | chart->addSeries(series); |
|
44 | 44 | \endcode |
|
45 | 45 | */ |
|
46 | 46 | |
|
47 | 47 | /*! |
|
48 | 48 | \qmlclass SplineSeries QSplineSeries |
|
49 | 49 | \inherits XYSeries |
|
50 | 50 | |
|
51 | 51 | The following QML shows how to create a simple spline chart: |
|
52 | 52 | \snippet ../demos/qmlchart/qml/qmlchart/View3.qml 1 |
|
53 | 53 | \beginfloatleft |
|
54 | 54 | \image demos_qmlchart3.png |
|
55 | 55 | \endfloat |
|
56 | 56 | \clearfloat |
|
57 | 57 | */ |
|
58 | 58 | |
|
59 | 59 | /*! |
|
60 | 60 | \fn QSeriesType QSplineSeries::type() const |
|
61 | 61 | Returns the type of the series |
|
62 | 62 | */ |
|
63 | 63 | |
|
64 | 64 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
65 | 65 | |
|
66 | 66 | /*! |
|
67 | 67 | Constructs empty series object which is a child of \a parent. |
|
68 | 68 | When series object is added to QChartView or QChart instance then the ownerships is transferred. |
|
69 | 69 | */ |
|
70 | 70 | |
|
71 | 71 | QSplineSeries::QSplineSeries(QObject *parent) : |
|
72 | 72 | QLineSeries(*new QSplineSeriesPrivate(this),parent) |
|
73 | 73 | { |
|
74 | 74 | Q_D(QSplineSeries); |
|
75 | 75 | QObject::connect(this,SIGNAL(pointAdded(int)), d, SLOT(updateControlPoints())); |
|
76 | 76 | QObject::connect(this,SIGNAL(pointRemoved(int)), d, SLOT(updateControlPoints())); |
|
77 | 77 | QObject::connect(this,SIGNAL(pointReplaced(int)), d, SLOT(updateControlPoints())); |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | /*! |
|
81 | 81 | Destroys the object. |
|
82 | 82 | */ |
|
83 | 83 | QSplineSeries::~QSplineSeries() |
|
84 | 84 | { |
|
85 | 85 | Q_D(QSplineSeries); |
|
86 | 86 | if(d->m_dataset){ |
|
87 | 87 | d->m_dataset->removeSeries(this); |
|
88 | 88 | } |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | QAbstractSeries::SeriesType QSplineSeries::type() const |
|
92 | 92 | { |
|
93 | 93 | return QAbstractSeries::SeriesTypeSpline; |
|
94 | 94 | } |
|
95 | 95 | |
|
96 | 96 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
97 | 97 | |
|
98 | 98 | QSplineSeriesPrivate::QSplineSeriesPrivate(QSplineSeries* q):QLineSeriesPrivate(q) |
|
99 | 99 | { |
|
100 | 100 | } |
|
101 | 101 | |
|
102 | 102 | /*! |
|
103 | 103 | Calculates control points which are needed by QPainterPath.cubicTo function to draw the cubic Bezier cureve between two points. |
|
104 | 104 | */ |
|
105 | 105 | void QSplineSeriesPrivate::calculateControlPoints() |
|
106 | 106 | { |
|
107 | 107 | Q_Q(QSplineSeries); |
|
108 | 108 | |
|
109 | 109 | const QList<QPointF>& points = q->points(); |
|
110 | 110 | |
|
111 | 111 | int n = points.count() - 1; |
|
112 | 112 | |
|
113 | 113 | if (n == 1) |
|
114 | 114 | { |
|
115 | 115 | //for n==1 |
|
116 | 116 | m_controlPoints[0].setX((2 * points[0].x() + points[1].x()) / 3); |
|
117 | 117 | m_controlPoints[0].setY((2 * points[0].y() + points[1].y()) / 3); |
|
118 | 118 | m_controlPoints[1].setX(2 * m_controlPoints[0].x() - points[0].x()); |
|
119 | 119 | m_controlPoints[1].setY(2 * m_controlPoints[0].y() - points[0].y()); |
|
120 | 120 | return; |
|
121 | 121 | } |
|
122 | 122 | |
|
123 | 123 | // Calculate first Bezier control points |
|
124 | 124 | // Set of equations for P0 to Pn points. |
|
125 | 125 | // |
|
126 | 126 | // | 2 1 0 0 ... 0 0 0 ... 0 0 0 | | P1_1 | | P0 + 2 * P1 | |
|
127 | 127 | // | 1 4 1 0 ... 0 0 0 ... 0 0 0 | | P1_2 | | 4 * P1 + 2 * P2 | |
|
128 | 128 | // | 0 1 4 1 ... 0 0 0 ... 0 0 0 | | P1_3 | | 4 * P2 + 2 * P3 | |
|
129 | 129 | // | . . . . . . . . . . . . | | ... | | ... | |
|
130 | 130 | // | 0 0 0 0 ... 1 4 1 ... 0 0 0 | * | P1_i | = | 4 * P(i-1) + 2 * Pi | |
|
131 | 131 | // | . . . . . . . . . . . . | | ... | | ... | |
|
132 | 132 | // | 0 0 0 0 0 0 0 0 ... 1 4 1 | | P1_(n-1)| | 4 * P(n-2) + 2 * P(n-1) | |
|
133 | 133 | // | 0 0 0 0 0 0 0 0 ... 0 2 7 | | P1_n | | 8 * P(n-1) + Pn | |
|
134 | 134 | // |
|
135 | 135 | QVector<qreal> vector; |
|
136 | 136 | vector.resize(n); |
|
137 | 137 | |
|
138 | 138 | vector[0] = points[0].x() + 2 * points[1].x(); |
|
139 | 139 | |
|
140 | 140 | |
|
141 | 141 | for (int i = 1; i < n - 1; ++i){ |
|
142 | 142 | vector[i] = 4 * points[i].x() + 2 * points[i + 1].x(); |
|
143 | 143 | } |
|
144 | 144 | |
|
145 | 145 | vector[n - 1] = (8 * points[n-1].x() + points[n].x()) / 2.0; |
|
146 | 146 | |
|
147 | 147 | QVector<qreal> xControl = firstControlPoints(vector); |
|
148 | 148 | |
|
149 | 149 | vector[0] = points[0].y() + 2 * points[1].y(); |
|
150 | 150 | |
|
151 | 151 | for (int i = 1; i < n - 1; ++i) { |
|
152 | 152 | vector[i] = 4 * points[i].y() + 2 * points[i + 1].y(); |
|
153 | 153 | } |
|
154 | 154 | |
|
155 | 155 | vector[n - 1] = (8 * points[n-1].y() + points[n].y()) / 2.0; |
|
156 | 156 | |
|
157 | 157 | QVector<qreal> yControl = firstControlPoints(vector); |
|
158 | 158 | |
|
159 | 159 | for (int i = 0,j =0; i < n; ++i, ++j) { |
|
160 | 160 | |
|
161 | 161 | m_controlPoints[j].setX(xControl[i]); |
|
162 | 162 | m_controlPoints[j].setY(yControl[i]); |
|
163 | 163 | |
|
164 | 164 | j++; |
|
165 | 165 | |
|
166 | 166 | if (i < n - 1){ |
|
167 | 167 | m_controlPoints[j].setX(2 * points[i+1].x() - xControl[i + 1]); |
|
168 | 168 | m_controlPoints[j].setY(2 * points[i+1].y() - yControl[i + 1]); |
|
169 | 169 | }else{ |
|
170 | 170 | m_controlPoints[j].setX((points[n].x() + xControl[n - 1]) / 2); |
|
171 | 171 | m_controlPoints[j].setY((points[n].y() + yControl[n - 1]) / 2); |
|
172 | 172 | } |
|
173 | 173 | } |
|
174 | 174 | } |
|
175 | 175 | |
|
176 | 176 | QVector<qreal> QSplineSeriesPrivate::firstControlPoints(const QVector<qreal>& vector) |
|
177 | 177 | { |
|
178 | 178 | QVector<qreal> result; |
|
179 | 179 | |
|
180 | 180 | int count = vector.count(); |
|
181 | 181 | result.resize(count); |
|
182 | 182 | result[0] = vector[0] / 2.0; |
|
183 | 183 | |
|
184 | 184 | QVector<qreal> temp; |
|
185 | 185 | temp.resize(count); |
|
186 | 186 | temp[0] = 0; |
|
187 | 187 | |
|
188 | 188 | qreal b = 2.0; |
|
189 | 189 | |
|
190 | 190 | for (int i = 1; i < count; i++) { |
|
191 | 191 | temp[i] = 1 / b; |
|
192 | 192 | b = (i < count - 1 ? 4.0 : 3.5) - temp[i]; |
|
193 | 193 | result[i]=(vector[i] - result[i - 1]) / b; |
|
194 | 194 | } |
|
195 | 195 | for (int i = 1; i < count; i++) |
|
196 | 196 | result[count - i - 1] -= temp[count - i] * result[count - i]; |
|
197 | 197 | |
|
198 | 198 | return result; |
|
199 | 199 | } |
|
200 | 200 | |
|
201 | 201 | QPointF QSplineSeriesPrivate::controlPoint(int index) const |
|
202 | 202 | { |
|
203 | // Q_D(const QSplineSeries); | |
|
204 | // return d->m_controlPoints[index]; | |
|
205 | 203 | return m_controlPoints[index]; |
|
206 | 204 | } |
|
207 | 205 | |
|
208 | 206 | /*! |
|
209 | 207 | Updates the control points, besed on currently avaiable knots. |
|
210 | 208 | */ |
|
211 | 209 | void QSplineSeriesPrivate::updateControlPoints() |
|
212 | 210 | { |
|
213 | 211 | Q_Q(QSplineSeries); |
|
214 | 212 | if (q->count() > 1) { |
|
215 | 213 | m_controlPoints.resize(2*q->count()-2); |
|
216 | 214 | calculateControlPoints(); |
|
217 | 215 | } |
|
218 | 216 | } |
|
219 | 217 | |
|
220 | 218 | ChartElement* QSplineSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
221 | 219 | { |
|
222 | 220 | Q_Q(QSplineSeries); |
|
223 | 221 | SplineChartItem* spline = new SplineChartItem(q,presenter); |
|
224 | 222 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
225 | 223 | spline->setAnimation(new SplineAnimation(spline)); |
|
226 | 224 | } |
|
227 | 225 | |
|
228 | 226 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
229 | 227 | return spline; |
|
230 | 228 | } |
|
231 | 229 | |
|
232 | 230 | #include "moc_qsplineseries.cpp" |
|
233 | 231 | #include "moc_qsplineseries_p.cpp" |
|
234 | 232 | |
|
235 | 233 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,172 +1,171 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "splinechartitem_p.h" |
|
22 | 22 | #include "qsplineseries_p.h" |
|
23 | 23 | #include "chartpresenter_p.h" |
|
24 | 24 | #include "splineanimation_p.h" |
|
25 | 25 | #include <QPainter> |
|
26 | 26 | #include <QGraphicsSceneMouseEvent> |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | SplineChartItem::SplineChartItem(QSplineSeries *series, ChartPresenter *presenter) : |
|
31 | 31 | XYChart(series, presenter), |
|
32 | 32 | QGraphicsItem(presenter ? presenter->rootItem() : 0), |
|
33 | 33 | m_series(series), |
|
34 | 34 | m_pointsVisible(false), |
|
35 | 35 | m_animation(0) |
|
36 | 36 | { |
|
37 | 37 | setZValue(ChartPresenter::SplineChartZValue); |
|
38 | 38 | QObject::connect(m_series->d_func(),SIGNAL(updated()),this,SLOT(handleUpdated())); |
|
39 | 39 | QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated())); |
|
40 | 40 | handleUpdated(); |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | QRectF SplineChartItem::boundingRect() const |
|
44 | 44 | { |
|
45 | 45 | return m_rect; |
|
46 | 46 | } |
|
47 | 47 | |
|
48 | 48 | QPainterPath SplineChartItem::shape() const |
|
49 | 49 | { |
|
50 | 50 | return m_path; |
|
51 | 51 | } |
|
52 | 52 | |
|
53 | 53 | void SplineChartItem::setAnimation(SplineAnimation* animation) |
|
54 | 54 | { |
|
55 | 55 | m_animation=animation; |
|
56 | 56 | XYChart::setAnimation(animation); |
|
57 | 57 | } |
|
58 | 58 | |
|
59 | 59 | ChartAnimation* SplineChartItem::animation() const |
|
60 | 60 | { |
|
61 | 61 | return m_animation; |
|
62 | 62 | } |
|
63 | 63 | |
|
64 | 64 | void SplineChartItem::setControlGeometryPoints(QVector<QPointF>& points) |
|
65 | 65 | { |
|
66 | 66 | m_controlPoints=points; |
|
67 | 67 | } |
|
68 | 68 | |
|
69 | 69 | QVector<QPointF> SplineChartItem::controlGeometryPoints() const |
|
70 | 70 | { |
|
71 | 71 | return m_controlPoints; |
|
72 | 72 | } |
|
73 | 73 | |
|
74 | 74 | void SplineChartItem::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints,int index) |
|
75 | 75 | { |
|
76 | 76 | QVector<QPointF> controlPoints; |
|
77 | 77 | |
|
78 | 78 | if(newPoints.count()>=2) { |
|
79 | 79 | controlPoints.resize(newPoints.count()*2-2); |
|
80 | 80 | } |
|
81 | 81 | |
|
82 | 82 | for (int i = 0; i < newPoints.size() - 1; i++) { |
|
83 | 83 | controlPoints[2*i] = calculateGeometryControlPoint(2 * i); |
|
84 | 84 | controlPoints[2 * i + 1] = calculateGeometryControlPoint(2 * i + 1); |
|
85 | 85 | } |
|
86 | 86 | |
|
87 |
if (m_animation) |
|
|
88 | m_animation->setup(oldPoints,newPoints,m_controlPoints,controlPoints,index); | |
|
89 | } | |
|
87 | if (m_animation) | |
|
88 | m_animation->setup(oldPoints, newPoints, m_controlPoints, controlPoints, index); | |
|
90 | 89 | |
|
91 |
|
|
|
92 | setControlGeometryPoints(controlPoints); | |
|
90 | m_points = newPoints; | |
|
91 | m_controlPoints = controlPoints; | |
|
93 | 92 | setDirty(false); |
|
94 | 93 | |
|
95 | 94 | if (m_animation) { |
|
96 | 95 | presenter()->startAnimation(m_animation); |
|
97 | 96 | } else { |
|
98 | 97 | updateGeometry(); |
|
99 | 98 | } |
|
100 | 99 | } |
|
101 | 100 | |
|
102 | 101 | QPointF SplineChartItem::calculateGeometryControlPoint(int index) const |
|
103 | 102 | { |
|
104 | 103 | return XYChart::calculateGeometryPoint(m_series->d_func()->controlPoint(index)); |
|
105 | 104 | } |
|
106 | 105 | |
|
107 | 106 | void SplineChartItem::updateGeometry() |
|
108 | 107 | { |
|
109 |
const QVector<QPointF> &points = |
|
|
110 |
const QVector<QPointF> &controlPoints = control |
|
|
108 | const QVector<QPointF> &points = m_points; | |
|
109 | const QVector<QPointF> &controlPoints = m_controlPoints; | |
|
111 | 110 | |
|
112 | 111 | if ((points.size()<2) || (controlPoints.size()<2)) { |
|
113 | 112 | prepareGeometryChange(); |
|
114 | 113 | m_path = QPainterPath(); |
|
115 | 114 | m_rect = QRect(); |
|
116 | 115 | return; |
|
117 | 116 | } |
|
118 | 117 | |
|
119 | 118 | Q_ASSERT(points.count()*2-2 == controlPoints.count()); |
|
120 | 119 | |
|
121 | 120 | QPainterPath splinePath(points.at(0)); |
|
122 | 121 | |
|
123 | 122 | for (int i = 0; i < points.size() - 1; i++) { |
|
124 | 123 | const QPointF& point = points.at(i + 1); |
|
125 | 124 | splinePath.cubicTo(controlPoints[2*i],controlPoints[2 * i + 1],point); |
|
126 | 125 | } |
|
127 | 126 | |
|
128 | 127 | prepareGeometryChange(); |
|
129 | 128 | m_path = splinePath; |
|
130 | 129 | m_rect = splinePath.boundingRect(); |
|
131 | 130 | setPos(origin()); |
|
132 | 131 | } |
|
133 | 132 | |
|
134 | 133 | //handlers |
|
135 | 134 | |
|
136 | 135 | void SplineChartItem::handleUpdated() |
|
137 | 136 | { |
|
138 | 137 | setVisible(m_series->isVisible()); |
|
139 | 138 | m_pointsVisible = m_series->pointsVisible(); |
|
140 | 139 | m_linePen = m_series->pen(); |
|
141 | 140 | m_pointPen = m_series->pen(); |
|
142 | 141 | m_pointPen.setWidthF(2*m_pointPen.width()); |
|
143 | 142 | update(); |
|
144 | 143 | } |
|
145 | 144 | |
|
146 | 145 | //painter |
|
147 | 146 | |
|
148 | 147 | void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
149 | 148 | { |
|
150 | 149 | Q_UNUSED(widget) |
|
151 | 150 | Q_UNUSED(option) |
|
152 | 151 | |
|
153 | 152 | painter->save(); |
|
154 | 153 | painter->setClipRect(clipRect()); |
|
155 | 154 | painter->setPen(m_linePen); |
|
156 | 155 | painter->drawPath(m_path); |
|
157 | 156 | if (m_pointsVisible) { |
|
158 | 157 | painter->setPen(m_pointPen); |
|
159 | 158 | painter->drawPoints(geometryPoints()); |
|
160 | 159 | } |
|
161 | 160 | painter->restore(); |
|
162 | 161 | } |
|
163 | 162 | |
|
164 | 163 | void SplineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
165 | 164 | { |
|
166 | 165 | emit XYChart::clicked(calculateDomainPoint(event->pos())); |
|
167 | 166 | QGraphicsItem::mousePressEvent(event); |
|
168 | 167 | } |
|
169 | 168 | |
|
170 | 169 | #include "moc_splinechartitem_p.cpp" |
|
171 | 170 | |
|
172 | 171 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,449 +1,448 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qxyseries.h" |
|
22 | 22 | #include "qxyseries_p.h" |
|
23 | 23 | #include "domain_p.h" |
|
24 | 24 | #include "legendmarker_p.h" |
|
25 | 25 | #include "qvaluesaxis.h" |
|
26 | 26 | |
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 | 29 | /*! |
|
30 | 30 | \class QXYSeries |
|
31 | 31 | \brief The QXYSeries class is a base class for line, spline and scatter series. |
|
32 | 32 | */ |
|
33 | 33 | /*! |
|
34 | 34 | \qmlclass XYSeries |
|
35 | 35 | \inherits AbstractSeries |
|
36 | 36 | The XYSeries class is a base class for line, spline and scatter series. |
|
37 | 37 | |
|
38 | 38 | The class cannot be instantiated directly. |
|
39 | 39 | */ |
|
40 | 40 | |
|
41 | 41 | /*! |
|
42 | 42 | \property QXYSeries::pointsVisible |
|
43 | 43 | Controls if the data points are visible and should be drawn. |
|
44 | 44 | */ |
|
45 | 45 | /*! |
|
46 | 46 | \qmlproperty bool XYSeries::pointsVisible |
|
47 | 47 | Controls if the data points are visible and should be drawn. |
|
48 | 48 | */ |
|
49 | 49 | |
|
50 | 50 | /*! |
|
51 | 51 | \fn QPen QXYSeries::pen() const |
|
52 | 52 | \brief Returns pen used to draw points for series. |
|
53 | 53 | \sa setPen() |
|
54 | 54 | */ |
|
55 | 55 | |
|
56 | 56 | /*! |
|
57 | 57 | \fn QBrush QXYSeries::brush() const |
|
58 | 58 | \brief Returns brush used to draw points for series. |
|
59 | 59 | \sa setBrush() |
|
60 | 60 | */ |
|
61 | 61 | |
|
62 | 62 | /*! |
|
63 | 63 | \property QXYSeries::color |
|
64 | 64 | The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and |
|
65 | 65 | fill (brush) color in case of QScatterSeries or QAreaSeries. |
|
66 | 66 | \sa QXYSeries::pen(), QXYSeries::brush() |
|
67 | 67 | */ |
|
68 | 68 | /*! |
|
69 | 69 | \qmlproperty color XYSeries::color |
|
70 | 70 | The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and |
|
71 | 71 | fill (brush) color in case of ScatterSeries or AreaSeries. |
|
72 | 72 | */ |
|
73 | 73 | |
|
74 | 74 | /*! |
|
75 | 75 | \fn void QXYSeries::clicked(const QPointF& point) |
|
76 | 76 | \brief Signal is emitted when user clicks the \a point on chart. |
|
77 | 77 | */ |
|
78 | 78 | /*! |
|
79 | 79 | \qmlsignal XYSeries::onClicked(QPointF point) |
|
80 | 80 | Signal is emitted when user clicks the \a point on chart. For example: |
|
81 | 81 | \code |
|
82 | 82 | LineSeries { |
|
83 | 83 | XYPoint { x: 0; y: 0 } |
|
84 | 84 | XYPoint { x: 1.1; y: 2.1 } |
|
85 | 85 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); |
|
86 | 86 | } |
|
87 | 87 | \endcode |
|
88 | 88 | */ |
|
89 | 89 | |
|
90 | 90 | /*! |
|
91 | 91 | \fn void QXYSeries::pointReplaced(int index) |
|
92 | 92 | Signal is emitted when a point has been replaced at \a index. |
|
93 | 93 | \sa replace() |
|
94 | 94 | */ |
|
95 | 95 | /*! |
|
96 | 96 | \qmlsignal XYSeries::onPointReplaced(int index) |
|
97 | 97 | Signal is emitted when a point has been replaced at \a index. |
|
98 | 98 | */ |
|
99 | 99 | |
|
100 | 100 | /*! |
|
101 | 101 | \fn void QXYSeries::pointAdded(int index) |
|
102 | 102 | Signal is emitted when a point has been added at \a index. |
|
103 | 103 | \sa append(), insert() |
|
104 | 104 | */ |
|
105 | 105 | /*! |
|
106 | 106 | \qmlsignal XYSeries::onPointAdded(int index) |
|
107 | 107 | Signal is emitted when a point has been added at \a index. |
|
108 | 108 | */ |
|
109 | 109 | |
|
110 | 110 | /*! |
|
111 | 111 | \fn void QXYSeries::pointRemoved(int index) |
|
112 | 112 | Signal is emitted when a point has been removed from \a index. |
|
113 | 113 | \sa remove() |
|
114 | 114 | */ |
|
115 | 115 | /*! |
|
116 | 116 | \qmlsignal XYSeries::onPointRemoved(int index) |
|
117 | 117 | Signal is emitted when a point has been removed from \a index. |
|
118 | 118 | */ |
|
119 | 119 | |
|
120 | 120 | /*! |
|
121 | 121 | \fn void QXYSeries::colorChanged(QColor color) |
|
122 | 122 | \brief Signal is emitted when the line (pen) color has changed to \a color. |
|
123 | 123 | */ |
|
124 | 124 | /*! |
|
125 | 125 | \qmlsignal XYSeries::onColorChanged(color color) |
|
126 | 126 | Signal is emitted when the line (pen) color has changed to \a color. |
|
127 | 127 | */ |
|
128 | 128 | |
|
129 | 129 | /*! |
|
130 | 130 | \fn void QXYSeriesPrivate::updated() |
|
131 | 131 | \brief \internal |
|
132 | 132 | */ |
|
133 | 133 | |
|
134 | 134 | /*! |
|
135 | 135 | \qmlmethod XYSeries::append(real x, real y) |
|
136 | 136 | Append point (\a x, \a y) to the series |
|
137 | 137 | */ |
|
138 | 138 | |
|
139 | 139 | /*! |
|
140 | 140 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) |
|
141 | 141 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not |
|
142 | 142 | exist. |
|
143 | 143 | */ |
|
144 | 144 | |
|
145 | 145 | /*! |
|
146 | 146 | \qmlmethod XYSeries::remove(real x, real y) |
|
147 | 147 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. |
|
148 | 148 | */ |
|
149 | 149 | |
|
150 | 150 | /*! |
|
151 | 151 | \qmlmethod XYSeries::insert(int index, real x, real y) |
|
152 | 152 | Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of |
|
153 | 153 | points. If index is the same as or bigger than count, the point is appended to the list of points. |
|
154 | 154 | */ |
|
155 | 155 | |
|
156 | 156 | /*! |
|
157 | 157 | \qmlmethod QPointF XYSeries::at(int index) |
|
158 | 158 | Returns point at \a index. Returns (0, 0) if the index is not valid. |
|
159 | 159 | */ |
|
160 | 160 | |
|
161 | 161 | /*! |
|
162 | 162 | \internal |
|
163 | 163 | |
|
164 | 164 | Constructs empty series object which is a child of \a parent. |
|
165 | 165 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
166 | 166 | */ |
|
167 | 167 | QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent) |
|
168 | 168 | { |
|
169 | 169 | } |
|
170 | 170 | |
|
171 | 171 | /*! |
|
172 | 172 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
173 | 173 | and are deleted when mentioned object are destroyed. |
|
174 | 174 | */ |
|
175 | 175 | QXYSeries::~QXYSeries() |
|
176 | 176 | { |
|
177 | 177 | } |
|
178 | 178 | |
|
179 | 179 | /*! |
|
180 | 180 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. |
|
181 | 181 | */ |
|
182 | 182 | void QXYSeries::append(qreal x,qreal y) |
|
183 | 183 | { |
|
184 | 184 | append(QPointF(x,y)); |
|
185 | 185 | } |
|
186 | 186 | |
|
187 | 187 | /*! |
|
188 | 188 | This is an overloaded function. |
|
189 | 189 | Adds data \a point to the series. Points are connected with lines on the chart. |
|
190 | 190 | */ |
|
191 | 191 | void QXYSeries::append(const QPointF &point) |
|
192 | 192 | { |
|
193 | 193 | Q_D(QXYSeries); |
|
194 | 194 | d->m_points<<point; |
|
195 | 195 | // emit d->pointAdded(d->m_points.count()-1); |
|
196 | 196 | emit pointAdded(d->m_points.count()-1); |
|
197 | 197 | } |
|
198 | 198 | |
|
199 | 199 | /*! |
|
200 | 200 | This is an overloaded function. |
|
201 | 201 | Adds list of data \a points to the series. Points are connected with lines on the chart. |
|
202 | 202 | */ |
|
203 | 203 | void QXYSeries::append(const QList<QPointF> &points) |
|
204 | 204 | { |
|
205 | 205 | foreach(const QPointF& point , points) { |
|
206 | 206 | append(point); |
|
207 | 207 | } |
|
208 | 208 | } |
|
209 | 209 | |
|
210 | 210 | /*! |
|
211 | 211 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. |
|
212 | 212 | */ |
|
213 | 213 | void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY) |
|
214 | 214 | { |
|
215 | 215 | replace(QPointF(oldX,oldY),QPointF(newX,newY)); |
|
216 | 216 | } |
|
217 | 217 | |
|
218 | 218 | /*! |
|
219 | 219 | Replaces \a oldPoint with \a newPoint. |
|
220 | 220 | */ |
|
221 | 221 | void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint) |
|
222 | 222 | { |
|
223 | 223 | Q_D(QXYSeries); |
|
224 | 224 | int index = d->m_points.indexOf(oldPoint); |
|
225 | 225 | if(index==-1) return; |
|
226 | 226 | d->m_points[index] = newPoint; |
|
227 | // emit d->pointReplaced(index); | |
|
228 | 227 | emit pointReplaced(index); |
|
229 | 228 | } |
|
230 | 229 | |
|
231 | 230 | /*! |
|
232 | 231 | Removes current \a x and \a y value. |
|
233 | 232 | */ |
|
234 | 233 | void QXYSeries::remove(qreal x,qreal y) |
|
235 | 234 | { |
|
236 | 235 | remove(QPointF(x,y)); |
|
237 | 236 | } |
|
238 | 237 | |
|
239 | 238 | /*! |
|
240 | 239 | Removes current \a point x value. |
|
241 | 240 | |
|
242 | 241 | Note: point y value is ignored. |
|
243 | 242 | */ |
|
244 | 243 | void QXYSeries::remove(const QPointF &point) |
|
245 | 244 | { |
|
246 | 245 | Q_D(QXYSeries); |
|
247 | 246 | int index = d->m_points.indexOf(point); |
|
248 | 247 | if(index==-1) return; |
|
249 | 248 | d->m_points.remove(index); |
|
250 | 249 | // emit d->pointRemoved(index); |
|
251 | 250 | emit pointRemoved(index); |
|
252 | 251 | } |
|
253 | 252 | |
|
254 | 253 | /*! |
|
255 | 254 | Inserts a \a point in the series at \a index position. |
|
256 | 255 | */ |
|
257 | 256 | void QXYSeries::insert(int index, const QPointF &point) |
|
258 | 257 | { |
|
259 | 258 | Q_D(QXYSeries); |
|
260 | 259 | d->m_points.insert(index, point); |
|
261 | 260 | // emit d->pointAdded(index); |
|
262 | 261 | emit pointAdded(index); |
|
263 | 262 | } |
|
264 | 263 | |
|
265 | 264 | /*! |
|
266 | 265 | Removes all points from the series. |
|
267 | 266 | */ |
|
268 | 267 | void QXYSeries::clear() |
|
269 | 268 | { |
|
270 | 269 | Q_D(QXYSeries); |
|
271 | 270 | for (int i = d->m_points.size() - 1; i >= 0; i--) |
|
272 | 271 | remove(d->m_points.at(i)); |
|
273 | 272 | } |
|
274 | 273 | |
|
275 | 274 | /*! |
|
276 | 275 | Returns list of points in the series. |
|
277 | 276 | */ |
|
278 | 277 | QList<QPointF> QXYSeries::points() const |
|
279 | 278 | { |
|
280 | 279 | Q_D(const QXYSeries); |
|
281 | 280 | return d->m_points.toList(); |
|
282 | 281 | } |
|
283 | 282 | |
|
284 | 283 | /*! |
|
285 | 284 | Returns number of data points within series. |
|
286 | 285 | */ |
|
287 | 286 | int QXYSeries::count() const |
|
288 | 287 | { |
|
289 | 288 | Q_D(const QXYSeries); |
|
290 | 289 | return d->m_points.count(); |
|
291 | 290 | } |
|
292 | 291 | |
|
293 | 292 | |
|
294 | 293 | /*! |
|
295 | 294 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the |
|
296 | 295 | pen from chart theme is used. |
|
297 | 296 | \sa QChart::setTheme() |
|
298 | 297 | */ |
|
299 | 298 | void QXYSeries::setPen(const QPen &pen) |
|
300 | 299 | { |
|
301 | 300 | Q_D(QXYSeries); |
|
302 | 301 | if (d->m_pen != pen) { |
|
303 | 302 | bool emitColorChanged = d->m_pen.color() != pen.color(); |
|
304 | 303 | d->m_pen = pen; |
|
305 | 304 | emit d->updated(); |
|
306 | 305 | if (emitColorChanged) |
|
307 | 306 | emit colorChanged(pen.color()); |
|
308 | 307 | } |
|
309 | 308 | } |
|
310 | 309 | |
|
311 | 310 | QPen QXYSeries::pen() const |
|
312 | 311 | { |
|
313 | 312 | Q_D(const QXYSeries); |
|
314 | 313 | return d->m_pen; |
|
315 | 314 | } |
|
316 | 315 | |
|
317 | 316 | /*! |
|
318 | 317 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
319 | 318 | from chart theme setting is used. |
|
320 | 319 | \sa QChart::setTheme() |
|
321 | 320 | */ |
|
322 | 321 | void QXYSeries::setBrush(const QBrush &brush) |
|
323 | 322 | { |
|
324 | 323 | Q_D(QXYSeries); |
|
325 | 324 | if (d->m_brush!=brush) { |
|
326 | 325 | d->m_brush = brush; |
|
327 | 326 | emit d->updated(); |
|
328 | 327 | } |
|
329 | 328 | } |
|
330 | 329 | |
|
331 | 330 | QBrush QXYSeries::brush() const |
|
332 | 331 | { |
|
333 | 332 | Q_D(const QXYSeries); |
|
334 | 333 | return d->m_brush; |
|
335 | 334 | } |
|
336 | 335 | |
|
337 | 336 | void QXYSeries::setColor(const QColor &color) |
|
338 | 337 | { |
|
339 | 338 | QPen p = pen(); |
|
340 | 339 | if (p.color() != color) { |
|
341 | 340 | p.setColor(color); |
|
342 | 341 | setPen(p); |
|
343 | 342 | } |
|
344 | 343 | } |
|
345 | 344 | |
|
346 | 345 | QColor QXYSeries::color() const |
|
347 | 346 | { |
|
348 | 347 | return pen().color(); |
|
349 | 348 | } |
|
350 | 349 | |
|
351 | 350 | void QXYSeries::setPointsVisible(bool visible) |
|
352 | 351 | { |
|
353 | 352 | Q_D(QXYSeries); |
|
354 | 353 | if (d->m_pointsVisible != visible){ |
|
355 | 354 | d->m_pointsVisible = visible; |
|
356 | 355 | emit d->updated(); |
|
357 | 356 | } |
|
358 | 357 | } |
|
359 | 358 | |
|
360 | 359 | bool QXYSeries::pointsVisible() const |
|
361 | 360 | { |
|
362 | 361 | Q_D(const QXYSeries); |
|
363 | 362 | return d->m_pointsVisible; |
|
364 | 363 | } |
|
365 | 364 | |
|
366 | 365 | |
|
367 | 366 | /*! |
|
368 | 367 | Stream operator for adding a data \a point to the series. |
|
369 | 368 | \sa append() |
|
370 | 369 | */ |
|
371 | 370 | QXYSeries& QXYSeries::operator<< (const QPointF &point) |
|
372 | 371 | { |
|
373 | 372 | append(point); |
|
374 | 373 | return *this; |
|
375 | 374 | } |
|
376 | 375 | |
|
377 | 376 | |
|
378 | 377 | /*! |
|
379 | 378 | Stream operator for adding a list of \a points to the series. |
|
380 | 379 | \sa append() |
|
381 | 380 | */ |
|
382 | 381 | |
|
383 | 382 | QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points) |
|
384 | 383 | { |
|
385 | 384 | append(points); |
|
386 | 385 | return *this; |
|
387 | 386 | } |
|
388 | 387 | |
|
389 | 388 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
390 | 389 | |
|
391 | 390 | |
|
392 | 391 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) : |
|
393 | 392 | QAbstractSeriesPrivate(q), |
|
394 | 393 | m_pointsVisible(false) |
|
395 | 394 | { |
|
396 | 395 | } |
|
397 | 396 | |
|
398 | 397 | void QXYSeriesPrivate::scaleDomain(Domain& domain) |
|
399 | 398 | { |
|
400 | 399 | qreal minX(0); |
|
401 | 400 | qreal minY(0); |
|
402 | 401 | qreal maxX(1); |
|
403 | 402 | qreal maxY(1); |
|
404 | 403 | |
|
405 | 404 | Q_Q(QXYSeries); |
|
406 | 405 | |
|
407 | 406 | const QList<QPointF>& points = q->points(); |
|
408 | 407 | |
|
409 | 408 | if (!points.isEmpty()){ |
|
410 | 409 | minX = points[0].x(); |
|
411 | 410 | minY = points[0].y(); |
|
412 | 411 | maxX = minX; |
|
413 | 412 | maxY = minY; |
|
414 | 413 | |
|
415 | 414 | for (int i = 0; i < points.count(); i++) { |
|
416 | 415 | qreal x = points[i].x(); |
|
417 | 416 | qreal y = points[i].y(); |
|
418 | 417 | minX = qMin(minX, x); |
|
419 | 418 | minY = qMin(minY, y); |
|
420 | 419 | maxX = qMax(maxX, x); |
|
421 | 420 | maxY = qMax(maxY, y); |
|
422 | 421 | } |
|
423 | 422 | } |
|
424 | 423 | |
|
425 | 424 | domain.setRange(minX,maxX,minY,maxY); |
|
426 | 425 | } |
|
427 | 426 | |
|
428 | 427 | QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend) |
|
429 | 428 | { |
|
430 | 429 | Q_Q(QXYSeries); |
|
431 | 430 | QList<LegendMarker*> list; |
|
432 | 431 | return list << new XYLegendMarker(q,legend); |
|
433 | 432 | } |
|
434 | 433 | |
|
435 | 434 | void QXYSeriesPrivate::initializeAxis(QAbstractAxis* axis) |
|
436 | 435 | { |
|
437 | 436 | Q_UNUSED(axis); |
|
438 | 437 | } |
|
439 | 438 | |
|
440 | 439 | QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
441 | 440 | { |
|
442 | 441 | Q_UNUSED(orientation); |
|
443 | 442 | return QAbstractAxis::AxisTypeValues; |
|
444 | 443 | } |
|
445 | 444 | |
|
446 | 445 | #include "moc_qxyseries.cpp" |
|
447 | 446 | #include "moc_qxyseries_p.cpp" |
|
448 | 447 | |
|
449 | 448 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,222 +1,219 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "xychart_p.h" |
|
22 | 22 | #include "qxyseries.h" |
|
23 | 23 | #include "qxyseries_p.h" |
|
24 | 24 | #include "chartpresenter_p.h" |
|
25 | 25 | #include "domain_p.h" |
|
26 | 26 | #include "qxymodelmapper.h" |
|
27 | 27 | #include <QPainter> |
|
28 | 28 | #include <QAbstractItemModel> |
|
29 | 29 | |
|
30 | 30 | |
|
31 | 31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | 32 | |
|
33 | 33 | //TODO: optimize : remove points which are not visible |
|
34 | 34 | |
|
35 | 35 | XYChart::XYChart(QXYSeries *series, ChartPresenter *presenter):ChartElement(presenter), |
|
36 | 36 | m_minX(0), |
|
37 | 37 | m_maxX(0), |
|
38 | 38 | m_minY(0), |
|
39 | 39 | m_maxY(0), |
|
40 | 40 | m_series(series), |
|
41 | 41 | m_animation(0), |
|
42 | 42 | m_dirty(true) |
|
43 | 43 | { |
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 | QObject::connect(series, SIGNAL(pointReplaced(int)), this,SLOT(handlePointReplaced(int))); | |
|
48 | QObject::connect(series, SIGNAL(pointAdded(int)), this,SLOT(handlePointAdded(int))); | |
|
49 | QObject::connect(series, SIGNAL(pointRemoved(int)), this,SLOT(handlePointRemoved(int))); | |
|
50 | QObject::connect(this, SIGNAL(clicked(QPointF)), series,SIGNAL(clicked(QPointF))); | |
|
44 | QObject::connect(series, SIGNAL(pointReplaced(int)), this, SLOT(handlePointReplaced(int))); | |
|
45 | QObject::connect(series, SIGNAL(pointAdded(int)), this, SLOT(handlePointAdded(int))); | |
|
46 | QObject::connect(series, SIGNAL(pointRemoved(int)), this, SLOT(handlePointRemoved(int))); | |
|
47 | QObject::connect(this, SIGNAL(clicked(QPointF)), series, SIGNAL(clicked(QPointF))); | |
|
51 | 48 | } |
|
52 | 49 | |
|
53 | 50 | void XYChart::setGeometryPoints(const QVector<QPointF>& points) |
|
54 | 51 | { |
|
55 | 52 | m_points = points; |
|
56 | 53 | } |
|
57 | 54 | |
|
58 | 55 | void XYChart::setClipRect(const QRectF &rect) |
|
59 | 56 | { |
|
60 | 57 | m_clipRect = rect; |
|
61 | 58 | } |
|
62 | 59 | |
|
63 | 60 | void XYChart::setAnimation(XYAnimation* animation) |
|
64 | 61 | { |
|
65 | 62 | m_animation=animation; |
|
66 | 63 | } |
|
67 | 64 | |
|
68 | 65 | void XYChart::setDirty(bool dirty) |
|
69 | 66 | { |
|
70 | 67 | m_dirty=dirty; |
|
71 | 68 | } |
|
72 | 69 | |
|
73 | 70 | QPointF XYChart::calculateGeometryPoint(const QPointF &point) const |
|
74 | 71 | { |
|
75 | 72 | const qreal deltaX = m_size.width()/(m_maxX-m_minX); |
|
76 | 73 | const qreal deltaY = m_size.height()/(m_maxY-m_minY); |
|
77 | 74 | qreal x = (point.x() - m_minX)* deltaX; |
|
78 | 75 | qreal y = (point.y() - m_minY)*-deltaY + m_size.height(); |
|
79 | 76 | return QPointF(x,y); |
|
80 | 77 | } |
|
81 | 78 | |
|
82 | 79 | QPointF XYChart::calculateGeometryPoint(int index) const |
|
83 | 80 | { |
|
84 | 81 | const qreal deltaX = m_size.width()/(m_maxX-m_minX); |
|
85 | 82 | const qreal deltaY = m_size.height()/(m_maxY-m_minY); |
|
86 | 83 | const QList<QPointF>& vector = m_series->points(); |
|
87 | 84 | qreal x = (vector[index].x() - m_minX)* deltaX; |
|
88 | 85 | qreal y = (vector[index].y() - m_minY)*-deltaY + m_size.height(); |
|
89 | 86 | return QPointF(x,y); |
|
90 | 87 | } |
|
91 | 88 | |
|
92 | 89 | QVector<QPointF> XYChart::calculateGeometryPoints() const |
|
93 | 90 | { |
|
94 | 91 | const qreal deltaX = m_size.width()/(m_maxX-m_minX); |
|
95 | 92 | const qreal deltaY = m_size.height()/(m_maxY-m_minY); |
|
96 | 93 | |
|
97 | 94 | QVector<QPointF> result; |
|
98 | 95 | result.resize(m_series->count()); |
|
99 | 96 | const QList<QPointF>& vector = m_series->points(); |
|
100 | 97 | for (int i = 0; i < m_series->count(); ++i) { |
|
101 | 98 | qreal x = (vector[i].x() - m_minX)* deltaX; |
|
102 | 99 | qreal y = (vector[i].y() - m_minY)*-deltaY + m_size.height(); |
|
103 | 100 | result[i].setX(x); |
|
104 | 101 | result[i].setY(y); |
|
105 | 102 | } |
|
106 | 103 | return result; |
|
107 | 104 | } |
|
108 | 105 | |
|
109 | 106 | QPointF XYChart::calculateDomainPoint(const QPointF &point) const |
|
110 | 107 | { |
|
111 | 108 | const qreal deltaX = m_size.width()/(m_maxX-m_minX); |
|
112 | 109 | const qreal deltaY = m_size.height()/(m_maxY-m_minY); |
|
113 | 110 | qreal x = point.x()/deltaX +m_minX; |
|
114 | 111 | qreal y = (point.y()-m_size.height())/(-deltaY)+ m_minY; |
|
115 | 112 | return QPointF(x,y); |
|
116 | 113 | } |
|
117 | 114 | |
|
118 | 115 | void XYChart::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints,int index) |
|
119 | 116 | { |
|
120 | 117 | |
|
121 | 118 | if (m_animation) { |
|
122 | 119 | m_animation->setup(oldPoints, newPoints, index); |
|
123 |
|
|
|
120 | m_points = newPoints; | |
|
124 | 121 | setDirty(false); |
|
125 | 122 | presenter()->startAnimation(m_animation); |
|
126 | 123 | } |
|
127 | 124 | else { |
|
128 |
|
|
|
125 | m_points = newPoints; | |
|
129 | 126 | updateGeometry(); |
|
130 | 127 | } |
|
131 | 128 | } |
|
132 | 129 | |
|
133 | 130 | //handlers |
|
134 | 131 | |
|
135 | 132 | void XYChart::handlePointAdded(int index) |
|
136 | 133 | { |
|
137 | 134 | Q_ASSERT(index<m_series->count()); |
|
138 | 135 | Q_ASSERT(index>=0); |
|
139 | 136 | |
|
140 | 137 | QVector<QPointF> points; |
|
141 | 138 | |
|
142 | 139 | if(m_dirty) { |
|
143 | 140 | points = calculateGeometryPoints(); |
|
144 | 141 | } else { |
|
145 | 142 | points = m_points; |
|
146 | 143 | QPointF point = calculateGeometryPoint(index); |
|
147 | 144 | points.insert(index, point); |
|
148 | 145 | } |
|
149 | 146 | |
|
150 | 147 | updateChart(m_points,points,index); |
|
151 | 148 | } |
|
152 | 149 | |
|
153 | 150 | void XYChart::handlePointRemoved(int index) |
|
154 | 151 | { |
|
155 | 152 | Q_ASSERT(index<=m_series->count()); |
|
156 | 153 | Q_ASSERT(index>=0); |
|
157 | 154 | |
|
158 | 155 | QVector<QPointF> points; |
|
159 | 156 | |
|
160 | 157 | if(m_dirty) { |
|
161 | 158 | points = calculateGeometryPoints(); |
|
162 | 159 | } else { |
|
163 | 160 | points = m_points; |
|
164 | 161 | points.remove(index); |
|
165 | 162 | } |
|
166 | 163 | |
|
167 | 164 | updateChart(m_points,points,index); |
|
168 | 165 | } |
|
169 | 166 | |
|
170 | 167 | void XYChart::handlePointReplaced(int index) |
|
171 | 168 | { |
|
172 | 169 | Q_ASSERT(index<m_series->count()); |
|
173 | 170 | Q_ASSERT(index>=0); |
|
174 | 171 | |
|
175 | 172 | QVector<QPointF> points; |
|
176 | 173 | |
|
177 | 174 | if(m_dirty) { |
|
178 | 175 | points = calculateGeometryPoints(); |
|
179 | 176 | } else { |
|
180 | 177 | QPointF point = calculateGeometryPoint(index); |
|
181 | 178 | points = m_points; |
|
182 | 179 | points.replace(index,point); |
|
183 | 180 | } |
|
184 | 181 | |
|
185 | 182 | updateChart(m_points,points,index); |
|
186 | 183 | } |
|
187 | 184 | |
|
188 | 185 | void XYChart::handleDomainUpdated() |
|
189 | 186 | { |
|
190 | 187 | m_minX=domain()->minX(); |
|
191 | 188 | m_maxX=domain()->maxX(); |
|
192 | 189 | m_minY=domain()->minY(); |
|
193 | 190 | m_maxY=domain()->maxY(); |
|
194 | 191 | if (isEmpty()) return; |
|
195 | 192 | |
|
196 | 193 | QVector<QPointF> points = calculateGeometryPoints(); |
|
197 | 194 | |
|
198 | 195 | updateChart(m_points,points); |
|
199 | 196 | } |
|
200 | 197 | |
|
201 | 198 | void XYChart::handleGeometryChanged(const QRectF &rect) |
|
202 | 199 | { |
|
203 | 200 | Q_ASSERT(rect.isValid()); |
|
204 | 201 | m_size=rect.size(); |
|
205 | 202 | m_clipRect=rect.translated(-rect.topLeft()); |
|
206 | 203 | m_origin=rect.topLeft(); |
|
207 | 204 | |
|
208 | 205 | if (isEmpty()) return; |
|
209 | 206 | |
|
210 | 207 | QVector<QPointF> points = calculateGeometryPoints(); |
|
211 | 208 | |
|
212 | 209 | updateChart(m_points,points); |
|
213 | 210 | } |
|
214 | 211 | |
|
215 | 212 | bool XYChart::isEmpty() |
|
216 | 213 | { |
|
217 | 214 | return !m_clipRect.isValid() || qFuzzyIsNull(m_maxX - m_minX) || qFuzzyIsNull(m_maxY - m_minY) || m_series->points().isEmpty(); |
|
218 | 215 | } |
|
219 | 216 | |
|
220 | 217 | #include "moc_xychart_p.cpp" |
|
221 | 218 | |
|
222 | 219 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,106 +1,106 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef XYCHARTITEM_H |
|
31 | 31 | #define XYCHARTITEM_H |
|
32 | 32 | |
|
33 | 33 | #include "qchartglobal.h" |
|
34 | 34 | #include "chartitem_p.h" |
|
35 | 35 | #include "xyanimation_p.h" |
|
36 | 36 | #include "qvaluesaxis.h" |
|
37 | 37 | #include <QPen> |
|
38 | 38 | |
|
39 | 39 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
40 | 40 | |
|
41 | 41 | class ChartPresenter; |
|
42 | 42 | class QXYSeries; |
|
43 | 43 | |
|
44 | 44 | class XYChart : public ChartElement |
|
45 | 45 | { |
|
46 | 46 | Q_OBJECT |
|
47 | 47 | public: |
|
48 | 48 | explicit XYChart(QXYSeries *series, ChartPresenter *presenter); |
|
49 |
~XYChart(){} |
|
|
49 | ~XYChart() {} | |
|
50 | 50 | |
|
51 | 51 | void setGeometryPoints(const QVector<QPointF>& points); |
|
52 | 52 | QVector<QPointF> geometryPoints() const { return m_points; } |
|
53 | 53 | |
|
54 | 54 | void setClipRect(const QRectF &rect); |
|
55 | 55 | QRectF clipRect() const { return m_clipRect; } |
|
56 | 56 | |
|
57 | 57 | QSizeF size() const { return m_size; } |
|
58 | 58 | QPointF origin() const { return m_origin; } |
|
59 | 59 | |
|
60 | 60 | void setAnimation(XYAnimation* animation); |
|
61 | 61 | ChartAnimation* animation() const { return m_animation; } |
|
62 | 62 | virtual void updateGeometry() = 0; |
|
63 | 63 | |
|
64 | 64 | bool isDirty() const { return m_dirty; } |
|
65 | 65 | void setDirty(bool dirty); |
|
66 | 66 | |
|
67 | 67 | public Q_SLOTS: |
|
68 | 68 | void handlePointAdded(int index); |
|
69 | 69 | void handlePointRemoved(int index); |
|
70 | 70 | void handlePointReplaced(int index); |
|
71 | 71 | void handleDomainUpdated(); |
|
72 | 72 | void handleGeometryChanged(const QRectF &size); |
|
73 | 73 | |
|
74 | 74 | Q_SIGNALS: |
|
75 | 75 | void clicked(const QPointF& point); |
|
76 | 76 | |
|
77 | 77 | protected: |
|
78 | 78 | virtual void updateChart(QVector<QPointF> &oldPoints,QVector<QPointF> &newPoints,int index = -1); |
|
79 | 79 | QPointF calculateGeometryPoint(const QPointF &point) const; |
|
80 | 80 | QPointF calculateGeometryPoint(int index) const; |
|
81 | 81 | QPointF calculateDomainPoint(const QPointF &point) const; |
|
82 | 82 | QVector<QPointF> calculateGeometryPoints() const; |
|
83 | 83 | |
|
84 | 84 | private: |
|
85 | 85 | inline bool isEmpty(); |
|
86 | 86 | |
|
87 | private: | |
|
87 | protected: | |
|
88 | 88 | qreal m_minX; |
|
89 | 89 | qreal m_maxX; |
|
90 | 90 | qreal m_minY; |
|
91 | 91 | qreal m_maxY; |
|
92 | 92 | QXYSeries* m_series; |
|
93 | 93 | QSizeF m_size; |
|
94 | 94 | QPointF m_origin; |
|
95 | 95 | QRectF m_clipRect; |
|
96 | 96 | QVector<QPointF> m_points; |
|
97 | 97 | XYAnimation* m_animation; |
|
98 | 98 | bool m_dirty; |
|
99 | 99 | |
|
100 | 100 | friend class AreaChartItem; |
|
101 | 101 | |
|
102 | 102 | }; |
|
103 | 103 | |
|
104 | 104 | QTCOMMERCIALCHART_END_NAMESPACE |
|
105 | 105 | |
|
106 | 106 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now