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

Method TestZoom

tests/backend/Retransform/RetransformTest.cpp:757–822  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

755}
756
757void RetransformTest::TestZoom() {
758 RetransformCallCounter c;
759 Project project;
760
761 auto* sheet = new Spreadsheet(QStringLiteral("Spreadsheet"), false);
762 sheet->setColumnCount(2);
763 sheet->setRowCount(100);
764
765 QVector<int> xData;
766 QVector<double> yData;
767 for (int i = 0; i < 100; i++) {
768 xData.append(i);
769 yData.append(i);
770 }
771 auto* xColumn = sheet->column(0);
772 xColumn->setColumnMode(AbstractColumn::ColumnMode::Integer);
773 xColumn->replaceInteger(0, xData);
774 auto* yColumn = sheet->column(1);
775 yColumn->setColumnMode(AbstractColumn::ColumnMode::Double);
776 yColumn->replaceValues(0, yData);
777
778 project.addChild(sheet);
779
780 auto* worksheet = new Worksheet(QStringLiteral("Worksheet - Spreadsheet"));
781 project.addChild(worksheet);
782
783 auto* p = new CartesianPlot(QStringLiteral("Plot - Spreadsheet"));
784 p->setType(CartesianPlot::Type::FourAxes); // Otherwise no axis are created
785 worksheet->addChild(p);
786
787 auto* curve = new XYCurve(QStringLiteral("curve"));
788 p->addChild(curve);
789 curve->setXColumn(xColumn);
790 curve->setYColumn(yColumn);
791
792 auto children = project.children(AspectType::AbstractAspect, AbstractAspect::ChildIndexFlag::Recursive);
793
794 // Spreadsheet "Spreadsheet"
795 // Column "1"
796 // Column "2"
797 // Worksheet "Worksheet-Spreadsheet"
798 // CartesianPlot "Plot-Spreadsheet"
799 // Axis "x"
800 // Axis "x2"
801 // Axis "y"
802 // Axis "y2"
803 // XYCurve "curve"
804 QCOMPARE(children.length(), 10);
805 for (const auto& child : children)
806 connect(child, &AbstractAspect::retransformCalledSignal, &c, &RetransformCallCounter::aspectRetransformed);
807
808 auto plots = project.children(AspectType::CartesianPlot, AbstractAspect::ChildIndexFlag::Recursive);
809 QCOMPARE(plots.length(), 1);
810 auto* plot = static_cast<CartesianPlot*>(plots[0]);
811 connect(static_cast<CartesianPlot*>(plot), &CartesianPlot::scaleRetransformed, &c, &RetransformCallCounter::retransformScaleCalled);
812
813 plot->zoomInX();
814

Callers

nothing calls this directly

Calls 15

appendMethod · 0.80
setYColumnMethod · 0.80
lengthMethod · 0.80
zoomInXMethod · 0.80
setColumnCountMethod · 0.45
setRowCountMethod · 0.45
columnMethod · 0.45
setColumnModeMethod · 0.45
replaceIntegerMethod · 0.45
replaceValuesMethod · 0.45
addChildMethod · 0.45
setTypeMethod · 0.45

Tested by

no test coverage detected