diff 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
line wrap: on
line diff
--- a/data/model/EditableDenseThreeDimensionalModel.cpp	Fri Oct 06 16:53:25 2006 +0000
+++ b/data/model/EditableDenseThreeDimensionalModel.cpp	Mon Oct 09 10:49:46 2006 +0000
@@ -70,7 +70,7 @@
     model->m_maximum = m_maximum;
 
     for (size_t i = 0; i < m_data.size(); ++i) {
-	model->setBinValues(i * m_resolution, m_data[i]);
+	model->setColumn(i, m_data[i]);
     }
 
     return model;
@@ -89,13 +89,19 @@
 }
 
 size_t
-EditableDenseThreeDimensionalModel::getYBinCount() const
+EditableDenseThreeDimensionalModel::getWidth() const
+{
+    return m_data.size();
+}
+
+size_t
+EditableDenseThreeDimensionalModel::getHeight() const
 {
     return m_yBinCount;
 }
 
 void
-EditableDenseThreeDimensionalModel::setYBinCount(size_t sz)
+EditableDenseThreeDimensionalModel::setHeight(size_t sz)
 {
     m_yBinCount = sz;
 }
@@ -125,14 +131,12 @@
 }
 
 void
-EditableDenseThreeDimensionalModel::getBinValues(long windowStart,
-                                                 BinValueSet &result) const
+EditableDenseThreeDimensionalModel::getColumn(size_t index,
+                                              Column &result) const
 {
     QMutexLocker locker(&m_mutex);
-    
-    long index = windowStart / m_resolution;
 
-    if (index >= 0 && index < long(m_data.size())) {
+    if (index < m_data.size()) {
 	result = m_data[index];
     } else {
 	result.clear();
@@ -142,15 +146,12 @@
 }
 
 float
-EditableDenseThreeDimensionalModel::getBinValue(long windowStart,
-                                                size_t n) const
+EditableDenseThreeDimensionalModel::getValueAt(size_t index, size_t n) const
 {
     QMutexLocker locker(&m_mutex);
-    
-    long index = windowStart / m_resolution;
 
-    if (index >= 0 && index < long(m_data.size())) {
-	const BinValueSet &s = m_data[index];
+    if (index < m_data.size()) {
+	const Column &s = m_data[index];
         std::cerr << "index " << index << ", n " << n << ", res " << m_resolution << ", size " << s.size()
                   << std::endl;
 	if (n < s.size()) return s[n];
@@ -160,15 +161,13 @@
 }
 
 void
-EditableDenseThreeDimensionalModel::setBinValues(long windowStart,
-					 const BinValueSet &values)
+EditableDenseThreeDimensionalModel::setColumn(size_t index,
+                                              const Column &values)
 {
     QMutexLocker locker(&m_mutex);
 
-    long index = windowStart / m_resolution;
-
-    while (index >= long(m_data.size())) {
-	m_data.push_back(BinValueSet());
+    while (index >= m_data.size()) {
+	m_data.push_back(Column());
     }
 
     bool newExtents = (m_data.empty() && (m_minimum == m_maximum));
@@ -187,6 +186,9 @@
 
     m_data[index] = values;
 
+    long windowStart = index;
+    windowStart *= m_resolution;
+
     if (m_notifyOnAdd) {
 	if (allChange) {
 	    emit modelChanged();