Mercurial > hg > svgui
diff layer/Colour3DPlotRenderer.cpp @ 1469:11a150e65ee1 by-id
Some work on updating layers for ModelId bits
author | Chris Cannam |
---|---|
date | Thu, 27 Jun 2019 13:16:25 +0100 |
parents | f72fb7fac92a |
children | f2525e6cbdf1 |
line wrap: on
line diff
--- a/layer/Colour3DPlotRenderer.cpp Thu Jun 13 15:35:01 2019 +0100 +++ b/layer/Colour3DPlotRenderer.cpp Thu Jun 27 13:16:25 2019 +0100 @@ -334,7 +334,7 @@ Colour3DPlotRenderer::RenderType Colour3DPlotRenderer::decideRenderType(const LayerGeometryProvider *v) const { - const DenseThreeDimensionalModel *model = m_sources.source; + auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); if (!model || !v || !(v->getViewManager())) { return DrawBufferPixelResolution; // or anything } @@ -398,7 +398,7 @@ } if (m_params.colourScale.getScale() == ColourScaleType::Phase && - m_sources.fft) { + !m_sources.fft.isNone()) { return column; } else { column = ColumnOp::applyGain(column, m_params.scaleFactor); @@ -414,27 +414,31 @@ Profiler profiler("Colour3DPlotRenderer::getColumn"); ColumnOp::Column column; + ColumnOp::Column fullColumn; - if (m_params.colourScale.getScale() == ColourScaleType::Phase && - m_sources.fft) { - - ColumnOp::Column fullColumn = m_sources.fft->getPhases(sx); - - column = vector<float>(fullColumn.data() + minbin, - fullColumn.data() + minbin + nbins); - - } else { - - ColumnOp::Column fullColumn = - (peakCacheIndex >= 0 ? - m_sources.peakCaches[peakCacheIndex] : - m_sources.source) - ->getColumn(sx); - - column = vector<float>(fullColumn.data() + minbin, - fullColumn.data() + minbin + nbins); + if (m_params.colourScale.getScale() == ColourScaleType::Phase) { + auto fftModel = ModelById::getAs<FFTModel>(m_sources.fft); + if (fftModel) { + fullColumn = fftModel->getPhases(sx); + } } + if (fullColumn.empty()) { + + if (peakCacheIndex >= 0) { + fullColumn = m_sources.peakCaches[peakCacheIndex]->getColumn(sx); + } else { + auto model = ModelById::getAs<DenseThreeDimensionalModel> + (m_sources.source); + if (!model) { + return vector<float>(nbins, 0.f); + } + fullColumn = model->getColumn(sx); + } + } + + column = vector<float>(fullColumn.data() + minbin, + fullColumn.data() + minbin + nbins); return column; } @@ -451,7 +455,8 @@ bool illuminate = v->shouldIlluminateLocalFeatures (m_sources.verticalBinLayer, illuminatePos); - const DenseThreeDimensionalModel *model = m_sources.source; + auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); + if (!model) return magRange; int x0 = rect.left(); int x1 = rect.right() + 1; @@ -602,7 +607,7 @@ peakCacheIndex = -1; binsPerPeak = -1; - const DenseThreeDimensionalModel *model = m_sources.source; + auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); if (!model) return; if (m_params.binDisplay == BinDisplay::PeakFrequencies) return; if (m_params.colourScale.getScale() == ColourScaleType::Phase) return; @@ -653,10 +658,8 @@ // buffer is at the same resolution as the target in the cache, so // no extra scaling needed. - const DenseThreeDimensionalModel *model = m_sources.source; - if (!model || !model->isOK() || !model->isReady()) { - throw std::logic_error("no source model provided, or model not ready"); - } + auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); + if (!model) return; int h = v->getPaintHeight(); @@ -794,10 +797,8 @@ // buffer is at bin resolution, i.e. buffer x == source column // number. We use toolkit smooth scaling for interpolation. - const DenseThreeDimensionalModel *model = m_sources.source; - if (!model || !model->isOK() || !model->isReady()) { - throw std::logic_error("no source model provided, or model not ready"); - } + auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); + if (!model) return; // The draw buffer will contain a fragment at bin resolution. We // need to ensure that it starts and ends at points where a @@ -950,7 +951,10 @@ Profiler profiler("Colour3DPlotRenderer::renderDrawBuffer"); int divisor = 1; - const DenseThreeDimensionalModel *sourceModel = m_sources.source; + auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); + if (!model) return 0; + + const DenseThreeDimensionalModel *sourceModel = model.get(); if (peakCacheIndex >= 0) { divisor = m_sources.peakCaches[peakCacheIndex]->getColumnsPerPeak(); sourceModel = m_sources.peakCaches[peakCacheIndex]; @@ -1125,7 +1129,8 @@ RenderTimer::SlowRender : RenderTimer::NoTimeout); - const FFTModel *fft = m_sources.fft; + auto fft = ModelById::getAs<FFTModel>(m_sources.fft); + if (!fft) return 0; int sh = fft->getHeight();