The manipulation of the supplied angles to DrawEllipticArc, forcing them in the range of 0<=angle<360, are unnecessary as the angles are used to inputs of trig functions, and incorrectly draw certain arcs. For example, an arc from 180 to 360 degrees will wrap 360 to 0 and will draw an arc backwards from 180 to 0 (equivolent to an arc from 0 to 180, the opposite of what was specified).
The line closing draw style is also inconsistent with wxDC.
Fix below as a unified diff:
Index: pdfdc29.inc =================================================================== --- pdfdc29.inc (revision 3182) +++ pdfdc29.inc (working copy) @@ -748,28 +748,6 @@ double sa, double ea) { wxCHECK_RET(m_pdfDocument, wxT("Invalid PDF DC")); - if (sa >= 360 || sa <= -360) - { - sa -= int(sa/360)*360; - } - if (ea >= 360 || ea <=- 360) - { - ea -= int(ea/360)*360; - } - if (sa < 0) - { - sa += 360; - } - if (ea < 0) - { - ea += 360; - } - if (wxIsSameDouble(sa, ea)) - { - DoDrawEllipse(x, y, width, height); - } - else - { SetupBrush(); SetupPen(); const wxBrush& curBrush = GetBrush(); @@ -779,20 +757,19 @@ if (doDraw || doFill) { m_pdfDocument->SetLineWidth(ScaleLogicalToPdfXRel(1)); // pen width != 1 sometimes fools readers when closing paths - int style = wxPDF_STYLE_FILL | wxPDF_STYLE_DRAWCLOSE; + int style = wxPDF_STYLE_FILL | wxPDF_STYLE_DRAW; if (!(doDraw && doFill)) { - style = (doFill) ? wxPDF_STYLE_FILL : wxPDF_STYLE_DRAWCLOSE; + style = (doFill) ? wxPDF_STYLE_FILL : wxPDF_STYLE_DRAW; } m_pdfDocument->Ellipse(ScaleLogicalToPdfX(x + 0.5 * width), ScaleLogicalToPdfY(y + 0.5 * height), ScaleLogicalToPdfXRel(0.5 * width), ScaleLogicalToPdfYRel(0.5 * height), - 0, sa, ea, style, 8, true); + 0, sa, ea, style, 8, false); CalcBoundingBox(x, y); CalcBoundingBox(x+width, y+height); } - } } void
If the FILL option is selected, then for the sample coming with wxPdfDocument the patched version does not deliver the same result in PDF as on screen. On screen an elliptic sector is filled, while in PDF the fill expands to the area that is delimited by the straight line between the endpoints of the arc.
Fixed in wxCode SVN.
Drawing and filling is now separated to get the same behaviour as in wxDC.