Mercurial > hg > svgui
changeset 474:efc2bd6d3611
* take a bit more care about peaks cache sizing
author | Chris Cannam |
---|---|
date | Thu, 29 Jan 2009 14:17:12 +0000 |
parents | 4f4f943bfdfc |
children | 3f4b10e76ccd |
files | layer/Colour3DPlotLayer.cpp |
diffstat | 1 files changed, 32 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Tue Jan 27 13:25:10 2009 +0000 +++ b/layer/Colour3DPlotLayer.cpp Thu Jan 29 14:17:12 2009 +0000 @@ -37,7 +37,7 @@ m_model(0), m_cache(0), m_peaksCache(0), - m_peakResolution(128), + m_peakResolution(256), m_cacheValidStart(0), m_cacheValidEnd(0), m_colourScale(LinearScale), @@ -73,6 +73,16 @@ connect(m_model, SIGNAL(modelChanged(size_t, size_t)), this, SLOT(modelChanged(size_t, size_t))); + m_peakResolution = 256; + if (model->getResolution() > 512) { + m_peakResolution = 16; + } else if (model->getResolution() > 128) { + m_peakResolution = 64; + } else if (model->getResolution() > 2) { + m_peakResolution = 128; + } + cacheInvalid(); + emit modelReplaced(); emit sliceableModelReplaced(oldModel, model); } @@ -750,7 +760,7 @@ m_cache = new QImage (cacheWidth, cacheHeight, QImage::Format_Indexed8); m_cache->setNumColors(256); - if (modelResolution < m_peakResolution / 2 && !m_normalizeVisibleArea) { + if (!m_normalizeVisibleArea) { m_peaksCache = new QImage (cacheWidth / m_peakResolution + 1, cacheHeight, QImage::Format_Indexed8); @@ -1118,13 +1128,23 @@ int zoomLevel = v->getZoomLevel(); QImage *source = m_cache; - if (m_peaksCache && - ((modelResolution * srRatio * m_peakResolution) / zoomLevel) < 1) { -// std::cerr << "using peaks cache" << std::endl; - source = m_peaksCache; - modelResolution *= m_peakResolution; + + std::cerr << "modelResolution " << modelResolution << ", srRatio " + << srRatio << ", m_peakResolution " << m_peakResolution + << ", zoomLevel " << zoomLevel << ", result " + << ((modelResolution * srRatio * m_peakResolution) / zoomLevel) + << std::endl; + + if (m_peaksCache) { + if (((modelResolution * srRatio * m_peakResolution) / zoomLevel) < 1) { + std::cerr << "using peaks cache" << std::endl; + source = m_peaksCache; + modelResolution *= m_peakResolution; + } else { + std::cerr << "not using peaks cache" << std::endl; + } } else { -// std::cerr << "not using peaks cache" << std::endl; + std::cerr << "have no peaks cache" << std::endl; } int psy1i = -1; @@ -1175,8 +1195,11 @@ for (int x = 0; x < w; ++x) { + int sx1i = sxa[x*2 + 1]; + if (sx1i < 0) continue; + int sx0i = sxa[x*2]; - int sx1i = sxa[x*2 + 1]; + if (sx0i >= sw) break; uchar peak = 0; for (int sx = sx0i; sx <= sx1i; ++sx) {