[Paraview] Sharing a library I wrote to generate ProgrammableFilters with property panel options

Shuhao Wu shuhao at shuhaowu.com
Fri Mar 16 13:37:15 EDT 2018


Thanks for all the feedback!

As a part of my own work, one of the thing that I'll likely work on next 
is to allow at least the request_data part of the programmable filter to 
be a part of a VTK pipeline (via likely vtkPythonAlgorithm) so it can be 
tested without dependencies to paraview in order to promote better testing.

If you have any other suggestions on how to improve this library, feel 
free to open an issue in the repository or contact me directly, as I'm 
sure there are a lot of things I'm not even aware is possible.

Cheers,
Shuhao

On 2018-03-16 12:47 PM, Cory Quammen wrote:
> Very cool, Shuhao. Thanks for sharing this with the ParaView community!
> 
> Cory
> 
> On Wed, Mar 14, 2018 at 2:39 PM, Shuhao Wu <shuhao at shuhaowu.com> wrote:
> 
>> 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/opensou
>> rce/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
>>
> 
> 
> 


More information about the ParaView mailing list