Skip to content

Commit

Permalink
Add curve fitting to step-left curve drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Apr 13, 2022
1 parent a7272f8 commit 886436d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/qwt_plot_curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,20 +786,32 @@ 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 );

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 );
}

Expand Down

0 comments on commit 886436d

Please sign in to comment.