[PyKDE] how to identify empty space on a qcanvas

Mike Tammerman mtammerman at gmail.com
Fri May 27 09:08:13 BST 2005


1. Retrieve all items from the canvas with QCanvas.allItems() method,
then make a set with the points of the item. Call it A.

2. Make a full set with all the points in the canvas. Call it B.

3. Get the difference. (B - A)

If your items are as simple as rectangels, it would be trivial.

Mike

On 5/27/05, Solly Brown <sollyb at cse.unsw.edu.au> wrote:
> I've got a qcanvas with a number of canvasitems moving about on it. I need
> to efficiently identify which areas of the canvas are empty (ie. don't
> have any objects on them).
> 
> The simplest implementation is to lay down a grid of qpoints on the
> canvas, and then just check whether there are collisions with each point
> -- if there are no collisions then that particular point area is empty.
> 
> The problem with this is that it's really slow... a 40x40 grid has 1600
> points and looping through all of them and calling 'collisions' on each
> one makes my display slow to a crawl.
> 
> Can anyone suggest an efficient way of identifying which points on a grid
> are clear (don't have collisions above them)?
> 
> Thanks for your help....!
> 
> Solly
> 
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>




More information about the PyQt mailing list