Andreas | 22 Mar 2012 21:12
Picon

Question on Mayavi scene in interactive GUI

Hello,

How would something like https://mail.enthought.com/pipermail/enthought-dev/2011-November/030194.html

integrate with http://github.enthought.com/mayavi/mayavi/auto/example_mlab_interactive_dialog.html   ?

E.g. to have a slider control node size via node_size.

In

self.plot=self.scene.mlab.plot3d(x,y,z,t,tube_radius=0.025,colormap='Spectral')

plot3d returns a pipeline. I have a variant of plot_graph (from the first link) placed in its own imported module, and call it with something like m3Dg.plot_graph(). What should this return for the output to be assignable to self.plot, given that it plots a number of separate things (tubes, nodes, etc.)? Or does that not make sense - would m3Dg.plot_graph() output a scene rather than a plot?

One could perhaps call each of the things plotted by plot.graph() separately. But then you would lose the nice packaging away of plot_graph() in its own module; and also, what would each of the return values be assigned to? I imagine self.plot can only be one thing?

Sorry if my question is confused, it's a bit overwhelming.

thanks,

Andreas
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
MayaVi-users mailing list
MayaVi-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mayavi-users
Gael Varoquaux | 22 Mar 2012 22:24
Favicon
Gravatar

Re: Question on Mayavi scene in interactive GUI

On Thu, Mar 22, 2012 at 08:12:00PM +0000, Andreas wrote:
>    One could perhaps call each of the things plotted by plot.graph()
>    separately. But then you would lose the nice packaging away of
>    plot_graph() in its own module; and also, what would each of the return
>    values be assigned to? I imagine self.plot can only be one thing?

Return two things from plot_graph: pts and tube_surf. Assign them to two
different attributes of your objects. One will be the pipeline
corresponding to the tubes, the other to nodes. You will be able to
control the properties of both in a similar way than the interactive
example.

HTH,

Gael

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
Andreas | 23 Mar 2012 01:39
Picon

Re: Question on Mayavi scene in interactive GUI

On 22/03/12 21:24, Gael Varoquaux wrote:
> On Thu, Mar 22, 2012 at 08:12:00PM +0000, Andreas wrote:
>>     One could perhaps call each of the things plotted by plot.graph()
>>     separately. But then you would lose the nice packaging away of
>>     plot_graph() in its own module; and also, what would each of the return
>>     values be assigned to? I imagine self.plot can only be one thing?
> Return two things from plot_graph: pts and tube_surf. Assign them to two
> different attributes of your objects. One will be the pipeline
> corresponding to the tubes, the other to nodes. You will be able to
> control the properties of both in a similar way than the interactive
> example.
>
> HTH,
>
> Gael

Right, thanks... how to make the association with the scene though?

self.plot_edges, self.plot_nodes = m3Dg.plot_graph(<<params>> )

opens a separate window for the plotting, and subsequently changing the 
slider does not update it.

self.scene.m3Dg.plot_graph()

does not work either, logically (?)

cheers,

Andreas

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
Gael Varoquaux | 23 Mar 2012 06:55
Favicon
Gravatar

Re: Question on Mayavi scene in interactive GUI

On Fri, Mar 23, 2012 at 12:39:35AM +0000, Andreas wrote:
> Right, thanks... how to make the association with the scene though?

> self.plot_edges, self.plot_nodes = m3Dg.plot_graph(<<params>> )

Rewrite the function so that it takes self.m3Dg as an argument and uses
m3Dg.mlab instead of mlab inside the function.

HTH,

Gael

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
Andreas | 23 Mar 2012 13:19
Picon

Re: Question on Mayavi scene in interactive GUI

On Fri 23 Mar 2012 05:55:43 GMT, Gael Varoquaux wrote:
> On Fri, Mar 23, 2012 at 12:39:35AM +0000, Andreas wrote:
>> Right, thanks... how to make the association with the scene though?
>
>> self.plot_edges, self.plot_nodes = m3Dg.plot_graph(<<params>>  )
>
> Rewrite the function so that it takes self.m3Dg as an argument and uses
> m3Dg.mlab instead of mlab inside the function.

I'm afraid I don't understand. "m3Dg" is not an attribute of the GUI 
object that "self" refers to; it simply comes from the line

    import mayavi_3d_graph as m3Dg

where "mayavi_3d_graph.py" is the name of the module where I put the 
"plot_graph()" definition.

If you have

    scene = Instance(MlabSceneModel, ())

then when doing

   self.scene.mlab.plot3d()

I suppose "mlab.plot3d()" works courtesy of "Instance". But "Instance" 
knows nothing about "m3Dg.plot_graph()".

Does that clarify my confusion? Thanks,

Andreas

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure

Gmane