| 1226 | } |
| 1227 | |
| 1228 | void CartesianPlotTest::wheelEventOutsideBottomRight() { |
| 1229 | Project project; |
| 1230 | |
| 1231 | auto* worksheet = new Worksheet(QStringLiteral("Worksheet")); |
| 1232 | project.addChild(worksheet); |
| 1233 | auto* view = dynamic_cast<WorksheetView*>(worksheet->view()); |
| 1234 | QVERIFY(view != nullptr); |
| 1235 | view->initMenus(); // needed by SET_CARTESIAN_MOUSE_MODE() |
| 1236 | |
| 1237 | auto* plot = new CartesianPlot(QStringLiteral("plot")); |
| 1238 | worksheet->addChild(plot); |
| 1239 | plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 1240 | plot->setNiceExtend(false); |
| 1241 | plot->setHorizontalPadding(Worksheet::convertToSceneUnits(1.5, Worksheet::Unit::Centimeter)); |
| 1242 | plot->setVerticalPadding(Worksheet::convertToSceneUnits(1.5, Worksheet::Unit::Centimeter)); |
| 1243 | plot->setRightPadding(Worksheet::convertToSceneUnits(1.5, Worksheet::Unit::Centimeter)); |
| 1244 | plot->setBottomPadding(Worksheet::convertToSceneUnits(1.5, Worksheet::Unit::Centimeter)); |
| 1245 | |
| 1246 | auto* equationCurve{new XYEquationCurve(QStringLiteral("f(x)"))}; |
| 1247 | equationCurve->setCoordinateSystemIndex(plot->defaultCoordinateSystemIndex()); |
| 1248 | plot->addChild(equationCurve); |
| 1249 | |
| 1250 | XYEquationCurve::EquationData data; |
| 1251 | data.min = QStringLiteral("0"); |
| 1252 | data.max = QStringLiteral("10"); |
| 1253 | data.count = 10; |
| 1254 | data.expression1 = QStringLiteral("x"); |
| 1255 | equationCurve->setEquationData(data); |
| 1256 | equationCurve->recalculate(); |
| 1257 | |
| 1258 | CHECK_RANGE(plot, equationCurve, Dimension::X, 0., 10.); |
| 1259 | CHECK_RANGE(plot, equationCurve, Dimension::Y, 0., 10.); |
| 1260 | |
| 1261 | plot->m_zoomFactor = 2; |
| 1262 | plot->setNiceExtend(false); |
| 1263 | const auto& rect = plot->dataRect(); |
| 1264 | |
| 1265 | int signalEmittedCounter = 0; |
| 1266 | connect(plot, |
| 1267 | &CartesianPlot::wheelEventSignal, |
| 1268 | [&signalEmittedCounter](const QPointF& sceneRelPos, int delta, int xIndex, int yIndex, bool considerDimension, Dimension dim) { |
| 1269 | signalEmittedCounter++; |
| 1270 | QCOMPARE(sceneRelPos.x(), 1.4); |
| 1271 | QCOMPARE(sceneRelPos.y(), -0.7); |
| 1272 | QVERIFY(delta > 0); |
| 1273 | Q_UNUSED(xIndex); |
| 1274 | Q_UNUSED(yIndex); |
| 1275 | QCOMPARE(considerDimension, false); |
| 1276 | Q_UNUSED(dim); |
| 1277 | }); |
| 1278 | |
| 1279 | QGraphicsSceneWheelEvent event; |
| 1280 | event.setPos(QPointF(rect.right() + 280, rect.bottom() + 490)); |
| 1281 | event.setDelta(10); // value not important, only sign |
| 1282 | plot->d_func()->wheelEvent(&event); |
| 1283 | CHECK_RANGE(plot, equationCurve, Dimension::X, 7., 12.); |
| 1284 | CHECK_RANGE(plot, equationCurve, Dimension::Y, -3.5, 1.5); |
| 1285 | QCOMPARE(signalEmittedCounter, 1); |
nothing calls this directly
no test coverage detected