Mercurial > hg > svgui
diff layer/SpectrogramLayer.cpp @ 193:57c2350a8c40
* Add slice layers (so you can display a slice of a colour 3d plot as if it were
a spectrum)
* Make spectrum layer a subclass of slice layer
author | Chris Cannam |
---|---|
date | Fri, 26 Jan 2007 16:59:57 +0000 |
parents | dd573e090eed |
children | 22c99c8aa1e0 |
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp Wed Jan 24 17:14:24 2007 +0000 +++ b/layer/SpectrogramLayer.cpp Fri Jan 26 16:59:57 2007 +0000 @@ -39,7 +39,6 @@ //#define DEBUG_SPECTROGRAM_REPAINT 1 SpectrogramLayer::SpectrogramLayer(Configuration config) : - Layer(), m_model(0), m_channel(0), m_windowSize(1024), @@ -62,7 +61,8 @@ m_lastEmittedZoomStep(-1), m_updateTimer(0), m_candidateFillStartFrame(0), - m_exiting(false) + m_exiting(false), + m_sliceableModel(0) { if (config == MelodicRange) { setWindowSize(8192); @@ -901,6 +901,20 @@ m_pixmapCaches.erase(v); if (m_fftModels.find(v) != m_fftModels.end()) { + + if (m_sliceableModel == m_fftModels[v].first) { + bool replaced = false; + for (ViewFFTMap::iterator i = m_fftModels.begin(); + i != m_fftModels.end(); ++i) { + if (i->second.first != m_sliceableModel) { + emit sliceableModelReplaced(m_sliceableModel, i->second.first); + replaced = true; + break; + } + } + if (!replaced) emit sliceableModelReplaced(m_sliceableModel, 0); + } + delete m_fftModels[v].first; m_fftModels.erase(v); } @@ -1626,6 +1640,12 @@ return 0; } + if (!m_sliceableModel) { + std::cerr << "SpectrogramLayer: emitting sliceableModelReplaced(0, " << model << ")" << std::endl; + ((SpectrogramLayer *)this)->sliceableModelReplaced(0, model); + m_sliceableModel = model; + } + m_fftModels[v] = FFTFillPair(model, 0); model->resume(); @@ -1640,6 +1660,15 @@ return m_fftModels[v].first; } +const Model * +SpectrogramLayer::getSliceableModel() const +{ + if (m_sliceableModel) return m_sliceableModel; + if (m_fftModels.empty()) return 0; + m_sliceableModel = m_fftModels.begin()->second.first; + return m_sliceableModel; +} + void SpectrogramLayer::invalidateFFTModels() { @@ -1649,6 +1678,12 @@ } m_fftModels.clear(); + + if (m_sliceableModel) { + std::cerr << "SpectrogramLayer: emitting sliceableModelReplaced(" << m_sliceableModel << ", 0)" << std::endl; + emit sliceableModelReplaced(m_sliceableModel, 0); + m_sliceableModel = 0; + } } void