Mercurial > hg > svgui
diff layer/TimeInstantLayer.cpp @ 359:020c485aa7e0
* 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 | 8b69f36c74be |
children | d58701996fae |
line wrap: on
line diff
--- a/layer/TimeInstantLayer.cpp Mon Feb 04 17:45:16 2008 +0000 +++ b/layer/TimeInstantLayer.cpp Wed Feb 06 12:49:49 2008 +0000 @@ -712,7 +712,7 @@ } void -TimeInstantLayer::copy(Selection s, Clipboard &to) +TimeInstantLayer::copy(View *v, Selection s, Clipboard &to) { if (!m_model) return; @@ -729,14 +729,17 @@ // alignment as it. If it was generated by deriving from another // layer's model, that would be... but it wasn't necessarily - point.setReferenceFrame(m_model->alignToReference(i->frame)); + point.setReferenceFrame(alignToReference(v, i->frame)); + + std::cerr << "TimeInstantLayer::copy: frame = " << i->frame << ", reference frame = " << point.getReferenceFrame() << std::endl; + to.addPoint(point); } } } bool -TimeInstantLayer::clipboardAlignmentDiffers(const Clipboard &clip) const +TimeInstantLayer::clipboardAlignmentDiffers(View *v, const Clipboard &clip) const { //!!! hoist -- all pastable layers will need this @@ -772,7 +775,7 @@ if (i->haveReferenceFrame()) { referenceFrame = i->getReferenceFrame(); } - long myMappedFrame = m_model->alignToReference(sourceFrame); + long myMappedFrame = alignToReference(v, sourceFrame); std::cerr << "sourceFrame = " << sourceFrame << ", referenceFrame = " << referenceFrame << " (have = " << i->haveReferenceFrame() << "), myMappedFrame = " << myMappedFrame << std::endl; @@ -783,7 +786,7 @@ } bool -TimeInstantLayer::paste(const Clipboard &from, int frameOffset, bool) +TimeInstantLayer::paste(View *v, const Clipboard &from, int frameOffset, bool) { if (!m_model) return false; @@ -845,7 +848,7 @@ bool realign = false; - if (clipboardAlignmentDiffers(from)) { + if (clipboardAlignmentDiffers(v, from)) { std::cerr << "Offer alignment option..." << std::endl; @@ -864,7 +867,6 @@ if (selected == options[1]) realign = true; } - SparseOneDimensionalModel::EditCommand *command = new SparseOneDimensionalModel::EditCommand(m_model, tr("Paste")); @@ -872,10 +874,29 @@ i != points.end(); ++i) { if (!i->haveFrame()) continue; + size_t frame = 0; - if (frameOffset > 0 || -frameOffset < i->getFrame()) { - frame = i->getFrame() + frameOffset; + + if (!realign) { + + frame = i->getFrame(); + + } else { + + if (i->haveReferenceFrame()) { + frame = i->getReferenceFrame(); + frame = alignFromReference(v, frame); + } else { + frame = i->getFrame(); + } } + + if (frameOffset > 0) frame += frameOffset; + else if (frameOffset < 0) { + if (frame > -frameOffset) frame += frameOffset; + else frame = 0; + } + SparseOneDimensionalModel::Point newPoint(frame); if (i->haveLabel()) { newPoint.label = i->getLabel();