wxPdfDocument: Plotting a Rotated Rectangle

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument: Plotting a Rotated Rectangle

Post by utelle »

rsb wrote: Mon Sep 07, 2020 2:16 pm I'm sorry Utelle, I got the PPI wrong. The screen DC returns 96, the wxPdfDC returns 1200.
GetSize() returns x: 13,200 and y: 10,200
Thanks for the information.

I adjusted the translation vector on setting the transformation matrix by taking the resolution into account. Please try the latest wxPdfDocument master. I hope this fixes the issue for you.
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Re: wxPdfDocument: Plotting a Rotated Rectangle

Post by rsb »

This is better, the rectangles display but they are offset down and to the left slightly. See second picture.

Also, In another design, we are displaying in color and the color turns to black and white at some point.
Looks like something is switching it off.

Screen Display
Screen Display
ScreenRR.PNG (9.09 KiB) Viewed 10391 times
Adobe PDF from WxPdfDocument
Adobe PDF from WxPdfDocument
wxPDF_RR.PNG (10.47 KiB) Viewed 10391 times
Thanks.
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument: Plotting a Rotated Rectangle

Post by utelle »

rsb wrote: Mon Sep 07, 2020 10:13 pm This is better, the rectangles display but they are offset down and to the left slightly. See second picture.
Most likely this indicates that the translation vector is still not right. Could you please check the values of m_scaleX and m_scaleY in method SetTransformMatrix? Which values do these variables have? If they are not equal to 1, but relatively close to 1, you could try to simply remove them from the calculation and check whether that does the trick.
rsb wrote: Mon Sep 07, 2020 10:13 pm Also, In another design, we are displaying in color and the color turns to black and white at some point.
Looks like something is switching it off.
When applying a transformation in PDF it is necessary to apply a save and restore of the graphics state as well. If you set the pen and/or brush after setting a transformation matrix, then resetting the transformation matrix has unfortunately the side effect of reverting to the previous pen and/or brush as well. That is, you should either always set pen and brush explicitly after setting a transformation matrix, or do the setting of pen and brush before setting the transformation matrix.
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Re: wxPdfDocument: Plotting a Rotated Rectangle

Post by rsb »

m_scaleX and m_scaleY are both equal to 1.0.
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument: Plotting a Rotated Rectangle

Post by utelle »

rsb wrote: Tue Sep 08, 2020 1:26 pm m_scaleX and m_scaleY are both equal to 1.0.
In that case I really don't have an explanation why the rotated rectangle seems to be shifted.

Without seeing the code that was actually executed I'm not able to track down the cause of the problem. That is, I need a sample exhibiting the erroneous behaviour for further analysis.
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument: Plotting a Rotated Rectangle

Post by utelle »

I made a quick experiment with the following result:

A rotated rounded rectangle on screen:
rounded-rectangle-screen.png
rounded-rectangle-screen.png (1.42 KiB) Viewed 10298 times
and the same rotated rounded rectangle in PDF:
rounded-rectangle-pdf.png
rounded-rectangle-pdf.png (4.26 KiB) Viewed 10298 times
I used exactly the same drawing code for screen and PDF.

As you can see there is no visible shift whatsoever.

So, if possible show the exact code you used to draw your rounded rectangles. Thanks.
Post Reply