Colour3DPlotExporter.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version. See the file
12  COPYING included with this distribution for more information.
13 */
14 
15 #ifndef COLOUR_3D_PLOT_EXPORTER_H
16 #define COLOUR_3D_PLOT_EXPORTER_H
17 
18 #include "Colour3DPlotRenderer.h"
19 
20 class Colour3DPlotExporter : public Model
21 {
22  Q_OBJECT
23 
24 public:
25  struct Sources {
26  // These must all outlive this class, or else discardSources()
27  // must be called
29  ModelId source; // always; a DenseThreeDimensionalModel
30  ModelId fft; // optionally; an FFTModel; used for phase/peak-freq modes
31  const LayerGeometryProvider *provider; // optionally
32  };
33 
34  struct Parameters {
36  binDisplay(BinDisplay::AllBins),
37  scaleFactor(1.0),
38  threshold(0.0),
39  gain(1.0),
40  normalization(ColumnNormalization::None) { }
41 
47 
51  double scaleFactor;
52 
57  double threshold;
58 
63  double gain;
64 
68  ColumnNormalization normalization;
69  };
70 
71  Colour3DPlotExporter(Sources sources, Parameters parameters);
73 
74  void discardSources();
75 
76  QVector<QString>
77  getStringExportHeaders(DataExportOptions options) const override;
78 
79  QVector<QVector<QString>>
80  toStringExportRows(DataExportOptions options,
81  sv_frame_t startFrame,
82  sv_frame_t duration) const override;
83 
84  // Further Model methods that we just delegate
85 
86  bool isOK() const override {
87  if (auto model = ModelById::get(m_sources.source)) {
88  return model->isOK();
89  }
90  return false;
91  }
92 
93  sv_frame_t getStartFrame() const override {
94  if (auto model = ModelById::get(m_sources.source)) {
95  return model->getStartFrame();
96  }
97  return 0;
98  }
99 
100  sv_frame_t getTrueEndFrame() const override {
101  if (auto model = ModelById::get(m_sources.source)) {
102  return model->getTrueEndFrame();
103  }
104  return 0;
105  }
106 
107  sv_samplerate_t getSampleRate() const override {
108  if (auto model = ModelById::get(m_sources.source)) {
109  return model->getSampleRate();
110  }
111  return 0;
112  }
113 
114  QString getTypeName() const override {
115  if (auto model = ModelById::get(m_sources.source)) {
116  return model->getTypeName();
117  }
118  return "(exporter)"; // internal fallback, no translation needed
119  }
120 
121  int getCompletion() const override {
122  if (auto model = ModelById::get(m_sources.source)) {
123  return model->getCompletion();
124  }
125  return 0;
126  }
127 
128 private:
131 };
132 
133 #endif
QString getTypeName() const override
ColumnNormalization normalization
Type of column normalization.
sv_samplerate_t getSampleRate() const override
const LayerGeometryProvider * provider
bool isOK() const override
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
sv_frame_t getStartFrame() const override
Interface for classes that provide geometry information (such as size, start frame, and a large number of other properties) about the disposition of a layer.
sv_frame_t getTrueEndFrame() const override
Colour3DPlotExporter(Sources sources, Parameters parameters)
Interface for layers in which the Y axis corresponds to bin number rather than scale value...
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...
int getCompletion() const override
double scaleFactor
Initial scale factor (e.g.
const VerticalBinLayer * verticalBinLayer