@@ -39,14 +39,14 SplineAnimation::~SplineAnimation() | |||||
39 |
|
39 | |||
40 | void SplineAnimation::setup(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints, QVector<QPointF> &oldControlPoints, QVector<QPointF> &newControlPoints, int index) |
|
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){ |
|
42 | if (newPoints.count() * 2 - 2 != newControlPoints.count() || newControlPoints.count() < 2) { | |
43 |
|
|
43 | m_valid=false; | |
44 |
|
|
44 | m_dirty=false; | |
45 |
|
|
45 | m_item->setGeometryPoints(newPoints); | |
46 |
|
|
46 | m_item->setControlGeometryPoints(newControlPoints); | |
47 |
|
|
47 | m_item->setDirty(false); | |
48 |
|
|
48 | m_item->updateGeometry(); | |
49 |
|
|
49 | return; | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | m_type = NewAnimation; |
|
52 | m_type = NewAnimation; |
@@ -200,8 +200,6 QVector<qreal> QSplineSeriesPrivate::firstControlPoints(const QVector<qreal>& ve | |||||
200 |
|
200 | |||
201 | QPointF QSplineSeriesPrivate::controlPoint(int index) const |
|
201 | QPointF QSplineSeriesPrivate::controlPoint(int index) const | |
202 | { |
|
202 | { | |
203 | // Q_D(const QSplineSeries); |
|
|||
204 | // return d->m_controlPoints[index]; |
|
|||
205 | return m_controlPoints[index]; |
|
203 | return m_controlPoints[index]; | |
206 | } |
|
204 | } | |
207 |
|
205 |
@@ -84,12 +84,11 void SplineChartItem::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> | |||||
84 | controlPoints[2 * i + 1] = calculateGeometryControlPoint(2 * i + 1); |
|
84 | controlPoints[2 * i + 1] = calculateGeometryControlPoint(2 * i + 1); | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 |
if (m_animation) |
|
87 | if (m_animation) | |
88 | m_animation->setup(oldPoints,newPoints,m_controlPoints,controlPoints,index); |
|
88 | m_animation->setup(oldPoints, newPoints, m_controlPoints, controlPoints, index); | |
89 | } |
|
|||
90 |
|
89 | |||
91 |
|
|
90 | m_points = newPoints; | |
92 | setControlGeometryPoints(controlPoints); |
|
91 | m_controlPoints = controlPoints; | |
93 | setDirty(false); |
|
92 | setDirty(false); | |
94 |
|
93 | |||
95 | if (m_animation) { |
|
94 | if (m_animation) { | |
@@ -106,8 +105,8 QPointF SplineChartItem::calculateGeometryControlPoint(int index) const | |||||
106 |
|
105 | |||
107 | void SplineChartItem::updateGeometry() |
|
106 | void SplineChartItem::updateGeometry() | |
108 | { |
|
107 | { | |
109 |
const QVector<QPointF> &points = |
|
108 | const QVector<QPointF> &points = m_points; | |
110 |
const QVector<QPointF> &controlPoints = control |
|
109 | const QVector<QPointF> &controlPoints = m_controlPoints; | |
111 |
|
110 | |||
112 | if ((points.size()<2) || (controlPoints.size()<2)) { |
|
111 | if ((points.size()<2) || (controlPoints.size()<2)) { | |
113 | prepareGeometryChange(); |
|
112 | prepareGeometryChange(); |
@@ -224,7 +224,6 void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint) | |||||
224 | int index = d->m_points.indexOf(oldPoint); |
|
224 | int index = d->m_points.indexOf(oldPoint); | |
225 | if(index==-1) return; |
|
225 | if(index==-1) return; | |
226 | d->m_points[index] = newPoint; |
|
226 | d->m_points[index] = newPoint; | |
227 | // emit d->pointReplaced(index); |
|
|||
228 | emit pointReplaced(index); |
|
227 | emit pointReplaced(index); | |
229 | } |
|
228 | } | |
230 |
|
229 |
@@ -41,13 +41,10 m_series(series), | |||||
41 | m_animation(0), |
|
41 | m_animation(0), | |
42 | m_dirty(true) |
|
42 | m_dirty(true) | |
43 | { |
|
43 | { | |
44 |
|
|
44 | QObject::connect(series, SIGNAL(pointReplaced(int)), this, SLOT(handlePointReplaced(int))); | |
45 |
|
|
45 | QObject::connect(series, SIGNAL(pointAdded(int)), this, SLOT(handlePointAdded(int))); | |
46 |
|
|
46 | QObject::connect(series, SIGNAL(pointRemoved(int)), this, SLOT(handlePointRemoved(int))); | |
47 | QObject::connect(series, SIGNAL(pointReplaced(int)), this,SLOT(handlePointReplaced(int))); |
|
47 | QObject::connect(this, SIGNAL(clicked(QPointF)), series, SIGNAL(clicked(QPointF))); | |
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))); |
|
|||
51 | } |
|
48 | } | |
52 |
|
49 | |||
53 | void XYChart::setGeometryPoints(const QVector<QPointF>& points) |
|
50 | void XYChart::setGeometryPoints(const QVector<QPointF>& points) | |
@@ -120,12 +117,12 void XYChart::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoin | |||||
120 |
|
117 | |||
121 | if (m_animation) { |
|
118 | if (m_animation) { | |
122 | m_animation->setup(oldPoints, newPoints, index); |
|
119 | m_animation->setup(oldPoints, newPoints, index); | |
123 |
|
|
120 | m_points = newPoints; | |
124 | setDirty(false); |
|
121 | setDirty(false); | |
125 | presenter()->startAnimation(m_animation); |
|
122 | presenter()->startAnimation(m_animation); | |
126 | } |
|
123 | } | |
127 | else { |
|
124 | else { | |
128 |
|
|
125 | m_points = newPoints; | |
129 | updateGeometry(); |
|
126 | updateGeometry(); | |
130 | } |
|
127 | } | |
131 | } |
|
128 | } |
@@ -46,7 +46,7 class XYChart : public ChartElement | |||||
46 | Q_OBJECT |
|
46 | Q_OBJECT | |
47 | public: |
|
47 | public: | |
48 | explicit XYChart(QXYSeries *series, ChartPresenter *presenter); |
|
48 | explicit XYChart(QXYSeries *series, ChartPresenter *presenter); | |
49 |
~XYChart(){} |
|
49 | ~XYChart() {} | |
50 |
|
50 | |||
51 | void setGeometryPoints(const QVector<QPointF>& points); |
|
51 | void setGeometryPoints(const QVector<QPointF>& points); | |
52 | QVector<QPointF> geometryPoints() const { return m_points; } |
|
52 | QVector<QPointF> geometryPoints() const { return m_points; } | |
@@ -84,7 +84,7 protected: | |||||
84 | private: |
|
84 | private: | |
85 | inline bool isEmpty(); |
|
85 | inline bool isEmpty(); | |
86 |
|
86 | |||
87 | private: |
|
87 | protected: | |
88 | qreal m_minX; |
|
88 | qreal m_minX; | |
89 | qreal m_maxX; |
|
89 | qreal m_maxX; | |
90 | qreal m_minY; |
|
90 | qreal m_minY; |
General Comments 0
You need to be logged in to leave comments.
Login now