comparison layer/WaveformLayer.cpp @ 1471:f2525e6cbdf1 by-id

More layer updates
author Chris Cannam
date Mon, 01 Jul 2019 14:17:13 +0100
parents 696e569ff21b
children 36ad3cdabf55
comparison
equal deleted inserted replaced
1470:696e569ff21b 1471:f2525e6cbdf1
72 WaveformLayer::setModel(ModelId modelId) 72 WaveformLayer::setModel(ModelId modelId)
73 { 73 {
74 auto oldModel = ModelById::getAs<RangeSummarisableTimeValueModel>(m_model); 74 auto oldModel = ModelById::getAs<RangeSummarisableTimeValueModel>(m_model);
75 auto newModel = ModelById::getAs<RangeSummarisableTimeValueModel>(modelId); 75 auto newModel = ModelById::getAs<RangeSummarisableTimeValueModel>(modelId);
76 76
77 if (!newModel) { 77 if (!modelId.isNone() && !newModel) {
78 SVCERR << "WARNING: WaveformLayer::setModel: Model is not a RangeSummarisableTimeValueModel" << endl; 78 throw std::logic_error("Not a RangeSummarisableTimeValueModel");
79 } 79 }
80
81 if (m_model == modelId) return;
82 m_model = modelId;
83
84 m_cacheValid = false;
80 85
81 bool channelsChanged = false; 86 bool channelsChanged = false;
82 if (m_channel == -1) { 87 if (m_channel == -1) {
83 if (!oldModel) { 88 if (!oldModel) {
84 if (newModel) { 89 if (newModel) {
90 channelsChanged = true; 95 channelsChanged = true;
91 } 96 }
92 } 97 }
93 } 98 }
94 99
95 m_model = modelId; 100 if (newModel) {
96 m_cacheValid = false; 101 connectSignals(m_model);
97 if (!newModel || !newModel->isOK()) return; 102 }
98 103
99 connectSignals(m_model);
100
101 emit modelReplaced(); 104 emit modelReplaced();
102 105
103 if (channelsChanged) emit layerParametersChanged(); 106 if (channelsChanged) emit layerParametersChanged();
104 } 107 }
105 108