当用户点击鼠标左键时,我们公司希望我们的paraview Web应用程序显示相关数据。
如何从选定点提取数据的另一部分很简单。 但我无法解决问题:如何在鼠标点击时在坐标中选取一个点?
我添加了一个回调函数来处理python脚本中的左键按下。 然后我尝试使用vtkPointPicker来投射光线并选择坐标中的点。 但是当点击鼠标时(运行picker run pick()时,运行python脚本作为服务器的pvpython程序将崩溃)。 在调试中我发现解除引用空指针的VTK代码是程序崩溃的原因。 但VTK源代码太复杂,无法进一步深入研究。
这是我的回调函数:
def CustomLeftButtonPress(obj, event): x = obj.GetEventPosition()[0] y = obj.GetEventPosition()[1] picker = vtkPointPicker() obj.SetPicker(picker) currentRenderer = obj.FindPokedRenderer(x,y) picker.Pick(x, y, 0.0, currentRenderer) ...picker.Pick(x, y, 0.0, currentRenderer)导致崩溃。
Our company want our paraview web application to show relevant data when users click left mouse button.
The other part like how to extract data from a selected point was straightforward. But I cannot solve the problem: how to pick a point in the coordinates while mouse click?
I added a callback function to handle left button press in the python script. And then I tried to use an vtkPointPicker to cast a ray and pick the point in the coordinates. But the pvpython program which run the python script as the server will crash when click mouse (to be exact when the picker run pick()). Under debugging I found that the VTK code dereferencing null pointer was why the program crash. But the VTK source code is just too complicated to delve into further.
Here is my callback function:
def CustomLeftButtonPress(obj, event): x = obj.GetEventPosition()[0] y = obj.GetEventPosition()[1] picker = vtkPointPicker() obj.SetPicker(picker) currentRenderer = obj.FindPokedRenderer(x,y) picker.Pick(x, y, 0.0, currentRenderer) ...picker.Pick(x, y, 0.0, currentRenderer) causes the crash.
最满意答案
我应该使用vtkWorldPointPicker而不是vtkPointPicker 。
I should use vtkWorldPointPicker instead of vtkPointPicker.
更多推荐
发布评论