Mercurial > hg > svapp
diff framework/MainWindowBase.cpp @ 538:287fce13a1ae subdivide-instants
Add Winnow as well
author | Chris Cannam |
---|---|
date | Fri, 25 Nov 2016 09:57:36 +0000 |
parents | dd195633fc9f |
children | 0d5c3abc9658 |
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp Fri Nov 25 09:38:53 2016 +0000 +++ b/framework/MainWindowBase.cpp Fri Nov 25 09:57:36 2016 +0000 @@ -626,6 +626,7 @@ emit canInsertItemAtSelection(haveCurrentPane && haveSelection && haveCurrentDurationLayer); emit canRenumberInstants(haveCurrentTimeInstantsLayer && haveSelection); emit canSubdivideInstants(haveCurrentTimeInstantsLayer && haveSelection); + emit canWinnowInstants(haveCurrentTimeInstantsLayer && haveSelection); emit canPlaySelection(haveMainModel && havePlayTarget && haveSelection); emit canClearSelection(haveSelection); emit canEditSelection(haveSelection && haveCurrentEditableLayer); @@ -1248,6 +1249,32 @@ if (c) CommandHistory::getInstance()->addCommand(c, false); } +void +MainWindowBase::winnowInstantsBy(int n) +{ + Pane *pane = m_paneStack->getCurrentPane(); + if (!pane) return; + + Layer *layer = dynamic_cast<TimeInstantLayer *>(pane->getSelectedLayer()); + if (!layer) return; + + MultiSelection ms(m_viewManager->getSelection()); + + Model *model = layer->getModel(); + SparseOneDimensionalModel *sodm = + dynamic_cast<SparseOneDimensionalModel *>(model); + if (!sodm) return; + + if (!m_labeller) return; + + Labeller labeller(*m_labeller); + labeller.setSampleRate(sodm->getSampleRate()); + + Command *c = labeller.winnow<SparseOneDimensionalModel::Point> + (*sodm, &ms, n); + if (c) CommandHistory::getInstance()->addCommand(c, false); +} + MainWindowBase::FileOpenStatus MainWindowBase::openPath(QString fileOrUrl, AudioFileOpenMode mode) {