Embedding Mayavi in Qt

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

Embedding Mayavi in Qt

seshu yamajala
Hello,

I modified the qt_embedding.py example a little, but nothing shows up in
the embedded scene. My code is available here:
https://gist.github.com/syamajala/8804396 I think the scene class
variable in Visualization is getting messed up when I call the
constructor for Sphere.

Also, I was also wondering, is it possible to use a picker with a scene
embedded in a Qt app?

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

Re: Embedding Mayavi in Qt

Marcel Hubble
Hello,

Your example works on my system. One possible problem might be that you need to set the environment variable:
    os.environ['QT_API'] = 'pyqt'

to ensure the correct QString representation for Mayavi. Especially if you are calling the code from ipython.
It is even possible that you have to set the environment variables before starting ipython (export QT_API=pyqt).

Cheers



On Tue, Feb 4, 2014 at 3:25 PM, seshu yamajala <[hidden email]> wrote:
Hello,

I modified the qt_embedding.py example a little, but nothing shows up in
the embedded scene. My code is available here:
https://gist.github.com/syamajala/8804396 I think the scene class
variable in Visualization is getting messed up when I call the
constructor for Sphere.

Also, I was also wondering, is it possible to use a picker with a scene
embedded in a Qt app?

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


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

Re: Embedding Mayavi in Qt

seshu yamajala
Hello,

Seting QT_API to pyqt seems to have fixed the problem. Thanks!

Also, the pickers seem to work too, however, sometimes its quite difficult to get the mouse click to register. I have a bunch of points drawn on the surface of the sphere and set the scale factor to 0.03 and the picker tolerance to 0.5, but it always seem to take a few clicks for it to do anything.

Thank You,
Seshu Yamajala

On 02/05/2014 10:31 AM, Marcel Hubble wrote:
Hello,

Your example works on my system. One possible problem might be that you need to set the environment variable:
    os.environ['QT_API'] = 'pyqt'

to ensure the correct QString representation for Mayavi. Especially if you are calling the code from ipython.
It is even possible that you have to set the environment variables before starting ipython (export QT_API=pyqt).


Cheers



On Tue, Feb 4, 2014 at 3:25 PM, seshu yamajala <[hidden email]> wrote:
Hello,

I modified the qt_embedding.py example a little, but nothing shows up in
the embedded scene. My code is available here:
https://gist.github.com/syamajala/8804396 I think the scene class
variable in Visualization is getting messed up when I call the
constructor for Sphere.

Also, I was also wondering, is it possible to use a picker with a scene
embedded in a Qt app?

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



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


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

Re: Embedding Mayavi in Qt

seshu yamajala
In reply to this post by Marcel Hubble
Hello,

I actually made a small mistake when I added the picker, because I was calling mlab.gcf() to get a figure to add the picker to instead of self.scene.mlab.gcf(), it was working fine, but then when I added a widget, two windows would pop up, one with the scene with the sphere and no widget, and a second window with an empty scene and the widget. Here is the updated code, which does not seem to work, https://gist.github.com/syamajala/8804396 even when I comment out lines 23 and 24 I still do not see anything.

Thank You,
Seshu Yamajala

On 02/05/2014 10:31 AM, Marcel Hubble wrote:
Hello,

Your example works on my system. One possible problem might be that you need to set the environment variable:
    os.environ['QT_API'] = 'pyqt'

to ensure the correct QString representation for Mayavi. Especially if you are calling the code from ipython.
It is even possible that you have to set the environment variables before starting ipython (export QT_API=pyqt).


Cheers



On Tue, Feb 4, 2014 at 3:25 PM, seshu yamajala <[hidden email]> wrote:
Hello,

I modified the qt_embedding.py example a little, but nothing shows up in
the embedded scene. My code is available here:
https://gist.github.com/syamajala/8804396 I think the scene class
variable in Visualization is getting messed up when I call the
constructor for Sphere.

Also, I was also wondering, is it possible to use a picker with a scene
embedded in a Qt app?

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



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


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

Re: Embedding Mayavi in Qt

