Mercurial > hg > sonic-visualiser
changeset 2442:b3330c31ea0e spectrogram-export
Add layer export of selected region as well as whole layer
author | Chris Cannam |
---|---|
date | Wed, 08 Jan 2020 15:41:46 +0000 (2020-01-08) |
parents | 3612bfc24950 |
children | 935107f64e5f |
files | main/MainWindow.cpp main/OSCHandler.cpp repoint-lock.json |
diffstat | 3 files changed, 35 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/main/MainWindow.cpp Wed Jan 08 15:40:58 2020 +0000 +++ b/main/MainWindow.cpp Wed Jan 08 15:41:46 2020 +0000 @@ -3020,9 +3020,29 @@ if (path == "") return; + MultiSelection ms = m_viewManager->getSelection(); + MultiSelection *selectionToWrite = nullptr; + + if (!ms.getSelections().empty()) { + + QStringList items; + items << tr("Export the content of the selected area") + << tr("Export the whole layer"); + + bool ok = false; + QString item = ListInputDialog::getItem + (this, tr("Select region to export"), + tr("Which region of the layer do you want to export?"), + items, 0, &ok); + + if (!ok || item.isEmpty()) return; + + if (item == items[0]) selectionToWrite = &ms; + } + QString error; - if (!exportLayerTo(layer, pane, path, error)) { + if (!exportLayerTo(layer, pane, selectionToWrite, path, error)) { QMessageBox::critical(this, tr("Failed to write file"), error); } else { m_recentFiles.addFile(path);
--- a/main/OSCHandler.cpp Wed Jan 08 15:40:58 2020 +0000 +++ b/main/OSCHandler.cpp Wed Jan 08 15:41:46 2020 +0000 @@ -156,10 +156,19 @@ Layer *currentLayer = nullptr; if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); if (currentPane) currentLayer = currentPane->getSelectedLayer(); + MultiSelection ms = m_viewManager->getSelection(); if (currentLayer) { QString error; - if (!exportLayerTo(currentLayer, currentPane, path, error)) { - SVCERR << "OSCHandler: Failed to export current layer to " << path << ": " << error << endl; + if (exportLayerTo + (currentLayer, currentPane, + ms.getSelections().empty() ? nullptr : &ms, + path, error)) { + SVDEBUG << "OSCHandler: Exported layer \"" + << currentLayer->getLayerPresentationName() + << "\" to path \"" << path << "\"" << endl; + } else { + SVCERR << "OSCHandler: Export failed to path \"" + << path << "\"" << endl; } } else { SVCERR << "OSCHandler: No current layer to export" << endl;
--- a/repoint-lock.json Wed Jan 08 15:40:58 2020 +0000 +++ b/repoint-lock.json Wed Jan 08 15:41:46 2020 +0000 @@ -4,13 +4,13 @@ "pin": "c42e50a5c297" }, "svcore": { - "pin": "ee3b248bda25" + "pin": "1318e069906b" }, "svgui": { - "pin": "3607b0092019" + "pin": "e6e7a8dc3b38" }, "svapp": { - "pin": "b06b18c15fd4" + "pin": "1e2e03197b8c" }, "checker": { "pin": "ef64b3f171d9"