diff layer/Colour3DPlotLayer.cpp @ 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
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();