comparison view/AlignmentView.cpp @ 1324:13d9b422f7fe zoom

Merge from default branch
author Chris Cannam
date Mon, 17 Sep 2018 13:51:31 +0100
parents 57d192e26331 a34a2a25907c
children c8a6fd3f9dff
comparison
equal deleted inserted replaced
1183:57d192e26331 1324:13d9b422f7fe
41 void 41 void
42 AlignmentView::viewCentreFrameChanged(View *v, sv_frame_t 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();
48 } else if (v == m_below) { 48 } else if (v == m_below) {
49 update(); 49 update();
50 } 50 }
51 } 51 }
52 52
53 void 53 void
54 AlignmentView::viewManagerPlaybackFrameChanged(sv_frame_t) 54 AlignmentView::viewManagerPlaybackFrameChanged(sv_frame_t)
71 71
72 void 72 void
73 AlignmentView::setViewAbove(View *v) 73 AlignmentView::setViewAbove(View *v)
74 { 74 {
75 if (m_above) { 75 if (m_above) {
76 disconnect(m_above, 0, this, 0); 76 disconnect(m_above, 0, this, 0);
77 } 77 }
78 78
79 m_above = v; 79 m_above = v;
80 80
81 if (m_above) { 81 if (m_above) {
82 connect(m_above, 82 connect(m_above,
83 SIGNAL(zoomLevelChanged(ZoomLevel, bool)), 83 SIGNAL(zoomLevelChanged(ZoomLevel, bool)),
84 this, 84 this,
85 SLOT(viewAboveZoomLevelChanged(ZoomLevel, bool))); 85 SLOT(viewAboveZoomLevelChanged(ZoomLevel, bool)));
86 } 86 }
87 } 87 }
88 88
89 void 89 void
90 AlignmentView::setViewBelow(View *v) 90 AlignmentView::setViewBelow(View *v)
91 { 91 {
92 if (m_below) { 92 if (m_below) {
93 disconnect(m_below, 0, this, 0); 93 disconnect(m_below, 0, this, 0);
94 } 94 }
95 95
96 m_below = v; 96 m_below = v;
97 97
98 if (m_below) { 98 if (m_below) {
99 connect(m_below, 99 connect(m_below,
100 SIGNAL(zoomLevelChanged(ZoomLevel, bool)), 100 SIGNAL(zoomLevelChanged(ZoomLevel, bool)),
101 this, 101 this,
102 SLOT(viewBelowZoomLevelChanged(ZoomLevel, bool))); 102 SLOT(viewBelowZoomLevelChanged(ZoomLevel, bool)));
103 } 103 }
104 } 104 }
105 105
106 void 106 void
128 paint.fillRect(rect(), bg); 128 paint.fillRect(rect(), bg);
129 129
130 vector<sv_frame_t> keyFrames = getKeyFrames(); 130 vector<sv_frame_t> keyFrames = getKeyFrames();
131 131
132 foreach (sv_frame_t f, keyFrames) { 132 foreach (sv_frame_t f, keyFrames) {
133 int ax = m_above->getXForFrame(f); 133 int ax = m_above->getXForFrame(f);
134 sv_frame_t rf = m_above->alignToReference(f); 134 sv_frame_t rf = m_above->alignToReference(f);
135 sv_frame_t 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<sv_frame_t> 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 }
149 149
150 SparseOneDimensionalModel *m = 0; 150 SparseOneDimensionalModel *m = 0;
151 151
152 // get the topmost such 152 // get the topmost such
153 for (int i = 0; i < m_above->getLayerCount(); ++i) { 153 for (int i = 0; i < m_above->getLayerCount(); ++i) {
154 if (qobject_cast<TimeInstantLayer *>(m_above->getLayer(i))) { 154 if (qobject_cast<TimeInstantLayer *>(m_above->getLayer(i))) {
155 SparseOneDimensionalModel *mm = 155 SparseOneDimensionalModel *mm =
156 qobject_cast<SparseOneDimensionalModel *> 156 qobject_cast<SparseOneDimensionalModel *>
157 (m_above->getLayer(i)->getModel()); 157 (m_above->getLayer(i)->getModel());
158 if (mm) m = mm; 158 if (mm) m = mm;
159 } 159 }
160 } 160 }
161 161
162 if (!m) { 162 if (!m) {
163 return getDefaultKeyFrames(); 163 return getDefaultKeyFrames();
164 } 164 }
165 165
166 vector<sv_frame_t> 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
183 183
184 sv_samplerate_t 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 (sv_frame_t 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 += sv_frame_t(rate * 5 + 0.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 }
195 195