| 1216 | } |
| 1217 | |
| 1218 | void RetransformTest::TestChangePlotRangeElement() { |
| 1219 | // Change the plotrange of one of the elements |
| 1220 | |
| 1221 | RetransformCallCounter c; |
| 1222 | Project project; |
| 1223 | |
| 1224 | auto* sheet = new Spreadsheet(QStringLiteral("Spreadsheet"), false); |
| 1225 | sheet->setColumnCount(2); |
| 1226 | sheet->setRowCount(100); |
| 1227 | |
| 1228 | QVector<int> xData; |
| 1229 | QVector<double> yData; |
| 1230 | for (int i = 0; i < 100; i++) { |
| 1231 | xData.append(i); |
| 1232 | yData.append(i); |
| 1233 | } |
| 1234 | auto* xColumn = sheet->column(0); |
| 1235 | xColumn->setColumnMode(AbstractColumn::ColumnMode::Integer); |
| 1236 | xColumn->replaceInteger(0, xData); |
| 1237 | auto* yColumn = sheet->column(1); |
| 1238 | yColumn->setColumnMode(AbstractColumn::ColumnMode::Double); |
| 1239 | yColumn->replaceValues(0, yData); |
| 1240 | |
| 1241 | project.addChild(sheet); |
| 1242 | |
| 1243 | auto* worksheet = new Worksheet(QStringLiteral("Worksheet")); |
| 1244 | project.addChild(worksheet); |
| 1245 | |
| 1246 | auto* p = new CartesianPlot(QStringLiteral("Plot")); |
| 1247 | p->setType(CartesianPlot::Type::FourAxes); // Otherwise no axis are created |
| 1248 | worksheet->addChild(p); |
| 1249 | |
| 1250 | auto* curve = new XYCurve(QStringLiteral("curve")); |
| 1251 | p->addChild(curve); |
| 1252 | curve->setXColumn(xColumn); |
| 1253 | curve->setYColumn(yColumn); |
| 1254 | |
| 1255 | auto children = project.children(AspectType::AbstractAspect, AbstractAspect::ChildIndexFlag::Recursive); |
| 1256 | |
| 1257 | // Spreadsheet "Spreadsheet" |
| 1258 | // Column "1" |
| 1259 | // Column "2" |
| 1260 | // Worksheet "Worksheet" |
| 1261 | // CartesianPlot "Plot" |
| 1262 | // Axis "x" |
| 1263 | // Axis "x2" |
| 1264 | // Axis "y" |
| 1265 | // Axis "y2" |
| 1266 | // XYCurve "curve" |
| 1267 | QCOMPARE(children.length(), 10); |
| 1268 | for (const auto& child : children) |
| 1269 | connect(child, &AbstractAspect::retransformCalledSignal, &c, &RetransformCallCounter::aspectRetransformed); |
| 1270 | |
| 1271 | auto plots = project.children(AspectType::CartesianPlot, AbstractAspect::ChildIndexFlag::Recursive); |
| 1272 | QCOMPARE(plots.length(), 1); |
| 1273 | auto* plot = static_cast<CartesianPlot*>(plots[0]); |
| 1274 | connect(static_cast<CartesianPlot*>(plot), &CartesianPlot::scaleRetransformed, &c, &RetransformCallCounter::retransformScaleCalled); |
| 1275 |
nothing calls this directly
no test coverage detected