# HG changeset patch # User Chris Cannam # Date 1586177760 -3600 # Node ID 5aef3f53a4259cbae79aaf7da6cf55a7b8e82eb2 # Parent 1da52d5e67004dc16e99605e5b5514fdbb749682# Parent 32171776fcc9a9a43b023f471757dbfd5b663578 Merge from branch sensible-delimited-data-strings diff -r 1da52d5e6700 -r 5aef3f53a425 layer/Colour3DPlotExporter.cpp --- a/layer/Colour3DPlotExporter.cpp Fri Apr 03 12:12:47 2020 +0100 +++ b/layer/Colour3DPlotExporter.cpp Mon Apr 06 13:56:00 2020 +0100 @@ -45,9 +45,8 @@ m_sources.provider = nullptr; } -QString -Colour3DPlotExporter::getDelimitedDataHeaderLine(QString delimiter, - DataExportOptions opts) const +QVector +Colour3DPlotExporter::getStringExportHeaders(DataExportOptions opts) const { auto model = ModelById::getAs(m_sources.source); @@ -74,19 +73,19 @@ if (minbin + nbins > sh) nbins = sh - minbin; } - QStringList list; + QVector headers; if (opts & DataExportAlwaysIncludeTimestamp) { if (opts & DataExportWriteTimeInFrames) { - list << "FRAME"; + headers << "FRAME"; } else { - list << "TIME"; + headers << "TIME"; } } if (m_params.binDisplay == BinDisplay::PeakFrequencies) { for (int i = 0; i < nbins/4; ++i) { - list << QString("FREQ %1").arg(i+1) + headers << QString("FREQ %1").arg(i+1) << QString("MAG %1").arg(i+1); } } else { @@ -111,18 +110,17 @@ .arg(i+1); } } - list << name; + headers << name; } } - return list.join(delimiter); + return headers; } -QString -Colour3DPlotExporter::toDelimitedDataString(QString delimiter, - DataExportOptions opts, - sv_frame_t startFrame, - sv_frame_t duration) const +QVector> +Colour3DPlotExporter::toStringExportRows(DataExportOptions opts, + sv_frame_t startFrame, + sv_frame_t duration) const { QMutexLocker locker(&m_mutex); @@ -161,7 +159,7 @@ int w = model->getWidth(); - QString s; + QVector> rows; for (int i = 0; i < w; ++i) { @@ -179,13 +177,13 @@ // The scale factor is always applied column = ColumnOp::applyGain(column, m_params.scaleFactor); - QStringList list; - + QVector row; + if (opts & DataExportAlwaysIncludeTimestamp) { if (opts & DataExportWriteTimeInFrames) { - list << QString("%1").arg(fr); + row << QString("%1").arg(fr); } else { - list << RealTime::frame2RealTime(fr, model->getSampleRate()) + row << RealTime::frame2RealTime(fr, model->getSampleRate()) .toString().c_str(); } } @@ -216,7 +214,7 @@ double freq = p.second; double value = column[bin - minbin]; - list << QString("%1").arg(freq) << QString("%1").arg(value); + row << QString("%1").arg(freq) << QString("%1").arg(value); } } else { @@ -226,15 +224,15 @@ } for (auto value: column) { - list << QString("%1").arg(value); + row << QString("%1").arg(value); } } - if (!list.empty()) { - s += list.join(delimiter) + "\n"; + if (!row.empty()) { + rows.push_back(row); } } - return s; + return rows; } diff -r 1da52d5e6700 -r 5aef3f53a425 layer/Colour3DPlotExporter.h --- a/layer/Colour3DPlotExporter.h Fri Apr 03 12:12:47 2020 +0100 +++ b/layer/Colour3DPlotExporter.h Mon Apr 06 13:56:00 2020 +0100 @@ -73,11 +73,13 @@ void discardSources(); - QString getDelimitedDataHeaderLine(QString, DataExportOptions) const override; + QVector + getStringExportHeaders(DataExportOptions options) const override; - QString toDelimitedDataString(QString, DataExportOptions, - sv_frame_t, sv_frame_t) const override; - + QVector> + toStringExportRows(DataExportOptions options, + sv_frame_t startFrame, + sv_frame_t duration) const override; // Further Model methods that we just delegate