[Paraview] Sharing a library I wrote to generate ProgrammableFilters with property panel options
Shuhao Wu
shuhao at shuhaowu.com
Wed Mar 14 14:39:01 EDT 2018
Hello all,
I hope this is not too spammy/self promoting, but I wanted to share a
small library that I created to wrap such that you create Python
Programmable Filters with custom property panel options from a regular
python file. The work is inspired by this blog post[1].
The library based system allows you to write your programmable filter
such that it will work outside of paraview so you can possibly mock the
inputs/outputs and run unit tests on then, while also allowing easy
export into a XML plugins to feed into Paraview for execution. This
should allow one to create higher quality, reusable filters. The library
is available at: https://github.com/shuhaowu/pvpyfilter. If there is
enough interest in this, and once I get to test it more, I can release
this onto PyPI for easier access.
A short example of this in action (longer one available in the
repository, complete with screenshots):
class ViscosityType(Enum):
Kinematic = 1
Dynamic = 2
class MyFilter(ProgrammableFilter):
label = "My Filter"
input_data_type = "vtkPolyData"
nu = Double("Viscousity", default=1.53e-5, slider=[0, 1e-4], help="...")
nu_type = IntegerEnum("Type", default=ViscosityType.Kinematic,
enum=ViscosityType)
@staticmethod
def request_data(inputs, outputs, nu, nu_type):
print(nu)
print(nu_type)
[1]:
https://blog.kitware.com/easy-customization-of-the-paraview-python-programmable-filter-property-panel/
-- I cannot find the script download from that link and had to get it
from somewhere else on the internet.
Shuhao
More information about the ParaView
mailing list