将 vtkOrientationMarkerWidget 与 QVTKRenderWindowInteractor [PyQt4/PySide] 一起使用

Using vtkOrientationMarkerWidget with QVTKRenderWindowInteractor [PyQt4/PySide]

我正在使用 QVTKRenderWindowInteractor 小部件 class 开发 PySide/vtk GUI。 小部件运行良好,除非我尝试使用 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()

类似的 bug has been already reported for ubuntu, showing that the bug is reproduced only with Qt example, while the same example without Qt 效果很好。

对这种行为有什么解决办法吗?

从 Nicholas R. Rypkema 那里得到了这个答案:

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

长话短说:这将解决您的问题

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()