enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.31k stars 285 forks source link

text3d and fullscreen #169

Closed fnielsen closed 8 years ago

fnielsen commented 9 years ago

On my system mayavi 4.4.0 (and the previous version) will make the text3d disappear when the window is made fullscreen.

Procedure:

from mayavi import mlab
mlab.points3d(0, 0, 0, opacity=0.5)
mlab.text3d(0, 0, 0, 'A')
mlab.show()

After these commands a sphere and an A is displayed. Pressing the fullscreen button makes the text3d disappear from the scene. The Text3D object is still visible in the 'Mayavi pipline' window.

fnielsen commented 9 years ago

It may be worth to note that the same problem does not appear for the 'text' function, so this works ok:

from mayavi import mlab
mlab.points3d(0, 0, 0, opacity=0.5)
mlab.text(0, 0, 'A', z=0)
mlab.show()
fnielsen commented 9 years ago

I have now tried the problem on two Ubuntu 12.04 systems. On both systems the issue appears.

perconte commented 9 years ago

On my system, text3D isn't displaying anything, does someone has an idea what the problem is? or had a similar problem?

eakraus commented 9 years ago

I have the same problem on my system (windows 8, pythonxy 2.7.10); text3d is not displaying anything. There are no error messages. Text3D objects do appear in the Mayavi pipeline window, yet the text isn't visible.

dmsurti commented 9 years ago

Reusing @fnielsen example:

In [1]: from mayavi import mlab

In [2]: mlab.points3d(0, 0, 0, opacity=0.5)
Out[2]: <mayavi.modules.glyph.Glyph at 0x12758d050>

In [3]: t = mlab.text3d(0, 0, 0, 'A')

In [4]: t.vector_text.update() // DO THIS

In [5]: mlab.show()

Update the vector_text. This is a bug and will be fixed in the next milestone. The real fix on a quick look is to add:

self.vector_text.update()

in _text_changed after Line 124 here: https://github.com/enthought/mayavi/blob/master/mayavi/modules/text3d.py#L124

perconte commented 9 years ago

great! thanks

2015-07-21 3:15 GMT+02:00 eakraus notifications@github.com:

I have the same problem on my system (windows 8, pythonxy 2.7.10); text3d is not displaying anything. There are no error messages. Text3D objects do appear in the Mayavi pipeline window, yet the text isn't visible.

— Reply to this email directly or view it on GitHub https://github.com/enthought/mayavi/issues/169#issuecomment-123120754.

fnielsen commented 9 years ago

I ran this:

from mayavi import mlab
mlab.points3d(0, 0, 0, opacity=0.5)
t = mlab.text3d(0, 0, 0, 'A')
t.vector_text.update()  # DO THIS
mlab.show()

and unfortunately I cannot confirm that it now works. There is still the problem for me. I do not have the same problem as @perconte. The text shows fine until fullscreen and then cannot be reestablished.

dmsurti commented 9 years ago

@fnielsen I see that you are using Ubuntu systems. This will need more investigation.

perconte commented 9 years ago

so I have an other problem sort of related, I'm unable to change the font size of the text visualization module. So mlab.text(0,0,0,'text',fontsize =12) and mlab.text(0,0,0,'text',fontsize =18) give the same result. Any idea? thanks in advance David

2015-07-21 10:22 GMT+02:00 Deepak Surti notifications@github.com:

@fnielsen https://github.com/fnielsen I see that you are using Ubuntu systems. This will need more investigation.

— Reply to this email directly or view it on GitHub https://github.com/enthought/mayavi/issues/169#issuecomment-123210772.

perconte commented 9 years ago

never mind, I just had to select Text scale mode none in TextActor

2015-07-21 17:52 GMT+02:00 David Perconte david.d.perconte@gmail.com:

so I have an other problem sort of related, I'm unable to change the font size of the text visualization module. So mlab.text(0,0,0,'text',fontsize =12) and mlab.text(0,0,0,'text',fontsize =18) give the same result. Any idea? thanks in advance David

2015-07-21 10:22 GMT+02:00 Deepak Surti notifications@github.com:

@fnielsen https://github.com/fnielsen I see that you are using Ubuntu systems. This will need more investigation.

— Reply to this email directly or view it on GitHub https://github.com/enthought/mayavi/issues/169#issuecomment-123210772.

kitchoi commented 8 years ago

