# HG changeset patch # User Hasan Yavuz Ă–ZDERYA # Date 2017-08-16 09:06:32 # Node ID d09252498ce0f8fe1e89a9c16a11fe1523e1e6a4 # Parent 0d17abb454a286127dae8c00f102d56d4fcf12f6 don't move the x axis when moving vertical scroll problem happens when x-axis is out of limit, extended zoom selection with rectangle tool diff --git a/src/scrollzoomer.cpp b/src/scrollzoomer.cpp --- a/src/scrollzoomer.cpp +++ b/src/scrollzoomer.cpp @@ -55,6 +55,7 @@ ScrollZoomer::ScrollZoomer( QWidget *can d_hScrollData = new ScrollData; d_vScrollData = new ScrollData; hscrollmove = false; + vscrollmove = false; } ScrollZoomer::~ScrollZoomer() @@ -150,7 +151,8 @@ void ScrollZoomer::rescale() // NOTE: Below snippet is copied from QwtPlotZoomer::rescale() just so that // we can refrain from updating y axis when moving horizontal scrollbar, so - // that auto-scale isn't disrupted. + // that auto-scale isn't disrupted. Also we don't want to jump around in + // x-axis when moving vertical scroll. { QwtPlot *plt = plot(); if ( !plt ) @@ -162,12 +164,15 @@ void ScrollZoomer::rescale() const bool doReplot = plt->autoReplot(); plt->setAutoReplot( false ); - double x1 = rect.left(); - double x2 = rect.right(); - if ( !plt->axisScaleDiv( xAxis() ).isIncreasing() ) - qSwap( x1, x2 ); + if (!vscrollmove) + { + double x1 = rect.left(); + double x2 = rect.right(); + if ( !plt->axisScaleDiv( xAxis() ).isIncreasing() ) + qSwap( x1, x2 ); - plt->setAxisScale( xAxis(), x1, x2 ); + plt->setAxisScale( xAxis(), x1, x2 ); + } if (!hscrollmove) { @@ -544,7 +549,9 @@ void ScrollZoomer::scrollBarMoved( } else { + vscrollmove = true; moveTo( QPointF( zoomRect().left(), min ) ); + vscrollmove = false; } Q_EMIT zoomed( zoomRect() ); diff --git a/src/scrollzoomer.h b/src/scrollzoomer.h --- a/src/scrollzoomer.h +++ b/src/scrollzoomer.h @@ -82,6 +82,7 @@ private: bool d_inZoom; bool d_alignCanvasToScales[ QwtPlot::axisCnt ]; bool hscrollmove; + bool vscrollmove; }; #endif