diff data/model/EditableDenseThreeDimensionalModel.cpp @ 478:1405f4a2caf3

* Add use-log-scale estimator. Not quite right yet; the model doesn't actually have any data in it yet at the point where we want to make this decision * Update changelog
author Chris Cannam
date Tue, 11 Nov 2008 13:54:47 +0000
parents beb2948baa77
children 55ad231c9db7
line wrap: on
line diff
--- a/data/model/EditableDenseThreeDimensionalModel.cpp	Tue Nov 11 09:41:45 2008 +0000
+++ b/data/model/EditableDenseThreeDimensionalModel.cpp	Tue Nov 11 13:54:47 2008 +0000
@@ -15,8 +15,9 @@
 
 #include "EditableDenseThreeDimensionalModel.h"
 
+#include "base/LogRange.h"
+
 #include <QTextStream>
-
 #include <QStringList>
 
 #include <iostream>
@@ -247,6 +248,35 @@
     emit modelChanged();
 }
 
+bool
+EditableDenseThreeDimensionalModel::shouldUseLogValueScale() const
+{
+    std::vector<float> sample;
+    std::vector<int> n;
+    
+    for (int i = 0; i < 10; ++i) {
+        size_t index = i * 10;
+        if (index < m_data.size()) {
+            const Column &c = m_data[index];
+            while (c.size() > sample.size()) {
+                sample.push_back(0.f);
+                n.push_back(0);
+            }
+            for (int j = 0; j < c.size(); ++j) {
+                sample[j] += c[j];
+                ++n[j];
+            }
+        }
+    }
+
+    if (sample.empty()) return false;
+    for (int j = 0; j < sample.size(); ++j) {
+        if (n[j]) sample[j] /= n[j];
+    }
+    
+    return LogRange::useLogScale(sample);
+}
+
 void
 EditableDenseThreeDimensionalModel::setCompletion(int completion, bool update)
 {