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

Method curvePointMove

tests/backend/Datapicker/DatapickerTest.cpp:864–906  ·  view source on GitHub ↗

! * check the correctness of the data point after the point was moved on the scene. */

Source from the content-addressed store, hash-verified

862 * check the correctness of the data point after the point was moved on the scene.
863 */
864void DatapickerTest::curvePointMove() {
865 Datapicker datapicker(QStringLiteral("Test"));
866 auto* image = datapicker.image();
867
868 // add reference points
869 datapicker.addNewPoint(QPointF(0, 1), image);
870 datapicker.addNewPoint(QPointF(0, 0), image);
871 datapicker.addNewPoint(QPointF(1, 0), image);
872
873 auto ap = image->axisPoints();
874 ap.type = DatapickerImage::GraphType::Linear;
875 image->setAxisPoints(ap);
876
877 // set logical coordinates for the reference points
878 DatapickerImageWidget w(nullptr);
879 w.setImages({image});
880 w.ui.sbPositionX1->setValue(0);
881 w.ui.sbPositionY1->setValue(10);
882 w.ui.sbPositionZ1->setValue(0);
883 w.ui.sbPositionX2->setValue(0);
884 w.ui.sbPositionY2->setValue(0);
885 w.ui.sbPositionZ2->setValue(0);
886 w.ui.sbPositionX3->setValue(10);
887 w.ui.sbPositionY3->setValue(0);
888 w.ui.sbPositionZ3->setValue(0);
889 w.logicalPositionChanged();
890
891 auto* curve = new DatapickerCurve(i18n("Curve"));
892 curve->addDatasheet(image->axisPoints().type);
893 datapicker.addChild(curve);
894
895 // add new curve point and check its logical coordinates
896 datapicker.addNewPoint(QPointF(0.5, 0.6), curve);
897 VALUES_EQUAL(curve->posXColumn()->valueAt(0), 5.);
898 VALUES_EQUAL(curve->posYColumn()->valueAt(0), 6.);
899
900 // move the last added point to a new position and check its logical coordinates again
901 auto points = curve->children<DatapickerPoint>(AbstractAspect::ChildIndexFlag::IncludeHidden);
902 QCOMPARE(points.count(), 1);
903 points[0]->setPosition(QPointF(0.2, 0.9)); // Changing the position of the point
904 VALUES_EQUAL(curve->posXColumn()->valueAt(0), 2.);
905 VALUES_EQUAL(curve->posYColumn()->valueAt(0), 9.);
906}
907
908/*!
909 * check the correctness of the data point after the point was moved on the scene with undo and redo after this.

Callers

nothing calls this directly

Calls 12

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
countMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected