Menu

#171 [wxPdfDocument] Bug in wxPdfDC::DrawEllipticArc

Subversion_TRUNK
closed-fixed
wxpdfdoc (23)
5
2015-11-23
2015-11-04
No

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

Discussion

  • Ulrich Telle

    Ulrich Telle - 2015-11-22

    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.

     
  • Ulrich Telle

    Ulrich Telle - 2015-11-23
    • status: open --> closed-fixed
     
  • Ulrich Telle

    Ulrich Telle - 2015-11-23

    Fixed in wxCode SVN.

    Drawing and filling is now separated to get the same behaviour as in wxDC.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.