Mercurial > hg > svgui
changeset 1138:998e31e92dbe spectrogram-minor-refactor
Restore phase display
author | Chris Cannam |
---|---|
date | Thu, 04 Aug 2016 14:02:56 +0100 |
parents | 4e7ed3252d80 |
children | 2976f57164ac |
files | layer/Colour3DPlotRenderer.cpp layer/Colour3DPlotRenderer.h layer/ColourScale.cpp |
diffstat | 3 files changed, 52 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotRenderer.cpp Thu Aug 04 11:26:11 2016 +0100 +++ b/layer/Colour3DPlotRenderer.cpp Thu Aug 04 14:02:56 2016 +0100 @@ -292,6 +292,41 @@ } } +ColumnOp::Column +Colour3DPlotRenderer::getColumn(int sx, int minbin, int nbins) const +{ + // order: + // get column -> scale -> normalise -> record extents -> + // peak pick -> distribute/interpolate -> apply display gain + + // we do the first bit here: + // get column -> scale -> normalise + + ColumnOp::Column column; + + 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 = m_sources.source->getColumn(sx); + + column = vector<float>(fullColumn.data() + minbin, + fullColumn.data() + minbin + nbins); + + column = ColumnOp::applyGain(column, m_params.scaleFactor); + + column = ColumnOp::normalize(column, m_params.normalization); + } + + return column; +} + MagnitudeRange Colour3DPlotRenderer::renderDirectTranslucent(const LayerGeometryProvider *v, QPainter &paint, @@ -351,23 +386,12 @@ if (sx != psx) { - //!!! this is in common with renderDrawBuffer - pull it out + // order: + // get column -> scale -> normalise -> record extents -> + // peak pick -> distribute/interpolate -> apply display gain - // order: - // get column -> scale -> record extents -> - // normalise -> peak pick -> apply display gain - - ColumnOp::Column fullColumn = model->getColumn(sx); - - ColumnOp::Column column = - vector<float>(fullColumn.data() + minbin, - fullColumn.data() + minbin + nbins); - - column = ColumnOp::applyGain(column, m_params.scaleFactor); - -// if (m_colourScale != ColourScaleType::Phase) { - preparedColumn = ColumnOp::normalize(column, m_params.normalization); -// } + // this does the first three: + preparedColumn = getColumn(sx, minbin, nbins); magRange.sample(preparedColumn); @@ -784,29 +808,16 @@ } if (sx != psx) { + + // order: + // get column -> scale -> normalise -> record extents -> + // peak pick -> distribute/interpolate -> apply display gain - // order: - // get column -> scale -> record extents -> - // normalise -> peak pick -> distribute/interpolate -> - // apply display gain - - ColumnOp::Column fullColumn = sourceModel->getColumn(sx); - -// cerr << "x " << x << ", sx " << sx << ", col height " << fullColumn.size() -// << ", minbin " << minbin << ", nbins " << nbins << endl; - - ColumnOp::Column column = - vector<float>(fullColumn.data() + minbin, - fullColumn.data() + minbin + nbins); - - column = ColumnOp::applyGain(column, m_params.scaleFactor); - -// if (m_colourScale != ColourScaleType::Phase) { - column = ColumnOp::normalize(column, m_params.normalization); -// } + // this does the first three: + ColumnOp::Column column = getColumn(sx, minbin, nbins); magRange.sample(column); - + if (m_params.binDisplay == BinDisplay::PeakBins) { column = ColumnOp::peakPick(column); } @@ -943,22 +954,8 @@ } if (sx != psx) { - - ColumnOp::Column fullColumn = fft->getColumn(sx); - - ColumnOp::Column column = - vector<float>(fullColumn.data() + minbin, - fullColumn.data() + minbin + nbins + 1); - - column = ColumnOp::applyGain(column, m_params.scaleFactor); - -//!!! if (m_colourScale != ColourScaleType::Phase) { - preparedColumn = ColumnOp::normalize - (column, m_params.normalization); -//!!! } - + preparedColumn = getColumn(sx, minbin, nbins); magRange.sample(preparedColumn); - psx = sx; }
--- a/layer/Colour3DPlotRenderer.h Thu Aug 04 11:26:11 2016 +0100 +++ b/layer/Colour3DPlotRenderer.h Thu Aug 04 14:02:56 2016 +0100 @@ -294,6 +294,8 @@ }; RenderType decideRenderType(const LayerGeometryProvider *) const; + + ColumnOp::Column getColumn(int sx, int minbin, int nbins) const; }; #endif
--- a/layer/ColourScale.cpp Thu Aug 04 11:26:11 2016 +0100 +++ b/layer/ColourScale.cpp Thu Aug 04 14:02:56 2016 +0100 @@ -88,7 +88,8 @@ if (m_params.scaleType == ColourScaleType::Phase) { double half = (maxPixF - 1.f) / 2.f; - return 1 + int((value * half) / M_PI + half); + int pixel = 1 + int((value * half) / M_PI + half); + return pixel; } value *= m_params.gain;