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

Method referenceLineSquareScaling

tests/backend/Worksheet/WorksheetElementTest.cpp:556–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

554}
555
556void 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
592void WorksheetElementTest::referenceLineSqrtScaling() {
593 Project project;

Callers

nothing calls this directly

Calls 12

setNiceExtendMethod · 0.80
lengthMethod · 0.80
dataRectMethod · 0.80
xMethod · 0.80
addChildMethod · 0.45
setTypeMethod · 0.45
nameMethod · 0.45
setRangeScaleMethod · 0.45
setOrientationMethod · 0.45
retransformMethod · 0.45
widthMethod · 0.45
centerMethod · 0.45

Tested by

no test coverage detected