annotate layer/Colour3DPlotExporter.h @ 1569:b33b0b06133e

Merge from branch csv-export-dialog
author Chris Cannam
date Tue, 14 Jan 2020 15:48:44 +0000
parents 3943553b95b0
children 9095fbec4e52
rev   line source
Chris@1554 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1554 2
Chris@1554 3 /*
Chris@1554 4 Sonic Visualiser
Chris@1554 5 An audio file viewer and annotation editor.
Chris@1554 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1554 7
Chris@1554 8 This program is free software; you can redistribute it and/or
Chris@1554 9 modify it under the terms of the GNU General Public License as
Chris@1554 10 published by the Free Software Foundation; either version 2 of the
Chris@1554 11 License, or (at your option) any later version. See the file
Chris@1554 12 COPYING included with this distribution for more information.
Chris@1554 13 */
Chris@1554 14
Chris@1554 15 #ifndef COLOUR_3D_PLOT_EXPORTER_H
Chris@1554 16 #define COLOUR_3D_PLOT_EXPORTER_H
Chris@1554 17
Chris@1554 18 #include "Colour3DPlotRenderer.h"
Chris@1554 19
Chris@1554 20 class Colour3DPlotExporter : public Model
Chris@1554 21 {
Chris@1554 22 Q_OBJECT
Chris@1554 23
Chris@1554 24 public:
Chris@1554 25 struct Sources {
Chris@1554 26 // These must all outlive this class, or else discardSources()
Chris@1554 27 // must be called
Chris@1554 28 const VerticalBinLayer *verticalBinLayer; // always
Chris@1554 29 ModelId source; // always; a DenseThreeDimensionalModel
Chris@1554 30 ModelId fft; // optionally; an FFTModel; used for phase/peak-freq modes
Chris@1554 31 const LayerGeometryProvider *provider; // optionally
Chris@1554 32 };
Chris@1554 33
Chris@1554 34 struct Parameters {
Chris@1554 35 Parameters() :
Chris@1561 36 binDisplay(BinDisplay::AllBins),
Chris@1561 37 scaleFactor(1.0),
Chris@1561 38 threshold(0.0),
Chris@1561 39 gain(1.0),
Chris@1568 40 normalization(ColumnNormalization::None) { }
Chris@1554 41
Chris@1554 42 /** Selection of bins to include in the export. */
Chris@1554 43 BinDisplay binDisplay;
Chris@1561 44
Chris@1561 45 /** Initial scale factor (e.g. for FFT scaling). This factor
Chris@1561 46 * is actually applied to exported values, in contrast to the
Chris@1561 47 * gain value below based on the ColourScale parameter. */
Chris@1561 48 double scaleFactor;
Chris@1561 49
Chris@1561 50 /** Threshold below which every value is mapped to background
Chris@1561 51 * pixel 0 in the display, matching the ColourScale object
Chris@1561 52 * parameters. This is used for thresholding in
Chris@1561 53 * peak-frequency output only. */
Chris@1561 54 double threshold;
Chris@1561 55
Chris@1561 56 /** Gain that is applied before thresholding, in the display,
Chris@1561 57 * matching the ColourScale object parameters. This is used
Chris@1561 58 * only to determined the thresholding level. The exported
Chris@1561 59 * values have the scaleFactor applied, but not this gain. */
Chris@1561 60 double gain;
Chris@1561 61
Chris@1561 62 /** Type of column normalization. Again, this is only used to
Chris@1561 63 * calculate thresholding level. The exported values are
Chris@1561 64 * un-normalized. */
Chris@1561 65 ColumnNormalization normalization;
Chris@1554 66 };
Chris@1554 67
Chris@1556 68 Colour3DPlotExporter(Sources sources, Parameters parameters);
Chris@1556 69 ~Colour3DPlotExporter();
Chris@1554 70
Chris@1556 71 void discardSources();
Chris@1565 72
Chris@1565 73 QString getDelimitedDataHeaderLine(QString, DataExportOptions) const override;
Chris@1565 74
Chris@1554 75 QString toDelimitedDataString(QString, DataExportOptions,
Chris@1554 76 sv_frame_t, sv_frame_t) const override;
Chris@1554 77
Chris@1556 78
Chris@1556 79 // Further Model methods that we just delegate
Chris@1556 80
Chris@1556 81 bool isOK() const override {
Chris@1556 82 if (auto model = ModelById::get(m_sources.source)) {
Chris@1556 83 return model->isOK();
Chris@1556 84 }
Chris@1556 85 return false;
Chris@1556 86 }
Chris@1556 87
Chris@1556 88 sv_frame_t getStartFrame() const override {
Chris@1556 89 if (auto model = ModelById::get(m_sources.source)) {
Chris@1556 90 return model->getStartFrame();
Chris@1556 91 }
Chris@1556 92 return 0;
Chris@1556 93 }
Chris@1556 94
Chris@1556 95 sv_frame_t getTrueEndFrame() const override {
Chris@1556 96 if (auto model = ModelById::get(m_sources.source)) {
Chris@1556 97 return model->getTrueEndFrame();
Chris@1556 98 }
Chris@1556 99 return 0;
Chris@1556 100 }
Chris@1556 101
Chris@1556 102 sv_samplerate_t getSampleRate() const override {
Chris@1556 103 if (auto model = ModelById::get(m_sources.source)) {
Chris@1556 104 return model->getSampleRate();
Chris@1556 105 }
Chris@1556 106 return 0;
Chris@1556 107 }
Chris@1556 108
Chris@1556 109 QString getTypeName() const override {
Chris@1556 110 if (auto model = ModelById::get(m_sources.source)) {
Chris@1556 111 return model->getTypeName();
Chris@1556 112 }
Chris@1556 113 return "(exporter)"; // internal fallback, no translation needed
Chris@1556 114 }
Chris@1556 115
Chris@1556 116 int getCompletion() const override {
Chris@1556 117 if (auto model = ModelById::get(m_sources.source)) {
Chris@1556 118 return model->getCompletion();
Chris@1556 119 }
Chris@1556 120 return 0;
Chris@1556 121 }
Chris@1556 122
Chris@1554 123 private:
Chris@1554 124 Sources m_sources;
Chris@1554 125 Parameters m_params;
Chris@1554 126 };
Chris@1554 127
Chris@1554 128 #endif