comparison src/MainWindow.cpp @ 239:d40c6cdb30a4

Make pitch-track editing operations update the notes as well, automatically
author Chris Cannam
date Thu, 27 Mar 2014 18:02:12 +0000
parents fce61899aeea
children 6ac45eb0f4c7
comparison
equal deleted inserted replaced
238:fce61899aeea 239:d40c6cdb30a4
1894 } 1894 }
1895 1895
1896 MainWindowBase::clearSelection(); 1896 MainWindowBase::clearSelection();
1897 1897
1898 CommandHistory::getInstance()->endCompoundOperation(); 1898 CommandHistory::getInstance()->endCompoundOperation();
1899
1900 if (!selections.empty()) {
1901 auxSnapNotes(*selections.begin());
1902 }
1899 } 1903 }
1900 1904
1901 void 1905 void
1902 MainWindow::selectionChangedByUser() 1906 MainWindow::selectionChangedByUser()
1903 { 1907 {
1976 k != selections.end(); ++k) { 1980 k != selections.end(); ++k) {
1977 m_analyser->deletePitches(*k); 1981 m_analyser->deletePitches(*k);
1978 } 1982 }
1979 1983
1980 CommandHistory::getInstance()->endCompoundOperation(); 1984 CommandHistory::getInstance()->endCompoundOperation();
1985
1986 snapNotesToPitches();
1981 } 1987 }
1982 1988
1983 void 1989 void
1984 MainWindow::octaveShift(bool up) 1990 MainWindow::octaveShift(bool up)
1985 { 1991 {
1993 1999
1994 m_analyser->shiftOctave(*k, up); 2000 m_analyser->shiftOctave(*k, up);
1995 } 2001 }
1996 2002
1997 CommandHistory::getInstance()->endCompoundOperation(); 2003 CommandHistory::getInstance()->endCompoundOperation();
2004
2005 snapNotesToPitches();
1998 } 2006 }
1999 2007
2000 void 2008 void
2001 MainWindow::togglePitchCandidates() 2009 MainWindow::togglePitchCandidates()
2002 { 2010 {
2025 m_analyser->switchPitchCandidate(*k, true); 2033 m_analyser->switchPitchCandidate(*k, true);
2026 } 2034 }
2027 2035
2028 CommandHistory::getInstance()->endCompoundOperation(); 2036 CommandHistory::getInstance()->endCompoundOperation();
2029 2037
2038 snapNotesToPitches();
2030 } 2039 }
2031 } else { 2040 } else {
2032 octaveShift(true); 2041 octaveShift(true);
2033 } 2042 }
2034 } 2043 }
2048 k != selections.end(); ++k) { 2057 k != selections.end(); ++k) {
2049 m_analyser->switchPitchCandidate(*k, false); 2058 m_analyser->switchPitchCandidate(*k, false);
2050 } 2059 }
2051 2060
2052 CommandHistory::getInstance()->endCompoundOperation(); 2061 CommandHistory::getInstance()->endCompoundOperation();
2062
2063 snapNotesToPitches();
2053 } 2064 }
2054 } else { 2065 } else {
2055 octaveShift(false); 2066 octaveShift(false);
2056 } 2067 }
2057 } 2068 }
2058 2069
2059 void 2070 void
2060 MainWindow::snapNotesToPitches() 2071 MainWindow::snapNotesToPitches()
2061 { 2072 {
2062 FlexiNoteLayer *layer =
2063 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes));
2064 if (!layer) return;
2065
2066 MultiSelection::SelectionList selections = m_viewManager->getSelections(); 2073 MultiSelection::SelectionList selections = m_viewManager->getSelections();
2067 2074
2068 if (!selections.empty()) { 2075 if (!selections.empty()) {
2069 2076
2070 CommandHistory::getInstance()->startCompoundOperation 2077 CommandHistory::getInstance()->startCompoundOperation
2071 (tr("Snap Notes to Pitches"), true); 2078 (tr("Snap Notes to Pitches"), true);
2072 2079
2073 for (MultiSelection::SelectionList::iterator k = selections.begin(); 2080 for (MultiSelection::SelectionList::iterator k = selections.begin();
2074 k != selections.end(); ++k) { 2081 k != selections.end(); ++k) {
2075 layer->snapSelectedNotesToPitchTrack(m_analyser->getPane(), *k); 2082 auxSnapNotes(*k);
2076 } 2083 }
2077 2084
2078 CommandHistory::getInstance()->endCompoundOperation(); 2085 CommandHistory::getInstance()->endCompoundOperation();
2079 } 2086 }
2080 } 2087 }
2088
2089 void
2090 MainWindow::auxSnapNotes(Selection s)
2091 {
2092 FlexiNoteLayer *layer =
2093 qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes));
2094 if (!layer) return;
2095
2096 layer->snapSelectedNotesToPitchTrack(m_analyser->getPane(), s);
2097 }
2081 2098
2082 void 2099 void
2083 MainWindow::splitNotesAtSelection() 2100 MainWindow::splitNotesAtSelection()
2084 { 2101 {
2085 FlexiNoteLayer *layer = 2102 FlexiNoteLayer *layer =