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

Method recreateAxisReferencePoints

tests/backend/Datapicker/DatapickerTest.cpp:1014–1091  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1012}
1013
1014void DatapickerTest::recreateAxisReferencePoints() {
1015 Datapicker datapicker(QStringLiteral("Test"));
1016 auto* image = datapicker.image();
1017
1018 // Set reference points
1019 datapicker.addNewPoint(QPointF(0, 1), image);
1020 datapicker.addNewPoint(QPointF(0, 0), image);
1021 datapicker.addNewPoint(QPointF(1, 0), image);
1022
1023 auto ap = image->axisPoints();
1024 ap.type = DatapickerImage::GraphType::Linear;
1025 image->setAxisPoints(ap);
1026
1027 DatapickerImageWidget w(nullptr);
1028 w.setImages({image});
1029 w.ui.sbPositionX1->setValue(0);
1030 w.ui.sbPositionY1->setValue(10);
1031 w.ui.sbPositionZ1->setValue(0);
1032 w.ui.sbPositionX2->setValue(0);
1033 w.ui.sbPositionY2->setValue(0);
1034 w.ui.sbPositionZ2->setValue(0);
1035 w.ui.sbPositionX3->setValue(10);
1036 w.ui.sbPositionY3->setValue(0);
1037 w.ui.sbPositionZ3->setValue(0);
1038 w.logicalPositionChanged();
1039
1040 auto* curve = new DatapickerCurve(i18n("Curve"));
1041 curve->addDatasheet(image->axisPoints().type);
1042 datapicker.addChild(curve);
1043
1044 datapicker.addNewPoint(QPointF(0.5, 0.5), curve); // updates the curve data
1045 VALUES_EQUAL(curve->posXColumn()->valueAt(0), 5.);
1046 VALUES_EQUAL(curve->posYColumn()->valueAt(0), 5.);
1047
1048 datapicker.addNewPoint(QPointF(0.7, 0.65), curve); // updates the curve data
1049 VALUES_EQUAL(curve->posXColumn()->valueAt(1), 7.);
1050 VALUES_EQUAL(curve->posYColumn()->valueAt(1), 6.5);
1051
1052 // QVERIFY(datapicker.image()->plotPointsType() != DatapickerImage::PointsType::AxisPoints);
1053 // datapicker.image()->setPlotPointsType(DatapickerImage::PointsType::AxisPoints);
1054
1055 datapicker.image()->clearReferencePoints();
1056 QCOMPARE(datapicker.image()->children<DatapickerPoint>(AbstractAspect::ChildIndexFlag::IncludeHidden).count(), 0);
1057
1058 QVERIFY(std::isnan(curve->posXColumn()->valueAt(0)));
1059 QVERIFY(std::isnan(curve->posYColumn()->valueAt(0)));
1060 QVERIFY(std::isnan(curve->posXColumn()->valueAt(1)));
1061 QVERIFY(std::isnan(curve->posYColumn()->valueAt(1)));
1062
1063 // Recreate points again
1064 datapicker.addNewPoint(QPointF(0, 1), image);
1065 datapicker.addNewPoint(QPointF(0, 0), image);
1066 datapicker.addNewPoint(QPointF(1, 0), image);
1067
1068 VALUES_EQUAL(curve->posXColumn()->valueAt(0), 5.);
1069 VALUES_EQUAL(curve->posYColumn()->valueAt(0), 5.);
1070 VALUES_EQUAL(curve->posXColumn()->valueAt(1), 7.);
1071 VALUES_EQUAL(curve->posYColumn()->valueAt(1), 6.5);

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected