Mercurial > hg > svgui
changeset 868:99299949f965 alignment_view
Don't hide time-instant layers when switching modes; use them as source of key frames in alignment view
author | Chris Cannam |
---|---|
date | Fri, 17 Oct 2014 16:47:53 +0100 |
parents | 99373ca20caf |
children | 7463ece5d5e8 |
files | view/AlignmentView.cpp view/AlignmentView.h |
diffstat | 2 files changed, 66 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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 <QPainter> +#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<int> keyFrames; - for (int f = m_above->getModelsStartFrame(); - f <= m_above->getModelsEndFrame(); - f += rate * 5) { - keyFrames.push_back(f); - } + vector<int> keyFrames = getKeyFrames(); foreach (int f, keyFrames) { int af = m_above->alignFromReference(f); @@ -138,3 +134,61 @@ paint.end(); } +vector<int> +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<TimeInstantLayer *>(m_above->getLayer(i))) { + SparseOneDimensionalModel *mm = + qobject_cast<SparseOneDimensionalModel *> + (m_above->getLayer(i)->getModel()); + if (mm) m = mm; + } + } + + if (!m) { + return getDefaultKeyFrames(); + } + + vector<int> 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<int> +AlignmentView::getDefaultKeyFrames() +{ + vector<int> 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; +} + + + + + +
--- 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<int> getKeyFrames(); + std::vector<int> getDefaultKeyFrames(); + View *m_above; View *m_below; };