View Full Version : Plotting part of a curve

6th June 2008, 14:07

I am new to Qwt and I do not find a way to draw only a part of a curve.
Let me explain more precisely.

I have huge data (multiple curves of 1 million points) to be plotted. To avoid duplicating data (which can be edited through a QTableView), I have a class inheriting QwtData for each Curve. These Curve objects are used by my table model linked with the QTableView.

Then I have created a QwtPlotCurve object for each curve, and call setData with my own QwtData.

Next, I call setAxisScale (and replot) regularly on my plot to display my curves with a "slidding window".

The problem is that 100000 points curves works quite well, but 1 millions ones are really not.
I have noticed that all the data are browsed even if only data between 30 to 100 (in X index) have to be displayed. I think that is the problem but I do not find a way to avoid that.

I have notice the draw function which take two parameters (from and to) but I do not know how to use it.

Any hint ? How can I boost all this stuff ?

Thanks in advance

7th June 2008, 11:21
With QwtPlotCurve::PaintFiltered or QwtPlotCurve::ClipPolygon you can reduce the number of points, that are painted.

But the best way to optimize your performance is to implement level of details in your derived Data class: whenever the scales are changing ( f.e. QwtScaleWidget::scaleDivChanged() ) you adjust your data class, so that it returns less points to the curve object.


9th June 2008, 09:17
Thanks a lot, it works just as I want and it allow me to do clever things !

17th July 2008, 23:42
Hi virdis,

I think i have the same problem right now . If you don't mind can you give me a snippet of your "drived data class".

It seems that you need to connect the QwtScaleWidget::scaleDivChanged() into your data class. Is that what you did?


19th July 2008, 11:51

I will try to send you a snippet next week since all the stuff is at work !

20th July 2008, 05:05
thank you very much It will help me a lot...


21st July 2008, 08:12
Here we are :

I have connected the scaleDivChanged signal of the xBottom axis to a slot.
In this slot, I get the xBottom ScaleDiv :
QwtScaleDiv* div = my_plot->axisScaleDiv(QwtPlot::xBottom);
Then, for each of my curves :
((MyDataType&)my_curve->data()).updateScale(div->lBound(), div->hBound());

MyDataType inherits QwtData and stores the current lower bound et higher bound which are changed by the updateScale method just used.
Then, in the x and y methods, I just add the lower bound to the requested index and returns the corresponding value.
The "size" function must be redefined too and it just returns (highBound-lowBound+1).

To be noticed that I have just made a "proof of concept". There is maybe a clever way to do that but it works.

Hope this help.