[patch] cosmetic fix for KPlotWidget

Hans Meine hans_meine at gmx.net
Sun Dec 2 20:06:28 GMT 2007


On Freitag 30 November 2007, Zack Rusin wrote:
> In Qt the coordinate system with the identity world matrix overlaps the
> pixel grid.

Do you mean "falls on" or "coincides" with "overlaps"?

> This is the only reasonable thing to do, otherwise the center 
> of the coordinate system occupies 0.5 pixel boundry and suddenly the
> integer coordinate system gets out of whack with the floating point
> coordinate system.

Actually, the patch is only necessary because the integer grid does *not* 
coincide with the float grid, as can be seen from the illustrations on 
http://doc.trolltech.com/4.3/coordsys.html

In my opinion and from my experience, the only reasonable thing to do is to 
let the integer and floating point coordinates mean the same thing.  However, 
the trolls chose to let floating point coordinates denote the upper left of 
the pixel facets (and changing that would be a big behavioural change, which 
is why I said I don't expect this to be fixed).  Thus, with antialiased 
painting, you need the (0.5, 0.5) offset.

Trolltech even documents that they implemented this offset for aliased 
painting:
> But by default the painter is aliased and other rules apply: When rendering
> with a one pixel wide pen the pixels will be rendered to the right and
> below the mathematically defined points.

This workaround would not be needed if the two grids were coincident.

Note that there's a difference between the pixel grid (i.e. the grid defined 
by integer coordinates, through pixel centers) and the grid *between* pixels, 
which is the grid that you usually perceive.

> The only way to get pixel snapping working is to pixel snap coordinates of
> the primitives themselves not to shift the whole world matrix. Disabling
> antialiasing for horizontal/vertical lines and drawing them in a seperate
> pass would also work.

Please, define what you mean with getting "pixel snapping" to work.  AFAICS, 
this is disabling antialiasing.

> One could probably ask trolls to pixel-snap horizontal/vertical lines in
> qpainter if it happens to be drawing with the identity matrix.

All these hacks would not be needed if... ah, I already made my point.

-- 
Ciao, /  /                                                    .o.
     /--/                                                     ..o
    /  / ANS                                                  ooo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20071202/72de2cf3/attachment.sig>


More information about the kde-core-devel mailing list