! * creates a new spreadsheet having the data with the positions and the values of the bins. * the new spreadsheet is added to the current folder. */
| 155 | * the new spreadsheet is added to the current folder. |
| 156 | */ |
| 157 | void Histogram::createDataSpreadsheet() { |
| 158 | if (!bins() || !binValues()) |
| 159 | return; |
| 160 | |
| 161 | auto* spreadsheet = new Spreadsheet(i18n("%1 - Data", name())); |
| 162 | spreadsheet->removeColumns(0, spreadsheet->columnCount()); // remove default columns |
| 163 | spreadsheet->setRowCount(bins()->rowCount()); |
| 164 | |
| 165 | // bin positions |
| 166 | auto* data = static_cast<const Column*>(bins())->data(); |
| 167 | auto* xColumn = new Column(i18n("bin positions"), *static_cast<QVector<double>*>(data)); |
| 168 | xColumn->setPlotDesignation(AbstractColumn::PlotDesignation::X); |
| 169 | spreadsheet->addChild(xColumn); |
| 170 | |
| 171 | // y values |
| 172 | data = static_cast<const Column*>(binValues())->data(); |
| 173 | auto* yColumn = new Column(i18n("bin values"), *static_cast<QVector<double>*>(data)); |
| 174 | yColumn->setPlotDesignation(AbstractColumn::PlotDesignation::Y); |
| 175 | spreadsheet->addChild(yColumn); |
| 176 | |
| 177 | // add the new spreadsheet to the current folder |
| 178 | folder()->addChild(spreadsheet); |
| 179 | } |
| 180 | |
| 181 | QMenu* Histogram::createContextMenu() { |
| 182 | Q_D(const Histogram); |
nothing calls this directly
no test coverage detected