From e319c1b6b829b0f0f5fe5339a3b1565ad9234fd3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Apr 2022 21:50:16 +0200 Subject: [PATCH] Add curve fitting to step-left curve drawing --- src/qwt_plot_curve.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/qwt_plot_curve.cpp b/src/qwt_plot_curve.cpp index c7ddddf2..c5e8fe35 100644 --- a/src/qwt_plot_curve.cpp +++ b/src/qwt_plot_curve.cpp @@ -786,6 +786,8 @@ void QwtPlotCurve::drawSteps( QPainter* painter, points[ip].ry() = yi; } + const bool doFit = (m_data->attributes & Fitted) && m_data->curveFitter; + if ( m_data->paintAttributes & ClipPolygons ) { QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter ); @@ -793,13 +795,23 @@ void QwtPlotCurve::drawSteps( QPainter* painter, const qreal pw = QwtPainter::effectivePenWidth( painter->pen() ); clipRect = clipRect.adjusted(-pw, -pw, pw, pw); - const QPolygonF clipped = QwtClipper::clippedPolygonF( + QPolygonF clipped = QwtClipper::clippedPolygonF( clipRect, polygon, false ); + if (doFit) + { + clipped = m_data->curveFitter->fitCurve(clipped); + } + QwtPainter::drawPolyline( painter, clipped ); } else { + if (doFit) + { + polygon = m_data->curveFitter->fitCurve(polygon); + } + QwtPainter::drawPolyline( painter, polygon ); }