PDA

View Full Version : QwtScaleEngine::buildInterval() default values



ars
1st December 2014, 14:25
My application typically uses Y-axis range in the area of +/-1ps to +/-1us. I'm using auto scaling so that qwt computes the optimum scaling of the traces displayed. This works fine in most cases, but in the pathological case of a trace being constant 0 for all x values auto scaling gives a Y range of [-0.5, 0.5] (seconds) which is not what my users would expect. This behavior is documented in QwtScaleEngine::buildInterval() documentation.

Unfortunately, buildInterval() method is not virtual. To change the behavior, I have to override QwtLinearScaleEngine::autoScale() method. The override would be the same code as in qwt library with the exception that the call to buildInterval() is replaced by a call to a different method. That approach is working, but not elegant as it reproduces 99% of the original autoScale() code in the override.

My questions:
- Is there a better way of using a user defined span for this pathological situation?
- If not, would it be possible to set a "nullSpan" in the QwtLinearScaleEngine in future releases of qwt?
- At least, could buildInterval() be changed to a virtual method in future releases?

Thanks for any suggestions
ars

Uwe
1st December 2014, 18:51
I have to override QwtLinearScaleEngine::autoScale() method.

Yes, nothing wrong about it.

Uwe


class YourScaleEngine: public QwtLinearScaleEngine
{
...

virtual void autoScale( int maxNumSteps,
double &x1, double &x2, double &stepSize ) const
{
if ( x1 == x2 )
{
x1 = ...;
x2 = ...;
stepSize = ...;

return;
}

QwtLinearScaleEngine::autoScale( maxNumSteps, x1, x2, stepSize );
}
};