17 #include "data/model/EditableDenseThreeDimensionalModel.h" 18 #include "data/model/FFTModel.h" 26 SVCERR <<
"Colour3DPlotExporter::Colour3DPlotExporter: constructed at " 32 SVCERR <<
"Colour3DPlotExporter[" <<
this <<
"]::~Colour3DPlotExporter" 39 SVCERR <<
"Colour3DPlotExporter[" <<
this <<
"]::discardSources" 41 QMutexLocker locker(&m_mutex);
57 if (!model || !layer) {
58 SVCERR <<
"ERROR: Colour3DPlotExporter::getDelimitedDataHeaderLine: Source model and layer required" << endl;
63 int sh = model->getHeight();
68 minbin = layer->getIBinForY(provider, provider->getPaintHeight());
69 if (minbin >= sh) minbin = sh - 1;
70 if (minbin < 0) minbin = 0;
72 nbins = layer->getIBinForY(provider, 0) - minbin + 1;
73 if (minbin + nbins > sh) nbins = sh - minbin;
76 QVector<QString> headers;
78 if (opts & DataExportAlwaysIncludeTimestamp) {
79 if (opts & DataExportWriteTimeInFrames) {
87 for (
int i = 0; i < nbins/4; ++i) {
88 headers << QString(
"FREQ %1").arg(i+1)
89 << QString(
"MAG %1").arg(i+1);
92 bool hasValues = model->hasBinValues();
93 QString unit = (hasValues ? model->getBinValueUnit() :
"");
94 for (
int i = minbin; i < minbin + nbins; ++i) {
95 QString name = model->getBinName(i);
99 name = QString(
"BIN %1: %2 %3")
101 .arg(model->getBinValue(i))
104 name = QString(
"BIN %1: %2")
106 .arg(model->getBinValue(i));
109 name = QString(
"BIN %1")
120 QVector<QVector<QString>>
122 sv_frame_t startFrame,
123 sv_frame_t duration)
const 125 QMutexLocker locker(&m_mutex);
137 if (!model || !layer) {
138 SVCERR <<
"ERROR: Colour3DPlotExporter::toDelimitedDataString: Source model and layer required" << endl;
142 SVCERR <<
"ERROR: Colour3DPlotExporter::toDelimitedDataString: FFT model required in peak frequencies mode" << endl;
147 int sh = model->getHeight();
152 minbin = layer->getIBinForY(provider, provider->getPaintHeight());
153 if (minbin >= sh) minbin = sh - 1;
154 if (minbin < 0) minbin = 0;
156 nbins = layer->getIBinForY(provider, 0) - minbin + 1;
157 if (minbin + nbins > sh) nbins = sh - minbin;
160 int w = model->getWidth();
162 QVector<QVector<QString>> rows;
164 for (
int i = 0; i < w; ++i) {
166 sv_frame_t fr = model->
getStartFrame() + i * model->getResolution();
167 if (fr < startFrame || fr >= startFrame + duration) {
173 auto column = model->getColumn(i);
174 column = ColumnOp::Column(column.data() + minbin,
175 column.data() + minbin + nbins);
180 QVector<QString> row;
182 if (opts & DataExportAlwaysIncludeTimestamp) {
183 if (opts & DataExportWriteTimeInFrames) {
184 row << QString(
"%1").arg(fr);
186 row << RealTime::frame2RealTime(fr, model->getSampleRate())
193 FFTModel::PeakSet peaks = fftModel->getPeakFrequencies
194 (FFTModel::AllPeaks, i, minbin, minbin + nbins - 1);
206 for (
const auto &p: peaks) {
214 double freq = p.second;
215 double value = column[bin - minbin];
217 row << QString(
"%1").arg(freq) << QString(
"%1").arg(value);
223 column = ColumnOp::peakPick(column);
226 for (
auto value: column) {
227 row << QString(
"%1").arg(value);
ColumnNormalization normalization
Type of column normalization.
const LayerGeometryProvider * provider
BinDisplay binDisplay
Selection of bins to include in the export.
double gain
Gain that is applied before thresholding, in the display, matching the ColourScale object parameters...
QVector< QVector< QString > > toStringExportRows(DataExportOptions options, sv_frame_t startFrame, sv_frame_t duration) const override
Colour3DPlotExporter(Sources sources, Parameters parameters)
QVector< QString > getStringExportHeaders(DataExportOptions options) const override
double threshold
Threshold below which every value is mapped to background pixel 0 in the display, matching the Colour...
virtual sv_frame_t getStartFrame() const =0
Retrieve the first visible sample frame on the widget.
double scaleFactor
Initial scale factor (e.g.
const VerticalBinLayer * verticalBinLayer