Mercurial > hg > svgui
diff layer/Layer.cpp @ 1469:11a150e65ee1 by-id
Some work on updating layers for ModelId bits
author | Chris Cannam |
---|---|
date | Thu, 27 Jun 2019 13:16:25 +0100 |
parents | 5554d5187494 |
children | 696e569ff21b |
line wrap: on
line diff
--- a/layer/Layer.cpp Thu Jun 13 15:35:01 2019 +0100 +++ b/layer/Layer.cpp Thu Jun 27 13:16:25 2019 +0100 @@ -46,18 +46,21 @@ } void -Layer::connectSignals(const Model *model) +Layer::connectSignals(ModelId modelId) { - connect(model, SIGNAL(modelChanged()), + auto model = ModelById::get(modelId); + if (!model) return; + + connect(model.get(), SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); - connect(model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + connect(model.get(), SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), this, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t))); - connect(model, SIGNAL(completionChanged()), + connect(model.get(), SIGNAL(completionChanged()), this, SIGNAL(modelCompletionChanged())); - connect(model, SIGNAL(alignmentCompletionChanged()), + connect(model.get(), SIGNAL(alignmentCompletionChanged()), this, SIGNAL(modelAlignmentCompletionChanged())); } @@ -84,7 +87,8 @@ (factory->getLayerType(this)); QString modelName; - if (getModel()) modelName = getModel()->objectName(); + auto model = ModelById::get(getModel()); + if (model) modelName = model->objectName(); QString text; if (modelName != "") { @@ -107,7 +111,7 @@ Layer::getPlayParameters() { // cerr << "Layer (" << this << ", " << objectName() << ")::getPlayParameters: model is "<< getModel() << endl; - const Model *model = getModel(); + auto model = ModelById::get(getModel()); if (model) { return PlayParameterRepository::getInstance()->getPlayParameters(model); } @@ -143,10 +147,10 @@ { if (!hasTimeXAxis()) return false; - const Model *m = getModel(); - if (!m) return false; + auto model = ModelById::get(getModel()); + if (!model) return false; - value = double(v->getFrameForX(x)) / m->getSampleRate(); + value = double(v->getFrameForX(x)) / model->getSampleRate(); unit = "s"; return true; } @@ -168,10 +172,9 @@ sv_frame_t Layer::alignToReference(LayerGeometryProvider *v, sv_frame_t frame) const { - const Model *m = getModel(); - SVDEBUG << "Layer::alignToReference(" << frame << "): model = " << m << ", alignment reference = " << (m ? m->getAlignmentReference() : nullptr) << endl; - if (m && m->getAlignmentReference()) { - return m->alignToReference(frame); + auto model = ModelById::get(getModel()); + if (model && !model->getAlignmentReference().isNone()) { + return model->alignToReference(frame); } else { return v->getView()->alignToReference(frame); } @@ -180,10 +183,9 @@ sv_frame_t Layer::alignFromReference(LayerGeometryProvider *v, sv_frame_t frame) const { - const Model *m = getModel(); - SVDEBUG << "Layer::alignFromReference(" << frame << "): model = " << m << ", alignment reference = " << (m ? m->getAlignmentReference() : nullptr) << endl; - if (m && m->getAlignmentReference()) { - return m->alignFromReference(frame); + auto model = ModelById::get(getModel()); + if (model && !model->getAlignmentReference().isNone()) { + return model->alignFromReference(frame); } else { return v->getView()->alignFromReference(frame); } @@ -644,12 +646,16 @@ .arg(extraAttributes).arg(encodeEntities(m_presentationName)); } + int modelExportId = -1; + auto model = ModelById::get(getModel()); + if (model) modelExportId = model->getExportId(); + stream << QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5") .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName (LayerFactory::getInstance()->getLayerType(this)))) .arg(getExportId()) .arg(encodeEntities(objectName())) - .arg(getModel() ? getModel()->getExportId() : -1) + .arg(modelExportId) .arg(extraAttributes); if (m_measureRects.empty()) { @@ -678,12 +684,16 @@ .arg(extraAttributes).arg(encodeEntities(m_presentationName)); } + int modelExportId = -1; + auto model = ModelById::get(getModel()); + if (model) modelExportId = model->getExportId(); + stream << QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n") .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName (LayerFactory::getInstance()->getLayerType(this)))) .arg(getExportId()) .arg(encodeEntities(objectName())) - .arg(getModel() ? getModel()->getExportId() : -1) + .arg(modelExportId) .arg(extraAttributes); }