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

Method removeReaddxColum

tests/backend/Retransform/RetransformTest.cpp:2190–2262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2188}
2189
2190void RetransformTest::removeReaddxColum() {
2191 Project project;
2192 auto* ws = new Worksheet(QStringLiteral("worksheet"));
2193 QVERIFY(ws != nullptr);
2194 project.addChild(ws);
2195
2196 auto* sheet = new Spreadsheet(QStringLiteral("Spreadsheet"), false);
2197 sheet->setColumnCount(2);
2198 sheet->setRowCount(11);
2199 project.addChild(sheet);
2200
2201 auto* p = new CartesianPlot(QStringLiteral("plot"));
2202 QVERIFY(p != nullptr);
2203 ws->addChild(p);
2204
2205 auto* curve{new XYEquationCurve(QStringLiteral("f(x)"))};
2206 curve->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex());
2207 p->addChild(curve);
2208
2209 XYEquationCurve::EquationData data;
2210 data.min = QStringLiteral("0");
2211 data.max = QStringLiteral("10");
2212 data.count = 11;
2213 data.expression1 = QStringLiteral("x");
2214 curve->setEquationData(data);
2215 curve->recalculate();
2216
2217 auto* curve2 = new XYCurve(QStringLiteral("curve2"));
2218 p->addChild(curve2);
2219
2220 auto* xColumn = sheet->column(0);
2221 auto* yColumn = sheet->column(1);
2222 {
2223 QVector<int> xData;
2224 QVector<double> yData;
2225 for (int i = 1; i < 11; i++) { // different to the above
2226 xData.append(i);
2227 yData.append(pow(i, 2));
2228 }
2229
2230 xColumn->setColumnMode(AbstractColumn::ColumnMode::Integer);
2231 xColumn->replaceInteger(0, xData);
2232 yColumn->setColumnMode(AbstractColumn::ColumnMode::Double);
2233 yColumn->replaceValues(0, yData);
2234 curve2->setXColumn(xColumn);
2235 curve2->setYColumn(yColumn);
2236 }
2237
2238 CHECK_RANGE(p, curve, Dimension::X, 0., 10.);
2239 CHECK_RANGE(p, curve, Dimension::Y, 0., 100.);
2240
2241 sheet->removeChild(xColumn);
2242
2243 // Curve 2 got invalid
2244 CHECK_RANGE(p, curve, Dimension::X, 0., 10.);
2245 CHECK_RANGE(p, curve, Dimension::Y, 0., 10.);
2246
2247 const auto oldNameXColumn = xColumn->name();

Callers

nothing calls this directly

Calls 15

setEquationDataMethod · 0.80
appendMethod · 0.80
setYColumnMethod · 0.80
addChildMethod · 0.45
setColumnCountMethod · 0.45
setRowCountMethod · 0.45
recalculateMethod · 0.45
columnMethod · 0.45
setColumnModeMethod · 0.45
replaceIntegerMethod · 0.45

Tested by

no test coverage detected