[Paraview-developers] Announce: vtkPythonClassAlgorithm

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Mon May 14 21:03:29 EDT 2018


Bob et. al,

I've finally got around to revisiting the original demo example I put
together to demonstrate using
​
vtkPythonAlgorithm <https://blog.kitware.com/vtkpythonalgorithm-is-great/>  in
ParaView. It's coming together quite well! While it's still early and the
code will change, if anyone's interested in following the development, the
code is on a branch here
<https://gitlab.kitware.com/utkarsh.ayachit/paraview/blob/pythonalgorithm_in_paraview/>
:

​
To get a
​vtk
PythonAlgorithm
​subclass ​
exposed in ParaView, currently
​,​
one would need 2 things:
1. `decorate
<https://gitlab.kitware.com/utkarsh.ayachit/paraview/blob/pythonalgorithm_in_paraview/Wrapping/Python/paraview/util/vtkAlgorithm.py#L29-83>`
API on your Python class that you want to expose in ParaView UI
​.​

2.  put a small XML plugin
<https://gitlab.kitware.com/utkarsh.ayachit/paraview/blob/pythonalgorithm_in_paraview/ParaViewCore/PythonAlgorithm/pythonalgorithm.xml#L3-14>
together to make ParaView aware of the module
​.​
​
​
​


​
The example
​linked
 generates UI as follows:

*I plan to get rid of step 2 (time permitting) so that one can simply
"load" a Python module/package as a plugin and get all decorated classes
available as filters/sources.*

*Any suggestions for improvements are welcome.*

*Thanks*
*Utkarsh*

​




On Wed, Aug 16, 2017 at 7:50 AM Bob Pepin <bobpepin at gmail.com> wrote:

> Hi,
>>
>
>
>> > I also think that a vanilla vtkPythonAlgorithm can not meet all the
>> needs of this feature. In my case I need for example to override
>> processRequest on the C++ level in order to reload the module on a new
>> request (and ideally only when the source code has changed, and only
>> optionally).
>>
>> This is a use-case that I'm skeptical we can support robustly in
>> ParaView esp. in all modes it operates (client-server etc). I am not
>> convinced it's that useful besides debugging, however. We can sure add
>> a "reload" button to manually reimport the module, but that's not
>> exactly what you want. But I'll stay posted.
>>
>>
> do you have a specific situation in mind regarding the reloading? Since
> the module uses Python's native functionality for reloading modules, I
> would assume that if we can load it, we can reload it. I agree however that
> checking whether the source has changed is a bit more delicate.
>
> Besides, I think that a Reload button would be perfect, especially if it
> did an Apply at the same time. I was considering adding a checkbox that
> ends up calling Modified() on the vtk Algorithm object upon
> checking/unchecking, do you know of a better solution using only existing
> ParaView features?
>
>
>> > The main issue going forward I can see right now involves passing
>> parameters to Python. Right now I have a C++ method SetStringProperty(name,
>> value) and use a <StringVectorProperty> with 2 elements. Now suppose I want
>> to have a FileName property so that SetStringProperty("filename", value) is
>> called when the FileName property is set to value. Do you know how to
>> achieve this with the existing mechanisms, for example is it possible to
>> have a StringVectorProperty with 2 elements where the first one is hidden
>> and set to a default value?
>>
>> Are you aware of this post:
>>
>> https://blog.kitware.com/easy-customization-of-the-paraview-python-programmable-filter-property-panel/
>
>
> Thanks, This was exactly what I was looking for. Just out of curiosity,
> how does the "magic" work here? I.e. how does PV decide whether to call
> SetProperty(value) or SetProperty(name, value)?
>
> I also added a HDF5 Reader plugin to the github repository as an example.
>
> Best,
> Bob
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/paraview-developers/attachments/20180514/caf5bf5a/attachment.html>


More information about the Paraview-developers mailing list