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

Method logarithmicNaturalXYMapping

tests/backend/Datapicker/DatapickerTest.cpp:582–625  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

580
581// Test if setting curve points on the image result in correct values for lnXY mapping
582void 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
628void DatapickerTest::logarithmic10XMapping() {

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