Changeset - d09252498ce0
[Not reviewed]
Hasan Yavuz Ă–ZDERYA - 8 years ago 2017-08-16 09:06:32
hy@ozderya.net
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
2 files changed with 14 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/scrollzoomer.cpp
Show inline comments
 
@@ -52,12 +52,13 @@ ScrollZoomer::ScrollZoomer( QWidget *can
 
    if ( !canvas )
 
        return;
 

	
 
    d_hScrollData = new ScrollData;
 
    d_vScrollData = new ScrollData;
 
    hscrollmove = false;
 
    vscrollmove = false;
 
}
 

	
 
ScrollZoomer::~ScrollZoomer()
 
{
 
    delete d_cornerWidget;
 
    delete d_vScrollData;
 
@@ -147,30 +148,34 @@ void ScrollZoomer::rescale()
 
            d_inZoom = true;
 
        }
 
    }
 

	
 
    // 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 )
 
            return;
 

	
 
        const QRectF &rect = zoomStack()[zoomRectIndex()];
 
        if ( rect != scaleRect() )
 
        {
 
            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)
 
            {
 
                double y1 = rect.top();
 
                double y2 = rect.bottom();
 
                if ( !plt->axisScaleDiv( yAxis() ).isIncreasing() )
 
@@ -541,13 +546,15 @@ void ScrollZoomer::scrollBarMoved(
 
        hscrollmove = true;
 
        moveTo( QPointF( min, zoomRect().top() ) );
 
        hscrollmove = false;
 
    }
 
    else
 
    {
 
        vscrollmove = true;
 
        moveTo( QPointF( zoomRect().left(), min ) );
 
        vscrollmove = false;
 
    }
 

	
 
    Q_EMIT zoomed( zoomRect() );
 
}
 

	
 
int ScrollZoomer::oppositeAxis( int axis ) const
src/scrollzoomer.h
Show inline comments
 
@@ -79,9 +79,10 @@ private:
 
    ScrollData *d_hScrollData;
 
    ScrollData *d_vScrollData;
 

	
 
    bool d_inZoom;
 
    bool d_alignCanvasToScales[ QwtPlot::axisCnt ];
 
    bool hscrollmove;
 
    bool vscrollmove;
 
};
 

	
 
#endif
0 comments (0 inline, 0 general)