Mercurial > hg > svapp
changeset 665:e19c609a7bec
Update so Document owns the alignment model's input aggregate model
author | Chris Cannam |
---|---|
date | Thu, 04 Apr 2019 16:17:11 +0100 |
parents | 6fd0ebfd2bbe |
children | 21673429dba5 d62fd61082a1 80aed2b914f6 |
files | framework/Align.cpp framework/Align.h framework/Document.cpp framework/SVFileReader.cpp |
diffstat | 4 files changed, 38 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/framework/Align.cpp Wed Jan 09 15:25:09 2019 +0000 +++ b/framework/Align.cpp Thu Apr 04 16:17:11 2019 +0100 @@ -14,6 +14,7 @@ */ #include "Align.h" +#include "Document.h" #include "data/model/WaveFileModel.h" #include "data/model/ReadOnlyWaveFileModel.h" @@ -33,7 +34,7 @@ #include <QApplication> bool -Align::alignModel(Model *ref, Model *other) +Align::alignModel(Document *doc, Model *ref, Model *other) { QSettings settings; settings.beginGroup("Preferences"); @@ -42,9 +43,9 @@ settings.endGroup(); if (useProgram && (program != "")) { - return alignModelViaProgram(ref, other, program); + return alignModelViaProgram(doc, ref, other, program); } else { - return alignModelViaTransform(ref, other); + return alignModelViaTransform(doc, ref, other); } } @@ -69,7 +70,7 @@ } bool -Align::alignModelViaTransform(Model *ref, Model *other) +Align::alignModelViaTransform(Document *doc, Model *ref, Model *other) { RangeSummarisableTimeValueModel *reference = qobject_cast <RangeSummarisableTimeValueModel *>(ref); @@ -106,7 +107,9 @@ components.push_back(AggregateWaveModel::ModelChannelSpec (rm, -1)); - Model *aggregateModel = new AggregateWaveModel(components); + AggregateWaveModel *aggregateModel = new AggregateWaveModel(components); + doc->addAggregateModel(aggregateModel); + ModelTransformer::Input aggregate(aggregateModel); TransformId id = getAlignmentTransformName(); @@ -146,7 +149,7 @@ path->setCompletion(0); AlignmentModel *alignmentModel = new AlignmentModel - (reference, other, aggregateModel, path); + (reference, other, path); connect(alignmentModel, SIGNAL(completionChanged()), this, SLOT(alignmentCompletionChanged())); @@ -169,7 +172,7 @@ } bool -Align::alignModelViaProgram(Model *ref, Model *other, QString program) +Align::alignModelViaProgram(Document *, Model *ref, Model *other, QString program) { WaveFileModel *reference = qobject_cast<WaveFileModel *>(ref); WaveFileModel *rm = qobject_cast<WaveFileModel *>(other); @@ -203,7 +206,8 @@ m_error = ""; - AlignmentModel *alignmentModel = new AlignmentModel(reference, other, nullptr, nullptr); + AlignmentModel *alignmentModel = + new AlignmentModel(reference, other, nullptr); rm->setAlignment(alignmentModel); QProcess *process = new QProcess;
--- a/framework/Align.h Wed Jan 09 15:25:09 2019 +0000 +++ b/framework/Align.h Thu Apr 04 16:17:11 2019 +0100 @@ -23,6 +23,7 @@ class Model; class AlignmentModel; +class Document; class Align : public QObject { @@ -47,10 +48,18 @@ * Align object will simply share the process or document * lifespan. */ - bool alignModel(Model *reference, Model *other); // via user preference + bool alignModel(Document *doc, + Model *reference, + Model *other); // via user preference - bool alignModelViaTransform(Model *reference, Model *other); - bool alignModelViaProgram(Model *reference, Model *other, QString program); + bool alignModelViaTransform(Document *doc, + Model *reference, + Model *other); + + bool alignModelViaProgram(Document *doc, + Model *reference, + Model *other, + QString program); /** * Return true if the alignment facility is available (relevant
--- a/framework/Document.cpp Wed Jan 09 15:25:09 2019 +0000 +++ b/framework/Document.cpp Thu Apr 04 16:17:11 2019 +0100 @@ -787,6 +787,12 @@ return; } +#ifdef DEBUG_DOCUMENT + SVDEBUG << "Document::releaseModel(" << model << ", type " + << model->getTypeName() << ", name \"" + << model->objectName() << "\")" << endl; +#endif + if (model == m_mainModel) { return; } @@ -803,7 +809,9 @@ } } } else if (m_aggregateModels.find(model) != m_aggregateModels.end()) { +#ifdef DEBUG_DOCUMENT SVDEBUG << "Document::releaseModel: is an aggregate model" << endl; +#endif toDelete = true; } else { SVCERR << "WARNING: Document::releaseModel: Unfound model " @@ -879,7 +887,7 @@ if (m_layers.find(layer) == m_layers.end()) { SVDEBUG << "Document::deleteLayer: Layer " - << layer << " (" << typeid(layer).name() << + << layer << " (typeid " << typeid(layer).name() << ") does not exist, or has already been deleted " << "(this may not be as serious as it sounds)" << endl; return; @@ -888,7 +896,7 @@ m_layers.erase(layer); #ifdef DEBUG_DOCUMENT - SVDEBUG << "Document::deleteLayer: Removing, now have " + SVDEBUG << "Document::deleteLayer: Removing (and about to release model), now have " << m_layers.size() << " layers" << endl; #endif @@ -1101,12 +1109,12 @@ // unaligned model just by looking at the model itself, // without also knowing what the main model is SVDEBUG << "Document::alignModel(" << model << "): is main model, setting appropriately" << endl; - rm->setAlignment(new AlignmentModel(model, model, nullptr, nullptr)); + rm->setAlignment(new AlignmentModel(model, model, nullptr)); return; } - if (!m_align->alignModel(m_mainModel, rm)) { - cerr << "Alignment failed: " << m_align->getError() << endl; + if (!m_align->alignModel(this, m_mainModel, rm)) { + SVCERR << "Alignment failed: " << m_align->getError() << endl; emit alignmentFailed(m_align->getError()); } }
--- a/framework/SVFileReader.cpp Wed Jan 09 15:25:09 2019 +0000 +++ b/framework/SVFileReader.cpp Thu Apr 04 16:17:11 2019 +0100 @@ -788,7 +788,7 @@ if (refModel && alignedModel && pathModel) { AlignmentModel *model = new AlignmentModel - (refModel, alignedModel, nullptr, nullptr); + (refModel, alignedModel, nullptr); PathModel *pm = dynamic_cast<PathModel *>(pathModel); if (!pm) { SVCERR << "WARNING: SV-XML: Model id " << path