Mercurial > hg > svcore
comparison data/model/EditableDenseThreeDimensionalModel.cpp @ 943:178ffa964096 tonioni
Merge from default branch
author | Chris Cannam |
---|---|
date | Wed, 02 Jul 2014 17:31:21 +0100 |
parents | 0009b2b066e0 |
children | cc27f35aa75c |
comparison
equal
deleted
inserted
replaced
935:f960d67ce842 | 943:178ffa964096 |
---|---|
155 | 155 |
156 EditableDenseThreeDimensionalModel::Column | 156 EditableDenseThreeDimensionalModel::Column |
157 EditableDenseThreeDimensionalModel::getColumn(int index) const | 157 EditableDenseThreeDimensionalModel::getColumn(int index) const |
158 { | 158 { |
159 QReadLocker locker(&m_lock); | 159 QReadLocker locker(&m_lock); |
160 if (int(index) >= m_data.size()) return Column(); | 160 if (index < 0 || index >= m_data.size()) return Column(); |
161 return expandAndRetrieve(index); | 161 return expandAndRetrieve(index); |
162 } | 162 } |
163 | 163 |
164 float | 164 float |
165 EditableDenseThreeDimensionalModel::getValueAt(int index, int n) const | 165 EditableDenseThreeDimensionalModel::getValueAt(int index, int n) const |
285 EditableDenseThreeDimensionalModel::Column | 285 EditableDenseThreeDimensionalModel::Column |
286 EditableDenseThreeDimensionalModel::expandAndRetrieve(int index) const | 286 EditableDenseThreeDimensionalModel::expandAndRetrieve(int index) const |
287 { | 287 { |
288 // See comment above m_trunc declaration in header | 288 // See comment above m_trunc declaration in header |
289 | 289 |
290 assert(int(index) < m_data.size()); | 290 assert(index >= 0 && index < int(m_data.size())); |
291 Column c = m_data.at(index); | 291 Column c = m_data.at(index); |
292 if (index == 0) { | 292 if (index == 0) { |
293 return c; | 293 return c; |
294 } | 294 } |
295 int trunc = (int)m_trunc[index]; | 295 int trunc = (int)m_trunc[index]; |
299 bool top = true; | 299 bool top = true; |
300 int tdist = trunc; | 300 int tdist = trunc; |
301 if (trunc < 0) { top = false; tdist = -trunc; } | 301 if (trunc < 0) { top = false; tdist = -trunc; } |
302 Column p = expandAndRetrieve(index - tdist); | 302 Column p = expandAndRetrieve(index - tdist); |
303 int psize = p.size(), csize = c.size(); | 303 int psize = p.size(), csize = c.size(); |
304 if (psize != int(m_yBinCount)) { | 304 if (psize != m_yBinCount) { |
305 cerr << "WARNING: EditableDenseThreeDimensionalModel::expandAndRetrieve: Trying to expand from incorrectly sized column" << endl; | 305 cerr << "WARNING: EditableDenseThreeDimensionalModel::expandAndRetrieve: Trying to expand from incorrectly sized column" << endl; |
306 } | 306 } |
307 if (top) { | 307 if (top) { |
308 for (int i = csize; i < psize; ++i) { | 308 for (int i = csize; i < psize; ++i) { |
309 c.push_back(p.at(i)); | 309 c.push_back(p.at(i)); |
388 } | 388 } |
389 | 389 |
390 QString | 390 QString |
391 EditableDenseThreeDimensionalModel::getBinName(int n) const | 391 EditableDenseThreeDimensionalModel::getBinName(int n) const |
392 { | 392 { |
393 if ((int)m_binNames.size() > n) return m_binNames[n]; | 393 if (n >= 0 && (int)m_binNames.size() > n) return m_binNames[n]; |
394 else return ""; | 394 else return ""; |
395 } | 395 } |
396 | 396 |
397 void | 397 void |
398 EditableDenseThreeDimensionalModel::setBinName(int n, QString name) | 398 EditableDenseThreeDimensionalModel::setBinName(int n, QString name) |