Hello!
Recently I was with a problem regarding doing scaling of a QwtPlot in a real-time plotting graph using setRawSamples called just once (discussion was done here¹). One thing I learned with Uwe on that thread was that, without calling the setData() method, I couldn't use auto scaling since the Qwt system wouldn't be aware that the curve's data had changed.
Well things have changed since then and now I don't have to do real time plotting anymore, but I still want to avoid calling setRawSamples() each second when the QwtPlot needs to be reploted (the reason is code "clarification" and efficiency), which would seem to mean that I'll have to reimplement QwtPlotCurve::boundingRect() as discussed on that topic.
The point I was thinking was: since I don't have to optimize the bounding rect calculation as previously discussed, I could very well use the same system setData() uses to do the axis recalculation, calling it each time I need to replot my graph (but again without calling setData/setRawData). I went, then, to the setData() method which is
if ( d_series != series )
{
delete d_series;
d_series = series;
dataChanged();
}
if ( d_series != series )
{
delete d_series;
d_series = series;
dataChanged();
}
To copy to clipboard, switch view to plain text mode
and figured out that probably the dataChanged() was the method I needed to call before doing the QwtPlot::replot(). I went after it and discovered that it is a pure virtual method from the QwtAbstractSeriesStore class that is defined in QwtPlotSeriesItem (and only here) as being
void QwtPlotSeriesItem::dataChanged()
{
itemChanged();
}
void QwtPlotSeriesItem::dataChanged()
{
itemChanged();
}
To copy to clipboard, switch view to plain text mode
while itemChanged() is
{
if ( d_data->plot )
d_data->plot->autoRefresh();
}
void QwtPlotItem::itemChanged()
{
if ( d_data->plot )
d_data->plot->autoRefresh();
}
To copy to clipboard, switch view to plain text mode
In other words, everything I needed to do, seems to me, was to do my reploting this way:
//update curve's data without calling setRawData again
myPlot->autoRefresh();
myPlot->replot();
//update curve's data without calling setRawData again
myPlot->autoRefresh();
myPlot->replot();
To copy to clipboard, switch view to plain text mode
or equivalent
{
poCurve->itemChanged();
}
myPlot->replot();
foreach (QwtPlotCurve* const poCurve, curveList)
{
poCurve->itemChanged();
}
myPlot->replot();
To copy to clipboard, switch view to plain text mode
Well, I did this and it didn't work the auto scaling is not working. What did I miss?
Thanks,
Momergil
¹: http://www.qtcentre.org/threads/5903...rking?p=262516
Bookmarks