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

Method createDataSpreadsheet

src/backend/worksheet/plots/cartesian/Histogram.cpp:157–179  ·  view source on GitHub ↗

! * 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. */

Source from the content-addressed store, hash-verified

155 * the new spreadsheet is added to the current folder.
156 */
157void 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
181QMenu* Histogram::createContextMenu() {
182 Q_D(const Histogram);

Callers

nothing calls this directly

Calls 7

removeColumnsMethod · 0.45
columnCountMethod · 0.45
setRowCountMethod · 0.45
rowCountMethod · 0.45
dataMethod · 0.45
setPlotDesignationMethod · 0.45
addChildMethod · 0.45

Tested by

no test coverage detected