
Originally Posted by
etienne1234
This code worked pretty well, but my problem is that in qwt 6.1.2 you don't access the scale divisions of an axis with a pointer anymore.
It's a reference now what should be of no difference memory- or performancewise, beside you make a copy in your code. But even when copying a QwtScaleDiv object to a local variable this shouldn't be such an expensive operation as the tick labels are stored in a QVector, what is implicitly shared ( depends of course on how often you call it ). By the way: if you want to have a local copy better use QwtPlot::axisInterval() - what returns the boundaries without the ticks.
Guess the code below should be even faster than the one you have posted ( beside the compiler does some magic to avoid retrieving the QwtScaleDivs several times ):
const QwtScaleDiv
& xScaleDiv
= myPlot
->axisScaleDiv
(QwtPlot::xBottom);
const QwtScaleDiv
& yScaleDiv
= myPlot
->axisScaleDiv
(QwtPlot::yLeft);
if( x < xScaleDiv.lowerBound() )
{
....
}
...
const QwtScaleDiv& xScaleDiv = myPlot->axisScaleDiv(QwtPlot::xBottom);
const QwtScaleDiv& yScaleDiv = myPlot->axisScaleDiv(QwtPlot::yLeft);
if( x < xScaleDiv.lowerBound() )
{
....
}
...
To copy to clipboard, switch view to plain text mode
If there is still a performance issue it is probably not because of how you update the boundaries of the scale in the code above.
Just a hint: I would update the bounding rectangle of the curve and then sync the axes with the bounding rectangle ( using the autoscaler or manually like in the method above ). You can avoid that the curve has to iterate over all points later to find out its bounding rectangle, when you run on an operation, where it is used.
Uwe
Bookmarks