Am 19.11.2008, 04:15 Uhr, schrieb Marcos Duarte <[EMAIL PROTECTED]>:
I still have a problem related to that: I can draw the circles on top of the bitmap but not if I do them with the mouse selection (at least in my computer). It seems there are boundaries impeding the drawing of one object on the top of other (same thing happens if I try to draw very close circles). I suspect this bounding box is needed for the mouse selection for example, so it can't be decreased it.
Ahh I see now what you mean. Events are not sent globally right now, they are only received by the node over which the cursor resides at the moment the event happens. So if you click left on the canvas the canvas gets the event, if you click left on the bitmap, the bitmap gets the event. I've now updated fc2 (SVN) which allows you to receive the "global" events in addition to the ones sent to the nodes. To do this you can just do canvas.subscribe( self.OnLeftClick, 'input.left_down' ) This enables you to receive all 'left_down' events, no matter which node the cursor was over. Same goes for all the other events. In addition this means, you don't have to bind to the wx.EVT_ events anymore. Of course you can also use the old logic to your advantage. So if you subscribe to the 'left_down' event of only the bitmap, then the user will be able to draw circles only on the bitmap and nowhere else. I am not sure if you want that, depends on your application. As a note for Chris, there's also canvas.subscribe( self.OnMotion, 'raw_input.move' ) now which is the same as the wx.EVT_MOTION event and is always received. The reason Marcos can't bind do it is because in GUI modes like grabbing 'raw_input.move' will be sent and would cause a circle to be created when you grab. So the GUI modes receive the 'raw_input' events and then the default mouse mode fires the 'input' events which Marcos can catch to draw the circle. So you can only draw circles in the default mouse mode and not in one of the grab, move, rotate, scale, ... modes. If he wants completely different behaviour I suggest writing a custom GUI mode. I've also made the node deletion step simpler. In the attached version of X5.py you see I've introduced the .node property to events. The .node property holds the node the cursor was over when the event occured. So I just bind right click to each circle node and then call canvas.removeChild( evt.node ), because evt.node is always the circle of course this works.
Yes, it would sound more intuitive if we could also get the global coordinates from an attribute of evt.coords. In fact, one thing I want to do is to apply my own spatial transformation (which I would calculate based on some points in the image) to the coordinates of the canvas. I don't need to do image calibration (I mean to change the image itself), I understand this is not the type of application fc was designed for (also because my images are bitmaps not svgs).
Can you tell me a bit more about your spatial transformation? Is it something like a mercator projection? Or more involved? If it's a linear one, then fc2 can transform also the image for you. FC2 also offers you to plugin custom transforms instead of the matrix ones as well, but these will most likely only work on the lowest level of the transform chain right now.
What I need is just the calibration (transformation) of the coordinates. So, in this scenario it would be great something like evt.coords.Global for the position at the global (screen) coordinate system; evt.coords.Local for the position at the local (canvas, or transformation equals to identity) coordinate system; evt.coords.Local2 for the position at another local (user defined) coordinate system (after a transformation), etc.
Yes, I like this kind of API, so I implemented it for the events. There's event.coords.world, event.coords.local and event.coords.screen now (see X5.py). World is the coordinates in world space, screen in screen space and local in the space of event.node (that is the current node's local space).
About binding the mouse events to wx and to fc, I understood from your post in wxpython that this is wrong. However, i can't adapt the solution Chris gave, Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMotion), to my case in fc2.
Yes, this won't work in fc2. I wouldn't call it wrong though. It's a current limitation in wxPython, that's all. See X5.py how to solve this by using canvas.subscribe( 'raw_input.move' ).
Please ask more questions :-)You shouldn't worry about that!
:-) -Matthias
X5.py
Description: Binary data
_______________________________________________ FloatCanvas mailing list [email protected] http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas
