Iterate over wxPointList with STL syntax in wxDC::DoDrawSpline

STL syntax is more readable than notation with legacy API.
This commit is contained in:
Artur Wieczorek
2021-07-04 20:05:35 +02:00
parent 4423f6d256
commit 819b11ff89

View File

@@ -902,46 +902,37 @@ void wxDCImpl::DoDrawSpline( const wxPointList *points )
{
wxCHECK_RET( IsOk(), wxT("invalid window dc") );
wxCHECK_RET(points, "NULL pointer to spline points?");
wxCHECK_RET(points->GetCount() >= 2, "incomplete list of spline points?");
wxCHECK_RET(points->size() >= 2, "incomplete list of spline points?");
const wxPoint *p;
double cx1, cy1, cx2, cy2;
double x1, y1, x2, y2;
wxPointList::compatibility_iterator node = points->GetFirst();
p = node->GetData();
wxPointList::const_iterator itPt= points->begin();
p = *itPt; ++itPt;
x1 = p->x;
y1 = p->y;
node = node->GetNext();
p = node->GetData();
p = *itPt; ++itPt;
x2 = p->x;
y2 = p->y;
cx1 = (double)((x1 + x2) / 2);
cy1 = (double)((y1 + y2) / 2);
cx2 = (double)((cx1 + x2) / 2);
cy2 = (double)((cy1 + y2) / 2);
double cx1 = (double)((x1 + x2) / 2);
double cy1 = (double)((y1 + y2) / 2);
double cx2 = (double)((cx1 + x2) / 2);
double cy2 = (double)((cy1 + y2) / 2);
wx_spline_add_point(x1, y1);
while ((node = node->GetNext())
#if !wxUSE_STD_CONTAINERS
!= NULL
#endif // !wxUSE_STD_CONTAINERS
)
while ( itPt != points->end() )
{
double cx3, cy3, cx4, cy4;
p = node->GetData();
x1 = x2;
y1 = y2;
p = *itPt; ++itPt;
x2 = p->x;
y2 = p->y;
cx4 = (double)(x1 + x2) / 2;
cy4 = (double)(y1 + y2) / 2;
cx3 = (double)(x1 + cx4) / 2;
cy3 = (double)(y1 + cy4) / 2;
double cx4 = (double)(x1 + x2) / 2;
double cy4 = (double)(y1 + y2) / 2;
double cx3 = (double)(x1 + cx4) / 2;
double cy3 = (double)(y1 + cy4) / 2;
wx_quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4);