Mercurial > hg > svgui
comparison layer/Colour3DPlotExporter.cpp @ 1568:3943553b95b0 csv-export-dialog
Add CSV export dialog, + associated supporting changes
author | Chris Cannam |
---|---|
date | Tue, 14 Jan 2020 15:41:17 +0000 |
parents | a6a31908bd13 |
children | b33b0b06133e |
comparison
equal
deleted
inserted
replaced
1566:1f80a514ce29 | 1568:3943553b95b0 |
---|---|
45 m_sources.provider = nullptr; | 45 m_sources.provider = nullptr; |
46 } | 46 } |
47 | 47 |
48 QString | 48 QString |
49 Colour3DPlotExporter::getDelimitedDataHeaderLine(QString delimiter, | 49 Colour3DPlotExporter::getDelimitedDataHeaderLine(QString delimiter, |
50 DataExportOptions) const | 50 DataExportOptions opts) const |
51 { | 51 { |
52 auto model = | 52 auto model = |
53 ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); | 53 ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); |
54 | 54 |
55 auto layer = m_sources.verticalBinLayer; | 55 auto layer = m_sources.verticalBinLayer; |
74 if (minbin + nbins > sh) nbins = sh - minbin; | 74 if (minbin + nbins > sh) nbins = sh - minbin; |
75 } | 75 } |
76 | 76 |
77 QStringList list; | 77 QStringList list; |
78 | 78 |
79 switch (m_params.timestampFormat) { | 79 if (opts & DataExportAlwaysIncludeTimestamp) { |
80 case TimestampFormat::None: | 80 if (opts & DataExportWriteTimeInFrames) { |
81 break; | 81 list << "FRAME"; |
82 case TimestampFormat::Frames: | 82 } else { |
83 list << "FRAME"; | 83 list << "TIME"; |
84 break; | 84 } |
85 case TimestampFormat::Seconds: | |
86 list << "TIME"; | |
87 break; | |
88 } | 85 } |
89 | 86 |
90 if (m_params.binDisplay == BinDisplay::PeakFrequencies) { | 87 if (m_params.binDisplay == BinDisplay::PeakFrequencies) { |
91 for (int i = 0; i < nbins/4; ++i) { | 88 for (int i = 0; i < nbins/4; ++i) { |
92 list << QString("FREQ %1").arg(i+1) | 89 list << QString("FREQ %1").arg(i+1) |
121 return list.join(delimiter); | 118 return list.join(delimiter); |
122 } | 119 } |
123 | 120 |
124 QString | 121 QString |
125 Colour3DPlotExporter::toDelimitedDataString(QString delimiter, | 122 Colour3DPlotExporter::toDelimitedDataString(QString delimiter, |
126 DataExportOptions, | 123 DataExportOptions opts, |
127 sv_frame_t startFrame, | 124 sv_frame_t startFrame, |
128 sv_frame_t duration) const | 125 sv_frame_t duration) const |
129 { | 126 { |
130 QMutexLocker locker(&m_mutex); | 127 QMutexLocker locker(&m_mutex); |
131 | 128 |
182 // The scale factor is always applied | 179 // The scale factor is always applied |
183 column = ColumnOp::applyGain(column, m_params.scaleFactor); | 180 column = ColumnOp::applyGain(column, m_params.scaleFactor); |
184 | 181 |
185 QStringList list; | 182 QStringList list; |
186 | 183 |
187 switch (m_params.timestampFormat) { | 184 if (opts & DataExportAlwaysIncludeTimestamp) { |
188 case TimestampFormat::None: | 185 if (opts & DataExportWriteTimeInFrames) { |
189 break; | 186 list << QString("%1").arg(fr); |
190 case TimestampFormat::Frames: | 187 } else { |
191 list << QString("%1").arg(fr); | 188 list << RealTime::frame2RealTime(fr, model->getSampleRate()) |
192 break; | 189 .toString().c_str(); |
193 case TimestampFormat::Seconds: | 190 } |
194 list << RealTime::frame2RealTime(fr, model->getSampleRate()) | |
195 .toString().c_str(); | |
196 break; | |
197 } | 191 } |
198 | 192 |
199 if (binDisplay == BinDisplay::PeakFrequencies) { | 193 if (binDisplay == BinDisplay::PeakFrequencies) { |
200 | 194 |
201 FFTModel::PeakSet peaks = fftModel->getPeakFrequencies | 195 FFTModel::PeakSet peaks = fftModel->getPeakFrequencies |