diff layer/WaveformLayer.cpp @ 1470:696e569ff21b by-id

Further layer updates for ById
author Chris Cannam
date Fri, 28 Jun 2019 17:37:22 +0100
parents e866102db32a
children f2525e6cbdf1
line wrap: on
line diff
--- a/layer/WaveformLayer.cpp	Thu Jun 27 13:16:25 2019 +0100
+++ b/layer/WaveformLayer.cpp	Fri Jun 28 17:37:22 2019 +0100
@@ -60,26 +60,41 @@
     delete m_cache;
 }
 
+const ZoomConstraint *
+WaveformLayer::getZoomConstraint() const
+{
+    auto model = ModelById::get(m_model);
+    if (model) return m_model->getZoomConstraint();
+    else return nullptr;
+}
+
 void
-WaveformLayer::setModel(const RangeSummarisableTimeValueModel *model)
+WaveformLayer::setModel(ModelId modelId)
 {
+    auto oldModel = ModelById::getAs<RangeSummarisableTimeValueModel>(m_model);
+    auto newModel = ModelById::getAs<RangeSummarisableTimeValueModel>(modelId);
+
+    if (!newModel) {
+        SVCERR << "WARNING: WaveformLayer::setModel: Model is not a RangeSummarisableTimeValueModel" << endl;
+    }
+    
     bool channelsChanged = false;
     if (m_channel == -1) {
-        if (!m_model) {
-            if (model) {
+        if (!oldModel) {
+            if (newModel) {
                 channelsChanged = true;
             }
         } else {
-            if (model &&
-                m_model->getChannelCount() != model->getChannelCount()) {
+            if (newModel &&
+                oldModel->getChannelCount() != newModel->getChannelCount()) {
                 channelsChanged = true;
             }
         }
     }
 
-    m_model = model;
+    m_model = modelId;
     m_cacheValid = false;
-    if (!m_model || !m_model->isOK()) return;
+    if (!newModel || !newModel->isOK()) return;
 
     connectSignals(m_model);