changeset 1101:1364cbf4453d spectrogram-minor-refactor

Begin using renderer in colour 3d plot layer
author Chris Cannam
date Wed, 13 Jul 2016 13:30:39 +0100
parents 102f986ec032
children 36a981a0fa31
files layer/Colour3DPlotLayer.cpp layer/Colour3DPlotLayer.h layer/SpectrogramLayer.cpp
diffstat 3 files changed, 53 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp	Wed Jul 13 13:06:28 2016 +0100
+++ b/layer/Colour3DPlotLayer.cpp	Wed Jul 13 13:30:39 2016 +0100
@@ -64,6 +64,7 @@
     m_peakResolution(256),
     m_miny(0),
     m_maxy(0),
+    m_synchronous(false),
     m_peakCache(0),
     m_peakCacheDivisor(8)
 {
@@ -81,6 +82,12 @@
 }
 
 void
+Colour3DPlotLayer::setSynchronousPainting(bool synchronous)
+{
+    m_synchronous = synchronous;
+}
+
+void
 Colour3DPlotLayer::setModel(const DenseThreeDimensionalModel *model)
 {
     if (m_model == model) return;
@@ -1318,6 +1325,36 @@
 }
 
 void
+Colour3DPlotLayer::paintAlternative(LayerGeometryProvider *v, QPainter &paint, QRect rect) const
+{
+    static int depth = 0;
+    
+    Colour3DPlotRenderer *renderer = getRenderer(v);
+
+    if (m_synchronous) {
+        (void)renderer->render(v, paint, rect);
+        return;
+    }
+
+    ++depth;
+    cerr << "paint depth " << depth << endl;
+    
+    (void)renderer->renderTimeConstrained(v, paint, rect);
+
+    //!!! + mag range
+
+    QRect uncached = renderer->getLargestUncachedRect();
+    if (uncached.width() > 0) {
+        cerr << "updating rect at " << uncached.x() << " width "
+             << uncached.width() << endl;
+        v->updatePaintRect(uncached);
+    }
+
+    cerr << "exiting paint depth " << depth << endl;
+    --depth;
+}
+
+void
 Colour3DPlotLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const
 {
 /*
@@ -1346,6 +1383,15 @@
 #endif
         return;
     }
+
+    //!!! why is the setLayerDormant(false) found here in
+    //!!! SpectrogramLayer not present in Colour3DPlotLayer?
+    //!!! unnecessary? vestigial? forgotten?
+
+    paintAlternative(v, paint, rect);
+    return;
+
+    //!!!???
     
     if (m_normalization == ColumnOp::NormalizeVisibleArea) {
         rect = v->getPaintRect();
--- a/layer/Colour3DPlotLayer.h	Wed Jul 13 13:06:28 2016 +0100
+++ b/layer/Colour3DPlotLayer.h	Wed Jul 13 13:30:39 2016 +0100
@@ -52,6 +52,7 @@
     }
     virtual const Model *getModel() const { return m_model; }
     virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const;
+    virtual void setSynchronousPainting(bool synchronous);
 
     virtual int getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &) const;
     virtual void paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const;
@@ -172,6 +173,8 @@
     int         m_miny;
     int         m_maxy;
 
+    bool        m_synchronous;
+
     mutable Dense3DModelPeakCache *m_peakCache;
     const int m_peakCacheDivisor;
     Dense3DModelPeakCache *getPeakCache() const;
@@ -208,6 +211,9 @@
     int getColourScaleWidth(QPainter &) const;
     void fillCache(int firstBin, int lastBin) const;
     void paintDense(LayerGeometryProvider *v, QPainter &paint, QRect rect) const;
+
+    void paintAlternative(LayerGeometryProvider *v, QPainter &paint, QRect rect) const;
+
 };
 
 #endif
--- a/layer/SpectrogramLayer.cpp	Wed Jul 13 13:06:28 2016 +0100
+++ b/layer/SpectrogramLayer.cpp	Wed Jul 13 13:30:39 2016 +0100
@@ -1531,6 +1531,7 @@
 ScrollableImageCache &
 SpectrogramLayer::getImageCacheReference(const LayerGeometryProvider *view) const
 {
+    //!!! to go?
     if (m_imageCaches.find(view->getId()) == m_imageCaches.end()) {
         m_imageCaches[view->getId()] = ScrollableImageCache();
     }