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

Method invalidcSystem

tests/cartesianplot/CartesianPlotTest.cpp:827–964  ·  view source on GitHub ↗

! * \brief CartesianPlotTest::invalidcSystem * Plot with 2 CoordinateSystems (with common x range), but the second has invalid start end (0, 0). * This scenario shall not destroy the x range when zooming in * */

Source from the content-addressed store, hash-verified

825 *
826 */
827void CartesianPlotTest::invalidcSystem() {
828 Project project;
829
830 auto* worksheet = new Worksheet(QStringLiteral("Worksheet"));
831 project.addChild(worksheet);
832 auto* view = dynamic_cast<WorksheetView*>(worksheet->view());
833 QVERIFY(view != nullptr);
834 view->initActions(); // needed by SET_CARTESIAN_MOUSE_MODE()
835
836 auto* plot = new CartesianPlot(QStringLiteral("plot"));
837 worksheet->addChild(plot);
838 plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created
839 SET_CARTESIAN_MOUSE_MODE(CartesianPlot::MouseMode::ZoomXSelection) // must be set after the plot was added
840
841 // Create new cSystem
842 Range<double> yRange;
843 yRange.setFormat(RangeT::Format::Numeric);
844 plot->addYRange(yRange);
845 plot->addCoordinateSystem();
846 QCOMPARE(plot->coordinateSystemCount(), 2);
847
848 auto* cSystem{plot->coordinateSystem(1)};
849 cSystem->setIndex(Dimension::Y, 1);
850 plot->setRangeDirty(Dimension::Y, 1, true);
851 plot->retransformScale(Dimension::Y, 1);
852
853 {
854 CHECK_RANGE_CSYSTEMINDEX(plot, 0, Dimension::X, 0., 1.);
855 CHECK_RANGE_CSYSTEMINDEX(plot, 0, Dimension::Y, 0., 1.);
856 CHECK_RANGE_CSYSTEMINDEX(plot, 1, Dimension::X, 0., 1.);
857 CHECK_RANGE_CSYSTEMINDEX(plot, 1, Dimension::Y, 0., 1.);
858 const Range<double> plotSceneRangeX = {plot->dataRect().x(), plot->dataRect().x() + plot->dataRect().width()};
859 const Range<double> plotSceneRangeY = {plot->dataRect().y() + plot->dataRect().height(), plot->dataRect().y()};
860
861 double bx = plotSceneRangeX.size() / (1 - 0);
862 double ax = plotSceneRangeX.start() - bx * 0;
863
864 double by = plotSceneRangeY.size() / (1 - 0);
865 double ay = plotSceneRangeY.start() - by * 0;
866
867 CHECK_SCALE_PLOT(plot, 0, Dimension::X, ax, bx, 0);
868 CHECK_SCALE_PLOT(plot, 0, Dimension::Y, ay, by, 0);
869 CHECK_SCALE_PLOT(plot, 1, Dimension::X, ax, bx, 0);
870 CHECK_SCALE_PLOT(plot, 1, Dimension::Y, ay, by, 0);
871 }
872
873 // Set range of the unused y range
874 Range<double> range;
875 range.setStart(0); // Both are set to the same value
876 range.setEnd(0); // Both are set to the same value
877 range.setFormat(RangeT::Format::Numeric);
878 range.setAutoScale(false);
879 range.setScale(RangeT::Scale::Linear);
880
881 {
882 // plot->setRange(Dimension::Y, 1, range); // does not work
883 // Implementation of setRange() must be used, because setRange() uses check to check if
884 // the range is valid, which it isn't in this test. To test neverthless and not removing a test

Callers

nothing calls this directly

Calls 15

addCoordinateSystemMethod · 0.80
retransformScaleMethod · 0.80
xMethod · 0.80
dataRectMethod · 0.80
heightMethod · 0.80
setAutoScaleMethod · 0.80
scaleAutoMethod · 0.80
mouseModeMethod · 0.80
QPointFClass · 0.50

Tested by

no test coverage detected