comparison data/model/EditableDenseThreeDimensionalModel.h @ 535:3ccf48fb81d6

* make compression optional in editable dense 3d model, and some tweaks
author Chris Cannam
date Fri, 23 Jan 2009 14:00:29 +0000
parents 6038cb6fcd30
children beb51f558e9c
comparison
equal deleted inserted replaced
534:6038cb6fcd30 535:3ccf48fb81d6
23 class EditableDenseThreeDimensionalModel : public DenseThreeDimensionalModel 23 class EditableDenseThreeDimensionalModel : public DenseThreeDimensionalModel
24 { 24 {
25 Q_OBJECT 25 Q_OBJECT
26 26
27 public: 27 public:
28
29 // EditableDenseThreeDimensionalModel supports a basic compression
30 // method that reduces the size of multirate data (e.g. wavelet
31 // transform outputs) that are stored as plain 3d grids by about
32 // 60% or thereabouts. However, it can only be used for models
33 // whose columns are set in order from 0 and never subsequently
34 // changed. If the model is going to be actually edited, it must
35 // have NoCompression.
36
37 enum CompressionType
38 {
39 NoCompression,
40 BasicMultirateCompression
41 };
42
28 EditableDenseThreeDimensionalModel(size_t sampleRate, 43 EditableDenseThreeDimensionalModel(size_t sampleRate,
29 size_t resolution, 44 size_t resolution,
30 size_t yBinCount, 45 size_t yBinCount,
46 CompressionType compression,
31 bool notifyOnAdd = true); 47 bool notifyOnAdd = true);
32 48
33 virtual bool isOK() const; 49 virtual bool isOK() const;
34 50
35 virtual size_t getSampleRate() const; 51 virtual size_t getSampleRate() const;
123 139
124 protected: 140 protected:
125 typedef QVector<Column> ValueMatrix; 141 typedef QVector<Column> ValueMatrix;
126 ValueMatrix m_data; 142 ValueMatrix m_data;
127 143
128 std::vector<signed char> m_trunc; // +ve -> top is truncated, -ve -> bottom 144 // m_trunc is used for simple compression. If at least the top N
145 // elements of column x (for N = some proportion of the column
146 // height) are equal to those of an earlier column x', then
147 // m_trunc[x] will contain x-x' and column x will be truncated so
148 // as to remove the duplicate elements. If the equal elements are
149 // at the bottom, then m_trunc[x] will contain x'-x (a negative
150 // value). If m_trunc[x] is 0 then the whole of column x is
151 // stored.
152 std::vector<signed char> m_trunc;
129 void truncateAndStore(size_t index, const Column & values); 153 void truncateAndStore(size_t index, const Column & values);
130 Column expandAndRetrieve(size_t index) const; 154 Column expandAndRetrieve(size_t index) const;
131 155
132 std::vector<QString> m_binNames; 156 std::vector<QString> m_binNames;
133 157
134 size_t m_sampleRate; 158 size_t m_sampleRate;
135 size_t m_resolution; 159 size_t m_resolution;
136 size_t m_yBinCount; 160 size_t m_yBinCount;
161 CompressionType m_compression;
137 float m_minimum; 162 float m_minimum;
138 float m_maximum; 163 float m_maximum;
139 bool m_haveExtents; 164 bool m_haveExtents;
140 bool m_notifyOnAdd; 165 bool m_notifyOnAdd;
141 long m_sinceLastNotifyMin; 166 long m_sinceLastNotifyMin;