Mercurial > hg > svgui
diff layer/SpectrumLayer.cpp @ 1389:1eb560b363e7 spectrogramparam
Make "zoom to region" work sensibly for slice/spectrum layers; ensure that min/max bin are remapped properly when changing fft size
author | Chris Cannam |
---|---|
date | Tue, 13 Nov 2018 14:06:48 +0000 |
parents | bca9870301b7 |
children | c39f2d439d59 |
line wrap: on
line diff
--- a/layer/SpectrumLayer.cpp Tue Nov 13 13:39:01 2018 +0000 +++ b/layer/SpectrumLayer.cpp Tue Nov 13 14:06:48 2018 +0000 @@ -287,6 +287,16 @@ SpectrumLayer::setWindowSize(int ws) { if (m_windowSize == ws) return; + + SVDEBUG << "setWindowSize: from " << m_windowSize + << " to " << ws << ": updating min and max bins from " + << m_minbin << " and " << m_maxbin << " to "; + + m_minbin = int(round((double(m_minbin) / m_windowSize) * ws)); + m_maxbin = int(round((double(m_maxbin) / m_windowSize) * ws)); + + SVDEBUG << m_minbin << " and " << m_maxbin << endl; + m_windowSize = ws; m_newFFTNeeded = true; emit layerParametersChanged(); @@ -314,8 +324,19 @@ SpectrumLayer::setOversampling(int oversampling) { if (m_oversampling == oversampling) return; + + SVDEBUG << "setOversampling: from " << m_oversampling + << " to " << oversampling << ": updating min and max bins from " + << m_minbin << " and " << m_maxbin << " to "; + + m_minbin = int(round((double(m_minbin) / m_oversampling) * oversampling)); + m_maxbin = int(round((double(m_maxbin) / m_oversampling) * oversampling)); + + SVDEBUG << m_minbin << " and " << m_maxbin << endl; + m_oversampling = oversampling; m_newFFTNeeded = true; + emit layerParametersChanged(); }