##// END OF EJS Templates
Added parametric zoom on QChart....
jeandet -
r2900:7532b52dd10c
parent child
Show More
@@ -354,6 +354,11 void QChart::zoomIn()
354 354 d_ptr->zoomIn(2.0);
355 355 }
356 356
357 void QChart::zoomIn2(double factor)
358 {
359 d_ptr->zoomIn2(factor);
360 }
361
357 362 /*!
358 363 Zooms in the view to a maximum level at which \a rect is still fully visible.
359 364 \note This is not supported for polar charts.
@@ -373,6 +378,11 void QChart::zoomOut()
373 378 d_ptr->zoomOut(2.0);
374 379 }
375 380
381 void QChart::zoomOut2(double factor)
382 {
383 d_ptr->zoomOut2(factor);
384 }
385
376 386 /*!
377 387 Zooms in the view by a custom \a factor.
378 388
@@ -834,6 +844,14 void QChartPrivate::zoomIn(qreal factor)
834 844 zoomIn(rect);
835 845 }
836 846
847 void QChartPrivate::zoomIn2(qreal factor)
848 {
849 QRectF rect = m_presenter->geometry();
850 rect.setWidth(rect.width() / factor);
851 rect.moveCenter(m_presenter->geometry().center());
852 zoomIn(rect);
853 }
854
837 855 void QChartPrivate::zoomIn(const QRectF &rect)
838 856 {
839 857 if (!rect.isValid())
@@ -879,6 +897,24 void QChartPrivate::zoomOut(qreal factor)
879 897 m_presenter->setState(ChartPresenter::ShowState,QPointF());
880 898 }
881 899
900 void QChartPrivate::zoomOut2(qreal factor)
901 {
902 const QRectF geometry = m_presenter->geometry();
903
904 QRectF r;
905 QSizeF size = geometry.size();
906 size.setWidth(size.width()/factor);
907 r.setSize(size);
908 r.moveCenter(QPointF(geometry.size().width()/2 ,geometry.size().height()/2));
909 if (!r.isValid())
910 return;
911
912 QPointF zoomPoint(r.center().x() / geometry.width(), r.center().y() / geometry.height());
913 m_presenter->setState(ChartPresenter::ZoomOutState,zoomPoint);
914 m_dataset->zoomOutDomain(r);
915 m_presenter->setState(ChartPresenter::ShowState,QPointF());
916 }
917
882 918 void QChartPrivate::scroll(qreal dx, qreal dy)
883 919 {
884 920 if (dx < 0) m_presenter->setState(ChartPresenter::ScrollLeftState,QPointF());
@@ -147,7 +147,9 public:
147 147 QEasingCurve animationEasingCurve() const;
148 148
149 149 void zoomIn();
150 void zoomIn2(double factor);
150 151 void zoomOut();
152 void zoomOut2(double factor);
151 153
152 154 void zoomIn(const QRectF &rect);
153 155 void zoom(qreal factor);
@@ -68,7 +68,9 public:
68 68
69 69 void init();
70 70 void zoomIn(qreal factor);
71 void zoomIn2(qreal factor);
71 72 void zoomOut(qreal factor);
73 void zoomOut2(qreal factor);
72 74 void zoomIn(const QRectF &rect);
73 75 void zoomReset();
74 76 bool isZoomed();
General Comments 0
You need to be logged in to leave comments. Login now