EditableDenseThreeDimensionalModel.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  This file copyright 2006 Chris Cannam and QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H
17 #define SV_EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H
18 
20 
21 #include <QMutex>
22 
23 #include <vector>
24 
26 {
27  Q_OBJECT
28 
29 public:
31  int resolution,
32  int height,
33  bool notifyOnAdd = true);
34 
35  bool isOK() const override;
36  bool isReady(int *completion = 0) const override;
37  void setCompletion(int completion, bool update = true);
38  int getCompletion() const override;
39 
40  sv_samplerate_t getSampleRate() const override;
41  sv_frame_t getStartFrame() const override;
42  sv_frame_t getTrueEndFrame() const override;
43 
47  virtual void setStartFrame(sv_frame_t);
48 
52  int getResolution() const override;
53 
57  virtual void setResolution(int sz);
58 
62  int getWidth() const override;
63 
67  int getHeight() const override;
68 
79  virtual void setHeight(int sz);
80 
84  float getMinimumLevel() const override;
85 
89  virtual void setMinimumLevel(float sz);
90 
94  float getMaximumLevel() const override;
95 
99  virtual void setMaximumLevel(float sz);
100 
104  Column getColumn(int x) const override;
105 
109  float getValueAt(int x, int n) const override;
110 
114  virtual void setColumn(int x, const Column &values);
115 
120  QString getBinName(int n) const override;
121 
125  virtual void setBinName(int n, QString);
126 
130  virtual void setBinNames(std::vector<QString> names);
131 
138  bool hasBinValues() const override;
139 
145  float getBinValue(int n) const override;
146 
152  virtual void setBinValues(std::vector<float> values);
153 
158  QString getBinValueUnit() const override;
159 
164  virtual void setBinValueUnit(QString unit);
165 
171  bool shouldUseLogValueScale() const override;
172 
173  QString getTypeName() const override { return tr("Editable Dense 3-D"); }
174 
175  QVector<QString>
176  getStringExportHeaders(DataExportOptions options) const override;
177 
178  QVector<QVector<QString>>
180  sv_frame_t startFrame,
181  sv_frame_t duration) const override;
182 
183  void toXml(QTextStream &out,
184  QString indent = "",
185  QString extraAttributes = "") const override;
186 
187 protected:
188  typedef std::vector<Column> ValueMatrix;
189  ValueMatrix m_data;
190 
191  std::vector<QString> m_binNames;
192  std::vector<float> m_binValues;
193  QString m_binValueUnit;
194 
199  float m_minimum;
200  float m_maximum;
206 
207  mutable QMutex m_mutex;
208 };
209 
210 #endif
float getMinimumLevel() const override
Return the minimum value of the value in each bin.
double sv_samplerate_t
Sample rate.
Definition: BaseTypes.h:51
virtual void setMinimumLevel(float sz)
Set the minimum value of the value in a bin.
int64_t sv_frame_t
Frame index, the unit of our time axis.
Definition: BaseTypes.h:31
virtual void setBinName(int n, QString)
Set the name of bin n.
QString getBinName(int n) const override
Return the name of bin n.
sv_frame_t getStartFrame() const override
Return the first audio frame spanned by the model.
void setCompletion(int completion, bool update=true)
int getWidth() const override
Return the number of columns.
float getBinValue(int n) const override
Return the value of bin n, if any.
EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate, int resolution, int height, bool notifyOnAdd=true)
int getCompletion() const override
Return an estimated percentage value showing how far through any background operation used to calcula...
virtual void setBinValueUnit(QString unit)
Set the name of the unit of the values return from getBinValue() if any.
QString getBinValueUnit() const override
Obtain the name of the unit of the values returned from getBinValue(), if any.
float getValueAt(int x, int n) const override
Get a single value, from the n&#39;th bin of the given column.
bool isReady(int *completion=0) const override
Return true if the model has finished loading or calculating all its data, for a model that is capabl...
virtual void setBinNames(std::vector< QString > names)
Set the names of all bins.
virtual void setMaximumLevel(float sz)
Set the maximum value of the value in a bin.
QString getTypeName() const override
Return the type of the model.
sv_frame_t getTrueEndFrame() const override
Return the audio frame at the end of the model.
bool shouldUseLogValueScale() const override
Return true if the distribution of values in the bins is such as to suggest a log scale (mapping to c...
sv_samplerate_t getSampleRate() const override
Return the frame rate in frames per second.
QVector< QString > getStringExportHeaders(DataExportOptions options) const override
Return a label for each column that would be written by toStringExportRows.
virtual void setStartFrame(sv_frame_t)
Set the frame offset of the first column.
QVector< QVector< QString > > toStringExportRows(DataExportOptions options, sv_frame_t startFrame, sv_frame_t duration) const override
Emit events starting within the given range as string rows ready for conversion to an e...
virtual void setResolution(int sz)
Set the number of sample frames covered by each set of bins.
virtual void setBinValues(std::vector< float > values)
Set the values of all bins (separate from their labels).
virtual void setHeight(int sz)
Set the number of bins in each column.
void toXml(QTextStream &out, QString indent="", QString extraAttributes="") const override
Stream this exportable object out to XML on a text stream.
bool isOK() const override
Return true if the model was constructed successfully.
float getMaximumLevel() const override
Return the maximum value of the value in each bin.
virtual void setColumn(int x, const Column &values)
Set the entire set of bin values at the given column.
bool hasBinValues() const override
Return true if the bins have values as well as names.
int getHeight() const override
Return the number of bins in each column.
Column getColumn(int x) const override
Get the set of bin values at the given column.
int getResolution() const override
Return the number of sample frames covered by each set of bins.
int DataExportOptions