python - 我可以将 Paraview 的渲染器或交互器添加到我的 PyQt5 应用程序中吗?

标签 python pyqt5 paraview

使用 paraview.simple 渲染的 python 脚本的简单示例是

 from paraview.simple import *                                                  
                                                                                
 sphere = Sphere(ThetaResolution=16, PhiResolution=32)                          
 shrink = Shrink(sphere)                                                        
 Show(shrink)                                                                   
 Render()
 Interact()

我可以以类似于添加 vtk 渲染器的方式将此渲染添加到 PyQt5 应用程序吗?在 vtk 中,这是通过以下行实现的

from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor

此交互器被添加为小部件。我可以例如添加 paraview 简单渲染器或交互器作为小部件?

最佳答案

您可以在初始化QVTKRenderWindowInteractor时提供渲染窗口和交互器,即

import paraview.simple as pvsimple
from vtkmodules.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
from PyQt5 import QtWidgets

app = QtWidgets.QApplication([])

# setup render widget
render_view = pvsimple.CreateRenderView()
render_widget = QVTKRenderWindowInteractor(rw=render_view.GetRenderWindow(),
                                           iren=render_view.GetInteractor())
render_widget.Initialize()

# add paraview simple sources/filters
sphere = pvsimple.Sphere(ThetaResolution=16, PhiResolution=32)
shrink = pvsimple.Shrink(sphere)
pvsimple.Show(shrink, render_view)

# show widget
render_widget.show()
app.exec()

关于python - 我可以将 Paraview 的渲染器或交互器添加到我的 PyQt5 应用程序中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64094386/

相关文章:

python - 通过向量大小为 vtkUnstructuredGrid 着色

python - 如何在当前运行循环中等待任务完成?

python - PYQT5 加载屏幕直到主 GUI 初始化(卡住屏幕)

python - 在 QGraphicsScene 中移动 QGraphicItems 的有效方法

python - PyQt5 日历小部件子项

python - 如何在基于paraview的python脚本中显示vtkUnstructuredGrid?

Python 请求错误 400 浏览器发送无效请求

python - 在 pandas 中使用索引来绘制数据

python 错误 "quote_from_bytes() expected bytes"

python - 在 Paraview 中合并来自多个文件的 PointData