332 should fix the problem that @perconte and @eakraus had about text3d not being shown. However, I cannot reproduce the fullscreen problem described by @fnielsen so I am not sure if #332 fixes that too. @fnielsen can you please verify if the problem with fullscreen persists please? If it does, could you specify the backend that you're using (wx or qt) and the VTK version please?

fnielsen commented 8 years ago

The issue seems to have been solved with the present git version of Mayavi. I see the 'A' in fullscreen.

$ virtualenv --system-site-packages virtualenv_mayavigit
$ cd virtualenv_mayavigit/
$ source bin/activate
$ pip install -I git+git://github.com/enthought/mayavi.git
$ python
>>> from mayavi import mlab
    (stack trace)
ValueError: cannot set toolkit to wx because it has already been set to qt4
>>> from mayavi import mlab
>>> mlab.points3d(0, 0, 0, opacity=0.5)
<mayavi.modules.glyph.Glyph object at 0x7f385ea5e0b0>
>>> mlab.text3d(0, 0, 0, 'A')
<mayavi.modules.text3d.Text3D object at 0x7f385ea1d5f0>
>>> mlab.show()

After these commands a ball and an 'A' are shown, - also in fullscreen.

(Interestingly, from mayavi import mlab produces now an error the first time called! "ValueError: cannot set toolkit to wx because it has already been set to qt4").

kitchoi commented 8 years ago

Thanks @fnielsen!

Interestingly, from mayavi import mlab produces now an error the first time called! "ValueError: cannot set toolkit to wx because it has already been set to qt4".

That's likely because you have wxpython installed and ipython has automatically switched to use wx for gui support. However, since pyface 5.0.0, the default backend used by mayavi is qt4, if the environment variable ETS_TOOLKIT is unset (i.e. ETS_TOOLKIT=qt4 is the default). If you would like to use qt4 as the backend while using ipython, invoke ipython with ipython --gui=qt. If you would like to use wx as backend, try to set ETS_TOOLKIT=wx. Please refer to http://docs.enthought.com/mayavi/mayavi/mlab.html and https://ipython.org/ipython-doc/2/interactive/reference.html#gui-event-loop-support

Note: I believe this issue can be closed when #332 is accepted and merged.

fnielsen commented 8 years ago

Yes, I have wxPython installed. ipython2 --gui=wx works. ipython2 --gui=qt did not and erred with "ValueError: API 'QDate' has already been set to version 1". With export ETS_TOOLKIT=qt4 then ipython2 works.

kitchoi commented 8 years ago

Oh yes you are right. ipython --gui=qt set the QDate api to 1 while pyface wanted to set the api to 2. This should be another issue for the doc. Thanks for trying these out and reporting!

kitchoi commented 8 years ago

Note: ipython --gui=qt would work fine if PySide is used instead of PyQt.

jenshnielsen commented 8 years ago

Does it work with PyQt4 if you correctly set QT_API? See http://docs.enthought.com/mayavi/mayavi/building_applications.html#integrating-in-a-qt-application and http://ipython.readthedocs.org/en/stable/interactive/reference.html#pyqt-and-pyside

kitchoi commented 8 years ago

@jenshnielsen I have tried QT_API too and it works for me.

kitchoi commented 8 years ago

@jenshnielsen Ah I guess you mean setting QT_API=pyqt and ipython. There is no QDate api error but my interactive window is not happy. Let me take a look.

jenshnielsen commented 8 years ago

Yes that was what I meant. It used to work (years ago) but perhaps something broke along the way

kitchoi commented 8 years ago

For ValueError: cannot set toolkit to wx because it has already been set to qt4 problem, this is fixed in the master branch of enthought/traitsui. If you do not want the bleeding edge, setting ETS_TOOLKIT=qt4 is the correct solution.

@jenshnielsen Sorry, I had a typo before when I set my environment (I actually had QT_API still at pyside when I tested pyqt). In summary, here is my finding. QT_API=pyqt; ETS_TOOLKIT=qt4; ipython work fine, interactive window is actually interactive. QT_API=pyside; ETS_TOOLKIT=qt4 will require ipython --gui=qt for the interactive window to be actually interactive

kitchoi commented 8 years ago

The ValueError: cannot set toolkit to wx because it has already been set to qt4 problem should be resolved with the new releases of traitsui and pyface.

The different usage of ipython with QT_API=pyqt and QT_API=pyside remains, as described in http://ipython.readthedocs.org/en/stable/interactive/reference.html#pyqt-and-pyside

Closing.