Test if setting curve points on the image result in correct values for logX mapping
| 626 | |
| 627 | // Test if setting curve points on the image result in correct values for logX mapping |
| 628 | void DatapickerTest::logarithmic10XMapping() { |
| 629 | Datapicker datapicker(QStringLiteral("Test")); |
| 630 | auto* image = datapicker.image(); |
| 631 | |
| 632 | // Set reference points |
| 633 | datapicker.addNewPoint(QPointF(3, 10), image); |
| 634 | datapicker.addNewPoint(QPointF(3, 0), image); |
| 635 | datapicker.addNewPoint(QPointF(13, 0), image); |
| 636 | |
| 637 | auto ap = image->axisPoints(); |
| 638 | ap.type = DatapickerImage::GraphType::Log10X; |
| 639 | image->setAxisPoints(ap); |
| 640 | |
| 641 | DatapickerImageWidget w(nullptr); |
| 642 | w.setImages({image}); |
| 643 | w.ui.sbPositionX1->setValue(0); |
| 644 | w.ui.sbPositionY1->setValue(100); |
| 645 | w.ui.sbPositionZ1->setValue(0); |
| 646 | w.ui.sbPositionX2->setValue(0); |
| 647 | w.ui.sbPositionY2->setValue(0); |
| 648 | w.ui.sbPositionZ2->setValue(0); |
| 649 | w.ui.sbPositionX3->setValue(100); |
| 650 | w.ui.sbPositionY3->setValue(0); |
| 651 | w.ui.sbPositionZ3->setValue(0); |
| 652 | w.logicalPositionChanged(); |
| 653 | |
| 654 | auto* curve = new DatapickerCurve(i18n("Curve")); |
| 655 | curve->addDatasheet(image->axisPoints().type); |
| 656 | datapicker.addChild(curve); |
| 657 | |
| 658 | datapicker.addNewPoint(QPointF(5, 6), curve); // updates the curve data |
| 659 | VALUES_EQUAL(curve->posXColumn()->valueAt(0), 0.); // x start is zero, which is not valid therefore the result is 0 |
| 660 | VALUES_EQUAL(curve->posYColumn()->valueAt(0), 0.); // x start is zero, which is not valid therefore the result is 0 |
| 661 | |
| 662 | QCOMPARE(w.ui.sbPositionX1->setValue(1), true); |
| 663 | QCOMPARE(w.ui.sbPositionX2->setValue(1), true); |
| 664 | w.ui.sbPositionX2->valueChanged(1); |
| 665 | QCOMPARE(image->axisPoints().type, DatapickerImage::GraphType::Log10X); |
| 666 | |
| 667 | // Value validated manually, not reverse calculated |
| 668 | VALUES_EQUAL(curve->posXColumn()->valueAt(0), 2.51188635826); // TODO: correct? |
| 669 | VALUES_EQUAL(curve->posYColumn()->valueAt(0), 60.); |
| 670 | } |
| 671 | |
| 672 | // Test if setting curve points on the image result in correct values for logY mapping |
| 673 | void DatapickerTest::logarithmic10YMapping() { |
nothing calls this directly
no test coverage detected