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

Further layer updates for ById
author Chris Cannam
date Fri, 28 Jun 2019 17:37:22 +0100
parents e561f0a8d75b
children f2525e6cbdf1
line wrap: on
line diff
--- a/layer/TimeInstantLayer.cpp	Thu Jun 27 13:16:25 2019 +0100
+++ b/layer/TimeInstantLayer.cpp	Fri Jun 28 17:37:22 2019 +0100
@@ -53,19 +53,29 @@
 {
 }
 
+int
+TimeInstantLayer::getCompletion(LayerGeometryProvider *) const
+{
+    auto model = ModelById::get(m_model);
+    if (model) return model->getCompletion();
+    else return 0;
+}
+
 void
-TimeInstantLayer::setModel(SparseOneDimensionalModel *model)
+TimeInstantLayer::setModel(ModelId modelId)
 {
-    if (m_model == model) return;
-    m_model = model;
+    if (m_model == modelId) return;
+    m_model = modelId;
 
+    auto newModel = ModelById::getAs<SparseOneDimensionalModel>(modelId);
+    
     connectSignals(m_model);
 
 #ifdef DEBUG_TIME_INSTANT_LAYER
-    cerr << "TimeInstantLayer::setModel(" << model << ")" << endl;
+    cerr << "TimeInstantLayer::setModel(" << modelId << ")" << endl;
 #endif
 
-    if (m_model && m_model->getRDFTypeURI().endsWith("Segment")) {
+    if (newModel && newModel->getRDFTypeURI().endsWith("Segment")) {
         setPlotStyle(PlotSegmentation);
     }
 
@@ -149,6 +159,14 @@
 }
 
 bool
+TimeInstantLayer::needsTextLabelHeight() const
+{
+    auto model = ModelById::getAs<SparseOneDimensionalModel>(m_model);
+    if (model) return m_model->hasTextLabels();
+    else return false;
+}
+
+bool
 TimeInstantLayer::isLayerScrollable(const LayerGeometryProvider *v) const
 {
     QPoint discard;