comparison 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
comparison
equal deleted inserted replaced
1470:696e569ff21b 1471:f2525e6cbdf1
206 default: return 0; 206 default: return 0;
207 } 207 }
208 } 208 }
209 209
210 void 210 void
211 SpectrogramLayer::setModel(const DenseTimeValueModel *model) 211 SpectrogramLayer::setModel(ModelId modelId)
212 { 212 {
213 // cerr << "SpectrogramLayer(" << this << "): setModel(" << model << ")" << endl; 213 auto newModel = ModelById::getAs<DenseTimeValueModel>(modelId);
214 214 if (!modelId.isNone() && !newModel) {
215 if (model == m_model) return; 215 throw std::logic_error("Not a DenseTimeValueModel");
216 216 }
217 m_model = model; 217
218 218 if (modelId == m_model) return;
219 recreateFFTModel(); 219 m_model = modelId;
220 220
221 if (!m_model || !m_model->isOK()) return; 221 if (newModel) {
222 222 recreateFFTModel();
223 connectSignals(m_model); 223
224 224 connectSignals(m_model);
225 connect(m_model, SIGNAL(modelChanged()), this, SLOT(cacheInvalid())); 225
226 connect(m_model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), 226 connect(newModel.get(), SIGNAL(modelChanged()),
227 this, SLOT(cacheInvalid(sv_frame_t, sv_frame_t))); 227 this, SLOT(cacheInvalid()));
228 228 connect(newModel.get(), SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)),
229 this, SLOT(cacheInvalid(sv_frame_t, sv_frame_t)));
230 }
231
229 emit modelReplaced(); 232 emit modelReplaced();
230 } 233 }
231 234
232 Layer::PropertyList 235 Layer::PropertyList
233 SpectrogramLayer::getProperties() const 236 SpectrogramLayer::getProperties() const