comparison layer/TimeValueLayer.cpp @ 1470:696e569ff21b by-id

Further layer updates for ById
author Chris Cannam
date Fri, 28 Jun 2019 17:37:22 +0100
parents 9abddbd57667
children f2525e6cbdf1
comparison
equal deleted inserted replaced
1469:11a150e65ee1 1470:696e569ff21b
69 m_scaleMaximum(0) 69 m_scaleMaximum(0)
70 { 70 {
71 71
72 } 72 }
73 73
74 void 74 int
75 TimeValueLayer::setModel(SparseTimeValueModel *model) 75 TimeValueLayer::getCompletion(LayerGeometryProvider *) const
76 { 76 {
77 if (m_model == model) return; 77 auto model = ModelById::get(m_model);
78 m_model = model; 78 if (model) return model->getCompletion();
79 else return 0;
80 }
81
82 void
83 TimeValueLayer::setModel(ModelId modelId)
84 {
85 if (m_model == modelId) return;
86 m_model = modelId;
87
88 auto newModel = ModelById::getAs<SparseOneDimensionalModel>(modelId);
79 89
80 connectSignals(m_model); 90 connectSignals(m_model);
81 91
82 m_scaleMinimum = 0; 92 m_scaleMinimum = 0;
83 m_scaleMaximum = 0; 93 m_scaleMaximum = 0;
84 94
85 if (m_model && m_model->getRDFTypeURI().endsWith("Segment")) { 95 if (newModel && newModel->getRDFTypeURI().endsWith("Segment")) {
86 setPlotStyle(PlotSegmentation); 96 setPlotStyle(PlotSegmentation);
87 } 97 }
88 if (m_model && m_model->getRDFTypeURI().endsWith("Change")) { 98 if (newModel && m_model->getRDFTypeURI().endsWith("Change")) {
89 setPlotStyle(PlotSegmentation); 99 setPlotStyle(PlotSegmentation);
90 } 100 }
91 101
92 #ifdef DEBUG_TIME_VALUE_LAYER 102 #ifdef DEBUG_TIME_VALUE_LAYER
93 cerr << "TimeValueLayer::setModel(" << model << ")" << endl; 103 cerr << "TimeValueLayer::setModel(" << model << ")" << endl;
148 if (name == "Plot Type" || name == "Draw Segment Division Lines" || 158 if (name == "Plot Type" || name == "Draw Segment Division Lines" ||
149 name == "Show Derivative") { 159 name == "Show Derivative") {
150 return tr("Plot Type"); 160 return tr("Plot Type");
151 } 161 }
152 return SingleColourLayer::getPropertyGroupName(name); 162 return SingleColourLayer::getPropertyGroupName(name);
163 }
164
165 bool
166 TimeValueLayer::needsTextLabelHeight() const
167 {
168 auto model = ModelById::get(m_model);
169 if (!model) return false;
170 return m_plotStyle == PlotSegmentation && model->hasTextLabels();
153 } 171 }
154 172
155 QString 173 QString
156 TimeValueLayer::getScaleUnits() const 174 TimeValueLayer::getScaleUnits() const
157 { 175 {