<div dir="ltr">Bob et. al,<br><br>I've finally got around to revisiting the original demo example I put together to demonstrate using <div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"></div><font face="arial, helvetica, sans-serif"><a href="https://blog.kitware.com/vtkpythonalgorithm-is-great/" target="_blank">vtkPythonAlgorithm</a></font> 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 <a href="https://gitlab.kitware.com/utkarsh.ayachit/paraview/blob/pythonalgorithm_in_paraview/">here</a>:<br><br><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"></div>To get a <div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">vtk</div>PythonAlgorithm <div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">subclass </div>exposed in ParaView, currently<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">,</div> one would need 2 things:<br>1. `<a href="https://gitlab.kitware.com/utkarsh.ayachit/paraview/blob/pythonalgorithm_in_paraview/Wrapping/Python/paraview/util/vtkAlgorithm.py#L29-83">decorate</a>` API on your Python class that you want to expose in ParaView UI<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">.</div><br>2. put a <a href="https://gitlab.kitware.com/utkarsh.ayachit/paraview/blob/pythonalgorithm_in_paraview/ParaViewCore/PythonAlgorithm/pythonalgorithm.xml#L3-14">small XML plugin</a> together to make ParaView aware of the module<div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"></div><br><div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"></div><span style="font-family:arial,helvetica,sans-serif">The example <div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline">linked </div> generates UI as follows:</span></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"><b style="font-weight:normal" id="m_805419994645251070gmail-docs-internal-guid-41c1832e-614b-d439-a90b-5c0e04017503"><img src="https://lh6.googleusercontent.com/eUSiMdIgH3Z1Eg6aa5ehx5V2aNk_KrYLiWlua-F5piRi6Xe29OWNkWSEDrL0ehxZYCccQDRc2T55mAf2YY4HMK2wm5QOEOBUCBKz3VP1X8ZbQfFOoX4roCzgnnW2QnBG17eGfQzkOBk" width="298px;" height="171px;"></b></div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"><b style="font-weight:normal"><br></b></div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"><b style="font-weight:normal">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.</b></div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"><b style="font-weight:normal"><br></b></div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"><b style="font-weight:normal">Any suggestions for improvements are welcome.</b></div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"><b style="font-weight:normal"><br></b></div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"><b style="font-weight:normal">Thanks</b></div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"><b style="font-weight:normal">Utkarsh</b></div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"><br></div></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;display:inline"></div></div><div><br></div><div><br></div></div><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 16, 2017 at 7:50 AM Bob Pepin <<a href="mailto:bobpepin@gmail.com" target="_blank">bobpepin@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> 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).<br>
<br>
This is a use-case that I'm skeptical we can support robustly in<br>
ParaView esp. in all modes it operates (client-server etc). I am not<br>
convinced it's that useful besides debugging, however. We can sure add<br>
a "reload" button to manually reimport the module, but that's not<br>
exactly what you want. But I'll stay posted.<br>
<br></blockquote><div><br></div><div>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.</div><div><br></div><div>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?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> 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?<br>
<br>
Are you aware of this post:<br>
<a href="https://blog.kitware.com/easy-customization-of-the-paraview-python-programmable-filter-property-panel/" rel="noreferrer" target="_blank">https://blog.kitware.com/easy-customization-of-the-paraview-python-programmable-filter-property-panel/</a></blockquote><div><br></div><div>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)? </div><div><br></div><div>I also added a HDF5 Reader plugin to the github repository as an example.</div><div><br></div><div>Best,</div><div>Bob</div></div></div>
</blockquote></div>