##// END OF EJS Templates
Fix domain switching
Michal Klocek -
r2288:a12d6a605fab
parent child
Show More
@@ -189,7 +189,6 bool ChartDataSet::attachAxis(QAbstractSeries* series,QAbstractAxis *axis)
189
189
190 if(type == AbstractDomain::UndefinedDomain) return false;
190 if(type == AbstractDomain::UndefinedDomain) return false;
191
191
192
193 if(domain->type()!=type){
192 if(domain->type()!=type){
194 domain = createDomain(type);
193 domain = createDomain(type);
195 }
194 }
@@ -201,8 +200,10 bool ChartDataSet::attachAxis(QAbstractSeries* series,QAbstractAxis *axis)
201 series->d_ptr->m_axes<<axis;
200 series->d_ptr->m_axes<<axis;
202 axis->d_ptr->m_series<<series;
201 axis->d_ptr->m_series<<series;
203
202
203 if(domain!=series->d_ptr->domain()){
204 series->d_ptr->setDomain(domain);
204 series->d_ptr->setDomain(domain);
205 series->d_ptr->initializeDomain();
205 series->d_ptr->initializeDomain();
206 }
206 series->d_ptr->initializeAxes();
207 series->d_ptr->initializeAxes();
207 axis->d_ptr->initializeDomain(domain);
208 axis->d_ptr->initializeDomain(domain);
208
209
@@ -397,24 +398,37 QList<QAbstractSeries *> ChartDataSet::series() const
397 AbstractDomain::DomainType ChartDataSet::selectDomain(QList<QAbstractAxis*> axes)
398 AbstractDomain::DomainType ChartDataSet::selectDomain(QList<QAbstractAxis*> axes)
398 {
399 {
399 enum Type {
400 enum Type {
401 Undefined = 0,
400 LogType = 0x1,
402 LogType = 0x1,
401 ValueType = 0x2
403 ValueType = 0x2
402 };
404 };
403
405
404 int horizontal(ValueType);
406 int horizontal(Undefined);
405 int vertical(ValueType);
407 int vertical(Undefined);
406
408
407 foreach(QAbstractAxis* axis, axes)
409 foreach(QAbstractAxis* axis, axes)
408 {
410 {
409 switch(axis->type()) {
411 switch(axis->type()) {
410 case QAbstractAxis::AxisTypeLogValue:
412 case QAbstractAxis::AxisTypeLogValue:
411 axis->orientation()==Qt::Horizontal?horizontal:vertical|=LogType;
413
414 if(axis->orientation()==Qt::Horizontal) {
415 horizontal|=LogType;
416 }
417 if(axis->orientation()==Qt::Vertical) {
418 vertical|=LogType;
419 }
420
412 break;
421 break;
413 case QAbstractAxis::AxisTypeValue:
422 case QAbstractAxis::AxisTypeValue:
414 case QAbstractAxis::AxisTypeBarCategory:
423 case QAbstractAxis::AxisTypeBarCategory:
415 case QAbstractAxis::AxisTypeCategory:
424 case QAbstractAxis::AxisTypeCategory:
416 case QAbstractAxis::AxisTypeDateTime:
425 case QAbstractAxis::AxisTypeDateTime:
417 axis->orientation()==Qt::Horizontal?horizontal:vertical|=ValueType;
426 if(axis->orientation()==Qt::Horizontal) {
427 horizontal|=ValueType;
428 }
429 if(axis->orientation()==Qt::Vertical) {
430 vertical|=ValueType;
431 }
418 break;
432 break;
419 default:
433 default:
420 qWarning()<<"Undefined type";
434 qWarning()<<"Undefined type";
@@ -422,6 +436,9 AbstractDomain::DomainType ChartDataSet::selectDomain(QList<QAbstractAxis*> axes
422 }
436 }
423 }
437 }
424
438
439 if(vertical==Undefined) vertical=ValueType;
440 if(horizontal==Undefined) horizontal=ValueType;
441
425 if(vertical==ValueType && horizontal== ValueType) {
442 if(vertical==ValueType && horizontal== ValueType) {
426 return AbstractDomain::XYDomain;
443 return AbstractDomain::XYDomain;
427 }
444 }
@@ -70,7 +70,6 QRectF ChartPresenter::geometry() const
70
70
71 void ChartPresenter::handleAxisAdded(QAbstractAxis *axis)
71 void ChartPresenter::handleAxisAdded(QAbstractAxis *axis)
72 {
72 {
73 qDebug()<<__FUNCTION__;
74 axis->d_ptr->initializeGraphics(rootItem());
73 axis->d_ptr->initializeGraphics(rootItem());
75 axis->d_ptr->initializeAnimations(m_options);
74 axis->d_ptr->initializeAnimations(m_options);
76 ChartAxis *item = axis->d_ptr->axisItem();
75 ChartAxis *item = axis->d_ptr->axisItem();
@@ -83,7 +82,6 void ChartPresenter::handleAxisAdded(QAbstractAxis *axis)
83
82
84 void ChartPresenter::handleAxisRemoved(QAbstractAxis *axis)
83 void ChartPresenter::handleAxisRemoved(QAbstractAxis *axis)
85 {
84 {
86 qDebug()<<__FUNCTION__;
87 ChartAxis *item = axis->d_ptr->m_item.take();
85 ChartAxis *item = axis->d_ptr->m_item.take();
88 item->hide();
86 item->hide();
89 item->disconnect();
87 item->disconnect();
@@ -96,7 +94,6 void ChartPresenter::handleAxisRemoved(QAbstractAxis *axis)
96
94
97 void ChartPresenter::handleSeriesAdded(QAbstractSeries *series)
95 void ChartPresenter::handleSeriesAdded(QAbstractSeries *series)
98 {
96 {
99 qDebug()<<__FUNCTION__;
100 series->d_ptr->initializeGraphics(rootItem());
97 series->d_ptr->initializeGraphics(rootItem());
101 series->d_ptr->initializeAnimations(m_options);
98 series->d_ptr->initializeAnimations(m_options);
102 ChartItem *chart = series->d_ptr->chartItem();
99 ChartItem *chart = series->d_ptr->chartItem();
@@ -112,7 +109,6 void ChartPresenter::handleSeriesAdded(QAbstractSeries *series)
112
109
113 void ChartPresenter::handleSeriesRemoved(QAbstractSeries *series)
110 void ChartPresenter::handleSeriesRemoved(QAbstractSeries *series)
114 {
111 {
115 qDebug()<<__FUNCTION__;
116 ChartItem *chart = series->d_ptr->m_item.take();
112 ChartItem *chart = series->d_ptr->m_item.take();
117 chart->hide();
113 chart->hide();
118 chart->disconnect();
114 chart->disconnect();
@@ -50,6 +50,7 void LogXLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY)
50 axisXChanged = true;
50 axisXChanged = true;
51 m_logMinX = log10(m_minX) / log10(m_logBaseX);
51 m_logMinX = log10(m_minX) / log10(m_logBaseX);
52 m_logMaxX = log10(m_maxX) / log10(m_logBaseX);
52 m_logMaxX = log10(m_maxX) / log10(m_logBaseX);
53 if(!m_signalsBlocked)
53 emit rangeHorizontalChanged(m_minX, m_maxX);
54 emit rangeHorizontalChanged(m_minX, m_maxX);
54 }
55 }
55
56
@@ -59,6 +60,7 void LogXLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY)
59 axisYChanged = true;
60 axisYChanged = true;
60 m_logMinY = log10(m_minY) / log10(m_logBaseY);
61 m_logMinY = log10(m_minY) / log10(m_logBaseY);
61 m_logMaxY = log10(m_maxY) / log10(m_logBaseY);
62 m_logMaxY = log10(m_maxY) / log10(m_logBaseY);
63 if(!m_signalsBlocked)
62 emit rangeVerticalChanged(m_minY, m_maxY);
64 emit rangeVerticalChanged(m_minY, m_maxY);
63 }
65 }
64
66
@@ -47,7 +47,7 void LogXYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY)
47 axisXChanged = true;
47 axisXChanged = true;
48 m_logMinX = log10(m_minX) / log10(m_logBaseX);
48 m_logMinX = log10(m_minX) / log10(m_logBaseX);
49 m_logMaxX = log10(m_maxX) / log10(m_logBaseX);
49 m_logMaxX = log10(m_maxX) / log10(m_logBaseX);
50
50 if(!m_signalsBlocked)
51 emit rangeHorizontalChanged(m_minX, m_maxX);
51 emit rangeHorizontalChanged(m_minX, m_maxX);
52 }
52 }
53
53
@@ -55,6 +55,7 void LogXYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY)
55 m_minY = minY;
55 m_minY = minY;
56 m_maxY = maxY;
56 m_maxY = maxY;
57 axisYChanged = true;
57 axisYChanged = true;
58 if(!m_signalsBlocked)
58 emit rangeVerticalChanged(m_minY, m_maxY);
59 emit rangeVerticalChanged(m_minY, m_maxY);
59 }
60 }
60
61
@@ -45,6 +45,7 void XLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY)
45 m_minX = minX;
45 m_minX = minX;
46 m_maxX = maxX;
46 m_maxX = maxX;
47 axisXChanged = true;
47 axisXChanged = true;
48 if(!m_signalsBlocked)
48 emit rangeHorizontalChanged(m_minX, m_maxX);
49 emit rangeHorizontalChanged(m_minX, m_maxX);
49 }
50 }
50
51
@@ -54,6 +55,7 void XLogYDomain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY)
54 axisYChanged = true;
55 axisYChanged = true;
55 m_logMinY = log10(m_minY) / log10(m_logBaseY);
56 m_logMinY = log10(m_minY) / log10(m_logBaseY);
56 m_logMaxY = log10(m_maxY) / log10(m_logBaseY);
57 m_logMaxY = log10(m_maxY) / log10(m_logBaseY);
58 if(!m_signalsBlocked)
57 emit rangeVerticalChanged(m_minY, m_maxY);
59 emit rangeVerticalChanged(m_minY, m_maxY);
58 }
60 }
59
61
General Comments 0
You need to be logged in to leave comments. Login now