Test if setting curve points on the image result in correct values for lnX mapping
| 492 | |
| 493 | // Test if setting curve points on the image result in correct values for lnX mapping |
| 494 | void DatapickerTest::logarithmicNaturalXMapping() { |
| 495 | Datapicker datapicker(QStringLiteral("Test")); |
| 496 | auto* image = datapicker.image(); |
| 497 | |
| 498 | // Set reference points |
| 499 | datapicker.addNewPoint(QPointF(3, 10), image); |
| 500 | datapicker.addNewPoint(QPointF(3, 0), image); |
| 501 | datapicker.addNewPoint(QPointF(13, 0), image); |
| 502 | |
| 503 | auto ap = image->axisPoints(); |
| 504 | ap.type = DatapickerImage::GraphType::LnX; |
| 505 | image->setAxisPoints(ap); |
| 506 | |
| 507 | DatapickerImageWidget w(nullptr); |
| 508 | w.setImages({image}); |
| 509 | w.ui.sbPositionX1->setValue(0); |
| 510 | w.ui.sbPositionY1->setValue(100); |
| 511 | w.ui.sbPositionZ1->setValue(0); |
| 512 | w.ui.sbPositionX2->setValue(0); |
| 513 | w.ui.sbPositionY2->setValue(0); |
| 514 | w.ui.sbPositionZ2->setValue(0); |
| 515 | w.ui.sbPositionX3->setValue(100); |
| 516 | w.ui.sbPositionY3->setValue(0); |
| 517 | w.ui.sbPositionZ3->setValue(0); |
| 518 | w.logicalPositionChanged(); |
| 519 | |
| 520 | auto* curve = new DatapickerCurve(i18n("Curve")); |
| 521 | curve->addDatasheet(image->axisPoints().type); |
| 522 | datapicker.addChild(curve); |
| 523 | |
| 524 | datapicker.addNewPoint(QPointF(5, 6), curve); // updates the curve data |
| 525 | VALUES_EQUAL(curve->posXColumn()->valueAt(0), 0.); // x start is zero, which is not valid therefore the result is 0 |
| 526 | VALUES_EQUAL(curve->posYColumn()->valueAt(0), 0.); // x start is zero, which is not valid therefore the result is 0 |
| 527 | |
| 528 | QCOMPARE(w.ui.sbPositionX1->setValue(1), true); |
| 529 | QCOMPARE(w.ui.sbPositionX2->setValue(1), true); |
| 530 | w.ui.sbPositionX1->valueChanged(1); // axisPointsChanged will call updatePoint() |
| 531 | |
| 532 | // Value validated manually, not reverse calculated |
| 533 | VALUES_EQUAL(curve->posXColumn()->valueAt(0), 2.51188635826); |
| 534 | VALUES_EQUAL(curve->posYColumn()->valueAt(0), 60.); |
| 535 | } |
| 536 | |
| 537 | // Test if setting curve points on the image result in correct values for lnY mapping |
| 538 | void DatapickerTest::logarithmicNaturalYMapping() { |
nothing calls this directly
no test coverage detected