annotate layer/Colour3DPlotExporter.h @ 1573:4e466690bf20

Comments and palette adjustments
author Chris Cannam
date Fri, 17 Jan 2020 13:45:57 +0000
parents 9095fbec4e52
children 32171776fcc9
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@1570 42 /** Selection of bins to include in the export. If a
Chris@1570 43 * LayerGeometryProvider is also included in Sources, then
Chris@1570 44 * the set of bins will also be constrained to the vertical
Chris@1570 45 * range of that. */
Chris@1554 46 BinDisplay binDisplay;
Chris@1561 47
Chris@1561 48 /** Initial scale factor (e.g. for FFT scaling). This factor
Chris@1561 49 * is actually applied to exported values, in contrast to the
Chris@1561 50 * gain value below based on the ColourScale parameter. */
Chris@1561 51 double scaleFactor;
Chris@1561 52
Chris@1561 53 /** Threshold below which every value is mapped to background
Chris@1561 54 * pixel 0 in the display, matching the ColourScale object
Chris@1561 55 * parameters. This is used for thresholding in
Chris@1561 56 * peak-frequency output only. */
Chris@1561 57 double threshold;
Chris@1561 58
Chris@1561 59 /** Gain that is applied before thresholding, in the display,
Chris@1561 60 * matching the ColourScale object parameters. This is used
Chris@1561 61 * only to determined the thresholding level. The exported
Chris@1561 62 * values have the scaleFactor applied, but not this gain. */
Chris@1561 63 double gain;
Chris@1561 64
Chris@1561 65 /** Type of column normalization. Again, this is only used to
Chris@1561 66 * calculate thresholding level. The exported values are
Chris@1561 67 * un-normalized. */
Chris@1561 68 ColumnNormalization normalization;
Chris@1554 69 };
Chris@1554 70
Chris@1556 71 Colour3DPlotExporter(Sources sources, Parameters parameters);
Chris@1556 72 ~Colour3DPlotExporter();
Chris@1554 73
Chris@1556 74 void discardSources();
Chris@1565 75
Chris@1565 76 QString getDelimitedDataHeaderLine(QString, DataExportOptions) const override;
Chris@1565 77
Chris@1554 78 QString toDelimitedDataString(QString, DataExportOptions,
Chris@1554 79 sv_frame_t, sv_frame_t) const override;
Chris@1554 80
Chris@1556 81
Chris@1556 82 // Further Model methods that we just delegate
Chris@1556 83
Chris@1556 84 bool isOK() const override {
Chris@1556 85 if (auto model = ModelById::get(m_sources.source)) {
Chris@1556 86 return model->isOK();
Chris@1556 87 }
Chris@1556 88 return false;
Chris@1556 89 }
Chris@1556 90
Chris@1556 91 sv_frame_t getStartFrame() const override {
Chris@1556 92 if (auto model = ModelById::get(m_sources.source)) {
Chris@1556 93 return model->getStartFrame();
Chris@1556 94 }
Chris@1556 95 return 0;
Chris@1556 96 }
Chris@1556 97
Chris@1556 98 sv_frame_t getTrueEndFrame() const override {
Chris@1556 99 if (auto model = ModelById::get(m_sources.source)) {
Chris@1556 100 return model->getTrueEndFrame();
Chris@1556 101 }
Chris@1556 102 return 0;
Chris@1556 103 }
Chris@1556 104
Chris@1556 105 sv_samplerate_t getSampleRate() const override {
Chris@1556 106 if (auto model = ModelById::get(m_sources.source)) {
Chris@1556 107 return model->getSampleRate();
Chris@1556 108 }
Chris@1556 109 return 0;
Chris@1556 110 }
Chris@1556 111
Chris@1556 112 QString getTypeName() const override {
Chris@1556 113 if (auto model = ModelById::get(m_sources.source)) {
Chris@1556 114 return model->getTypeName();
Chris@1556 115 }
Chris@1556 116 return "(exporter)"; // internal fallback, no translation needed
Chris@1556 117 }
Chris@1556 118
Chris@1556 119 int getCompletion() const override {
Chris@1556 120 if (auto model = ModelById::get(m_sources.source)) {
Chris@1556 121 return model->getCompletion();
Chris@1556 122 }
Chris@1556 123 return 0;
Chris@1556 124 }
Chris@1556 125
Chris@1554 126 private:
Chris@1554 127 Sources m_sources;
Chris@1554 128 Parameters m_params;
Chris@1554 129 };
Chris@1554 130
Chris@1554 131 #endif