| 1096 | } |
| 1097 | |
| 1098 | void RetransformTest::TestChangePlotRange() { |
| 1099 | RetransformCallCounter c; |
| 1100 | Project project; |
| 1101 | |
| 1102 | auto* sheet = new Spreadsheet(QStringLiteral("Spreadsheet"), false); |
| 1103 | sheet->setColumnCount(2); |
| 1104 | sheet->setRowCount(100); |
| 1105 | |
| 1106 | QVector<int> xData; |
| 1107 | QVector<double> yData; |
| 1108 | for (int i = 0; i < 100; i++) { |
| 1109 | xData.append(i); |
| 1110 | yData.append(i); |
| 1111 | } |
| 1112 | auto* xColumn = sheet->column(0); |
| 1113 | xColumn->setColumnMode(AbstractColumn::ColumnMode::Integer); |
| 1114 | xColumn->replaceInteger(0, xData); |
| 1115 | auto* yColumn = sheet->column(1); |
| 1116 | yColumn->setColumnMode(AbstractColumn::ColumnMode::Double); |
| 1117 | yColumn->replaceValues(0, yData); |
| 1118 | |
| 1119 | project.addChild(sheet); |
| 1120 | |
| 1121 | auto* worksheet = new Worksheet(QStringLiteral("Worksheet")); |
| 1122 | project.addChild(worksheet); |
| 1123 | |
| 1124 | auto* p = new CartesianPlot(QStringLiteral("Plot")); |
| 1125 | p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 1126 | worksheet->addChild(p); |
| 1127 | |
| 1128 | auto* curve = new XYCurve(QStringLiteral("curve")); |
| 1129 | p->addChild(curve); |
| 1130 | curve->setXColumn(xColumn); |
| 1131 | curve->setYColumn(yColumn); |
| 1132 | |
| 1133 | auto children = project.children(AspectType::AbstractAspect, AbstractAspect::ChildIndexFlag::Recursive); |
| 1134 | |
| 1135 | // Spreadsheet "Spreadsheet" |
| 1136 | // Column "1" |
| 1137 | // Column "2" |
| 1138 | // Worksheet "Worksheet" |
| 1139 | // CartesianPlot "Plot" |
| 1140 | // Axis "x" |
| 1141 | // Axis "y" |
| 1142 | // XYCurve "curve" |
| 1143 | QCOMPARE(children.length(), 8); |
| 1144 | for (const auto& child : children) |
| 1145 | connect(child, &AbstractAspect::retransformCalledSignal, &c, &RetransformCallCounter::aspectRetransformed); |
| 1146 | |
| 1147 | auto plots = project.children(AspectType::CartesianPlot, AbstractAspect::ChildIndexFlag::Recursive); |
| 1148 | QCOMPARE(plots.length(), 1); |
| 1149 | auto* plot = static_cast<CartesianPlot*>(plots[0]); |
| 1150 | connect(static_cast<CartesianPlot*>(plot), &CartesianPlot::scaleRetransformed, &c, &RetransformCallCounter::retransformScaleCalled); |
| 1151 | |
| 1152 | c.resetRetransformCount(); |
| 1153 | |
| 1154 | auto list = QStringList({// data rect of the plot does not change, so retransforming the |
| 1155 | // plot is not needed |
nothing calls this directly
no test coverage detected