[mv2] interacting and ipython?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[mv2] interacting and ipython?

Angus McMorland
Hi again,

Thanks for the last answer Gaël. My trouble is/was in not understanding how to create the connected data de novo, where altering the other data to fit seemed like a hack that would only work once. Anyway, onward and upward.

Next question: should something like the following be possible in a script I '%run' in ipython?

--
s = mlab.figure()

def on_click(obj, evt):
    print "Hello World!"

s.scene.interactor.add_observer('LeftButtonReleaseEvent', on_click)
--
Eventually I want to have two mlab figures and sychronize their views when the user twiddles either with the mouse, but so far I can't get the callback to fire. Or perhaps there's another, easier way to do this altogether?

Thanks again,

Angus.
--
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [mv2] interacting and ipython?

Gael Varoquaux
On Thu, Apr 15, 2010 at 09:06:42PM +0100, Angus McMorland wrote:
>    Next question: should something like the following be possible in a script
>    I '%run' in ipython?

Does mlab.sync_camera answer your question?

Ga�l

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [mv2] interacting and ipython?

Angus McMorland
On 15 April 2010 21:08, Gael Varoquaux <[hidden email]> wrote:
On Thu, Apr 15, 2010 at 09:06:42PM +0100, Angus McMorland wrote:
>    Next question: should something like the following be possible in a script
>    I '%run' in ipython?

Does mlab.sync_camera answer your question?

Looks like it really would, if it was in the version of mv2 I'm running (from the Ubuntu package 3.2.0-3). 

Perhaps I can make do without switching to installing from source. I've worked out the answer to my problem above: there is no 'LeftButtonReleaseEvent', but there is a 'MouseMoveEvent', and that activates the callback correctly. Is there somewhere I can find a list of these events that do exist? A quick grep in the mayavi directory doesn't show anything useful.

Thanks,

Angus.
--
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [mv2] interacting and ipython?

Gael Varoquaux
On Thu, Apr 15, 2010 at 09:19:03PM +0100, Angus McMorland wrote:
>    Looks like it really would, if it was in the version of mv2 I'm running
>    (from the Ubuntu package 3.2.0-3).�

Just have a look at the source, and copy the corresponding function. You
can always do that using track:
https://svn.enthought.com/enthought/browser/Mayavi/trunk/enthought/mayavi/tools/figure.py
for your interest, the function is:

def sync_camera(reference_figure, target_figure):
    """ Synchronise the camera of the target_figure on the camera of the
        reference_figure.
    """
    reference_figure.scene._renderer.sync_trait('active_camera',
                        target_figure.scene._renderer)
    target_figure.scene._renderer.active_camera.on_trait_change(
            lambda: do_later(target_figure.scene.render))


>    Perhaps I can make do without switching to installing from source. I've
>    worked out the answer to my problem above: there is no
>    'LeftButtonReleaseEvent', but there is a 'MouseMoveEvent', and that
>    activates the callback correctly. Is there somewhere I can find a list of
>    these events that do exist? A quick grep in the mayavi directory doesn't
>    show anything useful.

Right. The problem is that these events are not Mayavi entities, but VTK
ones, so you depend on the VTK documentation (which is quite lacking) and
a lot of googling.

HTH,

Ga�l

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [mv2] interacting and ipython?

Angus McMorland
On 15 April 2010 21:23, Gael Varoquaux <[hidden email]> wrote:
On Thu, Apr 15, 2010 at 09:19:03PM +0100, Angus McMorland wrote:
>    Looks like it really would, if it was in the version of mv2 I'm running
>    (from the Ubuntu package 3.2.0-3). 

Just have a look at the source, and copy the corresponding function.

Of course. That's perfect. Thanks very much.
--
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev