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

Method linearMapping

tests/backend/Datapicker/DatapickerTest.cpp:454–491  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

452
453// Test if setting curve points on the image result in correct values for Linear mapping
454void DatapickerTest::linearMapping() {
455 Datapicker datapicker(QStringLiteral("Test"));
456 auto* image = datapicker.image();
457
458 // Set reference points
459 datapicker.addNewPoint(QPointF(0, 1), image);
460 datapicker.addNewPoint(QPointF(0, 0), image);
461 datapicker.addNewPoint(QPointF(1, 0), image);
462
463 auto ap = image->axisPoints();
464 ap.type = DatapickerImage::GraphType::Linear;
465 image->setAxisPoints(ap);
466
467 DatapickerImageWidget w(nullptr);
468 w.setImages({image});
469 w.ui.sbPositionX1->setValue(0);
470 w.ui.sbPositionY1->setValue(10);
471 w.ui.sbPositionZ1->setValue(0);
472 w.ui.sbPositionX2->setValue(0);
473 w.ui.sbPositionY2->setValue(0);
474 w.ui.sbPositionZ2->setValue(0);
475 w.ui.sbPositionX3->setValue(10);
476 w.ui.sbPositionY3->setValue(0);
477 w.ui.sbPositionZ3->setValue(0);
478 w.logicalPositionChanged();
479
480 auto* curve = new DatapickerCurve(i18n("Curve"));
481 curve->addDatasheet(image->axisPoints().type);
482 datapicker.addChild(curve);
483
484 datapicker.addNewPoint(QPointF(0.5, 0.5), curve); // updates the curve data
485 VALUES_EQUAL(curve->posXColumn()->valueAt(0), 5.);
486 VALUES_EQUAL(curve->posYColumn()->valueAt(0), 5.);
487
488 datapicker.addNewPoint(QPointF(0.7, 0.65), curve); // updates the curve data
489 VALUES_EQUAL(curve->posXColumn()->valueAt(1), 7.);
490 VALUES_EQUAL(curve->posYColumn()->valueAt(1), 6.5);
491}
492
493// Test if setting curve points on the image result in correct values for lnX mapping
494void DatapickerTest::logarithmicNaturalXMapping() {

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected