@@ -236,6 +236,7 void ChartPresenter::zoomIn(const QRectF& rect) | |||
|
236 | 236 | { |
|
237 | 237 | QRectF r = rect.normalized(); |
|
238 | 238 | r.translate(-m_chartMargins.topLeft()); |
|
239 | if(!r.isValid()) return; | |
|
239 | 240 | if(m_animator) { |
|
240 | 241 | |
|
241 | 242 | QPointF point(r.center().x()/chartGeometry().width(),r.center().y()/chartGeometry().height()); |
@@ -257,6 +258,7 void ChartPresenter::zoomOut() | |||
|
257 | 258 | QSizeF size = chartGeometry().size(); |
|
258 | 259 | QRectF rect = chartGeometry(); |
|
259 | 260 | rect.translate(-m_chartMargins.topLeft()); |
|
261 | if(!rect.isValid()) return; | |
|
260 | 262 | m_dataset->zoomOutDomain(rect.adjusted(size.width()/4,size.height()/4,-size.width()/4,-size.height()/4),size); |
|
261 | 263 | //m_dataset->zoomOutDomain(m_zoomStack[m_zoomIndex-1],geometry().size()); |
|
262 | 264 |
@@ -67,6 +67,14 QSplineSeries::QSplineSeries(QObject *parent) : | |||
|
67 | 67 | { |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | QSplineSeries::~QSplineSeries() | |
|
71 | { | |
|
72 | Q_D(QSplineSeries); | |
|
73 | if(d->m_dataset){ | |
|
74 | d->m_dataset->removeSeries(this); | |
|
75 | } | |
|
76 | } | |
|
77 | ||
|
70 | 78 | QAbstractSeries::QSeriesType QSplineSeries::type() const |
|
71 | 79 | { |
|
72 | 80 | return QAbstractSeries::SeriesTypeSpline; |
@@ -37,6 +37,7 class QTCOMMERCIALCHART_EXPORT QSplineSeries : public QLineSeries | |||
|
37 | 37 | public: |
|
38 | 38 | |
|
39 | 39 | explicit QSplineSeries(QObject *parent = 0); |
|
40 | ~QSplineSeries(); | |
|
40 | 41 | QAbstractSeries::QSeriesType type() const; |
|
41 | 42 | |
|
42 | 43 | QPointF controlPoint(int index) const; |
@@ -23,6 +23,7 | |||
|
23 | 23 | #include "chartpresenter_p.h" |
|
24 | 24 | #include "chartanimator_p.h" |
|
25 | 25 | #include <QPainter> |
|
26 | #include <QDebug> | |
|
26 | 27 | |
|
27 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 29 | |
@@ -47,10 +48,12 QPainterPath SplineChartItem::shape() const | |||
|
47 | 48 | } |
|
48 | 49 | |
|
49 | 50 | void SplineChartItem::updateLayout(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints,int index) |
|
50 | { | |
|
51 | { | |
|
51 | 52 | QVector<QPointF> controlPoints; |
|
52 | 53 | |
|
53 |
|
|
|
54 | if(newPoints.count()>=2){ | |
|
55 | controlPoints.resize(newPoints.count()*2-2); | |
|
56 | } | |
|
54 | 57 | |
|
55 | 58 | for (int i = 0; i < newPoints.size() - 1; i++) { |
|
56 | 59 | controlPoints[2*i] = calculateGeometryControlPoint(2 * i); |
@@ -102,6 +105,7 void SplineChartItem::setLayout(QVector<QPointF> &points, QVector<QPointF> &cont | |||
|
102 | 105 | m_rect = splinePath.boundingRect(); |
|
103 | 106 | XYChartItem::setLayout(points); |
|
104 | 107 | m_controlPoints=controlPoints; |
|
108 | ||
|
105 | 109 | } |
|
106 | 110 | |
|
107 | 111 | //handlers |
@@ -121,7 +125,7 void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o | |||
|
121 | 125 | { |
|
122 | 126 | Q_UNUSED(widget) |
|
123 | 127 | Q_UNUSED(option) |
|
124 | ||
|
128 | qDebug()<<__FUNCTION__; | |
|
125 | 129 | painter->save(); |
|
126 | 130 | painter->setClipRect(clipRect()); |
|
127 | 131 | painter->setPen(m_linePen); |
@@ -416,7 +416,6 void QXYSeriesPrivate::scaleDomain(Domain& domain) | |||
|
416 | 416 | maxY=1.0; |
|
417 | 417 | } |
|
418 | 418 | |
|
419 | ||
|
420 | 419 | for (int i = 0; i < points.count(); i++) |
|
421 | 420 | { |
|
422 | 421 | qreal x = points[i].x(); |
@@ -239,7 +239,7 void XYChartItem::handleGeometryChanged(const QRectF &rect) | |||
|
239 | 239 | |
|
240 | 240 | bool XYChartItem::isEmpty() |
|
241 | 241 | { |
|
242 | return !m_clipRect.isValid() || qFuzzyIsNull(m_maxX - m_minX) || qFuzzyIsNull(m_maxY - m_minY); | |
|
242 | return !m_clipRect.isValid() || qFuzzyIsNull(m_maxX - m_minX) || qFuzzyIsNull(m_maxY - m_minY) || m_series->points().isEmpty(); | |
|
243 | 243 | } |
|
244 | 244 | |
|
245 | 245 | void XYChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
@@ -319,7 +319,6 void tst_QChart::isBackgroundVisible() | |||
|
319 | 319 | QFETCH(bool, isBackgroundVisible); |
|
320 | 320 | m_chart->setBackgroundVisible(isBackgroundVisible); |
|
321 | 321 | QCOMPARE(m_chart->isBackgroundVisible(), isBackgroundVisible); |
|
322 | ||
|
323 | 322 | } |
|
324 | 323 | |
|
325 | 324 | void tst_QChart::legend_data() |
@@ -338,15 +337,12 void tst_QChart::margins_data() | |||
|
338 | 337 | } |
|
339 | 338 | |
|
340 | 339 | void tst_QChart::margins() |
|
341 | {QTest::addColumn<int>("seriesCount"); | |
|
342 | QTest::newRow("0") << 0; | |
|
343 | QTest::newRow("-1") << -1; | |
|
340 | { | |
|
344 | 341 | createTestData(); |
|
345 | 342 | QRectF rect = m_chart->geometry(); |
|
346 | 343 | |
|
347 | 344 | QVERIFY(m_chart->margins().top()+m_chart->margins().bottom() < rect.height()); |
|
348 | 345 | QVERIFY(m_chart->margins().left()+m_chart->margins().right() < rect.width()); |
|
349 | ||
|
350 | 346 | } |
|
351 | 347 | |
|
352 | 348 | void tst_QChart::removeAllSeries_data() |
General Comments 0
You need to be logged in to leave comments.
Login now