Mercurial > hg > svgui
diff 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 |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Tue Jan 31 17:19:45 2006 +0000 +++ b/layer/Colour3DPlotLayer.cpp Wed Feb 01 14:49:49 2006 +0000 @@ -158,6 +158,8 @@ //!!! divide-by-zero! int pixel = int(((value - min) * 256) / (max - min)); + if (pixel == 256) pixel = 255; + m_cache->setPixel(f / modelWindow, y, pixel); } } @@ -225,14 +227,18 @@ if (sx >= 0 && sx < m_cache->width() && sy >= 0 && sy < m_cache->height()) { - int dv = m_cache->pixelIndex(sx, sy); - if (dv != 0 && paint.fontMetrics().height() < (h / sh)) { - QString text = QString("%1").arg(dv); - if (paint.fontMetrics().width(text) < w - 3) { - paint.setPen(Qt::white); - paint.drawText(rx0 + 2, - ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(), - QString("%1").arg(dv)); + if (w > 10) { + int dv = m_cache->pixelIndex(sx, sy); +// if (dv != 0 && paint.fontMetrics().height() < (h / sh)) { + if (paint.fontMetrics().height() < (h / sh)) { + float value = m_model->getBinValue(fx, sy); + QString text = QString("%1").arg(value); //dv); + if (paint.fontMetrics().width(text) < w - 3) { + paint.setPen(Qt::white); + paint.drawText(rx0 + 2, + ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(), + QString("%1").arg(value)); + } } } } @@ -266,6 +272,23 @@ */ } +int +Colour3DPlotLayer::getNearestFeatureFrame(int frame, + size_t &resolution, + bool snapRight) const +{ + if (!m_model) { + return Layer::getNearestFeatureFrame(frame, resolution, snapRight); + } + + resolution = m_model->getWindowSize(); + + int returnFrame = (frame / resolution) * resolution; + if (snapRight) returnFrame += resolution; + + return returnFrame; +} + #ifdef INCLUDE_MOCFILES #include "Colour3DPlotLayer.moc.cpp" #endif