changeset 1502:62aad7969f8b

Pass the cache pointer through rather than looking it up afresh from the model id for each column
author Chris Cannam
date Thu, 12 Sep 2019 11:53:17 +0100
parents 5d179afc0366
children 2c7a480f93ca
files layer/Colour3DPlotRenderer.cpp layer/Colour3DPlotRenderer.h
diffstat 2 files changed, 16 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotRenderer.cpp	Wed Sep 11 20:36:04 2019 +0100
+++ b/layer/Colour3DPlotRenderer.cpp	Thu Sep 12 11:53:17 2019 +0100
@@ -36,6 +36,7 @@
 using namespace std::rel_ops;
 
 //#define DEBUG_COLOUR_PLOT_REPAINT 1
+//#define DEBUG_COLOUR_PLOT_CACHE_SELECTION 1
 
 using namespace std;
 
@@ -387,7 +388,7 @@
 
 ColumnOp::Column
 Colour3DPlotRenderer::getColumn(int sx, int minbin, int nbins,
-                                int peakCacheIndex) const
+                                shared_ptr<DenseThreeDimensionalModel> source) const
 {
     // order:
     // get column -> scale -> normalise -> record extents ->
@@ -400,15 +401,15 @@
     
     if (m_params.showDerivative && sx > 0) {
 
-        auto prev = getColumnRaw(sx - 1, minbin, nbins, peakCacheIndex);
-        column = getColumnRaw(sx, minbin, nbins, peakCacheIndex);
+        auto prev = getColumnRaw(sx - 1, minbin, nbins, source);
+        column = getColumnRaw(sx, minbin, nbins, source);
         
         for (int i = 0; i < nbins; ++i) {
             column[i] -= prev[i];
         }
 
     } else {
-        column = getColumnRaw(sx, minbin, nbins, peakCacheIndex);
+        column = getColumnRaw(sx, minbin, nbins, source);
     }
 
     if (m_params.colourScale.getScale() == ColourScaleType::Phase &&
@@ -423,7 +424,7 @@
 
 ColumnOp::Column
 Colour3DPlotRenderer::getColumnRaw(int sx, int minbin, int nbins,
-                                   int peakCacheIndex) const
+                                   shared_ptr<DenseThreeDimensionalModel> source) const
 {
     Profiler profiler("Colour3DPlotRenderer::getColumn");
 
@@ -438,24 +439,9 @@
     }
 
     if (fullColumn.empty()) {
-        
-        if (peakCacheIndex >= 0) {
-            auto peakCache = ModelById::getAs<Dense3DModelPeakCache>
-                (m_sources.peakCaches[peakCacheIndex]);
-            if (!peakCache) {
-                return vector<float>(nbins, 0.f);
-            }                
-            fullColumn = peakCache->getColumn(sx);
-        } else {
-            auto model = ModelById::getAs<DenseThreeDimensionalModel>
-                (m_sources.source);
-            if (!model) {
-                return vector<float>(nbins, 0.f);
-            }
-            fullColumn = model->getColumn(sx);
-        }
+        fullColumn = source->getColumn(sx);
     }
-
+    
     column = vector<float>(fullColumn.data() + minbin,
                            fullColumn.data() + minbin + nbins);
     return column;
@@ -526,7 +512,7 @@
             // peak pick -> distribute/interpolate -> apply display gain
 
             // this does the first three:
-            preparedColumn = getColumn(sx, minbin, nbins, -1);
+            preparedColumn = getColumn(sx, minbin, nbins, model);
             
             magRange.sample(preparedColumn);
 
@@ -645,7 +631,7 @@
         if (!peakCache) continue;
         int bpp = peakCache->getColumnsPerPeak();
         ZoomLevel equivZoom(ZoomLevel::FramesPerPixel, binResolution * bpp);
-#ifdef DEBUG_COLOUR_PLOT_REPAINT
+#ifdef DEBUG_COLOUR_PLOT_CACHE_SELECTION
         SVDEBUG << "render " << m_sources.source
                 << ": getPreferredPeakCache: zoomLevel = " << zoomLevel
                 << ", cache " << ix << " has bpp = " << bpp
@@ -661,7 +647,7 @@
         }
     }
 
-#ifdef DEBUG_COLOUR_PLOT_REPAINT
+#ifdef DEBUG_COLOUR_PLOT_CACHE_SELECTION
     SVDEBUG << "render " << m_sources.source
             << ": getPreferredPeakCache: zoomLevel = " << zoomLevel
             << ", binResolution " << binResolution 
@@ -1119,7 +1105,7 @@
 
                 // this does the first three:
                 ColumnOp::Column column = getColumn(sx, minbin, nbins,
-                                                    peakCacheIndex);
+                                                    sourceModel);
 
                 magRange.sample(column);
 
@@ -1284,7 +1270,7 @@
             }
 
             if (sx != psx) {
-                preparedColumn = getColumn(sx, minbin, nbins, -1);
+                preparedColumn = getColumn(sx, minbin, nbins, fft);
                 magRange.sample(preparedColumn);
                 psx = sx;
             }
--- a/layer/Colour3DPlotRenderer.h	Wed Sep 11 20:36:04 2019 +0100
+++ b/layer/Colour3DPlotRenderer.h	Thu Sep 12 11:53:17 2019 +0100
@@ -33,6 +33,7 @@
 class VerticalBinLayer;
 class RenderTimer;
 class Dense3DModelPeakCache;
+class DenseThreeDimensionalModel;
 
 enum class BinDisplay {
     AllBins,
@@ -323,9 +324,9 @@
         const;
     
     ColumnOp::Column getColumn(int sx, int minbin, int nbins,
-                               int peakCacheIndex) const; // -1 => don't use cache
+                               std::shared_ptr<DenseThreeDimensionalModel> source) const;
     ColumnOp::Column getColumnRaw(int sx, int minbin, int nbins,
-                                  int peakCacheIndex) const; // -1 => don't use cache
+                                  std::shared_ptr<DenseThreeDimensionalModel> source) const;
 
     void getPreferredPeakCache(const LayerGeometryProvider *,
                                int &peakCacheIndex, int &binsPerPeak) const;