wxPDF wxBRUSHSTYLE substitude Topic is solved

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: wxPDF wxBRUSHSTYLE substitude

Post by utelle »

mael15 wrote: Fri Sep 17, 2021 12:50 pm i am confused, so can I use wxDC::DrawRectangle or do I have to use wxPdfDocument::Rect ? The former would be easier, but it does not show wxBRUSHSTYLE_BDIAGONAL_HATCH yet.
Well, of course you should be able to use wxDC::DrawRectangle. In my previous post I wrote that the problem seems to be a scaling problem, and I'm pretty sure that scaling is the key to the solution.
mael15 wrote: Fri Sep 17, 2021 12:50 pm I use this code:

Code: Select all

wxPdfDocument pdfDcmt;
pdfDcmt.SetCompression(false);
...
pdfDcmt.AddPage(orient, papSize);
int tpl = pdfDcmt.BeginTemplate();
dc = new wxPdfDC(&pdfDcmt, pageSzMM.x, pageSzMM.y);
dc->SetResolution(600);
Can you tell me the values of pageSzMM.x and pageSzMM.y, please?

Most likely the call SetResolution is responsible for the observed behaviour. wxPdfDC calculates internally a pattern size and it seems that the resolution is not taken into account correctly.
mael15 wrote: Fri Sep 17, 2021 12:50 pm and deep within printToDC

Code: Select all

dc.SetPen(ecBlue);
dc.SetBrush(wxBrush(ecBlue, wxBRUSHSTYLE_BDIAGONAL_HATCH));
dc.DrawRectangle(pnt, sz);
that results in the attached pdf with only a solid blue rectangle.
In fact, the rectangle is not filled with a solid color. You will see that if you display the PDF document in a PDF viewer and set the magnification factor to 800%, for example. You will see that the rectangle is hatched as requested.

As said the problem is the scaling. I will have to check the way how wxPdfDC calculates the pattern size. Most likely the calculation has to be changed to take the resolution into account somehow. However, I think we are already quite close to a working solution.
mael15 wrote: Fri Sep 17, 2021 12:50 pm I also tried it like in the minimal example with

Code: Select all

pdf.AddPattern(wxS("hatch1"), wxPDF_PATTERNSTYLE_BDIAGONAL_HATCH, 1, 1, wxColour(224, 0, 0));
pdf.SetFillPattern(wxS("hatch1"));
pdf.Rect(25, 30, 25, 25, wxPDF_STYLE_FILLDRAW);
but nothing shows up on the page.
Hm, at least in the PDF document you attached I see no trace at all of this rectangle with "hatch1" pattern.
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: wxPDF wxBRUSHSTYLE substitude

Post by mael15 »

utelle wrote: Fri Sep 17, 2021 2:37 pm You will see that if you display the PDF document in a PDF viewer and set the magnification factor to 800%, for example. You will see that the rectangle is hatched as requested.
Yes!!!! I did not think of zooming in, great! Sounds right that the resolution is probably the cause for this very dense hatch.
utelle wrote: Fri Sep 17, 2021 2:37 pm Can you tell me the values of pageSzMM.x and pageSzMM.y, please?
It is standard A4 210x297mm
utelle wrote: Fri Sep 17, 2021 2:37 pm Hm, at least in the PDF document you attached I see no trace at all of this rectangle with "hatch1" pattern.
Yes, I did not mean to be shown in the attachment, just wanted to mention it.
Thank you!
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPDF wxBRUSHSTYLE substitude

Post by utelle »

mael15 wrote: Fri Sep 17, 2021 3:57 pm
utelle wrote: Fri Sep 17, 2021 2:37 pm You will see that if you display the PDF document in a PDF viewer and set the magnification factor to 800%, for example. You will see that the rectangle is hatched as requested.
Yes!!!! I did not think of zooming in, great! Sounds right that the resolution is probably the cause for this very dense hatch.
I will check the pattern size calculation over the weekend. Most likely I will then provide a fix early next week.
mael15 wrote: Fri Sep 17, 2021 3:57 pm
utelle wrote: Fri Sep 17, 2021 2:37 pm Can you tell me the values of pageSzMM.x and pageSzMM.y, please?
It is standard A4 210x297mm
Thanks. Knowing the exact conditions helps to analyze the problem.
mael15 wrote: Fri Sep 17, 2021 3:57 pm
utelle wrote: Fri Sep 17, 2021 2:37 pm Hm, at least in the PDF document you attached I see no trace at all of this rectangle with "hatch1" pattern.
Yes, I did not mean to be shown in the attachment, just wanted to mention it.
Ok. We will look into that issue later. Drawing a rectangle with hatch pattern to a wxPdfDocument instance should always work, because the resolution set for wxPdfDC doesn't matter in that case.
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPDF wxBRUSHSTYLE substitude

Post by utelle »

In the latest wxPdfDocument version on GitHub I adjusted the scaling applied to hatch patterns, so that it should work now as expected. Please give it a try, and report back the results. Thanks in advance.
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: wxPDF wxBRUSHSTYLE substitude

Post by mael15 »

Perfect! wxDC::DrawRectangle with wxBRUSHSTYLE_BDIAGONAL_HATCH on a 600dpi pdf looks like it should now. Thank you VERY much! =D> :D :D
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPDF wxBRUSHSTYLE substitude

Post by utelle »

mael15 wrote: Sun Sep 19, 2021 11:23 am Perfect! wxDC::DrawRectangle with wxBRUSHSTYLE_BDIAGONAL_HATCH on a 600dpi pdf looks like it should now.
Thanks for confirming.
Post Reply