# HG changeset patch # User Chris Cannam # Date 1413560873 -3600 # Node ID 99299949f965da36ea359b48306407d9102b6e7e # Parent 99373ca20cafb664fbe36bdcfc95bc7308928fed Don't hide time-instant layers when switching modes; use them as source of key frames in alignment view diff -r 99373ca20caf -r 99299949f965 view/AlignmentView.cpp --- a/view/AlignmentView.cpp Fri Oct 17 14:58:51 2014 +0100 +++ b/view/AlignmentView.cpp Fri Oct 17 16:47:53 2014 +0100 @@ -17,6 +17,10 @@ #include +#include "data/model/SparseOneDimensionalModel.h" + +#include "layer/TimeInstantLayer.h" + using std::vector; AlignmentView::AlignmentView(QWidget *w) : @@ -104,9 +108,6 @@ { if (m_above == 0 || m_below == 0 || !m_manager) return; - int rate = m_manager->getMainModelSampleRate(); - if (rate == 0) return; - bool darkPalette = false; if (m_manager) darkPalette = m_manager->getGlobalDarkBackground(); @@ -120,12 +121,7 @@ paint.fillRect(rect(), bg); - vector keyFrames; - for (int f = m_above->getModelsStartFrame(); - f <= m_above->getModelsEndFrame(); - f += rate * 5) { - keyFrames.push_back(f); - } + vector keyFrames = getKeyFrames(); foreach (int f, keyFrames) { int af = m_above->alignFromReference(f); @@ -138,3 +134,61 @@ paint.end(); } +vector +AlignmentView::getKeyFrames() +{ + if (!m_above) { + return getDefaultKeyFrames(); + } + + SparseOneDimensionalModel *m = 0; + + // get the topmost such + for (int i = 0; i < m_above->getLayerCount(); ++i) { + if (qobject_cast(m_above->getLayer(i))) { + SparseOneDimensionalModel *mm = + qobject_cast + (m_above->getLayer(i)->getModel()); + if (mm) m = mm; + } + } + + if (!m) { + return getDefaultKeyFrames(); + } + + vector keyFrames; + + const SparseOneDimensionalModel::PointList pp = m->getPoints(); + for (SparseOneDimensionalModel::PointList::const_iterator pi = pp.begin(); + pi != pp.end(); ++pi) { + keyFrames.push_back(pi->frame); + } + + return keyFrames; +} + +vector +AlignmentView::getDefaultKeyFrames() +{ + vector keyFrames; + + if (!m_above || !m_manager) return keyFrames; + + int rate = m_manager->getMainModelSampleRate(); + if (rate == 0) return keyFrames; + + for (int f = m_above->getModelsStartFrame(); + f <= m_above->getModelsEndFrame(); + f += rate * 5) { + keyFrames.push_back(f); + } + + return keyFrames; +} + + + + + + diff -r 99373ca20caf -r 99299949f965 view/AlignmentView.h --- a/view/AlignmentView.h Fri Oct 17 14:58:51 2014 +0100 +++ b/view/AlignmentView.h Fri Oct 17 16:47:53 2014 +0100 @@ -40,6 +40,9 @@ virtual void paintEvent(QPaintEvent *e); virtual bool shouldLabelSelections() const { return false; } + std::vector getKeyFrames(); + std::vector getDefaultKeyFrames(); + View *m_above; View *m_below; };