Mercurial > hg > sonic-lineup
changeset 457:a05a0c3251d3
Add a subsequence option. Not working well in a lot of cases. To investigate.
| author | Chris Cannam |
|---|---|
| date | Thu, 16 Jul 2020 18:02:46 +0100 |
| parents | 5caad281c015 |
| children | 91c4b564ff87 |
| files | main/MainWindow.cpp main/MainWindow.h repoint-lock.json |
| diffstat | 3 files changed, 51 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/main/MainWindow.cpp Tue Jul 14 14:41:18 2020 +0100 +++ b/main/MainWindow.cpp Thu Jul 16 18:02:46 2020 +0100 @@ -144,6 +144,7 @@ m_ffwdAction(nullptr), m_rwdAction(nullptr), m_previousActiveAlignmentType(Align::NoAlignment), + m_previousSubsequence(false), m_recentSessions("RecentSessions", 20), m_exiting(false), m_preferencesDialog(nullptr), @@ -802,11 +803,23 @@ action->setCheckable(true); action->setChecked(preference == Align::ExternalProgramAlignment); connect(action, SIGNAL(triggered()), this, SLOT(alignmentTypeChanged())); - + menu->addSeparator(); action = menu->addAction(tr("Choose External Alignment Program...")); connect(action, SIGNAL(triggered()), this, SLOT(chooseAlignmentProgram())); + + menu->addSeparator(); + + action = menu->addAction(tr("Align to Section of Reference")); + action->setCheckable(true); + action->setChecked(Align::getUseSubsequenceAlignment()); + action->setEnabled(preference != Align::NoAlignment && + preference != Align::LinearAlignment && + preference != Align::TrimmedLinearAlignment); + connect(action, SIGNAL(triggered()), this, SLOT(alignmentSubsequenceChanged())); + + m_subsequenceAlignmentAction = action; } void @@ -2368,10 +2381,36 @@ Align::AlignmentType alignmentType = Align::getAlignmentTypeForTag(action->objectName()); + + m_subsequenceAlignmentAction->setEnabled + (alignmentType != Align::NoAlignment && + alignmentType != Align::LinearAlignment && + alignmentType != Align::TrimmedLinearAlignment); + + updateAlignmentPreferences(alignmentType, + Align::getUseSubsequenceAlignment()); +} + +void +MainWindow::alignmentSubsequenceChanged() +{ + QAction *action = dynamic_cast<QAction *>(sender()); + + if (!action || !m_viewManager) return; + + updateAlignmentPreferences(Align::getAlignmentPreference(), + action->isChecked()); +} + +void +MainWindow::updateAlignmentPreferences(Align::AlignmentType alignmentType, + bool subsequence) +{ + Align::setAlignmentPreference(alignmentType); + Align::setUseSubsequenceAlignment(subsequence); if (alignmentType == Align::NoAlignment) { - Align::setAlignmentPreference(alignmentType); m_viewManager->setAlignMode(false); m_document->setAutoAlignment(false); @@ -2382,11 +2421,10 @@ } else { - Align::setAlignmentPreference(alignmentType); - m_viewManager->setAlignMode(true); - if (alignmentType == m_previousActiveAlignmentType) { + if (alignmentType == m_previousActiveAlignmentType && + subsequence == m_previousSubsequence) { m_document->alignModels(); } else { m_document->realignModels(); @@ -2394,6 +2432,7 @@ m_document->setAutoAlignment(true); m_previousActiveAlignmentType = alignmentType; + m_previousSubsequence = subsequence; } for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
--- a/main/MainWindow.h Tue Jul 14 14:41:18 2020 +0100 +++ b/main/MainWindow.h Thu Jul 16 18:02:46 2020 +0100 @@ -125,7 +125,10 @@ void record() override; void alignmentTypeChanged(); + void alignmentSubsequenceChanged(); void chooseAlignmentProgram(); + void updateAlignmentPreferences(Align::AlignmentType type, + bool subsequence); void playSpeedChanged(int); void speedUpPlayback(); @@ -213,7 +216,9 @@ QAction *m_selectNextDisplayModeAction; QAction *m_externalAlignmentAction; + QAction *m_subsequenceAlignmentAction; Align::AlignmentType m_previousActiveAlignmentType; + bool m_previousSubsequence; RecentFiles m_recentSessions;
--- a/repoint-lock.json Tue Jul 14 14:41:18 2020 +0100 +++ b/repoint-lock.json Thu Jul 16 18:02:46 2020 +0100 @@ -10,7 +10,7 @@ "pin": "911330a28a7c" }, "svapp": { - "pin": "8fa98f89eda8" + "pin": "b651dc5ff555" }, "checker": { "pin": "e839338d3869" @@ -49,7 +49,7 @@ "pin": "fd0ace21dce3" }, "match": { - "pin": "b9defaa87d96" + "pin": "d9650fdabfc1" }, "constant-q-cpp": { "pin": "7ac84048e3e43c433d88e12d221af15e50f41591"
