Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将vtkOrientationMarkerWidget与QVTKRenderWindowInteractor[PyQt4/PySide]一起使用_Python_Pyqt4_Pyside_Vtk_Qvtkwidget - Fatal编程技术网

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

Python 将vtkOrientationMarkerWidget与QVTKRenderWindowInteractor[PyQt4/PySide]一起使用,python,pyqt4,pyside,vtk,qvtkwidget,Python,Pyqt4,Pyside,Vtk,Qvtkwidget,我使用QVTKRenderWindowInteractorwidget类在PySide/VTKGUI上工作。 该小部件工作正常,除非我尝试使用vtkorientiationmarkerwidget添加方向轴(见图): axesActor = vtk.vtkAxesActor(); axes = vtk.vtkOrientationMarkerWidget() axes.SetOrientationMarker(axesActor) axes.SetInteractor(self.iren) se

我使用
QVTKRenderWindowInteractor
widget类在PySide/VTKGUI上工作。 该小部件工作正常,除非我尝试使用
vtkorientiationmarkerwidget
添加方向轴(见图):

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

axes.EnabledOn()从Nicholas R.Rypkema那里得到了这个答案:

长话短说:这会解决你的问题

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()
axesActor=vtk.vtkAxesActor();
self.axes=vtk.vtkOrientationMarkerWidget()
self.axes.SetOrientationMarker(axesActor)
self.axes.SetInteractor(self.iren)
self.ren.AddActor(axesActor)

self.axes.EnabledOn()#您可以使用的不是最后两行,而是使用
axes.On()
测试
axes.On()
窗口冻结,它在您的机器上工作吗?使用PySide测试也会提供相同的行为。您应该将非现场资源中的重要部分添加到您的答案中。另外,您的代码片段是OP的文章中的CopyIta。谢谢,这对我很有用!关键是通过使Axis成为类成员(self.axes)来防止Axis超出范围。正如@mululu所说,这通过改变
vtKorientiationMarkerWidget
实例的生存期,通过使其成为主应用程序类(其子类
QtGui.QMainWindow
)的成员来解决问题其中定义了
QVTKRenderWindowInteractor
。回答接受!我报告说,这个解决方案同样适用于在使用C++中的VTK时解决同样的错误,即VTKStaskPosits的变量应该是一个生存在VTK循环执行期间的类的成员。