changeset 1123:343887ac6766 spectrogram-minor-refactor

Some tidying
author Chris Cannam
date Fri, 22 Jul 2016 14:42:36 +0100
parents 94370157b265
children b71a0491d287
files layer/Colour3DPlotLayer.cpp layer/Colour3DPlotRenderer.cpp layer/SpectrogramLayer.cpp
diffstat 3 files changed, 25 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp	Fri Jul 22 13:56:24 2016 +0100
+++ b/layer/Colour3DPlotLayer.cpp	Fri Jul 22 14:42:36 2016 +0100
@@ -1086,6 +1086,12 @@
     Colour3DPlotRenderer *renderer = getRenderer(v);
 
     Colour3DPlotRenderer::RenderResult result;
+    MagnitudeRange magRange;
+    int viewId = v->getId();
+
+    if (!renderer->geometryChanged(v)) {
+        magRange = m_viewMags[viewId];
+    }
     
     if (m_synchronous) {
 
@@ -1095,20 +1101,20 @@
 
         result = renderer->renderTimeConstrained(v, paint, rect);
 
-        //!!! + mag range
-
         QRect uncached = renderer->getLargestUncachedRect(v);
         if (uncached.width() > 0) {
-            cerr << "updating rect at " << uncached.x() << " width "
-                 << uncached.width() << endl;
             v->updatePaintRect(uncached);
         }
     }
     
-    //!!! at the mo this measures the range of the whole thing, not
-    //!!! just the view - need to reset it when view extents change
+    magRange.sample(result.range);
 
-    m_viewMags[v->getId()].sample(result.range);
+    if (magRange.isSet()) {
+        if (!(m_viewMags[viewId] == magRange)) {
+            m_viewMags[viewId] = magRange;
+    //!!! now need to do the normalise-visible thing
+        }
+    }
     
     cerr << "mag range in this view: "
          << m_viewMags[v->getId()].getMin()
--- a/layer/Colour3DPlotRenderer.cpp	Fri Jul 22 13:56:24 2016 +0100
+++ b/layer/Colour3DPlotRenderer.cpp	Fri Jul 22 14:42:36 2016 +0100
@@ -30,7 +30,7 @@
 
 #include <vector>
 
-#define DEBUG_SPECTROGRAM_REPAINT 1 //!!! name
+#define DEBUG_COLOUR_PLOT_REPAINT 1
 
 using namespace std;
 
@@ -119,6 +119,7 @@
         return { rect, range };
     }
     
+#ifdef DEBUG_COLOUR_PLOT_REPAINT
     cerr << "cache start " << m_cache.getStartFrame()
          << " valid left " << m_cache.getValidLeft()
          << " valid right " << m_cache.getValidRight()
@@ -127,6 +128,7 @@
          << " x0 " << x0
          << " x1 " << x1
          << endl;
+#endif
     
     if (m_cache.isValid()) { // some part of the cache is valid
 
@@ -135,24 +137,21 @@
             m_cache.getValidLeft() <= x0 &&
             m_cache.getValidRight() >= x1) {
 
+#ifdef DEBUG_COLOUR_PLOT_REPAINT
             cerr << "cache hit" << endl;
+#endif
             
             // cache is valid for the complete requested area
             paint.drawImage(rect, m_cache.getImage(), rect);
 
-            //!!! a dev debug check
-            if (!m_magCache.areColumnsSet(x0, x1 - x0)) {
-                cerr << "NB Columns (" << x0 << " -> " << x1-x0
-                     << ") not set in mag cache" << endl;
-//                throw std::logic_error("Columns not set in mag cache");
-            }
-            
             MagnitudeRange range = m_magCache.getRange(x0, x1 - x0);
 
             return { rect, range };
 
         } else {
+#ifdef DEBUG_COLOUR_PLOT_REPAINT
             cerr << "cache partial hit" << endl;
+#endif
             
             // cache doesn't begin at the right frame or doesn't
             // contain the complete view, but might be scrollable or
@@ -248,24 +247,11 @@
     
     return { pr, range };
 
-    //!!! todo: timing/incomplete paint
-
-    //!!! todo: peak frequency style
-
-    //!!! todo: transparent style from Colour3DPlot
-
-    //!!! todo: view magnitudes / normalise visible area
-
-    //!!! todo: alter documentation for view mag stuff (cached paints
-    //!!! do not update MagnitudeRange)
-
     //!!! todo, here or in caller: illuminateLocalFeatures
 
-    //!!! todo: colourmap rotation
+    //!!! todo: handle vertical range other than full range of column
     
     //!!! fft model scaling?
-    
-    //!!! should we own the Dense3DModelPeakCache here? or should it persist
 }
 
 Colour3DPlotRenderer::RenderType
