>> 1. Line 27: How to set the order of appearance of drawed objects?
>
> This is easy, just supply the where = 'back' or where = 'front' or where =
> siblingNodeAfterWhichToInsertThisNode parameters to create(). The first two
> forms are clear, the last form of "where" is useful if you want to insert a
> node at a very specific point in the front-to-back order. Note that front to
> back-order is also affected by grouping, so if one group is in front of
> another group, then all child nodes of the group in front will be in front
> of all the child nodes of the back group. Sounds more complicated than it is
> :) Just means if you have 2 images with points on them and the points are
> children of the images then you can move one map over the other and it will
> appear as you'd expect.
> Here's the relevant code:
>
> self.canvas.create( 'Circle', 300, pos = (0,0), look=('red', 'red'), where =
> 'front' )
>
> By default the bitmap is in front of everything, because it was added to the
> canvas first.

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.

>
>> 2. Line 49: How to delete a node selected with the mouse (the hit test
>> works fine to find the node but I can't delete it)?
>
> This is also easy, you almost got it. canvas.hitTest always returns a list
> of nodes which happen to be in the area to be tested. This list is sorted by
> order, the top-most node is the first element of the list. So you need to do
> this to use canvas.hitTest:
>
> nodes = self.canvas.hitTest(evt.wx_event.GetPosition())
> print nodes
> if not nodes:
>    return
> self.canvas.removeChild( nodes[0] )
>
> First you test whether you hit anything at all. If not, you return from the
> function. If there some nodes have been hit, you likely want to remove the
> top one which is nodes[0].
>
> I took the opportunity and extended the doc string of hitTest, so it should
> be clear what hitTest returns.
>

It is clear now, thanks.

>> 3. Line 72: I am trying to show the mouse position in a status bar but
>> after I use the menu bar (fc2 guimode), it stops to work.
>
> I found the cause. It's basically happening that your EVT_MOTION event
> interferes with the one setup internally in fc2. I've just posted a message
> to the wxPython mailing list asking for a way to solve this problem. Once
> this is clear I can probably fix fc2 so your code will continue to work.
>
> I've also made the 'Bitmap' model simpler to use, you can now use the img
> directly instead of imgData and the clumsy fc.arrayFromImage. This also
> makes creation much faster. Update your working copy to get this feature.
> In addition I made another modification which makes things go even faster on
> creation time, but I cannot check this modification in yet, because I have
> changes in the code which are not ready for svn yet.
>
> It also occured to me that using
>
>        print evt.wx_event.GetPosition()
>        nodes = self.canvas.hitTest(evt.wx_event.GetPosition())
>
> is a bit quirky. An easier way would be
>
>        print evt.coords
>        nodes = self.canvas.hitTest(evt.coords)
>
> Right now this is not implemented. I should probably think more about a way
> to tag coordinates with their respective coordinate system (like using a
> fc.Coords() class or adding a 'coordinateSytem' attribute to the evt.coords
> tuple).
>

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).
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.
As mentioned in the fc2 website, the matrix formalism would be very
appropriate for that.

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.

> All in all the most problematic things you've faced seem to come from thee
> lack of api documentation (the where parameter and the hitTest result).
>
> Please ask more questions :-)
>

You shouldn't worry about that!

thank you.

-
Marcos Duarte
http://lob.iv.fapesp.br/
University of Sao Paulo, Brazil
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to