I tried ... dc.DrawPolygon(Canvas.WorldToPixel(BB.reshape((4,2))))
but received ... 'total size of new array must be unchanged' For my troubles. -------------- Wx.XOR of worked OK but only when I coded obj.CalcBoundingBox() before I used the internal class variable like this ... BB = obj.BoundingBox Would you consider returning the BoundingBox variable so that we could use it like this ... BB = obj.CalcBoundingBox() It took me a while to determine that Bounding Box was only updated when its calculating routine was being called. Got there in the end though. All works OK now. Thanks Chris. David -----Original Message----- From: Christopher Barker [mailto:[EMAIL PROTECTED] Sent: 21 December 2007 20:30 To: [EMAIL PROTECTED]; Mailing List for the wxPython Float Canvas. Subject: Re: [fc] Displayed Bounding Box repaint issue. Hi David, A couple comments: David Poundall wrote: > I am selecting a group of objects and doing a BB.Merge to get an all > encompassing > > Bounding Box. I then paint the containing bounding box to canvas using … > dc = wx.ClientDC(Canvas) > dc.SetPen(wx.Pen('WHITE', 2, wx.DOT)) > dc.SetBrush(wx.TRANSPARENT_BRUSH) > dc.SetLogicalFunction(wx.XOR) > OutlinePoints = N.array( ( (BB[0,0], BB[0,1]), > (BB[0,0], BB[1,1]), > (BB[1,0], BB[1,1]), > (BB[1,0], BB[0,1]) )) A BB object is a subclass of a Numpyarray, so you should be able to just do: OutlinePoints = BB.reshape((4, 2)) > dc.DrawPolygon(Canvas.WorldToPixel(OutlinePoints)) > Selecting another item to the group gives a new BB.Merge result. To > draw the new > > Polygon to the Canvas I am trying to do a canvas refresh prior to using > the above code to display the new selection polygon. Interestingly, I've never tried that, even though it is the obvious thing to do! > The problem is that if a Canvas.Refresh() is placed before the above > code or I > > Completely redraw the canvas thereby clearing the old BB.merge polygon, > the new > > Polygon does not draw. > > Is there a timing or buffer issue in play here ?? I think there is a timing issue here. I don't totally understand this, but I think that Refresh() may not actually do a refresh NOW, but rather, put the request on the event stack. since you're in the middle of en event, the Refresh() may get run AFTER the code your re in is done. Possible solutions: 1) Use the trick that is used in most of the other code -- keep a copy of the coords of the old box around, and draw it again to erase it (that's what wx.XOR does) 2) try calling wx.GetApp().Yield(onlyIfNeeded=True), after your Refresh(), that may clear the event stack. 3) Use a wx.Overlay -- Robin just posted an example of this on the wxPython-users list. It's pretty cool. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.17.5/1190 - Release Date: 19/12/2007 19:37 No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.17.5/1190 - Release Date: 19/12/2007 19:37 _______________________________________________ FloatCanvas mailing list [email protected] http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas
