Dear all,
I’m trying to write a compiled plugin based on python programmable filter (following the example in https://www.paraview.org/Wiki/Plugin_Tutorial:_Subclassing_PythonProgrammableFilter ) to build a reader of a specific hdf5 file.
This reader should have a GUI to choose with a slider an item in a numbered set of objects and the min-max of this slider should dinamically be set depending on the input file content.
I’ve already written the requestData python script that generates an unstructured grid item by reading one of the objects described in the input file by mean of an integer index passed to the script using a SetParameter command associated in the xml file with an IntVectorProperty.
To define the limits of the slider I use an IntRangeDomain specifier in the xml that points to another information_only IntVectorProperty with an associated command GetRange that is a method I’ve added to my new class derived from vtkPythonProgrammableFilter class (using the macro vtkGetVector2Macro) to retrieve a Range vector added as a private attribure to my class.
Everythng seems to be ok if I add a C++ RequestInformation function to populate my Range attribute, but my question is: is it possible to populate this attribute through a python RequestInformation script instead of a C++ function? It would be very preferable as with a few h5py lines I can retrieve needed values instead of using libhdf5 from C++ function.
I’ve tried to find a method from python script to access to my class attributes but I haven’t found a way.
I hope to have been clear enough. Thank you in advance for any help.
Dear Utkarsh,
I’ve looked at those examples but I’ve not understood how I should use decorators to set not constant range for an IntVector but derived from any other function.
Could you please show me an example?
@smproxy.source(....)
class MySource(VTKPythonAlgorithmBase):
...
@smproperty.doublevector(name="ValueRangeInfo", information_only="1")
def GetValueRange(self):
print("getting range: (0, 100)")
# this should be setup in `RequestInformation`, if being read
# from a file. This will be called `RequestInformation` but before
# `RequestData`.
return (0, 100)
@smproperty.doublevector(name="Value", default_values=[0.0])
@smdomain.xml(\
"""<DoubleRangeDomain name="range" default_mode="mid">
<RequiredProperties>
<Property name="ValueRangeInfo" function="RangeInfo" />
</RequiredProperties>
</DoubleRangeDomain>
""")
def SetValue(self, val):
 print("settings value:", val)
When is 5.7 release expected to be downloadable? In the meantime is it sufficient to patch and recompile 5.6.0 superbuild with modifications you’ve done in your MR or anything else in 5.7 is necessary to get it working?
Utkarsh,
I’ve just tried to merge the files you changed in the commit above into the 5.6.0 superbuild I had already built and your example seems to work well. Thanks
But I’ve another question:
In my GUI I would like to have a dropdown list (an IntVector) to chose a parameter and the value set by this interactor should be used by the function that evaluates the range for the slider (before pressing Apply of course).
Is it possible to set some property to track the event of changing dropdown list choose to execute a function automatically?
I’m going on with my plugin based on PythonAlgorithms methods (according to Utkarsh suggestion) and now I’m trying to put a dropDownList which available choices are to be populated at runtime (depending on the content of the file I’m going to read).
and everything seems OK, but I would like to have only valid choices for the file I’m reading and not a fixed list.
Thank you for any help on this topic.
PS my previous question about having the slider limits automatically updating when I choose which axis in the dropdown list without pressing Apply is still useful…
This needed another quick fix (available here) following which your StringVectorProperty code should work. The widget was showing up disabled since the information property ended up picking only the first string from the returned list of strings. The fix referenced addresses that.