QwtCurveFitter::fitCurve called only for "Lines" style QwtPlotCurves -- not "Steps".
I'm finding, and seeing in Qwt 6.1.3 code, that the QPolygonF QwtCurveFitter::fitCurve(const QPolygonF&) const virtual method is being called only for QwtPlotCurves having the QwtPlotCurve::Lines curve style, and not for the QwtPlotCurve::Steps curve style.
I am seeing a call to fitCurve() in QwtPlotCurve::drawLines (QPainter* ..), but not in QwtPlotCurve::drawSteps (QPainter* ..).
I believe QwtWeedingCurveFitter would work for us in the Steps style, and we do kinda need it. Is there a fundamental reason why the algorithm ("Douglas and Peucker") or this implementation would be fundamentally unworkable for stepped curves?
If I'm seeing this correctly, I think we would have to modify QwtPlotCurve::drawSteps (QPainter* ..) to try this. Yes? But I'm wondering if that's an entirely arithmetically foolish thing to even be trying.
-----
FWIW ... I created a QwtWeedingCurveFitter subclass to do some of our own caching of the QwtWeedingCurveFitter results (also to dynamically track instance life-cycle) -- though I'm finding cache hits to not be especially successful, for apparent reasons.
Code:
class WeedFitter : public QwtWeedingCurveFitter
{
private:
static int _instanceCnt;
const int _instanceNum;
public:
virtual ~WeedFitter();
// virtual from QwtWeedingCurveFitter
virtual QPolygonF fitCurve
(const QPolygonF
&) const override;
};
This is coming up in my attempt to address the problem described in this other post ... http://www.qtcentre.org/threads/68094 ("Dense Qwt curves with dotted or dashed line style generally look solid").
Re: QwtCurveFitter::fitCurve called only for "Lines" style QwtPlotCurves -- not "Step
You have 2 options for how to do any type of point weeding:
- weeding the original points, passing the result as curve points
- weeding points after being translated into paint device coordinates ( setCurveFitter )
2) seems to be what you want to do, but as this is done inside every replot cycle it might slow down your performance - depending on the number of points and the order of the weeding algo heavily. In case of Douglas Peucker I recommend to do 1) depending on QwtScaleWidget::scaleDivChanged signals. It should be possible to define a reasonable level of details to limit how often weeding needs to be done.
But as your real motivation is about creating distances between 2 adjacent points, that is above the length of a dot/dash you could consider writing your own type of fitter using a simpler interpolation algo, that takes specific characteristics of your data into count.
Uwe