@@ -369,9 +355,6 @@
             // distribute/interpolate
 
             ColumnOp::Column fullColumn = model->getColumn(sx);
-
-//                cerr << "x " << x << ", sx " << sx << ", col height " << fullColumn.size()
-//                     << ", minbin " << minbin << ", maxbin " << maxbin << endl;
                 
             ColumnOp::Column column =
                 vector<float>(fullColumn.data() + minbin,
@@ -383,11 +366,6 @@
 //                    column = ColumnOp::fftScale(column, m_fftSize);
 //                }
 
-//!!! extents                recordColumnExtents(column,
-//                                    sx,
-//                                    overallMag,
-//                                    overallMagChanged);
-
 //                if (m_colourScale != ColourScaleType::Phase) {
             preparedColumn = ColumnOp::normalize(column, m_params.normalization);
 //                }
@@ -766,7 +744,7 @@
         
         ++columnCount;
 
-#ifdef DEBUG_SPECTROGRAM_REPAINT
+#ifdef DEBUG_COLOUR_PLOT_REPAINT
         cerr << "x = " << x << ", binforx[x] = " << binforx[x] << endl;
 #endif
         
@@ -784,7 +762,7 @@
         
         for (int sx = sx0; sx < sx1; ++sx) {
 
-#ifdef DEBUG_SPECTROGRAM_REPAINT
+#ifdef DEBUG_COLOUR_PLOT_REPAINT
             cerr << "sx = " << sx << endl;
 #endif
 
@@ -813,11 +791,6 @@
 //                }
 
                 magRange.sample(column);
-                
-//!!! extents                recordColumnExtents(column,
-//                                    sx,
-//                                    overallMag,
-//                                    overallMagChanged);
 
 //                if (m_colourScale != ColourScaleType::Phase) {
                     column = ColumnOp::normalize(column, m_params.normalization);
@@ -963,11 +936,6 @@
 //                    column = ColumnOp::fftScale(column, getFFTSize());
 //                }
 
-//!!! extents                recordColumnExtents(column,
-//                                    sx,
-//                                    overallMag,
-//                                    overallMagChanged);
-
 //!!!                if (m_colourScale != ColourScaleType::Phase) {
                     column = ColumnOp::normalize(column, m_params.normalization);
 //!!!                }
--- a/layer/SpectrogramLayer.cpp	Fri Jul 22 13:56:24 2016 +0100
+++ b/layer/SpectrogramLayer.cpp	Fri Jul 22 14:42:36 2016 +0100
@@ -1495,10 +1495,7 @@
     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) {
@@ -1513,12 +1510,8 @@
              << ", mag range in this paint: " << result.range.getMin() << " -> "
              << result.range.getMax() << endl;
         
-        //!!!
-
         QRect uncached = renderer->getLargestUncachedRect(v);
         if (uncached.width() > 0) {
-            cerr << "updating rect at " << uncached.x() << " width "
-                 << uncached.width() << endl;
             v->updatePaintRect(uncached);
         }
     }
@@ -1526,11 +1519,9 @@
     magRange.sample(result.range);
 
     if (magRange.isSet()) {
-        if (m_viewMags[viewId] == magRange) {
-            cerr << "mag range unchanged" << endl;
-        } else {
-            cerr << "mag range changed!!" << endl;
+        if (!(m_viewMags[viewId] == magRange)) {
             m_viewMags[viewId] = magRange;
+    //!!! now need to do the normalise-visible thing
         }
     }