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

Method saveLoadInvisiblePoint

tests/backend/InfoElement/InfoElementTest.cpp:1019–1112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1017}
1018
1019void InfoElementTest::saveLoadInvisiblePoint() {
1020 QString savePath;
1021 {
1022 Project project;
1023 auto* ws = new Worksheet(QStringLiteral("worksheet"));
1024 QVERIFY(ws != nullptr);
1025 project.addChild(ws);
1026
1027 auto* p = new CartesianPlot(QStringLiteral("plot"));
1028 QVERIFY(p != nullptr);
1029 ws->addChild(p);
1030
1031 auto* curve{new XYEquationCurve(QStringLiteral("f(x)"))};
1032 curve->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex());
1033 p->addChild(curve);
1034
1035 XYEquationCurve::EquationData data;
1036 data.min = QStringLiteral("0");
1037 data.max = QStringLiteral("10");
1038 data.count = 11;
1039 data.expression1 = QStringLiteral("x");
1040 curve->setEquationData(data);
1041 curve->recalculate();
1042
1043 auto* curve2{new XYEquationCurve(QStringLiteral("f(x^2)"))};
1044 curve2->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex());
1045 p->addChild(curve2);
1046
1047 data.min = QStringLiteral("0");
1048 data.max = QStringLiteral("10");
1049 data.count = 11;
1050 data.expression1 = QStringLiteral("x^2");
1051 curve2->setEquationData(data);
1052 curve2->recalculate();
1053
1054 CHECK_RANGE(p, curve, Dimension::X, 0., 10.);
1055 CHECK_RANGE(p, curve, Dimension::Y, 0., 100.);
1056
1057 auto* ie = new InfoElement(QStringLiteral("InfoElement"), p, curve, 4.9);
1058 QVERIFY(ie != nullptr);
1059 p->addChild(ie);
1060 ie->addCurve(curve2);
1061 {
1062 const auto points = ie->children<CustomPoint>();
1063 points.at(0)->setVisible(false); // Set the custom point invisible. So the line just points to the position
1064 QCOMPARE(ie->markerPointsCount(), 2);
1065 QCOMPARE(points.count(), 2);
1066 QCOMPARE(ie->markerPointAt(0).curve, curve);
1067 QCOMPARE(ie->markerPointAt(0).customPoint, points.at(0));
1068 QCOMPARE(points.at(0)->positionLogical(), QPointF(5, 5));
1069 QCOMPARE(points.at(0)->isVisible(), false);
1070
1071 QCOMPARE(ie->markerPointAt(1).curve, curve2);
1072 QCOMPARE(ie->markerPointAt(1).customPoint, points.at(1));
1073 QCOMPARE(points.at(1)->positionLogical(), QPointF(5, 25));
1074 QCOMPARE(points.at(1)->isVisible(), true);
1075 }
1076

Callers

nothing calls this directly

Calls 14

setEquationDataMethod · 0.80
markerPointsCountMethod · 0.80
markerPointAtMethod · 0.80
QPointFClass · 0.50
addChildMethod · 0.45
recalculateMethod · 0.45
addCurveMethod · 0.45
setVisibleMethod · 0.45
countMethod · 0.45
isVisibleMethod · 0.45

Tested by

no test coverage detected