Problem Drawing Arcs to wxPDFDC

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
rsb
Experienced Solver
Experienced Solver
Posts: 77
Joined: Fri May 29, 2015 7:26 pm

Problem Drawing Arcs to wxPDFDC

Postby rsb » Mon Mar 20, 2017 8:24 pm

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.

DCArc.PNG
DCArc.PNG (1.96 KiB) Viewed 51 times

PDFArc.PNG
PDFArc.PNG (2.29 KiB) Viewed 51 times


Any idea what wrong?

wxWidgets 3.1.0
wxPdfDocument 0.9.5
Windows 7
VS2015

Thanks very much.

utelle
Moderator
Moderator
Posts: 726
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Problem Drawing Arcs to wxPDFDC

Postby utelle » Mon Mar 20, 2017 9:37 pm

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

rsb
Experienced Solver
Experienced Solver
Posts: 77
Joined: Fri May 29, 2015 7:26 pm

Re: Problem Drawing Arcs to wxPDFDC

Postby rsb » Mon Mar 20, 2017 9:56 pm

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.

utelle
Moderator
Moderator
Posts: 726
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Problem Drawing Arcs to wxPDFDC

Postby utelle » Tue Mar 21, 2017 7:32 am

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


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 1 guest