# HG changeset patch # User Chris Cannam # Date 1480067856 0 # Node ID 287fce13a1aefc604e88f34a355ede7dc8306187 # Parent dd195633fc9fd3735dcf49fb71c9d881ad55e1ce Add Winnow as well diff -r dd195633fc9f -r 287fce13a1ae framework/MainWindowBase.cpp --- 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(pane->getSelectedLayer()); + if (!layer) return; + + MultiSelection ms(m_viewManager->getSelection()); + + Model *model = layer->getModel(); + SparseOneDimensionalModel *sodm = + dynamic_cast(model); + if (!sodm) return; + + if (!m_labeller) return; + + Labeller labeller(*m_labeller); + labeller.setSampleRate(sodm->getSampleRate()); + + Command *c = labeller.winnow + (*sodm, &ms, n); + if (c) CommandHistory::getInstance()->addCommand(c, false); +} + MainWindowBase::FileOpenStatus MainWindowBase::openPath(QString fileOrUrl, AudioFileOpenMode mode) { diff -r dd195633fc9f -r 287fce13a1ae framework/MainWindowBase.h --- a/framework/MainWindowBase.h Fri Nov 25 09:38:53 2016 +0000 +++ b/framework/MainWindowBase.h Fri Nov 25 09:57:36 2016 +0000 @@ -169,6 +169,7 @@ void canInsertItemAtSelection(bool); void canRenumberInstants(bool); void canSubdivideInstants(bool); + void canWinnowInstants(bool); void canDeleteCurrentLayer(bool); void canZoom(bool); void canScroll(bool); @@ -277,6 +278,7 @@ virtual void insertItemAt(sv_frame_t, sv_frame_t); virtual void renumberInstants(); virtual void subdivideInstantsBy(int); + virtual void winnowInstantsBy(int); virtual void documentModified(); virtual void documentRestored();