pythonpyqt4pysidevtkqvtkwidget

Using vtkOrientationMarkerWidget with QVTKRenderWindowInteractor [PyQt4/PySide]


I working on a PySide/vtk GUI using QVTKRenderWindowInteractor widget class. The widget is working well, unless when I try to add a orientation axis (see image) using vtkOrientationMarkerWidget:

axesActor = vtk.vtkAxesActor();
axes = vtk.vtkOrientationMarkerWidget()
axes.SetOrientationMarker(axesActor)
axes.SetInteractor(self.iren)
self.ren.AddActor(axesActor)
axes.EnabledOn() # <== application freeze-crash
axes.InteractiveOn()

A similar bug has been already reported for ubuntu, showing that the bug is reproduced only with Qt example, while the same example without Qt works well.

Any solution to this behavior ? enter image description here


Solution

  • Got this answer from Nicholas R. Rypkema :

    https://nrr.mit.edu/blog/note-about-vtk-pyqt-and-vtkorientationmarkerwidget

    Long story short : this will fix your problem

    axesActor = vtk.vtkAxesActor();
    self.axes = vtk.vtkOrientationMarkerWidget()
    self.axes.SetOrientationMarker(axesActor)
    self.axes.SetInteractor(self.iren)
    self.ren.AddActor(axesActor)
    self.axes.EnabledOn() # <== application freeze-crash
    self.axes.InteractiveOn()