MCPcopy Create free account
hub / github.com/KDE/labplot / logarithmicNaturalXMapping

Method logarithmicNaturalXMapping

tests/backend/Datapicker/DatapickerTest.cpp:494–535  ·  view source on GitHub ↗

Test if setting curve points on the image result in correct values for lnX mapping

Source from the content-addressed store, hash-verified

492
493// Test if setting curve points on the image result in correct values for lnX mapping
494void 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
538void DatapickerTest::logarithmicNaturalYMapping() {

Callers

nothing calls this directly

Calls 11

imageMethod · 0.80
addNewPointMethod · 0.80
setAxisPointsMethod · 0.80
addDatasheetMethod · 0.80
QPointFClass · 0.50
setImagesMethod · 0.45
setValueMethod · 0.45
addChildMethod · 0.45
valueAtMethod · 0.45
valueChangedMethod · 0.45

Tested by

no test coverage detected