Marcel Hubble
Hello again,

it seems to me that the problem now lies in the __init__ method of your Visualization class. The traits mechanisms are not properly initialised.

try putting this to initialise the Visualization class correctly

def __init__(points,**traits):
    super(HasTraits,self).__init__(**traits)

As for the picking, I think you cannot register the picker when your scene is still empty, but I don't have any experience with mayavi picking.

Cheers


On Wed, Feb 5, 2014 at 12:44 PM, seshu yamajala <[hidden email]> wrote:
Hello,

I actually made a small mistake when I added the picker, because I was calling mlab.gcf() to get a figure to add the picker to instead of self.scene.mlab.gcf(), it was working fine, but then when I added a widget, two windows would pop up, one with the scene with the sphere and no widget, and a second window with an empty scene and the widget. Here is the updated code, which does not seem to work, https://gist.github.com/syamajala/8804396 even when I comment out lines 23 and 24 I still do not see anything.

Thank You,
Seshu Yamajala

On 02/05/2014 10:31 AM, Marcel Hubble wrote:
Hello,

Your example works on my system. One possible problem might be that you need to set the environment variable:
    os.environ['QT_API'] = 'pyqt'

to ensure the correct QString representation for Mayavi. Especially if you are calling the code from ipython.
It is even possible that you have to set the environment variables before starting ipython (export QT_API=pyqt).


Cheers



On Tue, Feb 4, 2014 at 3:25 PM, seshu yamajala <[hidden email]> wrote:
Hello,

I modified the qt_embedding.py example a little, but nothing shows up in
the embedded scene. My code is available here:
https://gist.github.com/syamajala/8804396 I think the scene class
variable in Visualization is getting messed up when I call the
constructor for Sphere.

Also, I was also wondering, is it possible to use a picker with a scene
embedded in a Qt app?

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



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


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



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

Re: Embedding Mayavi in Qt

seshu yamajala
Hello,

That fixed my problems. As for the picker, I just used the @on_trait_change('scene.activated') decorator and then set the picker. Here is a working example, https://gist.github.com/syamajala/8804396

Thank You,
Seshu Yamjala

On 02/05/2014 07:00 PM, Marcel Hubble wrote:
Hello again,

it seems to me that the problem now lies in the __init__ method of your Visualization class. The traits mechanisms are not properly initialised.

try putting this to initialise the Visualization class correctly

def __init__(points,**traits):
    super(HasTraits,self).__init__(**traits)

As for the picking, I think you cannot register the picker when your scene is still empty, but I don't have any experience with mayavi picking.

Cheers


On Wed, Feb 5, 2014 at 12:44 PM, seshu yamajala <[hidden email]> wrote:
Hello,

I actually made a small mistake when I added the picker, because I was calling mlab.gcf() to get a figure to add the picker to instead of self.scene.mlab.gcf(), it was working fine, but then when I added a widget, two windows would pop up, one with the scene with the sphere and no widget, and a second window with an empty scene and the widget. Here is the updated code, which does not seem to work, https://gist.github.com/syamajala/8804396 even when I comment out lines 23 and 24 I still do not see anything.

Thank You,
Seshu Yamajala

On 02/05/2014 10:31 AM, Marcel Hubble wrote:
Hello,

Your example works on my system. One possible problem might be that you need to set the environment variable:
    os.environ['QT_API'] = 'pyqt'

to ensure the correct QString representation for Mayavi. Especially if you are calling the code from ipython.
It is even possible that you have to set the environment variables before starting ipython (export QT_API=pyqt).


Cheers



On Tue, Feb 4, 2014 at 3:25 PM, seshu yamajala <[hidden email]> wrote:
Hello,

I modified the qt_embedding.py example a little, but nothing shows up in
the embedded scene. My code is available here:
https://gist.github.com/syamajala/8804396 I think the scene class
variable in Visualization is getting messed up when I call the
constructor for Sphere.

Also, I was also wondering, is it possible to use a picker with a scene
embedded in a Qt app?

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



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


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




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


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