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
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/paraview

Reply via email to