! * \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 * */
| 825 | * |
| 826 | */ |
| 827 | void 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 |
nothing calls this directly
no test coverage detected