## Bugfix wxPdfDC

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
DerKleineNik
Knows some wx things
Posts: 29
Joined: Fri Sep 09, 2011 9:59 am

### Bugfix wxPdfDC

Hey,

by painting with wxPdfDC I found two little bugs: if I want to draw an arc, it draws a sector instead
(solved by changing line 631 in pdfDC28 to
m_pdfDocument->Ellipse(xxc,yyc,r,0,0,start,end,style,8,false) )

The other bug is that if I want to draw an arc with an ending angle of 270° (-90) it draws the counterpart angle (-310° instead of 50°)
this problem is solvable with a little piece of extra code in pdfgraphics at line 915:
if(afinish==-90) afinish=270;
this changes the ending angle from -90° to 270 in case the angle is -90 (this angle of -90° is calculated in pdfdc28 at line 28)

Regards, DerKleineNik

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

### Re: Bugfix wxPdfDC

DerKleineNik wrote:by painting with wxPdfDC I found two little bugs: if I want to draw an arc, it draws a sector instead
(solved by changing line 631 in pdfDC28 to
m_pdfDocument->Ellipse(xxc,yyc,r,0,0,start,end,style,8,false) )

Yes, you're right. And this is also true for the version for wxWidgets 2.9.x.

DerKleineNik wrote:The other bug is that if I want to draw an arc with an ending angle of 270° (-90) it draws the counterpart angle (-310° instead of 50°)
this problem is solvable with a little piece of extra code in pdfgraphics at line 915:
if(afinish==-90) afinish=270;
this changes the ending angle from -90° to 270 in case the angle is -90 (this angle of -90° is calculated in pdfdc28 at line 28)

I think this can be be fixed also in the wxPdfDC code (in local method angleByCoords).

I changed both issues in the. Please download the files pdfdc28.inc resp. pdfdc29.inc from there and check whether they now work for you.

Regards,

Ulrich

DerKleineNik
Knows some wx things
Posts: 29
Joined: Fri Sep 09, 2011 9:59 am

### Re: Bugfix wxPdfDC

Hello,

with this bugfix the problem with the Sector is solved (now draws just the arc) but the other problem with the angles still exists.

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

### Re: Bugfix wxPdfDC

DerKleineNik wrote:with this bugfix the problem with the Sector is solved (now draws just the arc) but the other problem with the angles still exists.

Hm, I really don't understand why passing afinish=270 to method Ellipse instead of afinish=-90 doesn't solve the problem while your patch within method Ellipse (which's effect is IMHO identical) does the trick according to your posting.

Could you please provide some code with which parameters you try to draw the arc and which result you expect?

Regards,

Ulrich

DerKleineNik
Knows some wx things
Posts: 29
Joined: Fri Sep 09, 2011 9:59 am

### Re: Bugfix wxPdfDC

Posting some Code would cause this Forum to explode as there are hundreds of lines drawn in different subclasses.
This problem occurs when i have a finishing angle of 270° (-90°).
In the method there is calculated drawed angle = finish angle - starting angle. If its calculated with -90° and you have a starting angle of for example 180° you get an angle of 270 to draw as -90 - 180 is -270. But the angle I want to draw there is 90° (270° - 180°)

Edit: Your bugfux just moves the problem as you changed

Code: Select all

` ret = diffY > 0 ? 90 : -90; `

to

Code: Select all

` ret = diffY > 0 ? 90 : 270; `

Now the problem occurs whe you have a starting angle of 270° and a finish angle of 0° (0° - 270° = 270°) but the angle to be drawn must be (0° - (-90°) = 90°)

The difference between my bugfix and yours is that you treat all angles the same and i just change the finishing angles in case that they are -90°. This you can't do in the wxpdfdc class in the anglebychoords method cause there you handle all angles no matter wether they are starting or finishing angles. If you'd like to solve the problem in the wxpdfdc class you have to check the angles in every circle or ellipse handling method and then change them to the needed values (negative or positive and over 180°)

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

### Re: Bugfix wxPdfDC

DerKleineNik wrote:Posting some Code would cause this Forum to explode as there are hundreds of lines drawn in different subclasses.

Well, I didn't expect that you post your complete code, one single call to DrawArc exhibiting the problem would have been sufficient. But I don't think posting code is necessary anymore.

DerKleineNik wrote:This problem occurs when i have a finishing angle of 270° (-90°).
In the method there is calculated drawed angle = finish angle - starting angle. If its calculated with -90° and you have a starting angle of for example 180° you get an angle of 270 to draw as -90 - 180 is -270. But the angle I want to draw there is 90° (270° - 180°)

Edit: Your bugfux just moves the problem as you changed

Code: Select all

` ret = diffY > 0 ? 90 : -90; `

to

Code: Select all

` ret = diffY > 0 ? 90 : 270; `

Now the problem occurs whe you have a starting angle of 270° and a finish angle of 0° (0° - 270° = 270°) but the angle to be drawn must be (0° - (-90°) = 90°)

That's the problem with hot fixes ... often they make the problem even worse.

DerKleineNik wrote:The difference between my bugfix and yours is that you treat all angles the same and i just change the finishing angles in case that they are -90°. This you can't do in the wxpdfdc class in the anglebychoords method cause there you handle all angles no matter wether they are starting or finishing angles. If you'd like to solve the problem in the wxpdfdc class you have to check the angles in every circle or ellipse handling method and then change them to the needed values (negative or positive and over 180°)

I still think the problem can be fixed in the wxPdfDC class. Since method DrawArc of wxPdfDC currently doesn't work conforming to the implementation in the on-screen wxDC class (for non-transparent brushes a sector is drawn, for transparent brushes an arc is drawn) I have to work on it anyway. I hope to be able to provide a solution in the near future.

Regards,

Ulrich

DerKleineNik
Knows some wx things
Posts: 29
Joined: Fri Sep 09, 2011 9:59 am

### Re: Bugfix wxPdfDC

Okay,
I just wanted to tell you what I found and how it possibly can be fixed.
This was just my quick and dirty fixes to make it work as i needed it.
I guess for other applikations this would not work maybe.