Mercurial > hg > svgui
changeset 1235:dd3901fe8623
Wire up normalise-visible-area mode in colour 3d plot
author | Chris Cannam |
---|---|
date | Fri, 27 Jan 2017 11:39:42 +0000 |
parents | 81dfe06a45c9 |
children | 784c92f93fb6 |
files | layer/Colour3DPlotLayer.cpp layer/Colour3DPlotLayer.h layer/Colour3DPlotRenderer.cpp |
diffstat | 3 files changed, 59 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Fri Jan 27 11:39:29 2017 +0000 +++ b/layer/Colour3DPlotLayer.cpp Fri Jan 27 11:39:42 2017 +0000 @@ -159,6 +159,7 @@ m_peakCache = 0; invalidateRenderers(); + invalidateMagnitudes(); emit modelReplaced(); emit sliceableModelReplaced(oldModel, model); @@ -168,6 +169,7 @@ Colour3DPlotLayer::cacheInvalid() { invalidateRenderers(); + invalidateMagnitudes(); } void @@ -179,6 +181,7 @@ m_peakCache = 0; invalidateRenderers(); + invalidateMagnitudes(); } void @@ -191,6 +194,15 @@ m_renderers.clear(); } +void +Colour3DPlotLayer::invalidateMagnitudes() +{ +#ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT + cerr << "Colour3DPlotLayer::invalidateMagnitudes called" << endl; +#endif + m_viewMags.clear(); +} + Dense3DModelPeakCache * Colour3DPlotLayer::getPeakCache() const { @@ -531,8 +543,9 @@ { if (m_normalizeVisibleArea == n) return; + invalidateRenderers(); + invalidateMagnitudes(); m_normalizeVisibleArea = n; - invalidateRenderers(); emit layerParametersChanged(); } @@ -615,17 +628,7 @@ bool Colour3DPlotLayer::isLayerScrollable(const LayerGeometryProvider * /* v */) const { - if (m_normalizeVisibleArea) { - return false; - } - //!!! ah hang on, if we're potentially rendering incrementally - //!!! they we can't be scrollable return false; -// if (getRenderer(v)->willRenderOpaque(v)) { -// return true; -// } -// QPoint discard; -// return !v->shouldIlluminateLocalFeatures(this, discard); } bool @@ -1034,7 +1037,9 @@ Colour3DPlotRenderer * Colour3DPlotLayer::getRenderer(const LayerGeometryProvider *v) const { - if (m_renderers.find(v->getId()) == m_renderers.end()) { + int viewId = v->getId(); + + if (m_renderers.find(viewId) == m_renderers.end()) { Colour3DPlotRenderer::Sources sources; sources.verticalBinLayer = this; @@ -1047,18 +1052,30 @@ cparams.scaleType = m_colourScale; cparams.gain = m_gain; - if (m_normalization == ColumnNormalization::None) { - cparams.minValue = m_model->getMinimumLevel(); - cparams.maxValue = m_model->getMaximumLevel(); + double minValue = 0.0; + double maxValue = 1.0; + + if (m_normalizeVisibleArea && m_viewMags[viewId].isSet()) { + minValue = m_viewMags[viewId].getMin(); + maxValue = m_viewMags[viewId].getMax(); + } else if (m_normalization == ColumnNormalization::None) { + minValue = m_model->getMinimumLevel(); + maxValue = m_model->getMaximumLevel(); } else if (m_normalization == ColumnNormalization::Hybrid) { - cparams.minValue = 0; - cparams.maxValue = log10(m_model->getMaximumLevel() + 1.0); + minValue = 0; + maxValue = log10(m_model->getMaximumLevel() + 1.0); } - if (cparams.maxValue <= cparams.minValue) { - cparams.maxValue = cparams.minValue + 0.1; + if (maxValue <= minValue) { + maxValue = minValue + 0.1f; } + + cparams.minValue = minValue; + cparams.maxValue = maxValue; + m_lastRenderedMags[viewId] = MagnitudeRange(float(minValue), + float(maxValue)); + Colour3DPlotRenderer::Parameters params; params.colourScale = ColourScale(cparams); params.normalization = m_normalization; @@ -1067,10 +1084,10 @@ params.invertVertical = m_invertVertical; params.interpolate = m_smooth; - m_renderers[v->getId()] = new Colour3DPlotRenderer(sources, params); + m_renderers[viewId] = new Colour3DPlotRenderer(sources, params); } - return m_renderers[v->getId()]; + return m_renderers[viewId]; } void @@ -1083,7 +1100,9 @@ MagnitudeRange magRange; int viewId = v->getId(); - if (!renderer->geometryChanged(v)) { + bool continuingPaint = !renderer->geometryChanged(v); + + if (continuingPaint) { magRange = m_viewMags[viewId]; } @@ -1104,17 +1123,25 @@ magRange.sample(result.range); if (magRange.isSet()) { - if (!(m_viewMags[viewId] == magRange)) { + if (m_viewMags[viewId] != magRange) { m_viewMags[viewId] = magRange; - //!!! now need to do the normalise-visible thing +#ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT + cerr << "mag range in this view has changed: " + << magRange.getMin() << " -> " << magRange.getMax() << endl; +#endif } } - SVDEBUG << "Colour3DPlotRenderer::paintWithRenderer: mag range in this view: " - << m_viewMags[v->getId()].getMin() - << " -> " - << m_viewMags[v->getId()].getMax() - << endl; + if (!continuingPaint && m_normalizeVisibleArea && + m_viewMags[viewId] != m_lastRenderedMags[viewId]) { +#ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT + cerr << "mag range has changed from last rendered range: re-rendering" + << endl; +#endif + delete m_renderers[viewId]; + m_renderers.erase(viewId); + v->updatePaintRect(v->getPaintRect()); + } } void @@ -1147,16 +1174,6 @@ return; } - //!!!??? - - if (m_normalizeVisibleArea) { - rect = v->getPaintRect(); - } - - //!!! why is the setLayerDormant(false) found here in - //!!! SpectrogramLayer not present in Colour3DPlotLayer? - //!!! unnecessary? vestigial? forgotten? - paintWithRenderer(v, paint, rect); }
--- a/layer/Colour3DPlotLayer.h Fri Jan 27 11:39:29 2017 +0000 +++ b/layer/Colour3DPlotLayer.h Fri Jan 27 11:39:42 2017 +0000 @@ -187,6 +187,8 @@ typedef std::map<int, MagnitudeRange> ViewMagMap; // key is view id mutable ViewMagMap m_viewMags; + mutable ViewMagMap m_lastRenderedMags; // when in normalizeVisibleArea mode + void invalidateMagnitudes(); typedef std::map<int, Colour3DPlotRenderer *> ViewRendererMap; // key is view id mutable ViewRendererMap m_renderers;
--- a/layer/Colour3DPlotRenderer.cpp Fri Jan 27 11:39:29 2017 +0000 +++ b/layer/Colour3DPlotRenderer.cpp Fri Jan 27 11:39:42 2017 +0000 @@ -105,7 +105,7 @@ } else if (m_secondsPerXPixelValid) { double predicted = m_secondsPerXPixel * rect.width(); -#ifdef DEBUG_COLOUR_PLOT_REPAINT +/#ifdef DEBUG_COLOUR_PLOT_REPAINT SVDEBUG << "Predicted time for width " << rect.width() << " = " << predicted << endl; #endif