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

Method wheelEventCenterAxes

tests/cartesianplot/CartesianPlotTest.cpp:1018–1102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1016}
1017
1018void CartesianPlotTest::wheelEventCenterAxes() {
1019 Project project;
1020
1021 auto* worksheet = new Worksheet(QStringLiteral("Worksheet"));
1022 project.addChild(worksheet);
1023 auto* view = dynamic_cast<WorksheetView*>(worksheet->view());
1024 QVERIFY(view != nullptr);
1025 view->initMenus(); // needed by SET_CARTESIAN_MOUSE_MODE()
1026
1027 auto* plot = new CartesianPlot(QStringLiteral("plot"));
1028 worksheet->addChild(plot);
1029 plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created
1030 plot->setNiceExtend(false);
1031
1032 auto* equationCurve{new XYEquationCurve(QStringLiteral("f(x)"))};
1033 equationCurve->setCoordinateSystemIndex(plot->defaultCoordinateSystemIndex());
1034 plot->addChild(equationCurve);
1035
1036 XYEquationCurve::EquationData data;
1037 data.min = QStringLiteral("0");
1038 data.max = QStringLiteral("10");
1039 data.count = 10;
1040 data.expression1 = QStringLiteral("x");
1041 equationCurve->setEquationData(data);
1042 equationCurve->recalculate();
1043
1044 CHECK_RANGE(plot, equationCurve, Dimension::X, 0., 10.);
1045 CHECK_RANGE(plot, equationCurve, Dimension::Y, 0., 10.);
1046
1047 plot->m_zoomFactor = 2;
1048 plot->setNiceExtend(false);
1049 const auto& rect = plot->dataRect();
1050
1051 int signalEmittedCounter = 0;
1052 connect(plot,
1053 &CartesianPlot::wheelEventSignal,
1054 [&signalEmittedCounter](const QPointF& sceneRelPos, int delta, int xIndex, int yIndex, bool considerDimension, Dimension dim) {
1055 signalEmittedCounter++;
1056 if (signalEmittedCounter == 1) {
1057 QCOMPARE(sceneRelPos.x(), 0.5);
1058 QCOMPARE(sceneRelPos.y(), 0.5);
1059 QVERIFY(delta > 0);
1060 QCOMPARE(xIndex, 0);
1061 QCOMPARE(yIndex, 0);
1062 QCOMPARE(considerDimension, true);
1063 QCOMPARE(dim, Dimension::X);
1064 } else {
1065 QCOMPARE(sceneRelPos.x(), 0.5);
1066 QCOMPARE(sceneRelPos.y(), 0.5);
1067 QVERIFY(delta < 0);
1068 QCOMPARE(xIndex, 0);
1069 QCOMPARE(yIndex, 0);
1070 QCOMPARE(considerDimension, true);
1071 QCOMPARE(dim, Dimension::Y);
1072 }
1073 });
1074
1075 const auto& axes = plot->children<Axis>();

Callers

nothing calls this directly

Calls 15

setNiceExtendMethod · 0.80
setEquationDataMethod · 0.80
dataRectMethod · 0.80
xMethod · 0.80
lengthMethod · 0.80
QPointFClass · 0.50
addChildMethod · 0.45
viewMethod · 0.45
initMenusMethod · 0.45
setTypeMethod · 0.45

Tested by

no test coverage detected