Mercurial > hg > svgui
changeset 1329:344f29e46258 zoom
Responding to a hang due to mismatching zoom and block sizes
author | Chris Cannam |
---|---|
date | Thu, 20 Sep 2018 15:42:12 +0100 |
parents | b39cd8fb309f |
children | c1f719094c25 |
files | layer/Colour3DPlotRenderer.cpp view/View.cpp view/ViewProxy.h |
diffstat | 3 files changed, 27 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotRenderer.cpp Thu Sep 20 13:14:15 2018 +0100 +++ b/layer/Colour3DPlotRenderer.cpp Thu Sep 20 15:42:12 2018 +0100 @@ -764,9 +764,14 @@ int drawBufferWidth; int binResolution = model->getResolution(); - for (int x = x0; ; --x) { + int limitOverrun = 100; // overrun from edge before we decide this + // isn't going to work out + int leftLimit = -limitOverrun; + int rightLimit = v->getPaintWidth() + limitOverrun; + + for (int x = x0; x > leftLimit; --x) { sv_frame_t f = v->getFrameForX(x); - if ((f / binResolution) * binResolution == f) { + if ((f / binResolution) * binResolution == f || x-1 == leftLimit) { if (leftCropFrame == -1) leftCropFrame = f; else if (x < x0 - 2) { leftBoundaryFrame = f; @@ -774,9 +779,10 @@ } } } - for (int x = x0 + repaintWidth; ; ++x) { + + for (int x = x0 + repaintWidth; x < rightLimit; ++x) { sv_frame_t f = v->getFrameForX(x); - if ((f / binResolution) * binResolution == f) { + if ((f / binResolution) * binResolution == f || x+1 == rightLimit) { if (rightCropFrame == -1) rightCropFrame = f; else if (x > x0 + repaintWidth + 2) { rightBoundaryFrame = f; @@ -784,6 +790,12 @@ } } } + + 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 13:14:15 2018 +0100 +++ b/view/View.cpp Thu Sep 20 15:42:12 2018 +0100 @@ -47,7 +47,7 @@ #include <cassert> #include <cmath> -//#define DEBUG_VIEW 1 +#define DEBUG_VIEW 1 //#define DEBUG_VIEW_WIDGET_PAINT 1 View::View(QWidget *w, bool showProgress) : @@ -328,6 +328,11 @@ { bool changeVisible = false; +#ifdef DEBUG_VIEW + SVCERR << "View::setCentreFrame: from " << m_centreFrame + << " to " << f << endl; +#endif + if (m_centreFrame != f) { sv_frame_t formerCentre = m_centreFrame; @@ -351,6 +356,9 @@ #ifdef DEBUG_VIEW_WIDGET_PAINT SVCERR << "View(" << this << ")::setCentreFrame: newPixel " << newPixel << ", formerPixel " << formerPixel << endl; #endif + // ensure the centre frame is a multiple of the zoom level + m_centreFrame = sv_frame_t(newPixel) * m_zoomLevel.level; + update(); changeVisible = true; }
--- a/view/ViewProxy.h Thu Sep 20 13:14:15 2018 +0100 +++ b/view/ViewProxy.h Thu Sep 20 15:42:12 2018 +0100 @@ -78,7 +78,7 @@ virtual ZoomLevel getZoomLevel() const { ZoomLevel z = m_view->getZoomLevel(); //!!! - cerr << "getZoomLevel: from " << z << " to "; +// cerr << "getZoomLevel: from " << z << " to "; if (z.zone == ZoomLevel::FramesPerPixel) { z.level /= m_scaleFactor; if (z.level < 1) { @@ -88,7 +88,7 @@ //!!!??? z.level *= m_scaleFactor; } - cerr << z << endl; +// cerr << z << endl; return z; } virtual QRect getPaintRect() const {