Guys:
Group is not all that well tested, I suspect an object needs to be
either in group or on its own, but can't be half and half.
It is in the group, but then I can't bind a "fc.EVT_FC_LEFT_DOWN".
I know this is semi off-topic, and probably a repeat of old news, but I
want to remind everyone that if the objects are similar to make use of
the "list" drawing routines (in my original copy of FC - Chris put a
note about this; which I ran with). They increase speed dramatically
when objects are the same. A snippit from my modified
FloatCanvas._DrawObjects routine:
<code>
#Some lists of fc draw objects
Branches = []
Nodes = []
Tees = []
#If we want to draw fast
if UseFastRoutine:
lw = 1
dc.DrawRectangleList([x._Draw(dc,WorldToPixel,ScaleWorldToPixel,HTdc,draw =
False) for x in Branches],
wx.Pen('BLACK',lw,wx.SOLID),
wx.Brush((255,255,255)))
dc.DrawEllipseList([x._Draw(dc,WorldToPixel,ScaleWorldToPixel,HTdc,draw
= False) for x in Nodes],
wx.Pen('BLACK',lw,wx.SOLID),
wx.Brush((255,255,255)))
dc.DrawRectangleList([x._Draw(dc,WorldToPixel,ScaleWorldToPixel,HTdc,draw =
False) for x in Tees],
wx.Pen('BLACK',lw,wx.SOLID),
wx.Brush((255,255,255)))
</code>
This is the best way I could find to make drawing times reasonable for
very large number of objects. The extra work pays off in the long run,
as the GUI is much much more responsive. I combine this with an
additional routine called FloatCanvas.Update which allows me to do the
fast drawing times while being able to update small pieces of the
workspace (so that when a user clicks on a single object, I can
highlight it, without having to re-draw everything. There are some
caveats with this when using different line widths .... ask me if you
want my solution). My Floatcanvas.Update function is attached for any
comments.
Werner - I don't think you have all that many objects but in case you
ever need to add more :-)
Thanks,
Ben
def Update(self, Objects = []):
print "%s.Update:" % (self)
if N.sometrue(self.PanelSize <= 2 ):
# it's possible for this to get called before being properly
initialized.
return
ScreenDC = wx.ClientDC(self)
ViewPortWorld = N.array(( self.PixelToWorld((0,0)),
self.PixelToWorld(self.PanelSize) )
)
self.ViewPortBB = N.array( ( N.minimum.reduce(ViewPortWorld),
N.maximum.reduce(ViewPortWorld) ) )
dc = wx.MemoryDC()
dc.SelectObject(self._Buffer)
dc.SetBackground(self.BackgroundBrush)
#dc.Clear()
self._DrawObjects(dc, Objects, ScreenDC, self.ViewPortBB,update = True)
#Do the blit
ScreenDC.Blit(0, 0, self.PanelSize[0],self.PanelSize[1], dc, 0, 0)
#Draw the message
self.DrawMessage(ScreenDC)
_______________________________________________
FloatCanvas mailing list
[email protected]
http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas