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

Method zoomInX_SingleRangeDateTimeNonMonotonic

tests/multirange/MultiRangeTest.cpp:360–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358}
359
360void MultiRangeTest::zoomInX_SingleRangeDateTimeNonMonotonic() {
361 Project project;
362 auto* ws = new Worksheet(QStringLiteral("worksheet"));
363 QVERIFY(ws != nullptr);
364 project.addChild(ws);
365
366 auto* view = dynamic_cast<WorksheetView*>(ws->view());
367 QVERIFY(view != nullptr);
368 view->initActions(); // needed by SET_CARTESIAN_MOUSE_MODE()
369
370 Spreadsheet* spreadsheetData = new Spreadsheet(QStringLiteral("data"), false);
371 spreadsheetData->setColumnCount(2);
372 spreadsheetData->setRowCount(3);
373 project.addChild(spreadsheetData);
374 auto* xCol = spreadsheetData->column(0);
375 xCol->setColumnMode(AbstractColumn::ColumnMode::DateTime);
376 QDateTime dt1 = QDateTime::fromString(QStringLiteral("2017-07-10T00:00:00Z"), Qt::ISODate);
377 QDateTime dt2 = QDateTime::fromString(QStringLiteral("2017-07-11T00:00:00Z"), Qt::ISODate);
378 QDateTime dt3 = QDateTime::fromString(QStringLiteral("2017-07-12T00:00:00Z"), Qt::ISODate);
379 QDateTime dt4 = QDateTime::fromString(QStringLiteral("2017-07-15T00:00:00Z"), Qt::ISODate);
380 QDateTime dt5 = QDateTime::fromString(QStringLiteral("2017-07-14T00:00:00Z"), Qt::ISODate); // Nonmonoton
381 QDateTime dt6 = QDateTime::fromString(QStringLiteral("2017-07-15T00:00:00Z"), Qt::ISODate);
382 QDateTime dt7 = QDateTime::fromString(QStringLiteral("2017-07-16T00:00:00Z"), Qt::ISODate);
383 QDateTime dt8 = QDateTime::fromString(QStringLiteral("2017-07-17T00:00:00Z"), Qt::ISODate);
384 QDateTime dt9 = QDateTime::fromString(QStringLiteral("2017-07-18T00:00:00Z"), Qt::ISODate);
385 QDateTime dt10 = QDateTime::fromString(QStringLiteral("2017-07-19T00:00:00Z"), Qt::ISODate);
386 xCol->replaceDateTimes(-1, QVector<QDateTime>({dt1, dt2, dt3, dt4, dt5, dt6, dt7, dt8, dt9, dt10}));
387 auto* yCol = spreadsheetData->column(1);
388 yCol->replaceValues(-1, QVector<double>({2., 3., 4., 5., 6., 7., 8., 9., 10., 11.}));
389
390 auto* p = new CartesianPlot(QStringLiteral("plot"));
391 p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created
392 p->setNiceExtend(false);
393 QVERIFY(p != nullptr);
394 ws->addChild(p);
395
396 auto* curve = new XYCurve(QStringLiteral("curve"));
397 p->addChild(curve);
398 curve->setXColumn(xCol);
399 curve->setYColumn(yCol);
400
401 CHECK_RANGE(p, curve, Dimension::X, (double)dt1.toMSecsSinceEpoch(), (double)dt10.toMSecsSinceEpoch());
402 CHECK_RANGE(p, curve, Dimension::Y, 2., 11.);
403
404 QCOMPARE(p->rangeCount(Dimension::X), 1);
405 QCOMPARE(p->rangeCount(Dimension::Y), 1);
406 QCOMPARE(p->range(Dimension::Y, 0).autoScale(), true);
407
408 const auto& axes = p->children<Axis>();
409 QCOMPARE(axes.count(), 2);
410 QCOMPARE(axes.at(0)->name(), QStringLiteral("x"));
411 axes.at(0)->setSelected(true);
412 SET_CARTESIAN_MOUSE_MODE(CartesianPlot::MouseMode::ZoomXSelection)
413
414 p->mousePressZoomSelectionMode(QPointF((double)dt3.toMSecsSinceEpoch(), 3.), 0);
415 p->mouseMoveZoomSelectionMode(QPointF((double)dt5.addSecs(3600 * 2).toMSecsSinceEpoch(), 3.),
416 0); // Adding an offset, because the error happens only if the exact time is not hit
417 p->mouseReleaseZoomSelectionMode(0);

Callers

nothing calls this directly

Calls 15

setNiceExtendMethod · 0.80
setYColumnMethod · 0.80
rangeMethod · 0.80
QPointFClass · 0.50
addChildMethod · 0.45
viewMethod · 0.45
initActionsMethod · 0.45
setColumnCountMethod · 0.45
setRowCountMethod · 0.45

Tested by

no test coverage detected