diff layer/TimeValueLayer.cpp @ 1471:f2525e6cbdf1 by-id

More layer updates
author Chris Cannam
date Mon, 01 Jul 2019 14:17:13 +0100
parents 696e569ff21b
children 36ad3cdabf55
line wrap: on
line diff
--- a/layer/TimeValueLayer.cpp	Fri Jun 28 17:37:22 2019 +0100
+++ b/layer/TimeValueLayer.cpp	Mon Jul 01 14:17:13 2019 +0100
@@ -82,27 +82,30 @@
 void
 TimeValueLayer::setModel(ModelId modelId)
 {
+    auto newModel = ModelById::getAs<SparseTimeValueModel>(modelId);
+    
+    if (!modelId.isNone() && !newModel) {
+        throw std::logic_error("Not a SparseTimeValueModel");
+    }
+    
     if (m_model == modelId) return;
     m_model = modelId;
 
-    auto newModel = ModelById::getAs<SparseOneDimensionalModel>(modelId);
+    if (newModel) {
+        
+        connectSignals(m_model);
 
-    connectSignals(m_model);
+        m_scaleMinimum = 0;
+        m_scaleMaximum = 0;
 
-    m_scaleMinimum = 0;
-    m_scaleMaximum = 0;
-
-    if (newModel && newModel->getRDFTypeURI().endsWith("Segment")) {
-        setPlotStyle(PlotSegmentation);
+        if (newModel->getRDFTypeURI().endsWith("Segment")) {
+            setPlotStyle(PlotSegmentation);
+        }
+        if (newModel->getRDFTypeURI().endsWith("Change")) {
+            setPlotStyle(PlotSegmentation);
+        }
     }
-    if (newModel && m_model->getRDFTypeURI().endsWith("Change")) {
-        setPlotStyle(PlotSegmentation);
-    }
-
-#ifdef DEBUG_TIME_VALUE_LAYER
-    cerr << "TimeValueLayer::setModel(" << model << ")" << endl;
-#endif
-
+    
     emit modelReplaced();
 }