Printing details, how can I change the shape of a pen?

Hello there.

I'm using the same code that draws a custom grid cell for a printout. Everything works ok, but when I zoom on the printout I can see that lines' endpoints are not square but round. Since I'm using lines to draw the grid, and don't use overlapping coordinates this results in a slightly ugly grid, which at some zoom level shows indentation (a very high zoom level, though).

I've looked at the wx.Pen class but I see no option to change the pen shape from a circle to a square. Can this be accomplished?

Also, the preview window tends to not draw lines at all when the zoom level is far away enough that the line doesn't represent a pixel width or something. Is there any trick to render the preview area twice the size then scale down with bicubic interpolation to have a higher chance of seeing grid lines everywhere?

This is the same graphical problem as excel preview. Maybe a trick would be to detect the displayed size pixels and set up the pen widths to be big enough that they fit pixels on the preview window?

···

--
Rastertech España S.A.
  Grzegorz Adam Hankiewicz
/Jefe de Producto TeraVial/

C/ Perfumería 21. Nave I. Polígono industrial La Mina
28770 Colmenar Viejo. Madrid (España)
Tel. +34 918 467 390 (Ext.17) *·* Fax +34 918 457 889
ghankiewicz@rastertech.es *·* www.rastertech.es <http://www.rastertech.es/>

Grzegorz Adam Hankiewicz wrote:

Hello there.

I'm using the same code that draws a custom grid cell for a printout. Everything works ok, but when I zoom on the printout I can see that lines' endpoints are not square but round. Since I'm using lines to draw the grid, and don't use overlapping coordinates this results in a slightly ugly grid, which at some zoom level shows indentation (a very high zoom level, though).

I've looked at the wx.Pen class but I see no option to change the pen shape from a circle to a square. Can this be accomplished?

  thePen.SetCap(wx.CAP_BUTT)

Also, the preview window tends to not draw lines at all when the zoom level is far away enough that the line doesn't represent a pixel width or something. Is there any trick to render the preview area twice the size then scale down with bicubic interpolation to have a higher chance of seeing grid lines everywhere?

I'm not sure I understand the problem, but your proposed solution is doable. Just create a bitmap the size you want, draw to it with a wx.MemoryDC, convert to wx.Image, rescale, convert to bitmap and draw on the preview canvas. Keep in mind however that when actually printing (not previewing) then the DPI will be very large compared to the preview and so that bitmap will end up consuming very much memory...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn escribió:

I've looked at the wx.Pen class but I see no option to change the pen shape from a circle to a square. Can this be accomplished?

  thePen.SetCap(wx.CAP_BUTT)

Ah, so that's what means setting a cap. Thanks, looks like CAP_PROJECTION is what I want.

···

--
     Rastertech España S.A.
  Grzegorz Adam Hankiewicz
/Jefe de Producto TeraVial/

C/ Perfumería 21. Nave I. Polígono industrial La Mina
28770 Colmenar Viejo. Madrid (España)
Tel. +34 918 467 390 (Ext.17) *·* Fax +34 918 457 889
ghankiewicz@rastertech.es *·* www.rastertech.es
<http://www.rastertech.es/&gt;