Wynand Singels wrote:
What I want to do now is let the user select a sub image by dragging a rectangle over the displayed image.
this is often called a "rubber band box" if you google for that, you should find some discussion about it.
When the the left button is clicked the OnLeftDown procedure saves the position and captures the mouse to the panel.
In the OnMotion procedure I check if event.Dragging() and event.LeftIsDown() are still TRUE. If they are we create another buffered context and draw the rectangle.
Why another buffered context? all you need is to draw over the current image with a wxClientDC. The trick is to draw your rectangle with the LogicalFunction set to XOR. that way, you can draw it a second time, and the image will be restored. This is nice, because then all you need to do is draw two rectangles as the mouse moves, not blit then entire image twice.
I've enclosed the module that does this for wx.lib.floatcanvas -- it's specific to floatcanvas, but you should get the idea.
-Chris
GUI.py (3.25 KB)
ยทยทยท
--
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
Chris.Barker@noaa.gov