diff --git a/src/chartdataset.cpp b/src/chartdataset.cpp index 165449a..2062015 100644 --- a/src/chartdataset.cpp +++ b/src/chartdataset.cpp @@ -341,7 +341,7 @@ void ChartDataSet::zoomInDomain(const QRectF &rect) QList domains; foreach(QAbstractSeries *s, m_seriesList) { AbstractDomain* domain = s->d_ptr->domain(); - s->d_ptr->m_domain->blockAxisSignals(true); + s->d_ptr->m_domain->blockRangeSignals(true); domains<zoomIn(rect); foreach(AbstractDomain *domain, domains) - domain->blockAxisSignals(false); + domain->blockRangeSignals(false); } void ChartDataSet::zoomOutDomain(const QRectF &rect) @@ -357,7 +357,7 @@ void ChartDataSet::zoomOutDomain(const QRectF &rect) QList domains; foreach(QAbstractSeries *s, m_seriesList) { AbstractDomain* domain = s->d_ptr->domain(); - s->d_ptr->m_domain->blockAxisSignals(true); + s->d_ptr->m_domain->blockRangeSignals(true); domains<zoomOut(rect); foreach(AbstractDomain *domain, domains) - domain->blockAxisSignals(false); + domain->blockRangeSignals(false); } void ChartDataSet::scrollDomain(qreal dx, qreal dy) { QList domains; foreach(QAbstractSeries *s, m_seriesList) { - AbstractDomain* domain = s->d_ptr->m_domain.data(); - if(domains.contains(domain)) continue; - s->d_ptr->m_domain->blockAxisSignals(true); + AbstractDomain* domain = s->d_ptr->domain(); + s->d_ptr->m_domain->blockRangeSignals(true); domains<move(dx, dy); foreach(AbstractDomain *domain, domains) - domain->blockAxisSignals(false); + domain->blockRangeSignals(false); } QList ChartDataSet::axes() const diff --git a/src/domain/abstractdomain.cpp b/src/domain/abstractdomain.cpp index 4915a96..ee87e64 100644 --- a/src/domain/abstractdomain.cpp +++ b/src/domain/abstractdomain.cpp @@ -30,7 +30,7 @@ AbstractDomain::AbstractDomain(QObject *parent) m_maxX(0), m_minY(0), m_maxY(0), - m_axisSignalsBlocked(false) + m_signalsBlocked(false) { } @@ -112,19 +112,23 @@ QPointF AbstractDomain::calculateDomainPoint(const QPointF &point) const void AbstractDomain::handleVerticalAxisRangeChanged(qreal min, qreal max) { - if(!m_axisSignalsBlocked) - setRangeY(min, max); + setRangeY(min, max); } void AbstractDomain::handleHorizontalAxisRangeChanged(qreal min, qreal max) { - if(!m_axisSignalsBlocked) - setRangeX(min, max); + setRangeX(min, max); } -void AbstractDomain::blockAxisSignals(bool block) +void AbstractDomain::blockRangeSignals(bool block) { - m_axisSignalsBlocked=block; + if(m_signalsBlocked!=block){ + m_signalsBlocked=block; + if(!block) { + emit rangeHorizontalChanged(m_minX,m_maxX); + emit rangeVerticalChanged(m_minY,m_maxY); + } + } } //algorithm defined by Paul S.Heckbert GraphicalGems I diff --git a/src/domain/abstractdomain_p.h b/src/domain/abstractdomain_p.h index 04bd7c8..4ef84eb 100644 --- a/src/domain/abstractdomain_p.h +++ b/src/domain/abstractdomain_p.h @@ -69,8 +69,8 @@ public: qreal spanY() const; bool isEmpty() const; - void blockAxisSignals(bool block); - bool axisSignalsBlocked() const { return m_axisSignalsBlocked; } + void blockRangeSignals(bool block); + bool rangeSignalsBlocked() const { return m_signalsBlocked; } friend bool QTCOMMERCIALCHART_AUTOTEST_EXPORT operator== (const AbstractDomain &domain1, const AbstractDomain &domain2); friend bool QTCOMMERCIALCHART_AUTOTEST_EXPORT operator!= (const AbstractDomain &domain1, const AbstractDomain &domain2); @@ -105,7 +105,7 @@ protected: qreal m_minY; qreal m_maxY; QSizeF m_size; - bool m_axisSignalsBlocked; + bool m_signalsBlocked; }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/domain/xydomain.cpp b/src/domain/xydomain.cpp index 1b237cb..6603566 100644 --- a/src/domain/xydomain.cpp +++ b/src/domain/xydomain.cpp @@ -42,14 +42,16 @@ void XYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) m_minX = minX; m_maxX = maxX; axisXChanged = true; - emit rangeHorizontalChanged(m_minX, m_maxX); + if(!m_signalsBlocked) + emit rangeHorizontalChanged(m_minX, m_maxX); } if (!qFuzzyCompare(m_minY, minY) || !qFuzzyCompare(m_maxY, maxY)) { m_minY = minY; m_maxY = maxY; axisYChanged = true; - emit rangeVerticalChanged(m_minY, m_maxY); + if(!m_signalsBlocked) + emit rangeVerticalChanged(m_minY, m_maxY); } if (axisXChanged || axisYChanged)