Chris,

The application requires that users essentially create 'representations' 
of things like city water distribution networks, which can get quite 
large. You are correct that this only becomes a problem if we want the 
objects to be 'hit-able' and there are more than ~10,000 of them.

Here is the solution I ended up with for hit testing without using a 
color map (using the bounding box of the object) :

# Custom Hit Test Function to Replace FloatCanvas.HitTest
def HitTest(self, event, HitEvent):
        if self.HitDict:
            # check if there are any objects in the dict for this event
            xy = event.GetPosition()
            xy = self.PixelToWorld( xy )
            for key in self.HitDict.keys():
                for key2 in self.HitDict[key].keys():
                    bb =  self.HitDict[key][key2].BoundingBox
                    if xy[0] > bb[0,0] and xy[0] < bb[1,0] and xy[1] < 
bb[1,1] and xy[1] > bb[0,1]:
                        print 'Hit Found1'
                        Object = self.HitDict[key][key2]
                        ## Add the hit coords to the Object
                        Object.HitCoords = self.PixelToWorld( xy )
                        Object.HitCoordsPixel = xy
                        Object.CallBackFuncs[HitEvent](Object)
                        print 'Hit Found2'
                        return True
            return False

For the MouseOverTest I modified it to contain a similar loop.

I have found that the performance is nearly identical on my Core Duo 
t2...@1.86ghz (2 GIG RAM)  for up to 30,000 to 40,000 objects. Redrawing 
the canvas with this many items is the limiting factor and any paint 
action I want to have after the hit test is going to take awhile anyway. 
I could speed this up to facilitate mouse over responses by indexing 
items in a grid (making the number of dictionary items to loop through 
smaller) but the most important thing for my application is that it 
doesn't fail as objects get added to the workspace.

I am not sure if there is any underlying issue or problem with wxPython 
or wxWidgets. It could very well be caching the brush and pens for the 
dispaly bitmap. The color map requires that we have a different pen and 
brush for each hit-able object, and whether or not they are cached can't 
make a difference since it doesn't reduce the set.

Also, your link:  [ 
http://msdn.microsoft.com/en-us/library/ms724291(VS.85 
<http://msdn.microsoft.com/en-us/library/ms724291%28VS.85>).aspx ] 
doesn't appear to be working.

Thanks for your help on this issue.

-- 
Benjamin Jessup
Mechanical Engineering Consultant
ABZ, Inc.

4451 Brookfield Corporate Dr. Suite 107
Chantilly, VA 20151
Office: (703)-631-7401
Fax: (703)-631-5282
Email: b...@abzinc.com

_______________________________________________
FloatCanvas mailing list
FloatCanvas@mithis.com
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to