Mercurial > hg > svgui
diff layer/SpectrogramLayer.cpp @ 1504:150d4e561b07
Only set maximum frequency on FFT model when in a special verticallyFixed mode
author | Chris Cannam |
---|---|
date | Thu, 12 Sep 2019 13:50:24 +0100 |
parents | 2c7a480f93ca |
children | e6362cf5ff1d |
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp Thu Sep 12 11:53:40 2019 +0100 +++ b/layer/SpectrogramLayer.cpp Thu Sep 12 13:50:24 2019 +0100 @@ -70,6 +70,7 @@ m_minFrequency(10), m_maxFrequency(8000), m_initialMaxFrequency(8000), + m_verticallyFixed(false), m_colourScale(ColourScaleType::Log), m_colourScaleMultiple(1.0), m_colourMap(0), @@ -134,6 +135,14 @@ } void +SpectrogramLayer::setVerticallyFixed() +{ + if (m_verticallyFixed) return; + m_verticallyFixed = true; + recreateFFTModel(); +} + +void SpectrogramLayer::deleteDerivedModels() { ModelById::release(m_fftModel); @@ -845,6 +854,10 @@ { if (m_minFrequency == mf) return; + if (m_verticallyFixed) { + throw std::logic_error("setMinFrequency called with value differing from the default, on SpectrogramLayer with verticallyFixed true"); + } + // SVDEBUG << "SpectrogramLayer::setMinFrequency: " << mf << endl; invalidateRenderers(); @@ -866,16 +879,16 @@ { if (m_maxFrequency == mf) return; + if (m_verticallyFixed) { + throw std::logic_error("setMaxFrequency called with value differing from the default, on SpectrogramLayer with verticallyFixed true"); + } + // SVDEBUG << "SpectrogramLayer::setMaxFrequency: " << mf << endl; invalidateRenderers(); invalidateMagnitudes(); m_maxFrequency = mf; - - if (auto fftModel = ModelById::getAs<FFTModel>(m_fftModel)) { - fftModel->setMaximumFrequency(m_maxFrequency); - } emit layerParametersChanged(); } @@ -1424,7 +1437,9 @@ return; } - newFFTModel->setMaximumFrequency(getMaxFrequency()); + if (m_verticallyFixed) { + newFFTModel->setMaximumFrequency(getMaxFrequency()); + } m_fftModel = ModelById::add(newFFTModel); @@ -1797,12 +1812,13 @@ invalidateRenderers(); invalidateMagnitudes(); + if (m_verticallyFixed && + (m_minFrequency != minf || m_maxFrequency != maxf)) { + throw std::logic_error("setDisplayExtents called with values differing from the defaults, on SpectrogramLayer with verticallyFixed true"); + } + m_minFrequency = minf; m_maxFrequency = maxf; - - if (auto fftModel = ModelById::getAs<FFTModel>(m_fftModel)) { - fftModel->setMaximumFrequency(m_maxFrequency); - } emit layerParametersChanged();