如何在paraview web下用鼠标实现拣选点(How to implement picking point by mouse under paraview web)

编程入门 行业动态 更新时间:2024-10-28 14:29:13
如何在paraview web下用鼠标实现拣选点(How to implement picking point by mouse under paraview web)

当用户点击鼠标左键时,我们公司希望我们的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.

更多推荐

本文发布于:2023-07-19 02:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1171567.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   用鼠标   web   paraview   mouse

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!