Mercurial > hg > svgui
changeset 1330:c1f719094c25 zoom
Ensure getFrameForX returns value on zoom blocksize boundary; take advantage of that (this is essentially reverting to the same behaviour as in the default branch, which we should probably have done all along)
author | Chris Cannam |
---|---|
date | Fri, 21 Sep 2018 11:50:05 +0100 |
parents | 344f29e46258 |
children | 9758dfc12555 |
files | layer/Colour3DPlotRenderer.cpp view/View.cpp |
diffstat | 2 files changed, 31 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotRenderer.cpp Thu Sep 20 15:42:12 2018 +0100 +++ b/layer/Colour3DPlotRenderer.cpp Fri Sep 21 11:50:05 2018 +0100 @@ -764,14 +764,14 @@ int drawBufferWidth; int binResolution = model->getResolution(); - int limitOverrun = 100; // overrun from edge before we decide this - // isn't going to work out - int leftLimit = -limitOverrun; - int rightLimit = v->getPaintWidth() + limitOverrun; + // These loops should eventually terminate provided that + // getFrameForX always returns a multiple of the zoom level, + // i.e. there is some x for which getFrameForX(x) == 0 and + // subsequent return values are equally spaced - for (int x = x0; x > leftLimit; --x) { + for (int x = x0; ; --x) { sv_frame_t f = v->getFrameForX(x); - if ((f / binResolution) * binResolution == f || x-1 == leftLimit) { + if ((f / binResolution) * binResolution == f) { if (leftCropFrame == -1) leftCropFrame = f; else if (x < x0 - 2) { leftBoundaryFrame = f; @@ -780,9 +780,9 @@ } } - for (int x = x0 + repaintWidth; x < rightLimit; ++x) { + for (int x = x0 + repaintWidth; ; ++x) { sv_frame_t f = v->getFrameForX(x); - if ((f / binResolution) * binResolution == f || x+1 == rightLimit) { + if ((f / binResolution) * binResolution == f) { if (rightCropFrame == -1) rightCropFrame = f; else if (x > x0 + repaintWidth + 2) { rightBoundaryFrame = f; @@ -791,11 +791,6 @@ } } - if (leftBoundaryFrame == -1 || rightBoundaryFrame == -1) { - SVCERR << "WARNING: failed to set left or right boundary frame (values are " << leftBoundaryFrame << " and " << rightBoundaryFrame << " respectively)" << endl; - return; - } - drawBufferWidth = int ((rightBoundaryFrame - leftBoundaryFrame) / binResolution);
--- a/view/View.cpp Thu Sep 20 15:42:12 2018 +0100 +++ b/view/View.cpp Fri Sep 21 11:50:05 2018 +0100 @@ -395,16 +395,33 @@ sv_frame_t View::getFrameForX(int x) const { + // Note, this must always return a value that is on a zoom-level + // boundary - regardless of whether the nominal centre frame is on + // such a boundary or not + int diff = x - (width()/2); - sv_frame_t fdiff = diff; - + sv_frame_t level = m_zoomLevel.level; + sv_frame_t fdiff, result; + if (m_zoomLevel.zone == ZoomLevel::FramesPerPixel) { - fdiff *= m_zoomLevel.level; + fdiff = diff * level; + result = ((fdiff + m_centreFrame) / level) * level; } else { - fdiff /= m_zoomLevel.level; + fdiff = diff / level; + result = fdiff + m_centreFrame; } - - return fdiff + m_centreFrame; +/* + if (x == 0) { + SVCERR << "getFrameForX(" << x << "): diff = " << diff << ", fdiff = " + << fdiff << ", m_centreFrame = " << m_centreFrame + << ", level = " << m_zoomLevel.level + << ", diff % level = " << (diff % m_zoomLevel.level) + << ", nominal " << fdiff + m_centreFrame + << ", will return " << result + << endl; + } +*/ + return result; } double