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 Jan 3, 2024
1 parent 293ba9b commit e319c1b
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 e319c1b

Please sign in to comment.