PDA

View Full Version : Axis scaling bug if asked to plot an empty curve?



jrm
15th November 2012, 18:37
If one of the curves that you're asked to plot is empty of data, axis scaling appears to include an extent starting at 0,0. I think the fix is for the code in qwt_plot_axis needs to recognize and allow for an invalid QRectF return. Perhaps thus:

-jrm


*** x86_linux_na/src/qwt_plot_axis.cpp 2011-08-01 10:34:05.000000000 -0400
--- qwt_plot_axis.cpp 2012-11-15 13:16:14.000000000 -0500
***************
*** 619,626 ****
if ( axisAutoScale( item->xAxis() ) || axisAutoScale( item->yAxis() ) )
{
const QRectF rect = item->boundingRect();
! intv[item->xAxis()] |= QwtInterval( rect.left(), rect.right() );
! intv[item->yAxis()] |= QwtInterval( rect.top(), rect.bottom() );
}
}

--- 619,628 ----
if ( axisAutoScale( item->xAxis() ) || axisAutoScale( item->yAxis() ) )
{
const QRectF rect = item->boundingRect();
! if (rect.isValid()) {
! intv[item->xAxis()] |= QwtInterval( rect.left(), rect.right() );
! intv[item->yAxis()] |= QwtInterval( rect.top(), rect.bottom() );
! }
}
}

Uwe
16th November 2012, 08:09
The fix excludes empty rectangles that you get f.e from markers or curves with one point ( or a horizontal or vertical line ).

Instead it needs to be:



const QRectF rect = item->boundingRect();

if ( rect.width() >= 0.0 )
intv[item->xAxis()] |= QwtInterval( rect.left(), rect.right() );

if ( rect.height() >= 0.0 )
intv[item->yAxis()] |= QwtInterval( rect.top(), rect.bottom() );


Fixed in SVN ( trunk and 6.0 ),

Uwe

jrm
19th November 2012, 15:29
Excellent! Many thanks! -jrm