Re: Cut a part of a Curve with QWT
Brought to you by:
rathmann
From: Uwe R. <Uwe...@ti...> - 2009-06-14 12:54:16
|
On Wednesday 10 June 2009 23:15, Gerard Vermeulen wrote: > I have seen that it looks like that Uwe implemented in svn this > algorithm > http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm > which reduces the amount of data to plot. I needed the algo at work ( not related to Qwt ), but I see a lot of potential for implementing different levels of detail to improve painting performance of curve lines ( without symbols ! ) for a huge number of points. I havn't tested the algo in combination with Qwt myself yet, but I see 2 different strategies how it can be used: a) Curve fitting curve->setCurveFitter(new QwtWeedingCurveFitter(tolerance)); curve->setCurveAttribute(QwtPlotCurve::Fitted, true); tolerance is a value how far the fitted points can be away from the original curve. Increasing the tolerance reduces the number of points and v.v. The algo is applied for the points after they have been translated (because of non linear scales) into screen coordinates - so a tolarance of 1.0 means, that the fitted curve might differ 1 pixel. This approach is very easy to implement and works for all zoom levels, but: - the fitting algorithm recalculated every time the curve is repainted - all points of the original curve will be translated for every repaint b) Level of details The basic idea is to calculate and store a couple of additional data sets in advance using increasing tolerances. Depending on the zoom level a different data set becomes active ( zooming in means using a data set with a smaller tolerance ). In combination with clipping (maybe also with some smart caching) it should be possible that there are never much more than 1000 points need to be painted. Such an implementation could be implemented below the QwtData interface. At least one of my ideas is to offer such an implementation sooner or later. -- I'm not sure how much performance improvement you can expect from a). Feedback from a real world application is welcome. Uwe PS: the Douglas-Peucker algo is implemented as QwtWeedingCurveFitter in SVN trunk. I guess qwt_curve_fitter.[h|cpp] can from SVN trunk can simply be copied into Qwt 5.2 and used there without further changes. |