Mercurial > hg > svgui
diff layer/SpectrogramLayer.cpp @ 1471:f2525e6cbdf1 by-id
More layer updates
author | Chris Cannam |
---|---|
date | Mon, 01 Jul 2019 14:17:13 +0100 |
parents | 66bf1abfefc1 |
children | dbff4b290bf0 |
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp Fri Jun 28 17:37:22 2019 +0100 +++ b/layer/SpectrogramLayer.cpp Mon Jul 01 14:17:13 2019 +0100 @@ -208,24 +208,27 @@ } void -SpectrogramLayer::setModel(const DenseTimeValueModel *model) +SpectrogramLayer::setModel(ModelId modelId) { -// cerr << "SpectrogramLayer(" << this << "): setModel(" << model << ")" << endl; - - if (model == m_model) return; - - m_model = model; - - recreateFFTModel(); - - if (!m_model || !m_model->isOK()) return; - - connectSignals(m_model); - - connect(m_model, SIGNAL(modelChanged()), this, SLOT(cacheInvalid())); - connect(m_model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), - this, SLOT(cacheInvalid(sv_frame_t, sv_frame_t))); - + auto newModel = ModelById::getAs<DenseTimeValueModel>(modelId); + if (!modelId.isNone() && !newModel) { + throw std::logic_error("Not a DenseTimeValueModel"); + } + + if (modelId == m_model) return; + m_model = modelId; + + if (newModel) { + recreateFFTModel(); + + connectSignals(m_model); + + connect(newModel.get(), SIGNAL(modelChanged()), + this, SLOT(cacheInvalid())); + connect(newModel.get(), SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SLOT(cacheInvalid(sv_frame_t, sv_frame_t))); + } + emit modelReplaced(); }