@@ -166,9 +166,10 void QValuesAxis::setRange(qreal min, qreal max) | |||||
166 |
|
166 | |||
167 | if (changed) { |
|
167 | if (changed) { | |
168 | emit rangeChanged(d->m_min,d->m_max); |
|
168 | emit rangeChanged(d->m_min,d->m_max); | |
|
169 | if(!signalsBlocked()){ | |||
169 | emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers); |
|
170 | emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers); | |
170 | } |
|
171 | } | |
171 | // d->setRange(min,max); |
|
172 | } | |
172 | } |
|
173 | } | |
173 |
|
174 | |||
174 | /*! |
|
175 | /*! |
@@ -258,20 +258,48 void ChartDataSet::removeAllSeries() | |||||
258 |
|
258 | |||
259 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) |
|
259 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) | |
260 | { |
|
260 | { | |
|
261 | //for performance reasons block, signals and scale "full" domain one by one. Gives twice less screen updates | |||
|
262 | ||||
|
263 | blockAxisSignals(true); | |||
|
264 | ||||
261 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
265 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
|
266 | ||||
262 | while (i.hasNext()) { |
|
267 | while (i.hasNext()) { | |
263 | i.next(); |
|
268 | i.next(); | |
264 | i.value()->zoomIn(rect,size); |
|
269 | i.value()->zoomIn(rect,size); | |
265 | } |
|
270 | } | |
|
271 | ||||
|
272 | blockAxisSignals(false); | |||
|
273 | ||||
266 | } |
|
274 | } | |
267 |
|
275 | |||
268 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) |
|
276 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) | |
269 | { |
|
277 | { | |
|
278 | //for performance reasons block, signals and scale "full" domain one by one. Gives twice less screen updates | |||
|
279 | ||||
|
280 | blockAxisSignals(true); | |||
|
281 | ||||
270 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
282 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
|
283 | ||||
271 | while (i.hasNext()) { |
|
284 | while (i.hasNext()) { | |
272 | i.next(); |
|
285 | i.next(); | |
273 | i.value()->zoomOut(rect,size); |
|
286 | i.value()->zoomOut(rect,size); | |
274 | } |
|
287 | } | |
|
288 | ||||
|
289 | blockAxisSignals(false); | |||
|
290 | } | |||
|
291 | ||||
|
292 | void ChartDataSet::blockAxisSignals(bool enabled) | |||
|
293 | { | |||
|
294 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |||
|
295 | ||||
|
296 | while (i.hasNext()) { | |||
|
297 | i.next(); | |||
|
298 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); | |||
|
299 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); | |||
|
300 | if(axisX) axisX->blockSignals(enabled); | |||
|
301 | if(axisY) axisY->blockSignals(enabled); | |||
|
302 | } | |||
275 | } |
|
303 | } | |
276 |
|
304 | |||
277 | int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type) |
|
305 | int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type) | |
@@ -395,11 +423,13 Domain* ChartDataSet::domain(QAbstractSeries *series) const | |||||
395 |
|
423 | |||
396 | void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size) |
|
424 | void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size) | |
397 | { |
|
425 | { | |
|
426 | blockAxisSignals(true); | |||
398 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
427 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
399 | while (i.hasNext()) { |
|
428 | while (i.hasNext()) { | |
400 | i.next(); |
|
429 | i.next(); | |
401 | i.value()->move(dx,dy,size); |
|
430 | i.value()->move(dx,dy,size); | |
402 | } |
|
431 | } | |
|
432 | blockAxisSignals(false); | |||
403 | } |
|
433 | } | |
404 |
|
434 | |||
405 | QList<QAbstractSeries*> ChartDataSet::series() const |
|
435 | QList<QAbstractSeries*> ChartDataSet::series() const |
@@ -82,6 +82,7 private: | |||||
82 | void addAxisX(QAbstractAxis* axis,QAbstractSeries* series); |
|
82 | void addAxisX(QAbstractAxis* axis,QAbstractSeries* series); | |
83 | void addAxisY(QAbstractAxis* axis,QAbstractSeries* series); |
|
83 | void addAxisY(QAbstractAxis* axis,QAbstractSeries* series); | |
84 | void removeAxes(QAbstractSeries* series); |
|
84 | void removeAxes(QAbstractSeries* series); | |
|
85 | void blockAxisSignals(bool enabled); | |||
85 |
|
86 | |||
86 | private: |
|
87 | private: | |
87 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisXMap; |
|
88 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisXMap; |
@@ -74,12 +74,11 private Q_SLOTS: | |||||
74 | void domain(); |
|
74 | void domain(); | |
75 | void zoomInDomain_data(); |
|
75 | void zoomInDomain_data(); | |
76 | void zoomInDomain(); |
|
76 | void zoomInDomain(); | |
77 | /* |
|
|||
78 | void zoomOutDomain_data(); |
|
77 | void zoomOutDomain_data(); | |
79 | void zoomOutDomain(); |
|
78 | void zoomOutDomain(); | |
80 | void scrollDomain_data(); |
|
79 | void scrollDomain_data(); | |
81 | void scrollDomain(); |
|
80 | void scrollDomain(); | |
82 | */ |
|
81 | ||
83 | private: |
|
82 | private: | |
84 | ChartDataSet* m_dataset; |
|
83 | ChartDataSet* m_dataset; | |
85 | }; |
|
84 | }; | |
@@ -520,28 +519,22 void tst_ChartDataSet::domain() | |||||
520 |
|
519 | |||
521 | void tst_ChartDataSet::zoomInDomain_data() |
|
520 | void tst_ChartDataSet::zoomInDomain_data() | |
522 | { |
|
521 | { | |
|
522 | QTest::addColumn<bool >("sameAxis"); | |||
523 | QTest::addColumn<QList<QAbstractSeries*> >("seriesList"); |
|
523 | QTest::addColumn<QList<QAbstractSeries*> >("seriesList"); | |
524 | QTest::newRow("line,line, line, spline") << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ); |
|
524 | QTest::newRow("sameAxis: line,line, line, spline") << true << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ); | |
|
525 | QTest::newRow("separeateAxis: line,line, line, spline") << false << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ); | |||
525 | } |
|
526 | } | |
526 |
|
527 | |||
527 | void tst_ChartDataSet::zoomInDomain() |
|
528 | void tst_ChartDataSet::zoomInDomain() | |
528 | { |
|
529 | { | |
|
530 | QFETCH(bool, sameAxis); | |||
529 | QFETCH(QList<QAbstractSeries*>, seriesList); |
|
531 | QFETCH(QList<QAbstractSeries*>, seriesList); | |
530 |
|
532 | |||
531 | foreach(QAbstractSeries* series, seriesList) { |
|
533 | foreach(QAbstractSeries* series, seriesList) { | |
532 | m_dataset->addSeries(series); |
|
534 | m_dataset->addSeries(series); | |
533 | } |
|
535 | } | |
534 |
|
536 | |||
535 | /* |
|
537 | if(sameAxis) m_dataset->createDefaultAxes(); | |
536 | QValuesAxis* axis = new QValuesAxis(); |
|
|||
537 |
|
||||
538 | for (int i = 0; i < seriesList.count(); i++) { |
|
|||
539 | m_dataset->setAxisX(seriesList.at(i), axis); |
|
|||
540 | } |
|
|||
541 | */ |
|
|||
542 | m_dataset->createDefaultAxes(); |
|
|||
543 |
|
||||
544 |
|
||||
545 |
|
538 | |||
546 | QList<QSignalSpy*> spyList; |
|
539 | QList<QSignalSpy*> spyList; | |
547 |
|
540 | |||
@@ -558,79 +551,74 void tst_ChartDataSet::zoomInDomain() | |||||
558 | qDeleteAll(spyList); |
|
551 | qDeleteAll(spyList); | |
559 | } |
|
552 | } | |
560 |
|
553 | |||
561 | /* |
|
554 | ||
|
555 | ||||
562 | void tst_ChartDataSet::zoomOutDomain_data() |
|
556 | void tst_ChartDataSet::zoomOutDomain_data() | |
563 | { |
|
557 | { | |
564 |
|
|
558 | zoomInDomain_data(); | |
565 | } |
|
559 | } | |
566 |
|
560 | |||
567 | void tst_ChartDataSet::zoomOutDomain() |
|
561 | void tst_ChartDataSet::zoomOutDomain() | |
568 | { |
|
562 | { | |
569 |
QFETCH( |
|
563 | QFETCH(bool, sameAxis); | |
570 | QFETCH(QAxis*, axis0); |
|
564 | QFETCH(QList<QAbstractSeries*>, seriesList); | |
571 | QFETCH(QLineSeries*, series1); |
|
|||
572 | QFETCH(QAxis*, axis1); |
|
|||
573 | QFETCH(QLineSeries*, series2); |
|
|||
574 | QFETCH(QAxis*, axis2); |
|
|||
575 | QFETCH(int, axisCount); |
|
|||
576 |
|
565 | |||
577 | Q_UNUSED(axisCount); |
|
566 | foreach(QAbstractSeries* series, seriesList) { | |
|
567 | m_dataset->addSeries(series); | |||
|
568 | } | |||
578 |
|
569 | |||
579 | m_dataset->addSeries(series0, axis0); |
|
570 | if (sameAxis) | |
580 | m_dataset->addSeries(series1, axis1); |
|
571 | m_dataset->createDefaultAxes(); | |
581 | m_dataset->addSeries(series2, axis2); |
|
|||
582 |
|
572 | |||
583 | Domain* domain0 = m_dataset->domain(series0); |
|
573 | QList<QSignalSpy*> spyList; | |
584 | Domain* domain1 = m_dataset->domain(series1); |
|
|||
585 | Domain* domain2 = m_dataset->domain(series2); |
|
|||
586 |
|
574 | |||
587 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
575 | foreach(QAbstractSeries* series, seriesList) { | |
588 |
QSignalSpy |
|
576 | spyList << new QSignalSpy(m_dataset->domain(series), SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
589 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
577 | } | |
590 |
|
578 | |||
591 | m_dataset->zoomOutDomain(QRect(0,0,100,100),QSize(1000,1000)); |
|
579 | m_dataset->zoomOutDomain(QRect(0, 0, 100, 100), QSize(1000, 1000)); | |
592 |
|
580 | |||
593 | TRY_COMPARE(spy0.count(), 1); |
|
581 | foreach(QSignalSpy* spy, spyList) { | |
594 |
TRY_COMPARE(spy |
|
582 | TRY_COMPARE(spy->count(), 1); | |
595 | TRY_COMPARE(spy2.count(), 1); |
|
583 | } | |
|
584 | ||||
|
585 | qDeleteAll (spyList); | |||
596 | } |
|
586 | } | |
597 |
|
587 | |||
598 | void tst_ChartDataSet::scrollDomain_data() |
|
588 | void tst_ChartDataSet::scrollDomain_data() | |
599 | { |
|
589 | { | |
600 |
|
|
590 | zoomInDomain_data(); | |
601 | } |
|
591 | } | |
602 |
|
592 | |||
603 | void tst_ChartDataSet::scrollDomain() |
|
593 | void tst_ChartDataSet::scrollDomain() | |
604 | { |
|
594 | { | |
605 |
QFETCH( |
|
595 | QFETCH(bool, sameAxis); | |
606 | QFETCH(QAxis*, axis0); |
|
596 | QFETCH(QList<QAbstractSeries*>, seriesList); | |
607 | QFETCH(QLineSeries*, series1); |
|
|||
608 | QFETCH(QAxis*, axis1); |
|
|||
609 | QFETCH(QLineSeries*, series2); |
|
|||
610 | QFETCH(QAxis*, axis2); |
|
|||
611 | QFETCH(int, axisCount); |
|
|||
612 |
|
597 | |||
613 | Q_UNUSED(axisCount); |
|
598 | foreach(QAbstractSeries* series, seriesList) { | |
|
599 | m_dataset->addSeries(series); | |||
|
600 | } | |||
614 |
|
601 | |||
615 | m_dataset->addSeries(series0, axis0); |
|
602 | if (sameAxis) | |
616 | m_dataset->addSeries(series1, axis1); |
|
603 | m_dataset->createDefaultAxes(); | |
617 | m_dataset->addSeries(series2, axis2); |
|
|||
618 |
|
604 | |||
619 | Domain* domain0 = m_dataset->domain(series0); |
|
605 | QList<QSignalSpy*> spyList; | |
620 | Domain* domain1 = m_dataset->domain(series1); |
|
|||
621 | Domain* domain2 = m_dataset->domain(series2); |
|
|||
622 |
|
606 | |||
623 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
607 | foreach(QAbstractSeries* series, seriesList) { | |
624 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
608 | spyList | |
625 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
609 | << new QSignalSpy(m_dataset->domain(series), | |
|
610 | SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |||
|
611 | } | |||
626 |
|
612 | |||
627 | m_dataset->scrollDomain(10,10,QSize(1000,1000)); |
|
613 | m_dataset->scrollDomain(10, 10, QSize(1000, 1000)); | |
628 |
|
614 | |||
629 | TRY_COMPARE(spy0.count(), 1); |
|
615 | foreach(QSignalSpy* spy, spyList) { | |
630 |
TRY_COMPARE(spy |
|
616 | TRY_COMPARE(spy->count(), 1); | |
631 | TRY_COMPARE(spy2.count(), 1); |
|
|||
632 | } |
|
617 | } | |
633 | */ |
|
618 | ||
|
619 | qDeleteAll(spyList); | |||
|
620 | } | |||
|
621 | ||||
634 | QTEST_MAIN(tst_ChartDataSet) |
|
622 | QTEST_MAIN(tst_ChartDataSet) | |
635 | #include "tst_chartdataset.moc" |
|
623 | #include "tst_chartdataset.moc" | |
636 |
|
624 |
General Comments 0
You need to be logged in to leave comments.
Login now