##// END OF EJS Templates
Fix xy series model issues due to API changes
Michal Klocek -
r1059:c23240068c61
parent child
Show More
@@ -244,7 +244,7 void QAreaSeriesPrivate::scaleDomain(Domain& domain)
244 244 }
245 245 if(lowerSeries) {
246 246
247 const QList<QPointF>& points = upperSeries->points();
247 const QList<QPointF>& points = lowerSeries->points();
248 248
249 249 for (int i = 0; i < points.count(); i++)
250 250 {
@@ -87,7 +87,7 void QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orie
87 87 {
88 88 Q_D(QSplineSeries);
89 89 QXYSeries::setModelMapping(modelX, modelY, orientation);
90 d->calculateControlPoints();
90 d->updateControlPoints();
91 91 }
92 92
93 93 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -104,16 +104,19 QSplineSeriesPrivate::QSplineSeriesPrivate(QSplineSeries* q):QLineSeriesPrivate(
104 104 */
105 105 void QSplineSeriesPrivate::calculateControlPoints()
106 106 {
107 Q_Q(QSplineSeries);
108
109 const QList<QPointF>& points = q->points();
107 110
108 int n = m_points.count() - 1;
111 int n = points.count() - 1;
109 112
110 113 if (n == 1)
111 114 {
112 115 //for n==1
113 m_controlPoints[0].setX((2 * m_points[0].x() + m_points[1].x()) / 3);
114 m_controlPoints[0].setY((2 * m_points[0].y() + m_points[1].y()) / 3);
115 m_controlPoints[1].setX(2 * m_controlPoints[0].x() - m_points[0].x());
116 m_controlPoints[1].setY(2 * m_controlPoints[0].y() - m_points[0].y());
116 m_controlPoints[0].setX((2 * points[0].x() + points[1].x()) / 3);
117 m_controlPoints[0].setY((2 * points[0].y() + points[1].y()) / 3);
118 m_controlPoints[1].setX(2 * m_controlPoints[0].x() - points[0].x());
119 m_controlPoints[1].setY(2 * m_controlPoints[0].y() - points[0].y());
117 120 return;
118 121 }
119 122
@@ -133,24 +136,24 void QSplineSeriesPrivate::calculateControlPoints()
133 136 QVector<qreal> vector;
134 137 vector.resize(n);
135 138
136 vector[0] = m_points[0].x() + 2 * m_points[1].x();
139 vector[0] = points[0].x() + 2 * points[1].x();
137 140
138 141
139 142 for (int i = 1; i < n - 1; ++i){
140 vector[i] = 4 * m_points[i].x() + 2 * m_points[i + 1].x();
143 vector[i] = 4 * points[i].x() + 2 * points[i + 1].x();
141 144 }
142 145
143 vector[n - 1] = (8 * m_points[n-1].x() + m_points[n].x()) / 2.0;
146 vector[n - 1] = (8 * points[n-1].x() + points[n].x()) / 2.0;
144 147
145 148 QVector<qreal> xControl = firstControlPoints(vector);
146 149
147 vector[0] = m_points[0].y() + 2 * m_points[1].y();
150 vector[0] = points[0].y() + 2 * points[1].y();
148 151
149 152 for (int i = 1; i < n - 1; ++i) {
150 vector[i] = 4 * m_points[i].y() + 2 * m_points[i + 1].y();
153 vector[i] = 4 * points[i].y() + 2 * points[i + 1].y();
151 154 }
152 155
153 vector[n - 1] = (8 * m_points[n-1].y() + m_points[n].y()) / 2.0;
156 vector[n - 1] = (8 * points[n-1].y() + points[n].y()) / 2.0;
154 157
155 158 QVector<qreal> yControl = firstControlPoints(vector);
156 159
@@ -162,11 +165,11 void QSplineSeriesPrivate::calculateControlPoints()
162 165 j++;
163 166
164 167 if (i < n - 1){
165 m_controlPoints[j].setX(2 * m_points[i+1].x() - xControl[i + 1]);
166 m_controlPoints[j].setY(2 * m_points[i+1].y() - yControl[i + 1]);
168 m_controlPoints[j].setX(2 * points[i+1].x() - xControl[i + 1]);
169 m_controlPoints[j].setY(2 * points[i+1].y() - yControl[i + 1]);
167 170 }else{
168 m_controlPoints[j].setX((m_points[n].x() + xControl[n - 1]) / 2);
169 m_controlPoints[j].setY((m_points[n].y() + yControl[n - 1]) / 2);
171 m_controlPoints[j].setX((points[n].x() + xControl[n - 1]) / 2);
172 m_controlPoints[j].setY((points[n].y() + yControl[n - 1]) / 2);
170 173 }
171 174 }
172 175 }
@@ -201,8 +204,9 QVector<qreal> QSplineSeriesPrivate::firstControlPoints(const QVector<qreal>& ve
201 204 */
202 205 void QSplineSeriesPrivate::updateControlPoints()
203 206 {
204 if (m_points.count() > 1) {
205 m_controlPoints.resize(2*m_points.count()-2);
207 Q_Q(QSplineSeries);
208 if (q->count() > 1) {
209 m_controlPoints.resize(2*q->count()-2);
206 210 calculateControlPoints();
207 211 }
208 212 }
@@ -395,11 +395,13 void QXYSeriesPrivate::scaleDomain(Domain& domain)
395 395 int tickXCount(domain.tickXCount());
396 396 int tickYCount(domain.tickYCount());
397 397
398 for (int i = 0; i < m_points.count(); i++)
399 {
398 Q_Q(QXYSeries);
400 399
401 qreal x = m_points[i].x();
402 qreal y = m_points[i].y();
400 const QList<QPointF>& points = q->points();
401 for (int i = 0; i < points.count(); i++)
402 {
403 qreal x = points[i].x();
404 qreal y = points[i].y();
403 405 minX = qMin(minX, x);
404 406 minY = qMin(minY, y);
405 407 maxX = qMax(maxX, x);
@@ -273,7 +273,6 void XYChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal
273 273 m_maxX=maxX;
274 274 m_minY=minY;
275 275 m_maxY=maxY;
276
277 276 if (isEmpty()) return;
278 277 QVector<QPointF> points = calculateGeometryPoints();
279 278 updateLayout(m_points,points);
General Comments 0
You need to be logged in to leave comments. Login now