| 1102 | } |
| 1103 | |
| 1104 | void CartesianPlotTest::wheelEventNotCenter() { |
| 1105 | Project project; |
| 1106 | |
| 1107 | auto* worksheet = new Worksheet(QStringLiteral("Worksheet")); |
| 1108 | project.addChild(worksheet); |
| 1109 | auto* view = dynamic_cast<WorksheetView*>(worksheet->view()); |
| 1110 | QVERIFY(view != nullptr); |
| 1111 | view->initMenus(); // needed by SET_CARTESIAN_MOUSE_MODE() |
| 1112 | |
| 1113 | auto* plot = new CartesianPlot(QStringLiteral("plot")); |
| 1114 | worksheet->addChild(plot); |
| 1115 | plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 1116 | plot->setNiceExtend(false); |
| 1117 | |
| 1118 | auto* equationCurve{new XYEquationCurve(QStringLiteral("f(x)"))}; |
| 1119 | equationCurve->setCoordinateSystemIndex(plot->defaultCoordinateSystemIndex()); |
| 1120 | plot->addChild(equationCurve); |
| 1121 | |
| 1122 | XYEquationCurve::EquationData data; |
| 1123 | data.min = QStringLiteral("0"); |
| 1124 | data.max = QStringLiteral("10"); |
| 1125 | data.count = 10; |
| 1126 | data.expression1 = QStringLiteral("x"); |
| 1127 | equationCurve->setEquationData(data); |
| 1128 | equationCurve->recalculate(); |
| 1129 | |
| 1130 | CHECK_RANGE(plot, equationCurve, Dimension::X, 0., 10.); |
| 1131 | CHECK_RANGE(plot, equationCurve, Dimension::Y, 0., 10.); |
| 1132 | |
| 1133 | plot->m_zoomFactor = 2; |
| 1134 | plot->setNiceExtend(false); |
| 1135 | const auto& rect = plot->dataRect(); |
| 1136 | |
| 1137 | const auto& axes = plot->children<Axis>(); |
| 1138 | QCOMPARE(axes.length(), 2); |
| 1139 | QCOMPARE(axes.at(0)->name(), QStringLiteral("x")); |
| 1140 | QCOMPARE(axes.at(1)->name(), QStringLiteral("y")); |
| 1141 | auto* xAxis = axes.at(0); |
| 1142 | // const auto* yAxis = axes.at(1); |
| 1143 | |
| 1144 | int signalEmittedCounter = 0; |
| 1145 | connect(plot, |
| 1146 | &CartesianPlot::wheelEventSignal, |
| 1147 | [&signalEmittedCounter](const QPointF& sceneRelPos, int delta, int xIndex, int yIndex, bool considerDimension, Dimension dim) { |
| 1148 | signalEmittedCounter++; |
| 1149 | QCOMPARE(sceneRelPos.x(), 0.75); |
| 1150 | QCOMPARE(sceneRelPos.y(), 0.2); |
| 1151 | QVERIFY(delta > 0); |
| 1152 | QCOMPARE(xIndex, 0); |
| 1153 | QCOMPARE(yIndex, 0); |
| 1154 | QCOMPARE(considerDimension, true); |
| 1155 | QCOMPARE(dim, Dimension::X); |
| 1156 | }); |
| 1157 | |
| 1158 | xAxis->setSelected(true); |
| 1159 | QGraphicsSceneWheelEvent event; |
| 1160 | event.setPos(QPointF(rect.left() + rect.width() * 3 / 4, rect.top() + rect.height() * 0.8)); |
| 1161 | event.setDelta(10); // value not important, only sign |
nothing calls this directly
no test coverage detected