diff layer/Colour3DPlotRenderer.cpp @ 1325:bc2cb82050a0 zoom

Gradual ZoomLevel updates
author Chris Cannam
date Wed, 19 Sep 2018 15:42:22 +0100
parents a34a2a25907c
children 344f29e46258
line wrap: on
line diff
--- a/layer/Colour3DPlotRenderer.cpp	Mon Sep 17 13:51:31 2018 +0100
+++ b/layer/Colour3DPlotRenderer.cpp	Wed Sep 19 15:42:22 2018 +0100
@@ -32,7 +32,10 @@
 
 #include <vector>
 
-//#define DEBUG_COLOUR_PLOT_REPAINT 1
+#include <utility>
+using namespace std::rel_ops;
+
+#define DEBUG_COLOUR_PLOT_REPAINT 1
 
 using namespace std;
 
@@ -315,7 +318,7 @@
     }
 
     int binResolution = model->getResolution();
-    int zoomLevel = v->getZoomLevel();
+    ZoomLevel zoomLevel = v->getZoomLevel();
     sv_samplerate_t modelRate = model->getSampleRate();
 
     double rateRatio = v->getViewManager()->getMainModelSampleRate() / modelRate;
@@ -332,12 +335,14 @@
         // explicitly requested opaque & sufficiently zoomed-in
         
         if (model->getHeight() * 3 < v->getPaintHeight() &&
-            relativeBinResolution >= 3 * zoomLevel) {
+            zoomLevel < ZoomLevel(ZoomLevel::FramesPerPixel,
+                                  int(round(relativeBinResolution / 3)))) {
             return DirectTranslucent;
         }
     }
 
-    if (relativeBinResolution > zoomLevel) {
+    if (ZoomLevel(ZoomLevel::FramesPerPixel,
+                  int(round(relativeBinResolution))) > zoomLevel) {
         return DrawBufferBinResolution;
     } else {
         return DrawBufferPixelResolution;
@@ -555,12 +560,12 @@
     if (m_params.binDisplay == BinDisplay::PeakFrequencies) return;
     if (m_params.colourScale.getScale() == ColourScaleType::Phase) return;
     
-    int zoomLevel = v->getZoomLevel();
+    ZoomLevel zoomLevel = v->getZoomLevel();
     int binResolution = model->getResolution();
     
     for (int ix = 0; in_range_for(m_sources.peakCaches, ix); ++ix) {
         int bpp = m_sources.peakCaches[ix]->getColumnsPerPeak();
-        int equivZoom = binResolution * bpp;
+        ZoomLevel equivZoom(ZoomLevel::FramesPerPixel, binResolution * bpp);
         if (zoomLevel >= equivZoom) {
             // this peak cache would work, though it might not be best
             if (bpp > binsPerPeak) {