Chris@152
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@152
|
2
|
Chris@152
|
3 /*
|
Chris@152
|
4 Sonic Visualiser
|
Chris@152
|
5 An audio file viewer and annotation editor.
|
Chris@152
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@202
|
7 This file copyright 2006 Chris Cannam and QMUL.
|
Chris@152
|
8
|
Chris@152
|
9 This program is free software; you can redistribute it and/or
|
Chris@152
|
10 modify it under the terms of the GNU General Public License as
|
Chris@152
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@152
|
12 License, or (at your option) any later version. See the file
|
Chris@152
|
13 COPYING included with this distribution for more information.
|
Chris@152
|
14 */
|
Chris@152
|
15
|
Chris@1581
|
16 #ifndef SV_EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H
|
Chris@1581
|
17 #define SV_EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H
|
Chris@152
|
18
|
Chris@152
|
19 #include "DenseThreeDimensionalModel.h"
|
Chris@152
|
20
|
Chris@1777
|
21 #include <QMutex>
|
Chris@536
|
22
|
Chris@533
|
23 #include <vector>
|
Chris@533
|
24
|
Chris@152
|
25 class EditableDenseThreeDimensionalModel : public DenseThreeDimensionalModel
|
Chris@152
|
26 {
|
Chris@152
|
27 Q_OBJECT
|
Chris@152
|
28
|
Chris@152
|
29 public:
|
Chris@1040
|
30 EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate,
|
Chris@1429
|
31 int resolution,
|
Chris@1429
|
32 int height,
|
Chris@1429
|
33 bool notifyOnAdd = true);
|
Chris@152
|
34
|
Chris@1580
|
35 bool isOK() const override;
|
Chris@1701
|
36 bool isReady(int *completion = 0) const override;
|
Chris@1701
|
37 void setCompletion(int completion, bool update = true);
|
Chris@1701
|
38 int getCompletion() const override;
|
Chris@152
|
39
|
Chris@1580
|
40 sv_samplerate_t getSampleRate() const override;
|
Chris@1580
|
41 sv_frame_t getStartFrame() const override;
|
Chris@1725
|
42 sv_frame_t getTrueEndFrame() const override;
|
Chris@152
|
43
|
Chris@152
|
44 /**
|
Chris@611
|
45 * Set the frame offset of the first column.
|
Chris@611
|
46 */
|
Chris@1038
|
47 virtual void setStartFrame(sv_frame_t);
|
Chris@611
|
48
|
Chris@611
|
49 /**
|
Chris@152
|
50 * Return the number of sample frames covered by each set of bins.
|
Chris@152
|
51 */
|
Chris@1580
|
52 int getResolution() const override;
|
Chris@152
|
53
|
Chris@152
|
54 /**
|
Chris@152
|
55 * Set the number of sample frames covered by each set of bins.
|
Chris@152
|
56 */
|
Chris@929
|
57 virtual void setResolution(int sz);
|
Chris@152
|
58
|
Chris@152
|
59 /**
|
Chris@182
|
60 * Return the number of columns.
|
Chris@182
|
61 */
|
Chris@1580
|
62 int getWidth() const override;
|
Chris@182
|
63
|
Chris@182
|
64 /**
|
Chris@1252
|
65 * Return the number of bins in each column.
|
Chris@152
|
66 */
|
Chris@1580
|
67 int getHeight() const override;
|
Chris@152
|
68
|
Chris@152
|
69 /**
|
Chris@1252
|
70 * Set the number of bins in each column.
|
Chris@1252
|
71 *
|
Chris@1252
|
72 * You can set (via setColumn) a vector of any length as a column,
|
Chris@1252
|
73 * but any column being retrieved will be resized to this height
|
Chris@1252
|
74 * (or the height that was supplied to the constructor, if this is
|
Chris@1252
|
75 * never called) on retrieval. That is, the model owner determines
|
Chris@1252
|
76 * the height of the model at a single stroke; the columns
|
Chris@1252
|
77 * themselves don't have any effect on the height of the model.
|
Chris@152
|
78 */
|
Chris@929
|
79 virtual void setHeight(int sz);
|
Chris@152
|
80
|
Chris@152
|
81 /**
|
Chris@152
|
82 * Return the minimum value of the value in each bin.
|
Chris@152
|
83 */
|
Chris@1580
|
84 float getMinimumLevel() const override;
|
Chris@152
|
85
|
Chris@152
|
86 /**
|
Chris@152
|
87 * Set the minimum value of the value in a bin.
|
Chris@152
|
88 */
|
Chris@152
|
89 virtual void setMinimumLevel(float sz);
|
Chris@152
|
90
|
Chris@152
|
91 /**
|
Chris@152
|
92 * Return the maximum value of the value in each bin.
|
Chris@152
|
93 */
|
Chris@1580
|
94 float getMaximumLevel() const override;
|
Chris@152
|
95
|
Chris@152
|
96 /**
|
Chris@152
|
97 * Set the maximum value of the value in a bin.
|
Chris@152
|
98 */
|
Chris@152
|
99 virtual void setMaximumLevel(float sz);
|
Chris@152
|
100
|
Chris@182
|
101 /**
|
Chris@182
|
102 * Get the set of bin values at the given column.
|
Chris@152
|
103 */
|
Chris@1580
|
104 Column getColumn(int x) const override;
|
Chris@152
|
105
|
Chris@152
|
106 /**
|
Chris@182
|
107 * Get a single value, from the n'th bin of the given column.
|
Chris@152
|
108 */
|
Chris@1580
|
109 float getValueAt(int x, int n) const override;
|
Chris@152
|
110
|
Chris@152
|
111 /**
|
Chris@182
|
112 * Set the entire set of bin values at the given column.
|
Chris@152
|
113 */
|
Chris@929
|
114 virtual void setColumn(int x, const Column &values);
|
Chris@152
|
115
|
Chris@881
|
116 /**
|
Chris@881
|
117 * Return the name of bin n. This is a single label per bin that
|
Chris@881
|
118 * does not vary from one column to the next.
|
Chris@881
|
119 */
|
Chris@1580
|
120 QString getBinName(int n) const override;
|
Chris@881
|
121
|
Chris@881
|
122 /**
|
Chris@881
|
123 * Set the name of bin n.
|
Chris@881
|
124 */
|
Chris@929
|
125 virtual void setBinName(int n, QString);
|
Chris@881
|
126
|
Chris@881
|
127 /**
|
Chris@881
|
128 * Set the names of all bins.
|
Chris@881
|
129 */
|
Chris@152
|
130 virtual void setBinNames(std::vector<QString> names);
|
Chris@152
|
131
|
Chris@881
|
132 /**
|
Chris@886
|
133 * Return true if the bins have values as well as names. (The
|
Chris@886
|
134 * values may have been derived from the names, e.g. by parsing
|
Chris@886
|
135 * numbers from them.) If this returns true, getBinValue() may be
|
Chris@886
|
136 * used to retrieve the values.
|
Chris@886
|
137 */
|
Chris@1580
|
138 bool hasBinValues() const override;
|
Chris@886
|
139
|
Chris@886
|
140 /**
|
Chris@886
|
141 * Return the value of bin n, if any. This is a "vertical scale"
|
Chris@886
|
142 * value which does not vary from one column to the next. This is
|
Chris@886
|
143 * only meaningful if hasBinValues() returns true.
|
Chris@886
|
144 */
|
Chris@1580
|
145 float getBinValue(int n) const override;
|
Chris@886
|
146
|
Chris@886
|
147 /**
|
Chris@886
|
148 * Set the values of all bins (separate from their labels). These
|
Chris@886
|
149 * are "vertical scale" values which do not vary from one column
|
Chris@886
|
150 * to the next.
|
Chris@886
|
151 */
|
Chris@886
|
152 virtual void setBinValues(std::vector<float> values);
|
Chris@886
|
153
|
Chris@886
|
154 /**
|
Chris@886
|
155 * Obtain the name of the unit of the values returned from
|
Chris@886
|
156 * getBinValue(), if any.
|
Chris@886
|
157 */
|
Chris@1580
|
158 QString getBinValueUnit() const override;
|
Chris@886
|
159
|
Chris@886
|
160 /**
|
Chris@886
|
161 * Set the name of the unit of the values return from
|
Chris@886
|
162 * getBinValue() if any.
|
Chris@886
|
163 */
|
Chris@886
|
164 virtual void setBinValueUnit(QString unit);
|
Chris@886
|
165
|
Chris@886
|
166 /**
|
Chris@881
|
167 * Return true if the distribution of values in the bins is such
|
Chris@881
|
168 * as to suggest a log scale (mapping to colour etc) may be better
|
Chris@881
|
169 * than a linear one.
|
Chris@881
|
170 */
|
Chris@1580
|
171 bool shouldUseLogValueScale() const override;
|
Chris@478
|
172
|
Chris@1580
|
173 QString getTypeName() const override { return tr("Editable Dense 3-D"); }
|
Chris@345
|
174
|
Chris@1679
|
175 QString toDelimitedDataString(QString delimiter,
|
Chris@1679
|
176 DataExportOptions options,
|
Chris@1679
|
177 sv_frame_t startFrame,
|
Chris@1679
|
178 sv_frame_t duration) const override;
|
Chris@318
|
179
|
Chris@1580
|
180 void toXml(QTextStream &out,
|
Chris@152
|
181 QString indent = "",
|
Chris@1580
|
182 QString extraAttributes = "") const override;
|
Chris@152
|
183
|
Chris@152
|
184 protected:
|
Chris@1154
|
185 typedef std::vector<Column> ValueMatrix;
|
Chris@152
|
186 ValueMatrix m_data;
|
Chris@152
|
187
|
Chris@152
|
188 std::vector<QString> m_binNames;
|
Chris@886
|
189 std::vector<float> m_binValues;
|
Chris@886
|
190 QString m_binValueUnit;
|
Chris@152
|
191
|
Chris@1038
|
192 sv_frame_t m_startFrame;
|
Chris@1040
|
193 sv_samplerate_t m_sampleRate;
|
Chris@929
|
194 int m_resolution;
|
Chris@929
|
195 int m_yBinCount;
|
Chris@152
|
196 float m_minimum;
|
Chris@152
|
197 float m_maximum;
|
Chris@256
|
198 bool m_haveExtents;
|
Chris@152
|
199 bool m_notifyOnAdd;
|
Chris@1110
|
200 sv_frame_t m_sinceLastNotifyMin;
|
Chris@1110
|
201 sv_frame_t m_sinceLastNotifyMax;
|
Chris@152
|
202 int m_completion;
|
Chris@152
|
203
|
Chris@1777
|
204 mutable QMutex m_mutex;
|
Chris@152
|
205 };
|
Chris@152
|
206
|
Chris@152
|
207 #endif
|