Ah, a bit of a tricky problem!

Astan Chee wrote:
> Sorry, my mistake. Here is the code that I've worked on. What I mean to 
> say is that I can select them and group them to move, but I cant ungroup 
> them or move them individually unless I manually select it.

When do you want them ungrouped? Right after moving?

Anyway, you should be able to remove the Group from the Canvas:

self.Canvas.RemoveObject(G)


>> Using this, I found that I have problems binding the selected objects 
>> to be moved or unbind them and select new ones (dynamic binding or 
>> unbinding).

Yeah, I don't think unbinding is really robust -- it needs to be. In 
general, the Event binding code needs to be refactoring -- more put in 
the draw objects, less in the Canvas -- I think that would make dynamic 
binding/unbinding easier.

Suggestions (and code!) welcome!.

But did you try:

DrawObject.UnBindAll()

You might not want to unbind all (and it might not work quite anyway), 
but you could re-bind the ones you want.

>> Also I took the selectionbox code from the floatcanvas.GUI but since 
>> the events doubled up on each other, I included it directly. Im not 
>> sure how to handle events that double up on each other

That's a bit of a problem. I really don't want a lot of if..elf.. blocks 
in the code -- it just doesn't feel clean.

I'm working on solving this with GUIModes -- the idea is that you have a 
bunch of GUIModes, and each one defines what needs to happen with all 
the mouse events. One mode for selecting objects, one for moving, one 
for zooming+panning, etc.

That's how the current core FloatCanvas code is working now, but all my 
demos pre-date that, and don't use it really for user code.

Take a look at Tests/EditingModes in SVN to see where I'm going

>> and my 
>> implementation to select is rather crude since I dont know how to get 
>> a position of an object in drawcanvas.

Well, it depends on how you define position, but I think what you want is

DrawObject.BoundingBox

every DrawObject should have one. It's a BBox object (defined in 
FloatCanvas.Utilities.BBox ) It has methods like:

BBox.Overlaps(OtherBBox) and BBox.Inside(OtherBBox) that should be helpful.

One of these days, I'd like to use a spatial index, like a quadtree or 
Btree for this kind of thing -- but who knows when!

>> Also, Chris I think you 
>> mentioned that .AddObject returns the reference to the drawobject 
>> being added, it seems that it only returns the condition if it added 
>> the object or not (i.e. true or false).

Actually, it always returns True! I think what I was referring to before 
was that the FloatCanvas.Add**** methods, that create the object while 
adding it, return the object created.

I've just changed FloatCanvas.AddObject(obj) to return the object also 
-- for symmetries sake, and why not?

I hope some of this helps,

-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]
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to