Mercurial > hg > svapp
diff framework/Document.cpp @ 86:dd74c5332b49
* More work on aligning copy/paste between layers. It's a surprisingly
complicated business.
author | Chris Cannam |
---|---|
date | Wed, 06 Feb 2008 12:49:49 +0000 |
parents | c60bf8995166 |
children | db267a315058 |
line wrap: on
line diff
--- a/framework/Document.cpp Tue Feb 05 13:46:45 2008 +0000 +++ b/framework/Document.cpp Wed Feb 06 12:49:49 2008 +0000 @@ -370,8 +370,14 @@ } for (ModelMap::iterator i = m_models.begin(); i != m_models.end(); ++i) { - if (oldMainModel && - (i->first->getAlignmentReference() == oldMainModel)) { + + if (m_autoAlignment) { + + alignModel(i->first); + + } else if (oldMainModel && + (i->first->getAlignmentReference() == oldMainModel)) { + alignModel(i->first); } } @@ -381,6 +387,10 @@ emit modelAboutToBeDeleted(oldMainModel); } + if (m_autoAlignment) { + alignModel(m_mainModel); + } + emit mainModelChanged(m_mainModel); delete oldMainModel; @@ -760,14 +770,27 @@ void Document::alignModel(Model *model) { - if (!m_mainModel || model == m_mainModel) return; + if (!m_mainModel) return; RangeSummarisableTimeValueModel *rm = dynamic_cast<RangeSummarisableTimeValueModel *>(model); if (!rm) return; - if (rm->getAlignmentReference() == m_mainModel) return; + if (rm->getAlignmentReference() == m_mainModel) { + std::cerr << "Document::alignModel: model " << rm << " is already aligned to main model " << m_mainModel << std::endl; + return; + } + if (model == m_mainModel) { + // The reference has an empty alignment to itself. This makes + // it possible to distinguish between the reference and any + // unaligned model just by looking at the model itself, + // without also knowing what the main model is + std::cerr << "Document::alignModel(" << model << "): is main model, setting appropriately" << std::endl; + rm->setAlignment(new AlignmentModel(model, model, 0, 0)); + return; + } + // This involves creating three new models: // 1. an AggregateWaveModel to provide the mixdowns of the main @@ -845,6 +868,7 @@ for (ModelMap::iterator i = m_models.begin(); i != m_models.end(); ++i) { alignModel(i->first); } + alignModel(m_mainModel); } Document::AddLayerCommand::AddLayerCommand(Document *d,