changeset 538:287fce13a1ae subdivide-instants

Add Winnow as well
author Chris Cannam
date Fri, 25 Nov 2016 09:57:36 +0000
parents dd195633fc9f
children 630c4a9885ca
files framework/MainWindowBase.cpp framework/MainWindowBase.h
diffstat 2 files changed, 29 insertions(+), 0 deletions(-) [+]
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)
 {
--- 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();