Test if setting curve points on the image result in correct values for logXY mapping
| 716 | |
| 717 | // Test if setting curve points on the image result in correct values for logXY mapping |
| 718 | void DatapickerTest::logarithmic10XYMapping() { |
| 719 | Datapicker datapicker(QStringLiteral("Test")); |
| 720 | auto* image = datapicker.image(); |
| 721 | |
| 722 | // Set reference points |
| 723 | datapicker.addNewPoint(QPointF(3, 10), image); |
| 724 | datapicker.addNewPoint(QPointF(3, 0), image); |
| 725 | datapicker.addNewPoint(QPointF(13, 0), image); |
| 726 | |
| 727 | auto ap = image->axisPoints(); |
| 728 | ap.type = DatapickerImage::GraphType::Log10XY; |
| 729 | image->setAxisPoints(ap); |
| 730 | |
| 731 | DatapickerImageWidget w(nullptr); |
| 732 | w.setImages({image}); |
| 733 | w.ui.sbPositionX1->setValue(0); |
| 734 | w.ui.sbPositionY1->setValue(100); |
| 735 | w.ui.sbPositionZ1->setValue(0); |
| 736 | w.ui.sbPositionX2->setValue(0); |
| 737 | w.ui.sbPositionY2->setValue(0); |
| 738 | w.ui.sbPositionZ2->setValue(0); |
| 739 | w.ui.sbPositionX3->setValue(100); |
| 740 | w.ui.sbPositionY3->setValue(0); |
| 741 | w.ui.sbPositionZ3->setValue(0); |
| 742 | w.logicalPositionChanged(); |
| 743 | |
| 744 | auto* curve = new DatapickerCurve(i18n("Curve")); |
| 745 | curve->addDatasheet(image->axisPoints().type); |
| 746 | datapicker.addChild(curve); |
| 747 | |
| 748 | datapicker.addNewPoint(QPointF(5, 6), curve); // updates the curve data |
| 749 | VALUES_EQUAL(curve->posXColumn()->valueAt(0), 0.); // x start is zero, which is not valid therefore the result is 0 |
| 750 | VALUES_EQUAL(curve->posYColumn()->valueAt(0), 0.); // x start is zero, which is not valid therefore the result is 0 |
| 751 | |
| 752 | QCOMPARE(w.ui.sbPositionX1->setValue(1), true); |
| 753 | QCOMPARE(w.ui.sbPositionX2->setValue(1), true); |
| 754 | QCOMPARE(w.ui.sbPositionY2->setValue(1), true); |
| 755 | QCOMPARE(w.ui.sbPositionY3->setValue(1), true); |
| 756 | w.ui.sbPositionY3->valueChanged(1); // axisPointsChanged will call updatePoint() |
| 757 | // Values validated manually, not reverse calculated |
| 758 | VALUES_EQUAL(curve->posXColumn()->valueAt(0), 2.51188635826); |
| 759 | VALUES_EQUAL(curve->posYColumn()->valueAt(0), 15.8489322662); |
| 760 | } |
| 761 | |
| 762 | /*! |
| 763 | * check the correctness of the data points after one of the reference points was moved on the scene. |
nothing calls this directly
no test coverage detected