Mercurial > hg > svgui
diff layer/Colour3DPlotLayer.cpp @ 1453:39f1154c0e97 single-point
Smoother cache & colour management in colour 3d plots
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 13:42:18 +0100 |
parents | af824022bffd |
children | 11a150e65ee1 |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Fri May 03 17:45:39 2019 +0100 +++ b/layer/Colour3DPlotLayer.cpp Thu May 09 13:42:18 2019 +0100 @@ -147,9 +147,10 @@ connectSignals(m_model); - connect(m_model, SIGNAL(modelChanged()), this, SLOT(modelChanged())); + connect(m_model, SIGNAL(modelChanged()), + this, SLOT(handleModelChanged())); connect(m_model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), - this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); + this, SLOT(handleModelChangedWithin(sv_frame_t, sv_frame_t))); m_peakResolution = 256; if (model->getResolution() > 512) { @@ -160,35 +161,22 @@ m_peakResolution = 128; } - if (m_peakCache) m_peakCache->aboutToDelete(); - delete m_peakCache; - m_peakCache = nullptr; - - invalidateRenderers(); - invalidateMagnitudes(); + invalidatePeakCache(); emit modelReplaced(); emit sliceableModelReplaced(oldModel, model); } void -Colour3DPlotLayer::cacheInvalid() +Colour3DPlotLayer::invalidatePeakCache() { + // renderers use the peak cache, so we must invalidate those too invalidateRenderers(); invalidateMagnitudes(); -} - -void -Colour3DPlotLayer::cacheInvalid(sv_frame_t /* startFrame */, - sv_frame_t /* endFrame */) -{ - //!!! should do this only if the range is visible + if (m_peakCache) m_peakCache->aboutToDelete(); delete m_peakCache; m_peakCache = nullptr; - - invalidateRenderers(); - invalidateMagnitudes(); } void @@ -220,7 +208,7 @@ } void -Colour3DPlotLayer::modelChanged() +Colour3DPlotLayer::handleModelChanged() { if (!m_colourScaleSet && m_colourScale == ColourScaleType::Linear) { if (m_model) { @@ -231,11 +219,12 @@ } } } - cacheInvalid(); + invalidatePeakCache(); + emit modelChanged(); } void -Colour3DPlotLayer::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) +Colour3DPlotLayer::handleModelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) { if (!m_colourScaleSet && m_colourScale == ColourScaleType::Linear) { if (m_model && m_model->getWidth() > 50) { @@ -246,7 +235,7 @@ } } } - cacheInvalid(startFrame, endFrame); + emit modelChangedWithin(startFrame, endFrame); } Layer::PropertyList @@ -620,6 +609,13 @@ return m_smooth; } +bool +Colour3DPlotLayer::hasLightBackground() const +{ + return ColourMapper(m_colourMap, m_colourInverted, 1.f, 255.f) + .hasLightBackground(); +} + void Colour3DPlotLayer::setLayerDormant(const LayerGeometryProvider *v, bool dormant) { @@ -636,7 +632,7 @@ Layer::setLayerDormant(v, true); - cacheInvalid(); + invalidatePeakCache(); // for memory-saving purposes } else {