| 554 | } |
| 555 | |
| 556 | void WorksheetElementTest::referenceLineSquareScaling() { |
| 557 | Project project; |
| 558 | |
| 559 | auto* worksheet = new Worksheet(QStringLiteral("Worksheet")); |
| 560 | project.addChild(worksheet); |
| 561 | |
| 562 | auto* plot = new CartesianPlot(QStringLiteral("plot")); |
| 563 | worksheet->addChild(plot); |
| 564 | plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 565 | plot->setNiceExtend(true); |
| 566 | |
| 567 | const auto& axes = plot->children<Axis>(); |
| 568 | QCOMPARE(axes.length(), 2); |
| 569 | QCOMPARE(axes.at(0)->name(), QStringLiteral("x")); |
| 570 | QCOMPARE(axes.at(1)->name(), QStringLiteral("y")); |
| 571 | auto* xAxis = axes.at(0); |
| 572 | |
| 573 | CHECK_RANGE(plot, xAxis, Dimension::X, 0., 1.); |
| 574 | CHECK_RANGE(plot, xAxis, Dimension::Y, 0., 1.); |
| 575 | |
| 576 | plot->setRangeScale(Dimension::X, 0, RangeT::Scale::Square); |
| 577 | |
| 578 | CHECK_RANGE(plot, xAxis, Dimension::X, 0.01, 1.); |
| 579 | CHECK_RANGE(plot, xAxis, Dimension::Y, 0., 1.); |
| 580 | |
| 581 | auto* referenceLine = new ReferenceLine(plot, QStringLiteral("TestLine")); |
| 582 | referenceLine->setOrientation(ReferenceLine::Orientation::Horizontal); |
| 583 | plot->addChild(referenceLine); |
| 584 | referenceLine->retransform(); |
| 585 | |
| 586 | const auto& rect = plot->dataRect(); |
| 587 | |
| 588 | QCOMPARE(qAbs(referenceLine->d_func()->length), rect.width()); |
| 589 | QCOMPARE(referenceLine->d_func()->pos().x(), rect.center().x()); |
| 590 | } |
| 591 | |
| 592 | void WorksheetElementTest::referenceLineSqrtScaling() { |
| 593 | Project project; |
nothing calls this directly
no test coverage detected