chartpresenter.cpp
401 lines
| 14.2 KiB
| text/x-c
|
CppLexer
/ src / chartpresenter.cpp
Jani Honkonen
|
r794 | /**************************************************************************** | ||
** | ||||
** Copyright (C) 2012 Digia Plc | ||||
** All rights reserved. | ||||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
** This file is part of the Qt Commercial Charts Add-on. | ||||
** | ||||
** $QT_BEGIN_LICENSE$ | ||||
** Licensees holding valid Qt Commercial licenses may use this file in | ||||
** accordance with the Qt Commercial License Agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
Michal Klocek
|
r139 | #include "qchart.h" | ||
Michal Klocek
|
r140 | #include "qchartaxis.h" | ||
Michal Klocek
|
r131 | #include "chartpresenter_p.h" | ||
#include "chartdataset_p.h" | ||||
Michal Klocek
|
r143 | #include "charttheme_p.h" | ||
Michal Klocek
|
r530 | #include "chartanimator_p.h" | ||
Michal Klocek
|
r139 | //series | ||
sauimone
|
r338 | #include "qbarseries.h" | ||
#include "qstackedbarseries.h" | ||||
#include "qpercentbarseries.h" | ||||
Michal Klocek
|
r349 | #include "qlineseries.h" | ||
Michal Klocek
|
r421 | #include "qareaseries.h" | ||
Jani Honkonen
|
r142 | #include "qpieseries.h" | ||
Tero Ahola
|
r158 | #include "qscatterseries.h" | ||
Marek Rosa
|
r295 | #include "qsplineseries.h" | ||
Michal Klocek
|
r139 | //items | ||
Michal Klocek
|
r140 | #include "axisitem_p.h" | ||
Michal Klocek
|
r421 | #include "areachartitem_p.h" | ||
sauimone
|
r666 | #include "barchartitem_p.h" | ||
#include "stackedbarchartitem_p.h" | ||||
#include "percentbarchartitem_p.h" | ||||
Michal Klocek
|
r145 | #include "linechartitem_p.h" | ||
Jani Honkonen
|
r568 | #include "piechartitem_p.h" | ||
Michal Klocek
|
r470 | #include "scatterchartitem_p.h" | ||
Marek Rosa
|
r460 | #include "splinechartitem_p.h" | ||
Michal Klocek
|
r131 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart), | ||||
Marek Rosa
|
r401 | m_chart(chart), | ||
Michal Klocek
|
r530 | m_animator(0), | ||
Marek Rosa
|
r401 | m_dataset(dataset), | ||
m_chartTheme(0), | ||||
Marek Rosa
|
r418 | m_rect(QRectF(QPoint(0,0),m_chart->size())), | ||
Michal Klocek
|
r645 | m_options(QChart::NoAnimation), | ||
Michal Klocek
|
r742 | m_themeForce(false), | ||
m_backgroundPadding(10) | ||||
Michal Klocek
|
r131 | { | ||
Marek Rosa
|
r401 | createConnections(); | ||
Michal Klocek
|
r740 | setTheme(QChart::ChartThemeDefault,false); | ||
Michal Klocek
|
r131 | } | ||
ChartPresenter::~ChartPresenter() | ||||
{ | ||||
Michal Klocek
|
r531 | delete m_chartTheme; | ||
Michal Klocek
|
r131 | } | ||
Michal Klocek
|
r140 | void ChartPresenter::createConnections() | ||
Michal Klocek
|
r131 | { | ||
QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged())); | ||||
Michal Klocek
|
r439 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),this,SLOT(handleSeriesAdded(QSeries*,Domain*))); | ||
Michal Klocek
|
r360 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),this,SLOT(handleSeriesRemoved(QSeries*))); | ||
Michal Klocek
|
r439 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*,Domain*)),this,SLOT(handleAxisAdded(QChartAxis*,Domain*))); | ||
Michal Klocek
|
r223 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),this,SLOT(handleAxisRemoved(QChartAxis*))); | ||
} | ||||
Michal Klocek
|
r131 | void ChartPresenter::handleGeometryChanged() | ||
{ | ||||
Michal Klocek
|
r439 | QRectF rect(QPoint(0,0),m_chart->size()); | ||
sauimone
|
r803 | QRectF padding = m_chart->padding(); | ||
rect.adjust(padding.left(), padding.top(), -padding.right(), -padding.bottom()); | ||||
Michal Klocek
|
r439 | |||
//rewrite zoom stack | ||||
Michal Klocek
|
r678 | /* | ||
Michal Klocek
|
r439 | for(int i=0;i<m_zoomStack.count();i++){ | ||
QRectF r = m_zoomStack[i]; | ||||
qreal w = rect.width()/m_rect.width(); | ||||
qreal h = rect.height()/m_rect.height(); | ||||
QPointF tl = r.topLeft(); | ||||
tl.setX(tl.x()*w); | ||||
tl.setY(tl.y()*h); | ||||
QPointF br = r.bottomRight(); | ||||
br.setX(br.x()*w); | ||||
br.setY(br.y()*h); | ||||
r.setTopLeft(tl); | ||||
r.setBottomRight(br); | ||||
m_zoomStack[i]=r; | ||||
} | ||||
Michal Klocek
|
r678 | */ | ||
Michal Klocek
|
r439 | m_rect = rect; | ||
Michal Klocek
|
r147 | Q_ASSERT(m_rect.isValid()); | ||
Michal Klocek
|
r139 | emit geometryChanged(m_rect); | ||
} | ||||
Michal Klocek
|
r131 | |||
Michal Klocek
|
r439 | void ChartPresenter::handleAxisAdded(QChartAxis* axis,Domain* domain) | ||
Michal Klocek
|
r223 | { | ||
Michal Klocek
|
r677 | Axis* item = new Axis(axis,this,axis==m_dataset->axisX()?Axis::X_AXIS : Axis::Y_AXIS); | ||
Michal Klocek
|
r298 | |||
Michal Klocek
|
r530 | if(m_options.testFlag(QChart::GridAxisAnimations)){ | ||
m_animator->addAnimation(item); | ||||
Michal Klocek
|
r439 | } | ||
Michal Klocek
|
r530 | |||
Michal Klocek
|
r439 | if(axis==m_dataset->axisX()){ | ||
Michal Klocek
|
r645 | m_chartTheme->decorate(axis,true,m_themeForce); | ||
Michal Klocek
|
r531 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); | ||
Michal Klocek
|
r439 | //initialize | ||
Michal Klocek
|
r531 | item->handleRangeChanged(domain->minX(),domain->maxX(),domain->tickXCount()); | ||
Michal Klocek
|
r562 | |||
Michal Klocek
|
r439 | } | ||
else{ | ||||
Michal Klocek
|
r645 | m_chartTheme->decorate(axis,false,m_themeForce); | ||
Michal Klocek
|
r531 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); | ||
Michal Klocek
|
r439 | //initialize | ||
Michal Klocek
|
r531 | item->handleRangeChanged(domain->minY(),domain->maxY(),domain->tickYCount()); | ||
Michal Klocek
|
r223 | } | ||
Michal Klocek
|
r298 | |||
Michal Klocek
|
r223 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); | ||
Michal Klocek
|
r439 | //initialize | ||
Michal Klocek
|
r259 | item->handleGeometryChanged(m_rect); | ||
Tero Ahola
|
r561 | m_axisItems.insert(axis, item); | ||
Michal Klocek
|
r223 | } | ||
void ChartPresenter::handleAxisRemoved(QChartAxis* axis) | ||||
{ | ||||
Michal Klocek
|
r677 | Axis* item = m_axisItems.take(axis); | ||
Michal Klocek
|
r223 | Q_ASSERT(item); | ||
Michal Klocek
|
r530 | if(m_animator) m_animator->removeAnimation(item); | ||
Michal Klocek
|
r223 | delete item; | ||
} | ||||
Michal Klocek
|
r439 | void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain) | ||
Michal Klocek
|
r131 | { | ||
Michal Klocek
|
r677 | Chart *item = 0 ; | ||
Michal Klocek
|
r531 | |||
Michal Klocek
|
r131 | switch(series->type()) | ||
{ | ||||
Marek Rosa
|
r418 | case QSeries::SeriesTypeLine: { | ||
Marek Rosa
|
r426 | |||
Marek Rosa
|
r418 | QLineSeries* lineSeries = static_cast<QLineSeries*>(series); | ||
Michal Klocek
|
r677 | LineChartItem* line = new LineChartItem(lineSeries,this); | ||
Michal Klocek
|
r531 | if(m_options.testFlag(QChart::SeriesAnimations)) { | ||
m_animator->addAnimation(line); | ||||
Michal Klocek
|
r139 | } | ||
Michal Klocek
|
r645 | m_chartTheme->decorate(lineSeries, m_dataset->seriesIndex(series),m_themeForce); | ||
Michal Klocek
|
r531 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),line,SLOT(handleGeometryChanged(const QRectF&))); | ||
QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),line,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); | ||||
item = line; | ||||
Marek Rosa
|
r426 | break; | ||
} | ||||
Michal Klocek
|
r421 | |||
Marek Rosa
|
r426 | case QSeries::SeriesTypeArea: { | ||
Michal Klocek
|
r139 | |||
Marek Rosa
|
r426 | QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series); | ||
Michal Klocek
|
r677 | AreaChartItem* area = new AreaChartItem(areaSeries,this); | ||
Marek Rosa
|
r426 | if(m_options.testFlag(QChart::SeriesAnimations)) { | ||
Michal Klocek
|
r648 | m_animator->addAnimation(area->upperLineItem()); | ||
if(areaSeries->lowerSeries()) m_animator->addAnimation(area->lowerLineItem()); | ||||
Michal Klocek
|
r131 | } | ||
Michal Klocek
|
r645 | m_chartTheme->decorate(areaSeries, m_dataset->seriesIndex(series),m_themeForce); | ||
Michal Klocek
|
r531 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),area,SLOT(handleGeometryChanged(const QRectF&))); | ||
QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),area,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); | ||||
item=area; | ||||
Marek Rosa
|
r401 | break; | ||
} | ||||
Michal Klocek
|
r139 | |||
Marek Rosa
|
r418 | case QSeries::SeriesTypeBar: { | ||
QBarSeries* barSeries = static_cast<QBarSeries*>(series); | ||||
Michal Klocek
|
r677 | BarChartItem* bar = new BarChartItem(barSeries,this); | ||
Michal Klocek
|
r531 | if(m_options.testFlag(QChart::SeriesAnimations)) { | ||
sauimone
|
r671 | m_animator->addAnimation(bar); | ||
Michal Klocek
|
r531 | } | ||
Michal Klocek
|
r645 | m_chartTheme->decorate(barSeries, m_dataset->seriesIndex(barSeries),m_themeForce); | ||
Michal Klocek
|
r531 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),bar,SLOT(handleGeometryChanged(const QRectF&))); | ||
QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),bar,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); | ||||
item=bar; | ||||
Marek Rosa
|
r401 | break; | ||
} | ||||
Michal Klocek
|
r131 | |||
Marek Rosa
|
r418 | case QSeries::SeriesTypeStackedBar: { | ||
QStackedBarSeries* stackedBarSeries = static_cast<QStackedBarSeries*>(series); | ||||
Michal Klocek
|
r677 | StackedBarChartItem* bar = new StackedBarChartItem(stackedBarSeries,this); | ||
Michal Klocek
|
r531 | if(m_options.testFlag(QChart::SeriesAnimations)) { | ||
sauimone
|
r671 | m_animator->addAnimation(bar); | ||
Michal Klocek
|
r531 | } | ||
Michal Klocek
|
r645 | m_chartTheme->decorate(stackedBarSeries, m_dataset->seriesIndex(stackedBarSeries),m_themeForce); | ||
Michal Klocek
|
r531 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),bar,SLOT(handleGeometryChanged(const QRectF&))); | ||
QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),bar,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); | ||||
item=bar; | ||||
Marek Rosa
|
r401 | break; | ||
} | ||||
Michal Klocek
|
r139 | |||
Marek Rosa
|
r418 | case QSeries::SeriesTypePercentBar: { | ||
QPercentBarSeries* percentBarSeries = static_cast<QPercentBarSeries*>(series); | ||||
Michal Klocek
|
r677 | PercentBarChartItem* bar = new PercentBarChartItem(percentBarSeries,this); | ||
Michal Klocek
|
r531 | if(m_options.testFlag(QChart::SeriesAnimations)) { | ||
sauimone
|
r671 | m_animator->addAnimation(bar); | ||
Michal Klocek
|
r531 | } | ||
Michal Klocek
|
r645 | m_chartTheme->decorate(percentBarSeries, m_dataset->seriesIndex(percentBarSeries),m_themeForce); | ||
Michal Klocek
|
r531 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),bar,SLOT(handleGeometryChanged(const QRectF&))); | ||
QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),bar,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); | ||||
item=bar; | ||||
Marek Rosa
|
r401 | break; | ||
} | ||||
Michal Klocek
|
r476 | |||
Michal Klocek
|
r531 | case QSeries::SeriesTypeScatter: { | ||
QScatterSeries *scatterSeries = static_cast<QScatterSeries *>(series); | ||||
Michal Klocek
|
r677 | ScatterChartItem *scatter = new ScatterChartItem(scatterSeries,this); | ||
Tero Ahola
|
r538 | if(m_options.testFlag(QChart::SeriesAnimations)) { | ||
m_animator->addAnimation(scatter); | ||||
} | ||||
Michal Klocek
|
r645 | m_chartTheme->decorate(scatterSeries, m_dataset->seriesIndex(series),m_themeForce); | ||
Tero Ahola
|
r538 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),scatter,SLOT(handleGeometryChanged(const QRectF&))); | ||
QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),scatter,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); | ||||
item = scatter; | ||||
break; | ||||
Michal Klocek
|
r531 | } | ||
Marek Rosa
|
r418 | |||
Michal Klocek
|
r531 | case QSeries::SeriesTypePie: { | ||
QPieSeries *pieSeries = static_cast<QPieSeries *>(series); | ||||
Michal Klocek
|
r677 | PieChartItem* pie = new PieChartItem(pieSeries, this); | ||
Michal Klocek
|
r531 | if(m_options.testFlag(QChart::SeriesAnimations)) { | ||
Jani Honkonen
|
r618 | m_animator->addAnimation(pie); | ||
Michal Klocek
|
r531 | } | ||
Michal Klocek
|
r645 | m_chartTheme->decorate(pieSeries, m_dataset->seriesIndex(series),m_themeForce); | ||
Michal Klocek
|
r531 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),pie,SLOT(handleGeometryChanged(const QRectF&))); | ||
QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),pie,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); | ||||
Marek Rosa
|
r418 | // Hide all from background when there is only piechart | ||
// TODO: refactor this ugly code... should be one setting for this | ||||
if (m_chartItems.count() == 0) { | ||||
Michal Klocek
|
r534 | m_chart->axisX()->hide(); | ||
m_chart->axisY()->hide(); | ||||
Michal Klocek
|
r131 | } | ||
Michal Klocek
|
r531 | item=pie; | ||
Marek Rosa
|
r401 | break; | ||
} | ||||
Marek Rosa
|
r427 | |||
Marek Rosa
|
r419 | case QSeries::SeriesTypeSpline: { | ||
Tero Ahola
|
r538 | QSplineSeries* splineSeries = static_cast<QSplineSeries*>(series); | ||
Michal Klocek
|
r677 | SplineChartItem* spline = new SplineChartItem(splineSeries, this); | ||
Tero Ahola
|
r538 | if(m_options.testFlag(QChart::SeriesAnimations)) { | ||
m_animator->addAnimation(spline); | ||||
} | ||||
Michal Klocek
|
r645 | m_chartTheme->decorate(splineSeries, m_dataset->seriesIndex(series),m_themeForce); | ||
Tero Ahola
|
r538 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),spline,SLOT(handleGeometryChanged(const QRectF&))); | ||
QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),spline,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); | ||||
item=spline; | ||||
break; | ||||
} | ||||
Marek Rosa
|
r401 | default: { | ||
qDebug()<< "Series type" << series->type() << "not implemented."; | ||||
Marek Rosa
|
r295 | break; | ||
} | ||||
Michal Klocek
|
r131 | } | ||
Michal Klocek
|
r439 | |||
Michal Klocek
|
r531 | //initialize | ||
item->handleDomainChanged(domain->minX(),domain->maxX(),domain->minY(),domain->maxY()); | ||||
if(m_rect.isValid()) item->handleGeometryChanged(m_rect); | ||||
m_chartItems.insert(series,item); | ||||
Michal Klocek
|
r131 | } | ||
Michal Klocek
|
r360 | void ChartPresenter::handleSeriesRemoved(QSeries* series) | ||
Michal Klocek
|
r139 | { | ||
Michal Klocek
|
r677 | Chart* item = m_chartItems.take(series); | ||
Michal Klocek
|
r530 | Q_ASSERT(item); | ||
Michal Klocek
|
r560 | if(m_animator) { | ||
//small hack to handle area animations | ||||
if(series->type()==QSeries::SeriesTypeArea){ | ||||
QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series); | ||||
AreaChartItem* area = static_cast<AreaChartItem*>(item); | ||||
m_animator->removeAnimation(area->upperLineItem()); | ||||
Michal Klocek
|
r648 | if(areaSeries->lowerSeries()) m_animator->removeAnimation(area->lowerLineItem()); | ||
Michal Klocek
|
r560 | }else | ||
m_animator->removeAnimation(item); | ||||
} | ||||
Marek Rosa
|
r401 | delete item; | ||
Michal Klocek
|
r139 | } | ||
Michal Klocek
|
r131 | |||
Michal Klocek
|
r740 | void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force) | ||
Michal Klocek
|
r143 | { | ||
Michal Klocek
|
r531 | if(m_chartTheme && m_chartTheme->id() == theme) return; | ||
Michal Klocek
|
r143 | delete m_chartTheme; | ||
Michal Klocek
|
r645 | m_themeForce = force; | ||
Michal Klocek
|
r143 | m_chartTheme = ChartTheme::createTheme(theme); | ||
Michal Klocek
|
r645 | m_chartTheme->decorate(m_chart,m_themeForce); | ||
sauimone
|
r783 | m_chartTheme->decorate(m_chart->legend(),m_themeForce); | ||
Michal Klocek
|
r531 | resetAllElements(); | ||
Michal Klocek
|
r176 | } | ||
Michal Klocek
|
r740 | QChart::ChartTheme ChartPresenter::theme() | ||
Michal Klocek
|
r143 | { | ||
Michal Klocek
|
r153 | return m_chartTheme->id(); | ||
} | ||||
Michal Klocek
|
r298 | void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options) | ||
{ | ||||
if(m_options!=options) { | ||||
m_options=options; | ||||
Michal Klocek
|
r530 | if(m_options!=QChart::NoAnimation && !m_animator) { | ||
m_animator= new ChartAnimator(this); | ||||
Michal Klocek
|
r298 | } | ||
Michal Klocek
|
r531 | resetAllElements(); | ||
Michal Klocek
|
r298 | } | ||
Michal Klocek
|
r530 | |||
Michal Klocek
|
r298 | } | ||
Michal Klocek
|
r531 | void ChartPresenter::resetAllElements() | ||
{ | ||||
QList<QChartAxis*> axisList = m_axisItems.uniqueKeys(); | ||||
QList<QSeries*> seriesList = m_chartItems.uniqueKeys(); | ||||
foreach(QChartAxis* axis, axisList) { | ||||
handleAxisRemoved(axis); | ||||
handleAxisAdded(axis,m_dataset->domain(axis)); | ||||
} | ||||
foreach(QSeries* series, seriesList) { | ||||
handleSeriesRemoved(series); | ||||
handleSeriesAdded(series,m_dataset->domain(series)); | ||||
} | ||||
} | ||||
Michal Klocek
|
r439 | void ChartPresenter::zoomIn() | ||
{ | ||||
QRectF rect = geometry(); | ||||
rect.setWidth(rect.width()/2); | ||||
rect.setHeight(rect.height()/2); | ||||
rect.moveCenter(geometry().center()); | ||||
zoomIn(rect); | ||||
} | ||||
void ChartPresenter::zoomIn(const QRectF& rect) | ||||
{ | ||||
QRectF r = rect.normalized(); | ||||
sauimone
|
r803 | r.translate(-m_chart->padding().topLeft()); | ||
Michal Klocek
|
r531 | if(m_animator) { | ||
QPointF point(r.center().x()/geometry().width(),r.center().y()/geometry().height()); | ||||
m_animator->setState(ChartAnimator::ZoomInState,point); | ||||
} | ||||
Michal Klocek
|
r439 | m_dataset->zoomInDomain(r,geometry().size()); | ||
Michal Klocek
|
r531 | if(m_animator) { | ||
m_animator->setState(ChartAnimator::ShowState); | ||||
} | ||||
Michal Klocek
|
r439 | } | ||
void ChartPresenter::zoomOut() | ||||
{ | ||||
Michal Klocek
|
r531 | if(m_animator) | ||
{ | ||||
m_animator->setState(ChartAnimator::ZoomOutState); | ||||
} | ||||
Michal Klocek
|
r678 | |||
QSizeF size = geometry().size(); | ||||
QRectF rect = geometry(); | ||||
sauimone
|
r803 | rect.translate(-m_chart->padding().topLeft()); | ||
m_dataset->zoomOutDomain(rect.adjusted(size.width()/4,size.height()/4,-size.width()/4,-size.height()/4),size); | ||||
Michal Klocek
|
r678 | //m_dataset->zoomOutDomain(m_zoomStack[m_zoomIndex-1],geometry().size()); | ||
Michal Klocek
|
r531 | if(m_animator){ | ||
m_animator->setState(ChartAnimator::ShowState); | ||||
} | ||||
Michal Klocek
|
r439 | } | ||
Michal Klocek
|
r531 | void ChartPresenter::scroll(int dx,int dy) | ||
{ | ||||
if(m_animator){ | ||||
if(dx<0) m_animator->setState(ChartAnimator::ScrollLeftState,QPointF()); | ||||
if(dx>0) m_animator->setState(ChartAnimator::ScrollRightState,QPointF()); | ||||
if(dy<0) m_animator->setState(ChartAnimator::ScrollUpState,QPointF()); | ||||
if(dy>0) m_animator->setState(ChartAnimator::ScrollDownState,QPointF()); | ||||
} | ||||
m_dataset->scrollDomain(dx,dy,geometry().size()); | ||||
sauimone
|
r547 | if(m_animator){ | ||
Michal Klocek
|
r531 | m_animator->setState(ChartAnimator::ShowState); | ||
} | ||||
} | ||||
Michal Klocek
|
r298 | QChart::AnimationOptions ChartPresenter::animationOptions() const | ||
{ | ||||
return m_options; | ||||
} | ||||
Michal Klocek
|
r143 | |||
Michal Klocek
|
r131 | #include "moc_chartpresenter_p.cpp" | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||