| 590 | } |
| 591 | |
| 592 | void WorksheetElementTest::referenceLineSqrtScaling() { |
| 593 | Project project; |
| 594 | |
| 595 | auto* worksheet = new Worksheet(QStringLiteral("Worksheet")); |
| 596 | project.addChild(worksheet); |
| 597 | |
| 598 | auto* plot = new CartesianPlot(QStringLiteral("plot")); |
| 599 | worksheet->addChild(plot); |
| 600 | plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 601 | plot->setNiceExtend(true); |
| 602 | |
| 603 | const auto& axes = plot->children<Axis>(); |
| 604 | QCOMPARE(axes.length(), 2); |
| 605 | QCOMPARE(axes.at(0)->name(), QStringLiteral("x")); |
| 606 | QCOMPARE(axes.at(1)->name(), QStringLiteral("y")); |
| 607 | auto* xAxis = axes.at(0); |
| 608 | |
| 609 | CHECK_RANGE(plot, xAxis, Dimension::X, 0., 1.); |
| 610 | CHECK_RANGE(plot, xAxis, Dimension::Y, 0., 1.); |
| 611 | |
| 612 | plot->setRangeScale(Dimension::X, 0, RangeT::Scale::Sqrt); |
| 613 | |
| 614 | CHECK_RANGE(plot, xAxis, Dimension::X, 0., 1.); |
| 615 | CHECK_RANGE(plot, xAxis, Dimension::Y, 0., 1.); |
| 616 | |
| 617 | auto* referenceLine = new ReferenceLine(plot, QStringLiteral("TestLine")); |
| 618 | referenceLine->setOrientation(ReferenceLine::Orientation::Horizontal); |
| 619 | plot->addChild(referenceLine); |
| 620 | referenceLine->retransform(); |
| 621 | |
| 622 | const auto& rect = plot->dataRect(); |
| 623 | |
| 624 | QCOMPARE(qAbs(referenceLine->d_func()->length), rect.width()); |
| 625 | QCOMPARE(referenceLine->d_func()->pos().x(), rect.center().x()); |
| 626 | } |
| 627 | |
| 628 | void WorksheetElementTest::referenceLineInverseScaling() { |
| 629 | Project project; |
nothing calls this directly
no test coverage detected