From a12d6a605fabba72ac27c612a02b9cd1d9c7ad08 2012-11-26 12:58:47 From: Michal Klocek Date: 2012-11-26 12:58:47 Subject: [PATCH] Fix domain switching --- diff --git a/src/chartdataset.cpp b/src/chartdataset.cpp index 33134f6..165449a 100644 --- a/src/chartdataset.cpp +++ b/src/chartdataset.cpp @@ -189,7 +189,6 @@ bool ChartDataSet::attachAxis(QAbstractSeries* series,QAbstractAxis *axis) if(type == AbstractDomain::UndefinedDomain) return false; - if(domain->type()!=type){ domain = createDomain(type); } @@ -201,8 +200,10 @@ bool ChartDataSet::attachAxis(QAbstractSeries* series,QAbstractAxis *axis) series->d_ptr->m_axes<d_ptr->m_series<d_ptr->setDomain(domain); - series->d_ptr->initializeDomain(); + if(domain!=series->d_ptr->domain()){ + series->d_ptr->setDomain(domain); + series->d_ptr->initializeDomain(); + } series->d_ptr->initializeAxes(); axis->d_ptr->initializeDomain(domain); @@ -397,24 +398,37 @@ QList ChartDataSet::series() const AbstractDomain::DomainType ChartDataSet::selectDomain(QList axes) { enum Type { + Undefined = 0, LogType = 0x1, ValueType = 0x2 }; - int horizontal(ValueType); - int vertical(ValueType); + int horizontal(Undefined); + int vertical(Undefined); foreach(QAbstractAxis* axis, axes) { switch(axis->type()) { case QAbstractAxis::AxisTypeLogValue: - axis->orientation()==Qt::Horizontal?horizontal:vertical|=LogType; + + if(axis->orientation()==Qt::Horizontal) { + horizontal|=LogType; + } + if(axis->orientation()==Qt::Vertical) { + vertical|=LogType; + } + break; case QAbstractAxis::AxisTypeValue: case QAbstractAxis::AxisTypeBarCategory: case QAbstractAxis::AxisTypeCategory: case QAbstractAxis::AxisTypeDateTime: - axis->orientation()==Qt::Horizontal?horizontal:vertical|=ValueType; + if(axis->orientation()==Qt::Horizontal) { + horizontal|=ValueType; + } + if(axis->orientation()==Qt::Vertical) { + vertical|=ValueType; + } break; default: qWarning()<<"Undefined type"; @@ -422,6 +436,9 @@ AbstractDomain::DomainType ChartDataSet::selectDomain(QList axes } } + if(vertical==Undefined) vertical=ValueType; + if(horizontal==Undefined) horizontal=ValueType; + if(vertical==ValueType && horizontal== ValueType) { return AbstractDomain::XYDomain; } diff --git a/src/chartpresenter.cpp b/src/chartpresenter.cpp index 1f16599..a7ae5de 100644 --- a/src/chartpresenter.cpp +++ b/src/chartpresenter.cpp @@ -70,7 +70,6 @@ QRectF ChartPresenter::geometry() const void ChartPresenter::handleAxisAdded(QAbstractAxis *axis) { - qDebug()<<__FUNCTION__; axis->d_ptr->initializeGraphics(rootItem()); axis->d_ptr->initializeAnimations(m_options); ChartAxis *item = axis->d_ptr->axisItem(); @@ -83,7 +82,6 @@ void ChartPresenter::handleAxisAdded(QAbstractAxis *axis) void ChartPresenter::handleAxisRemoved(QAbstractAxis *axis) { - qDebug()<<__FUNCTION__; ChartAxis *item = axis->d_ptr->m_item.take(); item->hide(); item->disconnect(); @@ -96,7 +94,6 @@ void ChartPresenter::handleAxisRemoved(QAbstractAxis *axis) void ChartPresenter::handleSeriesAdded(QAbstractSeries *series) { - qDebug()<<__FUNCTION__; series->d_ptr->initializeGraphics(rootItem()); series->d_ptr->initializeAnimations(m_options); ChartItem *chart = series->d_ptr->chartItem(); @@ -112,7 +109,6 @@ void ChartPresenter::handleSeriesAdded(QAbstractSeries *series) void ChartPresenter::handleSeriesRemoved(QAbstractSeries *series) { - qDebug()<<__FUNCTION__; ChartItem *chart = series->d_ptr->m_item.take(); chart->hide(); chart->disconnect(); diff --git a/src/domain/logxlogydomain.cpp b/src/domain/logxlogydomain.cpp index ed117c4..812eb89 100644 --- a/src/domain/logxlogydomain.cpp +++ b/src/domain/logxlogydomain.cpp @@ -50,6 +50,7 @@ void LogXLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) axisXChanged = true; m_logMinX = log10(m_minX) / log10(m_logBaseX); m_logMaxX = log10(m_maxX) / log10(m_logBaseX); + if(!m_signalsBlocked) emit rangeHorizontalChanged(m_minX, m_maxX); } @@ -59,6 +60,7 @@ void LogXLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) axisYChanged = true; m_logMinY = log10(m_minY) / log10(m_logBaseY); m_logMaxY = log10(m_maxY) / log10(m_logBaseY); + if(!m_signalsBlocked) emit rangeVerticalChanged(m_minY, m_maxY); } diff --git a/src/domain/logxydomain.cpp b/src/domain/logxydomain.cpp index c15c495..a5a846c 100644 --- a/src/domain/logxydomain.cpp +++ b/src/domain/logxydomain.cpp @@ -47,7 +47,7 @@ void LogXYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) axisXChanged = true; m_logMinX = log10(m_minX) / log10(m_logBaseX); m_logMaxX = log10(m_maxX) / log10(m_logBaseX); - + if(!m_signalsBlocked) emit rangeHorizontalChanged(m_minX, m_maxX); } @@ -55,6 +55,7 @@ void LogXYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) m_minY = minY; m_maxY = maxY; axisYChanged = true; + if(!m_signalsBlocked) emit rangeVerticalChanged(m_minY, m_maxY); } diff --git a/src/domain/xlogydomain.cpp b/src/domain/xlogydomain.cpp index 6b79123..79c5b19 100644 --- a/src/domain/xlogydomain.cpp +++ b/src/domain/xlogydomain.cpp @@ -45,6 +45,7 @@ void XLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) m_minX = minX; m_maxX = maxX; axisXChanged = true; + if(!m_signalsBlocked) emit rangeHorizontalChanged(m_minX, m_maxX); } @@ -54,6 +55,7 @@ void XLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) axisYChanged = true; m_logMinY = log10(m_minY) / log10(m_logBaseY); m_logMaxY = log10(m_maxY) / log10(m_logBaseY); + if(!m_signalsBlocked) emit rangeVerticalChanged(m_minY, m_maxY); }