Test if setting curve points on the image result in correct values for lnXY mapping
| 580 | |
| 581 | // Test if setting curve points on the image result in correct values for lnXY mapping |
| 582 | void DatapickerTest::logarithmicNaturalXYMapping() { |
| 583 | Datapicker datapicker(QStringLiteral("Test")); |
| 584 | auto* image = datapicker.image(); |
| 585 | |
| 586 | // Set reference points |
| 587 | datapicker.addNewPoint(QPointF(3, 10), image); |
| 588 | datapicker.addNewPoint(QPointF(3, 0), image); |
| 589 | datapicker.addNewPoint(QPointF(13, 0), image); |
| 590 | |
| 591 | auto ap = image->axisPoints(); |
| 592 | ap.type = DatapickerImage::GraphType::LnXY; |
| 593 | image->setAxisPoints(ap); |
| 594 | |
| 595 | DatapickerImageWidget w(nullptr); |
| 596 | w.setImages({image}); |
| 597 | w.ui.sbPositionX1->setValue(0); |
| 598 | w.ui.sbPositionY1->setValue(100); |
| 599 | w.ui.sbPositionZ1->setValue(0); |
| 600 | w.ui.sbPositionX2->setValue(0); |
| 601 | w.ui.sbPositionY2->setValue(0); |
| 602 | w.ui.sbPositionZ2->setValue(0); |
| 603 | w.ui.sbPositionX3->setValue(100); |
| 604 | w.ui.sbPositionY3->setValue(0); |
| 605 | w.ui.sbPositionZ3->setValue(0); |
| 606 | w.logicalPositionChanged(); |
| 607 | |
| 608 | auto* curve = new DatapickerCurve(i18n("Curve")); |
| 609 | curve->addDatasheet(image->axisPoints().type); |
| 610 | datapicker.addChild(curve); |
| 611 | |
| 612 | datapicker.addNewPoint(QPointF(5, 6), curve); // updates the curve data |
| 613 | VALUES_EQUAL(curve->posXColumn()->valueAt(0), 0.); // x start is zero, which is not valid therefore the result is 0 |
| 614 | VALUES_EQUAL(curve->posYColumn()->valueAt(0), 0.); // x start is zero, which is not valid therefore the result is 0 |
| 615 | |
| 616 | QCOMPARE(w.ui.sbPositionX1->setValue(1), true); // axisPointsChanged will call updatePoint() |
| 617 | QCOMPARE(w.ui.sbPositionX2->setValue(1), true); // axisPointsChanged will call updatePoint() |
| 618 | QCOMPARE(w.ui.sbPositionY2->setValue(1), true); // axisPointsChanged will call updatePoint() |
| 619 | QCOMPARE(w.ui.sbPositionY3->setValue(1), true); // axisPointsChanged will call updatePoint() |
| 620 | w.ui.sbPositionY1->valueChanged(1); // axisPointsChanged will call updatePoint() |
| 621 | |
| 622 | // Values validated manually, not reverse calculated |
| 623 | VALUES_EQUAL(curve->posXColumn()->valueAt(0), 2.51188635826); |
| 624 | VALUES_EQUAL(curve->posYColumn()->valueAt(0), 15.8489322662); |
| 625 | } |
| 626 | |
| 627 | // Test if setting curve points on the image result in correct values for logX mapping |
| 628 | void DatapickerTest::logarithmic10XMapping() { |
nothing calls this directly
no test coverage detected