Mercurial > hg > svgui
comparison view/AlignmentView.cpp @ 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 | 6a590241d8ad |
comparison
equal
deleted
inserted
replaced
867:99373ca20caf | 868:99299949f965 |
---|---|
14 */ | 14 */ |
15 | 15 |
16 #include "AlignmentView.h" | 16 #include "AlignmentView.h" |
17 | 17 |
18 #include <QPainter> | 18 #include <QPainter> |
19 | |
20 #include "data/model/SparseOneDimensionalModel.h" | |
21 | |
22 #include "layer/TimeInstantLayer.h" | |
19 | 23 |
20 using std::vector; | 24 using std::vector; |
21 | 25 |
22 AlignmentView::AlignmentView(QWidget *w) : | 26 AlignmentView::AlignmentView(QWidget *w) : |
23 View(w, false), | 27 View(w, false), |
102 void | 106 void |
103 AlignmentView::paintEvent(QPaintEvent *) | 107 AlignmentView::paintEvent(QPaintEvent *) |
104 { | 108 { |
105 if (m_above == 0 || m_below == 0 || !m_manager) return; | 109 if (m_above == 0 || m_below == 0 || !m_manager) return; |
106 | 110 |
107 int rate = m_manager->getMainModelSampleRate(); | |
108 if (rate == 0) return; | |
109 | |
110 bool darkPalette = false; | 111 bool darkPalette = false; |
111 if (m_manager) darkPalette = m_manager->getGlobalDarkBackground(); | 112 if (m_manager) darkPalette = m_manager->getGlobalDarkBackground(); |
112 | 113 |
113 QColor fg = Qt::black, bg = Qt::white; | 114 QColor fg = Qt::black, bg = Qt::white; |
114 if (darkPalette) std::swap(fg, bg); | 115 if (darkPalette) std::swap(fg, bg); |
118 paint.setBrush(Qt::NoBrush); | 119 paint.setBrush(Qt::NoBrush); |
119 paint.setRenderHint(QPainter::Antialiasing, true); | 120 paint.setRenderHint(QPainter::Antialiasing, true); |
120 | 121 |
121 paint.fillRect(rect(), bg); | 122 paint.fillRect(rect(), bg); |
122 | 123 |
123 vector<int> keyFrames; | 124 vector<int> keyFrames = getKeyFrames(); |
124 for (int f = m_above->getModelsStartFrame(); | |
125 f <= m_above->getModelsEndFrame(); | |
126 f += rate * 5) { | |
127 keyFrames.push_back(f); | |
128 } | |
129 | 125 |
130 foreach (int f, keyFrames) { | 126 foreach (int f, keyFrames) { |
131 int af = m_above->alignFromReference(f); | 127 int af = m_above->alignFromReference(f); |
132 int ax = m_above->getXForFrame(af); | 128 int ax = m_above->getXForFrame(af); |
133 int bf = m_below->alignFromReference(f); | 129 int bf = m_below->alignFromReference(f); |
136 } | 132 } |
137 | 133 |
138 paint.end(); | 134 paint.end(); |
139 } | 135 } |
140 | 136 |
137 vector<int> | |
138 AlignmentView::getKeyFrames() | |
139 { | |
140 if (!m_above) { | |
141 return getDefaultKeyFrames(); | |
142 } | |
143 | |
144 SparseOneDimensionalModel *m = 0; | |
145 | |
146 // get the topmost such | |
147 for (int i = 0; i < m_above->getLayerCount(); ++i) { | |
148 if (qobject_cast<TimeInstantLayer *>(m_above->getLayer(i))) { | |
149 SparseOneDimensionalModel *mm = | |
150 qobject_cast<SparseOneDimensionalModel *> | |
151 (m_above->getLayer(i)->getModel()); | |
152 if (mm) m = mm; | |
153 } | |
154 } | |
155 | |
156 if (!m) { | |
157 return getDefaultKeyFrames(); | |
158 } | |
159 | |
160 vector<int> keyFrames; | |
161 | |
162 const SparseOneDimensionalModel::PointList pp = m->getPoints(); | |
163 for (SparseOneDimensionalModel::PointList::const_iterator pi = pp.begin(); | |
164 pi != pp.end(); ++pi) { | |
165 keyFrames.push_back(pi->frame); | |
166 } | |
167 | |
168 return keyFrames; | |
169 } | |
170 | |
171 vector<int> | |
172 AlignmentView::getDefaultKeyFrames() | |
173 { | |
174 vector<int> keyFrames; | |
175 | |
176 if (!m_above || !m_manager) return keyFrames; | |
177 | |
178 int rate = m_manager->getMainModelSampleRate(); | |
179 if (rate == 0) return keyFrames; | |
180 | |
181 for (int f = m_above->getModelsStartFrame(); | |
182 f <= m_above->getModelsEndFrame(); | |
183 f += rate * 5) { | |
184 keyFrames.push_back(f); | |
185 } | |
186 | |
187 return keyFrames; | |
188 } | |
189 | |
190 | |
191 | |
192 | |
193 | |
194 |