diff layer/SpectrogramLayer.cpp @ 1122:94370157b265 spectrogram-minor-refactor

Fixes and debug output for mag range calculations
author Chris Cannam
date Fri, 22 Jul 2016 13:56:24 +0100
parents d930ff725f64
children 343887ac6766
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Fri Jul 22 12:17:55 2016 +0100
+++ b/layer/SpectrogramLayer.cpp	Fri Jul 22 13:56:24 2016 +0100
@@ -1491,6 +1491,15 @@
     Colour3DPlotRenderer *renderer = getRenderer(v);
 
     Colour3DPlotRenderer::RenderResult result;
+    MagnitudeRange magRange;
+    int viewId = v->getId();
+
+    if (!renderer->geometryChanged(v)) {
+        cerr << "geometry unchanged, extending view mag range" << endl;
+        magRange = m_viewMags[viewId];
+    } else {
+        cerr << "geometry changed!! creating new view mag range" << endl;
+    }
     
     if (m_synchronous) {
 
@@ -1500,7 +1509,8 @@
 
         result = renderer->renderTimeConstrained(v, paint, rect);
 
-        cerr << "mag range in this paint: " << result.range.getMin() << " -> "
+        cerr << "rect width from this paint: " << result.rendered.width()
+             << ", mag range in this paint: " << result.range.getMin() << " -> "
              << result.range.getMax() << endl;
         
         //!!!
@@ -1513,17 +1523,22 @@
         }
     }
 
-    //!!! at the mo this measures the range of the whole thing, not
-    //!!! just the view - need to reset it when view extents change
-
-    m_viewMags[v->getId()].sample(result.range);
+    magRange.sample(result.range);
+
+    if (magRange.isSet()) {
+        if (m_viewMags[viewId] == magRange) {
+            cerr << "mag range unchanged" << endl;
+        } else {
+            cerr << "mag range changed!!" << endl;
+            m_viewMags[viewId] = magRange;
+        }
+    }
     
     cerr << "mag range in this view: "
-         << m_viewMags[v->getId()].getMin()
+         << m_viewMags[viewId].getMin()
          << " -> "
-         << m_viewMags[v->getId()].getMax()
+         << m_viewMags[viewId].getMax()
          << endl;
-        
 }
 
 void