Mercurial > hg > svgui
diff layer/Colour3DPlotLayer.cpp @ 772:986f1670a502 tonioni
Merge from default branch
author | Chris Cannam |
---|---|
date | Wed, 14 May 2014 09:58:16 +0100 |
parents | d7e8cefedbbc |
children | 1d526ba11a24 |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Fri Apr 11 16:34:12 2014 +0100 +++ b/layer/Colour3DPlotLayer.cpp Wed May 14 09:58:16 2014 +0100 @@ -579,6 +579,13 @@ return true; } +bool +Colour3DPlotLayer::getYScaleValue(const View *v, int y, + float &value, QString &unit) const +{ + return false;//!!! +} + int Colour3DPlotLayer::getVerticalZoomSteps(int &defaultStep) const { @@ -952,6 +959,7 @@ size_t cacheHeight = m_model->getHeight(); if (m_cache && (m_cache->height() != int(cacheHeight))) { + // height has changed: delete everything rather than resizing delete m_cache; delete m_peaksCache; m_cache = 0; @@ -959,6 +967,7 @@ } if (m_cache && (m_cache->width() != int(cacheWidth))) { + // width has changed and we have an existing cache: resize it QImage *newCache = new QImage(m_cache->copy(0, 0, cacheWidth, cacheHeight)); delete m_cache; @@ -966,7 +975,7 @@ if (m_peaksCache) { QImage *newPeaksCache = new QImage(m_peaksCache->copy - (0, 0, cacheWidth / m_peakResolution, cacheHeight)); + (0, 0, cacheWidth / m_peakResolution + 1, cacheHeight)); delete m_peaksCache; m_peaksCache = newPeaksCache; } @@ -991,6 +1000,9 @@ m_cacheValidEnd = 0; } +// cerr << "cache size = " << m_cache->width() << "x" << m_cache->height() +// << " peaks cache size = " << m_peaksCache->width() << "x" << m_peaksCache->height() << endl; + if (m_cacheValidStart <= firstBin && m_cacheValidEnd >= lastBin) { #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT cerr << "Cache is valid in this region already" << endl; @@ -1117,6 +1129,12 @@ values = getColumn(c); + if (c >= m_cache->width()) { + cerr << "ERROR: column " << c << " >= cache width " + << m_cache->width() << endl; + continue; + } + for (size_t y = 0; y < cacheHeight; ++y) { float value = min; @@ -1145,7 +1163,11 @@ if (m_invertVertical) { m_cache->setPixel(c, cacheHeight - y - 1, pixel); } else { - m_cache->setPixel(c, y, pixel); + if (y >= m_cache->height()) { + cerr << "ERROR: row " << y << " >= cache height " << m_cache->height() << endl; + } else { + m_cache->setPixel(c, y, pixel); + } } } @@ -1153,11 +1175,23 @@ size_t notch = (c % m_peakResolution); if (notch == m_peakResolution-1 || c == fillEnd) { size_t pc = c / m_peakResolution; + if (pc >= m_peaksCache->width()) { + cerr << "ERROR: peak column " << pc + << " (from col " << c << ") >= peaks cache width " + << m_peaksCache->width() << endl; + continue; + } for (size_t y = 0; y < cacheHeight; ++y) { if (m_invertVertical) { m_peaksCache->setPixel(pc, cacheHeight - y - 1, peaks[y]); } else { - m_peaksCache->setPixel(pc, y, peaks[y]); + if (y >= m_peaksCache->height()) { + cerr << "ERROR: row " << y + << " >= peaks cache height " + << m_peaksCache->height() << endl; + } else { + m_peaksCache->setPixel(pc, y, peaks[y]); + } } } for (int y = 0; y < cacheHeight; ++y) {