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

Method curveRangeChange

tests/multirange/MultiRangeTest3.cpp:42–100  ·  view source on GitHub ↗

! * \brief MultiRangeTest3::curveRangeChange * When changing the coordinatesystem of an object like a curve, the * curve shall be updated accordingly also for undo/redo */

Source from the content-addressed store, hash-verified

40 * curve shall be updated accordingly also for undo/redo
41 */
42void MultiRangeTest3::curveRangeChange() {
43 Project project;
44 auto* ws = new Worksheet(QStringLiteral("worksheet"));
45 QVERIFY(ws != nullptr);
46 project.addChild(ws);
47
48 auto* plot = new CartesianPlot(QStringLiteral("plot"));
49 QVERIFY(plot != nullptr);
50 ws->addChild(plot);
51
52 auto* curve{new XYEquationCurve(QStringLiteral("f(x)"))};
53 curve->setCoordinateSystemIndex(plot->defaultCoordinateSystemIndex());
54 plot->addChild(curve);
55
56 XYEquationCurve::EquationData data;
57 data.min = QStringLiteral("0");
58 data.max = QStringLiteral("10");
59 data.count = 100;
60 data.expression1 = QStringLiteral("sin(x*2*pi*3)");
61 curve->setEquationData(data);
62 curve->recalculate();
63
64 CHECK_RANGE(plot, curve, Dimension::X, 0., 10.);
65 CHECK_RANGE(plot, curve, Dimension::Y, -1., 1.);
66
67 // Create new cSystem
68 Range<double> yRange;
69 yRange.setFormat(RangeT::Format::Numeric);
70 yRange.setAutoScale(false);
71 yRange.setRange(0, 10);
72 plot->addYRange(yRange);
73 CartesianCoordinateSystem* cSystem = new CartesianCoordinateSystem(plot);
74 cSystem->setIndex(Dimension::X, 0);
75 cSystem->setIndex(Dimension::Y, 1);
76 plot->addCoordinateSystem(cSystem);
77
78 QCOMPARE(plot->coordinateSystemCount(), 2);
79 QCOMPARE(plot->coordinateSystem(1), cSystem);
80
81 CHECK_RANGE(plot, curve, Dimension::X, 0., 10.);
82 CHECK_RANGE(plot, curve, Dimension::Y, -1., 1.);
83
84 curve->setCoordinateSystemIndex(1);
85
86 CHECK_RANGE(plot, curve, Dimension::X, 0., 10.);
87 CHECK_RANGE(plot, curve, Dimension::Y, 0., 10.);
88
89 curve->undoStack()->undo();
90
91 QCOMPARE(curve->coordinateSystemIndex(), 0);
92 CHECK_RANGE(plot, curve, Dimension::X, 0., 10.);
93 CHECK_RANGE(plot, curve, Dimension::Y, -1., 1.);
94
95 curve->undoStack()->redo();
96
97 QCOMPARE(curve->coordinateSystemIndex(), 1);
98 CHECK_RANGE(plot, curve, Dimension::X, 0., 10.);
99 CHECK_RANGE(plot, curve, Dimension::Y, 0., 10.);

Callers

nothing calls this directly

Calls 15

setEquationDataMethod · 0.80
setAutoScaleMethod · 0.80
addCoordinateSystemMethod · 0.80
coordinateSystemIndexMethod · 0.80
addChildMethod · 0.45
recalculateMethod · 0.45
setFormatMethod · 0.45
setRangeMethod · 0.45
addYRangeMethod · 0.45
setIndexMethod · 0.45

Tested by

no test coverage detected