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@152
|
16 #ifndef _EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H_
|
Chris@152
|
17 #define _EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H_
|
Chris@152
|
18
|
Chris@152
|
19 #include "DenseThreeDimensionalModel.h"
|
Chris@152
|
20
|
Chris@533
|
21 #include <vector>
|
Chris@533
|
22
|
Chris@152
|
23 class EditableDenseThreeDimensionalModel : public DenseThreeDimensionalModel
|
Chris@152
|
24 {
|
Chris@152
|
25 Q_OBJECT
|
Chris@152
|
26
|
Chris@152
|
27 public:
|
Chris@152
|
28 EditableDenseThreeDimensionalModel(size_t sampleRate,
|
Chris@152
|
29 size_t resolution,
|
Chris@152
|
30 size_t yBinCount,
|
Chris@152
|
31 bool notifyOnAdd = true);
|
Chris@152
|
32
|
Chris@152
|
33 virtual bool isOK() const;
|
Chris@152
|
34
|
Chris@152
|
35 virtual size_t getSampleRate() const;
|
Chris@152
|
36 virtual size_t getStartFrame() const;
|
Chris@152
|
37 virtual size_t getEndFrame() const;
|
Chris@152
|
38
|
Chris@152
|
39 virtual Model *clone() const;
|
Chris@152
|
40
|
Chris@152
|
41
|
Chris@152
|
42 /**
|
Chris@152
|
43 * Return the number of sample frames covered by each set of bins.
|
Chris@152
|
44 */
|
Chris@152
|
45 virtual size_t getResolution() const;
|
Chris@152
|
46
|
Chris@152
|
47 /**
|
Chris@152
|
48 * Set the number of sample frames covered by each set of bins.
|
Chris@152
|
49 */
|
Chris@152
|
50 virtual void setResolution(size_t sz);
|
Chris@152
|
51
|
Chris@152
|
52 /**
|
Chris@182
|
53 * Return the number of columns.
|
Chris@182
|
54 */
|
Chris@182
|
55 virtual size_t getWidth() const;
|
Chris@182
|
56
|
Chris@182
|
57 /**
|
Chris@152
|
58 * Return the number of bins in each set of bins.
|
Chris@152
|
59 */
|
Chris@182
|
60 virtual size_t getHeight() const;
|
Chris@152
|
61
|
Chris@152
|
62 /**
|
Chris@152
|
63 * Set the number of bins in each set of bins.
|
Chris@152
|
64 */
|
Chris@182
|
65 virtual void setHeight(size_t sz);
|
Chris@152
|
66
|
Chris@152
|
67 /**
|
Chris@152
|
68 * Return the minimum value of the value in each bin.
|
Chris@152
|
69 */
|
Chris@152
|
70 virtual float getMinimumLevel() const;
|
Chris@152
|
71
|
Chris@152
|
72 /**
|
Chris@152
|
73 * Set the minimum value of the value in a bin.
|
Chris@152
|
74 */
|
Chris@152
|
75 virtual void setMinimumLevel(float sz);
|
Chris@152
|
76
|
Chris@152
|
77 /**
|
Chris@152
|
78 * Return the maximum value of the value in each bin.
|
Chris@152
|
79 */
|
Chris@152
|
80 virtual float getMaximumLevel() const;
|
Chris@152
|
81
|
Chris@152
|
82 /**
|
Chris@152
|
83 * Set the maximum value of the value in a bin.
|
Chris@152
|
84 */
|
Chris@152
|
85 virtual void setMaximumLevel(float sz);
|
Chris@152
|
86
|
Chris@182
|
87 /**
|
Chris@182
|
88 * Return true if there are data available for the given column.
|
Chris@182
|
89 */
|
Chris@182
|
90 virtual bool isColumnAvailable(size_t x) const { return x < getWidth(); }
|
Chris@152
|
91
|
Chris@152
|
92 /**
|
Chris@182
|
93 * Get the set of bin values at the given column.
|
Chris@152
|
94 */
|
Chris@533
|
95 virtual Column getColumn(size_t x) const;
|
Chris@152
|
96
|
Chris@152
|
97 /**
|
Chris@182
|
98 * Get a single value, from the n'th bin of the given column.
|
Chris@152
|
99 */
|
Chris@182
|
100 virtual float getValueAt(size_t x, size_t n) const;
|
Chris@152
|
101
|
Chris@152
|
102 /**
|
Chris@182
|
103 * Set the entire set of bin values at the given column.
|
Chris@152
|
104 */
|
Chris@182
|
105 virtual void setColumn(size_t x, const Column &values);
|
Chris@152
|
106
|
Chris@152
|
107 virtual QString getBinName(size_t n) const;
|
Chris@152
|
108 virtual void setBinName(size_t n, QString);
|
Chris@152
|
109 virtual void setBinNames(std::vector<QString> names);
|
Chris@152
|
110
|
Chris@478
|
111 bool shouldUseLogValueScale() const;
|
Chris@478
|
112
|
Chris@333
|
113 virtual void setCompletion(int completion, bool update = true);
|
Chris@152
|
114 virtual int getCompletion() const { return m_completion; }
|
Chris@152
|
115
|
Chris@345
|
116 QString getTypeName() const { return tr("Editable Dense 3-D"); }
|
Chris@345
|
117
|
Chris@318
|
118 virtual QString toDelimitedDataString(QString delimiter) const;
|
Chris@318
|
119
|
Chris@152
|
120 virtual void toXml(QTextStream &out,
|
Chris@152
|
121 QString indent = "",
|
Chris@152
|
122 QString extraAttributes = "") const;
|
Chris@152
|
123
|
Chris@152
|
124 protected:
|
Chris@533
|
125 typedef QVector<Column> ValueMatrix;
|
Chris@152
|
126 ValueMatrix m_data;
|
Chris@152
|
127
|
Chris@534
|
128 std::vector<signed char> m_trunc; // +ve -> top is truncated, -ve -> bottom
|
Chris@534
|
129 void truncateAndStore(size_t index, const Column & values);
|
Chris@534
|
130 Column expandAndRetrieve(size_t index) const;
|
Chris@534
|
131
|
Chris@152
|
132 std::vector<QString> m_binNames;
|
Chris@152
|
133
|
Chris@152
|
134 size_t m_sampleRate;
|
Chris@152
|
135 size_t m_resolution;
|
Chris@152
|
136 size_t m_yBinCount;
|
Chris@152
|
137 float m_minimum;
|
Chris@152
|
138 float m_maximum;
|
Chris@256
|
139 bool m_haveExtents;
|
Chris@152
|
140 bool m_notifyOnAdd;
|
Chris@152
|
141 long m_sinceLastNotifyMin;
|
Chris@152
|
142 long m_sinceLastNotifyMax;
|
Chris@152
|
143 int m_completion;
|
Chris@152
|
144
|
Chris@152
|
145 mutable QMutex m_mutex;
|
Chris@152
|
146 };
|
Chris@152
|
147
|
Chris@152
|
148 #endif
|