Hello,

I'm drawing an arc using a wxDC object and it looks fine, (first picture). However,

when I draw the same arc using a wxPDFDC object, it's not right (second picture).

In the pictures, there are two arcs, the arc to the left of the plus sign in the first

picture is wrong in the PDF document.

Any idea what wrong?

wxWidgets 3.1.0

wxPdfDocument 0.9.5

Windows 7

VS2015

Thanks very much.

## Problem Drawing Arcs to wxPDFDC

### Re: Problem Drawing Arcs to wxPDFDC

rsb wrote:I'm drawing an arc using a wxDC object and it looks fine, (first picture). However,

when I draw the same arc using a wxPDFDC object, it's not right (second picture).

In the pictures, there are two arcs, the arc to the left of the plus sign in the first

picture is wrong in the PDF document.

Could you please provide the code you use to draw the arcs? This would help to analyze the problem. Thanks.

Regards,

Ulrich

### Re: Problem Drawing Arcs to wxPDFDC

Hope this is good enough:

if( start_angle < end_angle )

{

if( start_angle <= mid_angle && mid_angle <= end_angle )

dc.DrawArc(startPoint.x, startPoint.y, endPoint.x, endPoint.y, centerPoint.x, centerPoint.y);

else

dc.DrawArc(endPoint.x, endPoint.y, startPoint.x, startPoint.y, centerPoint.x, centerPoint.y);

}

else

{

if( end_angle <= mid_angle && mid_angle <= start_angle )

dc.DrawArc(endPoint.x, endPoint.y, startPoint.x, startPoint.y, centerPoint.x, centerPoint.y);

else

dc.DrawArc(startPoint.x, startPoint.y, endPoint.x, endPoint.y, centerPoint.x, centerPoint.y);

}

Start, mid and end angles are determined using:

start angle --> atan2((double) start.y - center.y,(double) start.x - center.x))

mid angle --> atan2((double) mid.y - center.y,(double) mid.x - center.x))

end angle --> atan2((double) end.y - center.y,(double) end.x - center.x))

Thanks.

if( start_angle < end_angle )

{

if( start_angle <= mid_angle && mid_angle <= end_angle )

dc.DrawArc(startPoint.x, startPoint.y, endPoint.x, endPoint.y, centerPoint.x, centerPoint.y);

else

dc.DrawArc(endPoint.x, endPoint.y, startPoint.x, startPoint.y, centerPoint.x, centerPoint.y);

}

else

{

if( end_angle <= mid_angle && mid_angle <= start_angle )

dc.DrawArc(endPoint.x, endPoint.y, startPoint.x, startPoint.y, centerPoint.x, centerPoint.y);

else

dc.DrawArc(startPoint.x, startPoint.y, endPoint.x, endPoint.y, centerPoint.x, centerPoint.y);

}

Start, mid and end angles are determined using:

start angle --> atan2((double) start.y - center.y,(double) start.x - center.x))

mid angle --> atan2((double) mid.y - center.y,(double) mid.x - center.x))

end angle --> atan2((double) end.y - center.y,(double) end.x - center.x))

Thanks.

### Re: Problem Drawing Arcs to wxPDFDC

rsb wrote:Hope this is good enough:

if( start_angle < end_angle )

{

if( start_angle <= mid_angle && mid_angle <= end_angle )

dc.DrawArc(startPoint.x, startPoint.y, endPoint.x, endPoint.y, centerPoint.x, centerPoint.y);

else

dc.DrawArc(endPoint.x, endPoint.y, startPoint.x, startPoint.y, centerPoint.x, centerPoint.y);

}

else

{

if( end_angle <= mid_angle && mid_angle <= start_angle )

dc.DrawArc(endPoint.x, endPoint.y, startPoint.x, startPoint.y, centerPoint.x, centerPoint.y);

else

dc.DrawArc(startPoint.x, startPoint.y, endPoint.x, endPoint.y, centerPoint.x, centerPoint.y);

}

Start, mid and end angles are determined using:

start angle --> atan2((double) start.y - center.y,(double) start.x - center.x))

mid angle --> atan2((double) mid.y - center.y,(double) mid.x - center.x))

end angle --> atan2((double) end.y - center.y,(double) end.x - center.x))

Thanks.

Your given code draws only exactly 1 arc. Is the same code used to draw both arcs? If yes, you need 2 sets of points for start, mid, end, and center. I have no clue whether both sets share the same mid point or not, and how you derived the center points. Could you please provide a sample set of points showing the observed behaviour?

Obviously the problem has something to do with how the drawing direction of the arc is derived from the angles.

Regards,

Ulrich

### Who is online

Users browsing this forum: No registered users and 1 guest