diff layer/Colour3DPlotRenderer.cpp @ 1136:9ff838a64461 spectrogram-minor-refactor

Re-enable (little-used) normalise-visible-range option in spectrogram layer
author Chris Cannam
date Wed, 03 Aug 2016 16:16:23 +0100
parents 628cd329c241
children 998e31e92dbe
line wrap: on
line diff
--- a/layer/Colour3DPlotRenderer.cpp	Wed Aug 03 14:20:27 2016 +0100
+++ b/layer/Colour3DPlotRenderer.cpp	Wed Aug 03 16:16:23 2016 +0100
@@ -674,19 +674,24 @@
         sourceLeft = 0;
     }
     
-    int sourceWidth = targetWidth;
-    
     cerr << "repaintWidth = " << repaintWidth
          << ", targetWidth = " << targetWidth << endl;
     
     if (targetWidth > 0) {
+        // we are copying from an image that has already been scaled,
+        // hence using the same width in both geometries
         m_cache.drawImage(targetLeft, targetWidth,
                           scaled,
-                          sourceLeft, sourceWidth);
+                          sourceLeft, targetWidth);
     }
     
     for (int i = 0; i < targetWidth; ++i) {
-        int sourceIx = int((double(i) / targetWidth) * sourceWidth);
+        // but the mag range vector has not been scaled
+        int sourceIx = int((double(i + sourceLeft) / scaled.width())
+                           * int(m_magRanges.size()));
+//        int sourceIx = int((double(i) / targetWidth) * sourceWidth);
+        cerr << "mag range target ix = " << i << ", source ix = "
+             << sourceIx << ", of " << m_magRanges.size() << endl;
         if (in_range_for(m_magRanges, sourceIx)) {
             m_magCache.sampleColumn(i, m_magRanges.at(sourceIx));
         }
@@ -787,8 +792,8 @@
 
                 ColumnOp::Column fullColumn = sourceModel->getColumn(sx);
 
-                cerr << "x " << x << ", sx " << sx << ", col height " << fullColumn.size()
-                     << ", minbin " << minbin << ", nbins " << nbins << endl;
+//                cerr << "x " << x << ", sx " << sx << ", col height " << fullColumn.size()
+//                     << ", minbin " << minbin << ", nbins " << nbins << endl;
                 
                 ColumnOp::Column column =
                     vector<float>(fullColumn.data() + minbin,