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: 973
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument: Plotting a Rotated Rectangle

Post by utelle » Mon Sep 07, 2020 6:29 pm

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: 164
Joined: Fri May 29, 2015 7:26 pm

Re: wxPdfDocument: Plotting a Rotated Rectangle

Post by rsb » 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.

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.

ScreenRR.PNG
Screen Display
ScreenRR.PNG (9.09 KiB) Viewed 336 times
wxPDF_RR.PNG
Adobe PDF from WxPdfDocument
wxPDF_RR.PNG (10.47 KiB) Viewed 336 times
Thanks.

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

Re: wxPdfDocument: Plotting a Rotated Rectangle

Post by utelle » Tue Sep 08, 2020 7:04 am

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: 164
Joined: Fri May 29, 2015 7:26 pm

Re: wxPdfDocument: Plotting a Rotated Rectangle

Post by rsb » Tue Sep 08, 2020 1:26 pm

m_scaleX and m_scaleY are both equal to 1.0.

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

Re: wxPdfDocument: Plotting a Rotated Rectangle

Post by utelle » Tue Sep 08, 2020 4:45 pm

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: 973
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument: Plotting a Rotated Rectangle

Post by utelle » Wed Sep 09, 2020 8:38 am

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 243 times
and the same rotated rounded rectangle in PDF:
rounded-rectangle-pdf.png
rounded-rectangle-pdf.png (4.26 KiB) Viewed 243 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