Mercurial > hg > svapp
changeset 539:630c4a9885ca 3.0-integration
Merge from branch subdivide-instants
author | Chris Cannam |
---|---|
date | Fri, 25 Nov 2016 10:08:52 +0000 |
parents | 36aa947ec962 (current diff) 287fce13a1ae (diff) |
children | 0d5c3abc9658 |
files | |
diffstat | 2 files changed, 60 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp Wed Nov 16 16:12:42 2016 +0000 +++ b/framework/MainWindowBase.cpp Fri Nov 25 10:08:52 2016 +0000 @@ -625,6 +625,8 @@ emit canInsertInstantsAtBoundaries(haveCurrentPane && haveSelection); 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); @@ -1217,9 +1219,60 @@ Labeller labeller(*m_labeller); labeller.setSampleRate(sodm->getSampleRate()); - // This uses a command - - labeller.labelAll<SparseOneDimensionalModel::Point>(*sodm, &ms); + Command *c = labeller.labelAll<SparseOneDimensionalModel::Point>(*sodm, &ms); + if (c) CommandHistory::getInstance()->addCommand(c, false); +} + +void +MainWindowBase::subdivideInstantsBy(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.subdivide<SparseOneDimensionalModel::Point> + (*sodm, &ms, n); + 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
--- a/framework/MainWindowBase.h Wed Nov 16 16:12:42 2016 +0000 +++ b/framework/MainWindowBase.h Fri Nov 25 10:08:52 2016 +0000 @@ -168,6 +168,8 @@ void canInsertInstantsAtBoundaries(bool); void canInsertItemAtSelection(bool); void canRenumberInstants(bool); + void canSubdivideInstants(bool); + void canWinnowInstants(bool); void canDeleteCurrentLayer(bool); void canZoom(bool); void canScroll(bool); @@ -275,6 +277,8 @@ virtual void insertItemAtSelection(); 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();