Am 21.12.2008, 10:52 Uhr, schrieb Marcos Duarte <[email protected]>:

> The problem is that I don't have any clue on how to implement the more
> complex toolbar functions, like ZoomIn and Move, which require
> constant interaction with the canvas.
> I couldn't figure out how to do that even after looking at NavCanvas
> and GuiMode functions.
> I tried simple things like just calling
> floatcanvas.guiMode.GUIModeZoomIn() and binding the toolbar event with
> this method but it doesn't work. I was thinking that I could directly
> call the GuiMode function in a simple way, I also tried to modify the
> NavCanvas function to work with MDI windows but there are some stuff
> there I don't understand, but nothing worked

The answer to this question depends on what exactly you are trying to  
achieve. I suppose what you want to do is to move canvas2 when you move  
canvas1. E.g. canvas1 shows the XY plane while canvas2 shows the XZ plane  
of your 3d space. In this case you will have to write your own kind of gui  
mode, because the default ones have not been designed for that.
If it's really the XY, XZ plane thing you want to do, I can code a little  
example and add it to the demo to help you getting started. If you want to  
do something else (e.g. both canvases are the XY plane and you just want  
to link their movements), please explain this in detail, then I can  
probably give you a starting point, too.

> Two more questions:
>
> How to automatically resize (zoom to fit) the canvas when the MDI
> window is resized? (I am using
> self.GetActiveChild().GetChildren()[0].canvas.zoomToExtents() but it
> does not work well; you will see that if you try the attached code).

This seems to work:

     def onSize(self, event):
         wx.CallAfter( self.ActiveChild.Children[0].canvas.zoomToExtents )
         event.Skip()

I tried moving the event.Skip() before the zoomToExtents call, but it  
didn't help, so I used wx.CallAfter. Maybe there's a better solution, for  
now this one will do I think.

> How to change the look of a FC2 object? The FC2 objects have many
> attributes but .look does not work.

You are right. I've added this in SVN now. I've changed the "Looks" demo  
tutorial so if you click one of the shapes it changes its look to a random  
one. So now you can do a simple node.look = someLook and it will work.

> Here are two very minor 'misbehavior' in FC2:
>
> In FC2, just for stability, when somebody tries to rotate a circle(!),
> FC2 crashes (I did that with the rotate gui tool).
> The problem is with line 61 of transform.py, because numpy.linalg.inv(
> normalized ) returns an error of singular matrix.
> To avoid this problem, you might capture the error and return the
> identity matrix in this case.

I think transform.py should throw an exception, because it fails to invert  
the matrix. The real problem must be in the function which created the  
non-invertible matrix in the first place. I could not reproduce this  
problem, no matter which object I rotated (the object should not matter).  
Looking over the code I found one thing in  
floatcanvas/math/vector.py/get_angle which might've caused the problem.  
I've fixed this, but I'm not sure if it will help.
>
> If the user uses the functions Export Image or Export SVG, and then
> press cancel on the Select File dialog, an error occurs on lines 169
> or 173 of navcanvas.py.
> Just add a test to see if the user did press save or if the filename
> is not empty.

This one is fixed now in SVN, just like the math error above. It was  
caused by the last change where I refactored this code a bit.

Thanks for spotting the limitations and the bugs!

-Matthias
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to