comparison data/model/EditableDenseThreeDimensionalModel.cpp @ 182:f75f8a1cd7b1

* Some dull work to continue unifying the fft model and editable dense 3d model interfaces
author Chris Cannam
date Mon, 09 Oct 2006 10:49:46 +0000
parents 9c652f2c39b1
children 91fdc752e540
comparison
equal deleted inserted replaced
181:9c652f2c39b1 182:f75f8a1cd7b1
68 68
69 model->m_minimum = m_minimum; 69 model->m_minimum = m_minimum;
70 model->m_maximum = m_maximum; 70 model->m_maximum = m_maximum;
71 71
72 for (size_t i = 0; i < m_data.size(); ++i) { 72 for (size_t i = 0; i < m_data.size(); ++i) {
73 model->setBinValues(i * m_resolution, m_data[i]); 73 model->setColumn(i, m_data[i]);
74 } 74 }
75 75
76 return model; 76 return model;
77 } 77 }
78 78
87 { 87 {
88 m_resolution = sz; 88 m_resolution = sz;
89 } 89 }
90 90
91 size_t 91 size_t
92 EditableDenseThreeDimensionalModel::getYBinCount() const 92 EditableDenseThreeDimensionalModel::getWidth() const
93 {
94 return m_data.size();
95 }
96
97 size_t
98 EditableDenseThreeDimensionalModel::getHeight() const
93 { 99 {
94 return m_yBinCount; 100 return m_yBinCount;
95 } 101 }
96 102
97 void 103 void
98 EditableDenseThreeDimensionalModel::setYBinCount(size_t sz) 104 EditableDenseThreeDimensionalModel::setHeight(size_t sz)
99 { 105 {
100 m_yBinCount = sz; 106 m_yBinCount = sz;
101 } 107 }
102 108
103 float 109 float
123 { 129 {
124 m_maximum = level; 130 m_maximum = level;
125 } 131 }
126 132
127 void 133 void
128 EditableDenseThreeDimensionalModel::getBinValues(long windowStart, 134 EditableDenseThreeDimensionalModel::getColumn(size_t index,
129 BinValueSet &result) const 135 Column &result) const
130 { 136 {
131 QMutexLocker locker(&m_mutex); 137 QMutexLocker locker(&m_mutex);
132 138
133 long index = windowStart / m_resolution; 139 if (index < m_data.size()) {
134
135 if (index >= 0 && index < long(m_data.size())) {
136 result = m_data[index]; 140 result = m_data[index];
137 } else { 141 } else {
138 result.clear(); 142 result.clear();
139 } 143 }
140 144
141 while (result.size() < m_yBinCount) result.push_back(m_minimum); 145 while (result.size() < m_yBinCount) result.push_back(m_minimum);
142 } 146 }
143 147
144 float 148 float
145 EditableDenseThreeDimensionalModel::getBinValue(long windowStart, 149 EditableDenseThreeDimensionalModel::getValueAt(size_t index, size_t n) const
146 size_t n) const
147 { 150 {
148 QMutexLocker locker(&m_mutex); 151 QMutexLocker locker(&m_mutex);
149 152
150 long index = windowStart / m_resolution; 153 if (index < m_data.size()) {
151 154 const Column &s = m_data[index];
152 if (index >= 0 && index < long(m_data.size())) {
153 const BinValueSet &s = m_data[index];
154 std::cerr << "index " << index << ", n " << n << ", res " << m_resolution << ", size " << s.size() 155 std::cerr << "index " << index << ", n " << n << ", res " << m_resolution << ", size " << s.size()
155 << std::endl; 156 << std::endl;
156 if (n < s.size()) return s[n]; 157 if (n < s.size()) return s[n];
157 } 158 }
158 159
159 return m_minimum; 160 return m_minimum;
160 } 161 }
161 162
162 void 163 void
163 EditableDenseThreeDimensionalModel::setBinValues(long windowStart, 164 EditableDenseThreeDimensionalModel::setColumn(size_t index,
164 const BinValueSet &values) 165 const Column &values)
165 { 166 {
166 QMutexLocker locker(&m_mutex); 167 QMutexLocker locker(&m_mutex);
167 168
168 long index = windowStart / m_resolution; 169 while (index >= m_data.size()) {
169 170 m_data.push_back(Column());
170 while (index >= long(m_data.size())) {
171 m_data.push_back(BinValueSet());
172 } 171 }
173 172
174 bool newExtents = (m_data.empty() && (m_minimum == m_maximum)); 173 bool newExtents = (m_data.empty() && (m_minimum == m_maximum));
175 bool allChange = false; 174 bool allChange = false;
176 175
184 allChange = true; 183 allChange = true;
185 } 184 }
186 } 185 }
187 186
188 m_data[index] = values; 187 m_data[index] = values;
188
189 long windowStart = index;
190 windowStart *= m_resolution;
189 191
190 if (m_notifyOnAdd) { 192 if (m_notifyOnAdd) {
191 if (allChange) { 193 if (allChange) {
192 emit modelChanged(); 194 emit modelChanged();
193 } else { 195 } else {