comparison layer/Colour3DPlotLayer.cpp @ 24:6b794a2af3d9

* Add Chromagram plugin, and make a number of fixes to the dense 3d model and colour 3d plot class to accommodate it * Add pitch-conversion methods in base/Pitch * Commit previously overlooked Command.cpp
author Chris Cannam
date Wed, 01 Feb 2006 14:49:49 +0000
parents 1deb5f87a18c
children dcdb21b62dbb
comparison
equal deleted inserted replaced
23:ca57f70b0e48 24:6b794a2af3d9
156 if (y < values.size()) value = values[y]; 156 if (y < values.size()) value = values[y];
157 157
158 //!!! divide-by-zero! 158 //!!! divide-by-zero!
159 int pixel = int(((value - min) * 256) / (max - min)); 159 int pixel = int(((value - min) * 256) / (max - min));
160 160
161 if (pixel == 256) pixel = 255;
162
161 m_cache->setPixel(f / modelWindow, y, pixel); 163 m_cache->setPixel(f / modelWindow, y, pixel);
162 } 164 }
163 } 165 }
164 } 166 }
165 167
223 if (w < 1) w = 1; 225 if (w < 1) w = 1;
224 paint.drawRect(rx0, ry0 - h / sh - 1, w, h / sh + 1); 226 paint.drawRect(rx0, ry0 - h / sh - 1, w, h / sh + 1);
225 227
226 if (sx >= 0 && sx < m_cache->width() && 228 if (sx >= 0 && sx < m_cache->width() &&
227 sy >= 0 && sy < m_cache->height()) { 229 sy >= 0 && sy < m_cache->height()) {
228 int dv = m_cache->pixelIndex(sx, sy); 230 if (w > 10) {
229 if (dv != 0 && paint.fontMetrics().height() < (h / sh)) { 231 int dv = m_cache->pixelIndex(sx, sy);
230 QString text = QString("%1").arg(dv); 232 // if (dv != 0 && paint.fontMetrics().height() < (h / sh)) {
231 if (paint.fontMetrics().width(text) < w - 3) { 233 if (paint.fontMetrics().height() < (h / sh)) {
232 paint.setPen(Qt::white); 234 float value = m_model->getBinValue(fx, sy);
233 paint.drawText(rx0 + 2, 235 QString text = QString("%1").arg(value); //dv);
234 ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(), 236 if (paint.fontMetrics().width(text) < w - 3) {
235 QString("%1").arg(dv)); 237 paint.setPen(Qt::white);
238 paint.drawText(rx0 + 2,
239 ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(),
240 QString("%1").arg(value));
241 }
236 } 242 }
237 } 243 }
238 } 244 }
239 } 245 }
240 } 246 }
264 270
265 paint.drawImage(x0, 0, scaled); 271 paint.drawImage(x0, 0, scaled);
266 */ 272 */
267 } 273 }
268 274
275 int
276 Colour3DPlotLayer::getNearestFeatureFrame(int frame,
277 size_t &resolution,
278 bool snapRight) const
279 {
280 if (!m_model) {
281 return Layer::getNearestFeatureFrame(frame, resolution, snapRight);
282 }
283
284 resolution = m_model->getWindowSize();
285
286 int returnFrame = (frame / resolution) * resolution;
287 if (snapRight) returnFrame += resolution;
288
289 return returnFrame;
290 }
291
269 #ifdef INCLUDE_MOCFILES 292 #ifdef INCLUDE_MOCFILES
270 #include "Colour3DPlotLayer.moc.cpp" 293 #include "Colour3DPlotLayer.moc.cpp"
271 #endif 294 #endif
272 295
273 296