comparison view/AlignmentView.cpp @ 976:f2c63ec85901 alignment-simple

Branch to test simple FFT model code
author Chris Cannam
date Mon, 15 Jun 2015 09:15:55 +0100
parents c0549bf12973
children 57d192e26331 a34a2a25907c
comparison
equal deleted inserted replaced
946:36cddc3de023 976:f2c63ec85901
30 { 30 {
31 setObjectName(tr("AlignmentView")); 31 setObjectName(tr("AlignmentView"));
32 } 32 }
33 33
34 void 34 void
35 AlignmentView::globalCentreFrameChanged(int f) 35 AlignmentView::globalCentreFrameChanged(sv_frame_t f)
36 { 36 {
37 View::globalCentreFrameChanged(f); 37 View::globalCentreFrameChanged(f);
38 update(); 38 update();
39 } 39 }
40 40
41 void 41 void
42 AlignmentView::viewCentreFrameChanged(View *v, int f) 42 AlignmentView::viewCentreFrameChanged(View *v, sv_frame_t f)
43 { 43 {
44 View::viewCentreFrameChanged(v, f); 44 View::viewCentreFrameChanged(v, f);
45 if (v == m_above) { 45 if (v == m_above) {
46 m_centreFrame = f; 46 m_centreFrame = f;
47 update(); 47 update();
49 update(); 49 update();
50 } 50 }
51 } 51 }
52 52
53 void 53 void
54 AlignmentView::viewManagerPlaybackFrameChanged(int) 54 AlignmentView::viewManagerPlaybackFrameChanged(sv_frame_t)
55 { 55 {
56 update(); 56 update();
57 } 57 }
58 58
59 void 59 void
125 paint.setBrush(Qt::NoBrush); 125 paint.setBrush(Qt::NoBrush);
126 paint.setRenderHint(QPainter::Antialiasing, true); 126 paint.setRenderHint(QPainter::Antialiasing, true);
127 127
128 paint.fillRect(rect(), bg); 128 paint.fillRect(rect(), bg);
129 129
130 vector<int> keyFrames = getKeyFrames(); 130 vector<sv_frame_t> keyFrames = getKeyFrames();
131 131
132 foreach (int f, keyFrames) { 132 foreach (sv_frame_t f, keyFrames) {
133 int ax = m_above->getXForFrame(f); 133 int ax = m_above->getXForFrame(f);
134 int rf = m_above->alignToReference(f); 134 sv_frame_t rf = m_above->alignToReference(f);
135 int bf = m_below->alignFromReference(rf); 135 sv_frame_t bf = m_below->alignFromReference(rf);
136 int bx = m_below->getXForFrame(bf); 136 int bx = m_below->getXForFrame(bf);
137 paint.drawLine(ax, 0, bx, height()); 137 paint.drawLine(ax, 0, bx, height());
138 } 138 }
139 139
140 paint.end(); 140 paint.end();
141 } 141 }
142 142
143 vector<int> 143 vector<sv_frame_t>
144 AlignmentView::getKeyFrames() 144 AlignmentView::getKeyFrames()
145 { 145 {
146 if (!m_above) { 146 if (!m_above) {
147 return getDefaultKeyFrames(); 147 return getDefaultKeyFrames();
148 } 148 }
161 161
162 if (!m) { 162 if (!m) {
163 return getDefaultKeyFrames(); 163 return getDefaultKeyFrames();
164 } 164 }
165 165
166 vector<int> keyFrames; 166 vector<sv_frame_t> keyFrames;
167 167
168 const SparseOneDimensionalModel::PointList pp = m->getPoints(); 168 const SparseOneDimensionalModel::PointList pp = m->getPoints();
169 for (SparseOneDimensionalModel::PointList::const_iterator pi = pp.begin(); 169 for (SparseOneDimensionalModel::PointList::const_iterator pi = pp.begin();
170 pi != pp.end(); ++pi) { 170 pi != pp.end(); ++pi) {
171 keyFrames.push_back(pi->frame); 171 keyFrames.push_back(pi->frame);
172 } 172 }
173 173
174 return keyFrames; 174 return keyFrames;
175 } 175 }
176 176
177 vector<int> 177 vector<sv_frame_t>
178 AlignmentView::getDefaultKeyFrames() 178 AlignmentView::getDefaultKeyFrames()
179 { 179 {
180 vector<int> keyFrames; 180 vector<sv_frame_t> keyFrames;
181 181
182 if (!m_above || !m_manager) return keyFrames; 182 if (!m_above || !m_manager) return keyFrames;
183 183
184 int rate = m_manager->getMainModelSampleRate(); 184 sv_samplerate_t rate = m_manager->getMainModelSampleRate();
185 if (rate == 0) return keyFrames; 185 if (rate == 0) return keyFrames;
186 186
187 for (int f = m_above->getModelsStartFrame(); 187 for (sv_frame_t f = m_above->getModelsStartFrame();
188 f <= m_above->getModelsEndFrame(); 188 f <= m_above->getModelsEndFrame();
189 f += rate * 5) { 189 f += sv_frame_t(rate * 5 + 0.5)) {
190 keyFrames.push_back(f); 190 keyFrames.push_back(f);
191 } 191 }
192 192
193 return keyFrames; 193 return keyFrames;
194 } 194 }