[Paraview] [EXT] Re: More Customization of Python programmable Filter Panel
Dennis Conklin
dennis_conklin at goodyear.com
Fri Sep 25 13:01:13 EDT 2015
All,
Just as FYI, to close this up:
1. For vtkMultiblockDataSet – set input and output both to this in .py file, then edited resulting xml file to make input vtkDataSet – otherwise Paraview never recogonized it as a valid filter for a vtkMultiblockDataSet
2. Parameters will be arranged in alphabetical order in the xml file – just rearrange them into whatever order you want.
3. Can hide script as shown in Cory’s note below
4. Can add icon and new Filter group as shown here: http://www.paraview.org/Wiki/ParaView/Plugin_HowTo, which I found partway thru this discussion
Attached is a picture of the finished product
Dennis
From: Cory Quammen [mailto:cory.quammen at kitware.com]
Sent: Thursday, September 24, 2015 4:55 PM
To: Dennis Conklin <dennis_conklin at goodyear.com>; ParaView <paraview at paraview.org>
Subject: Re: [EXT] Re: [Paraview] More Customization of Python programmable Filter Panel
Oops, copying the list in to my last response.
On Thu, Sep 24, 2015 at 4:53 PM, Cory Quammen <cory.quammen at kitware.com<mailto:cory.quammen at kitware.com>> wrote:
On Thu, Sep 24, 2015 at 4:47 PM, Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>> wrote:
Cory,
I applied to bake.e, which is a vtkMultiblockDataSet (I believe!).
Yes. You can confirm in the Information tab next to the Properties tab.
I tried both “B” and “b” without success.
It should indeed be capital B.
I just now changed the input_type to vtkDataSet, which I guessed was more general and now it works. I have no idea why vtkMultiblockDataSet didn’t work, but I have a workaround.
Hmm, I'm not sure why that would be.
Thanks again for slogging thru this with me.
No problem!
Cory
Dennis
From: Cory Quammen [mailto:cory.quammen at kitware.com<mailto:cory.quammen at kitware.com>]
Sent: Thursday, September 24, 2015 4:42 PM
To: Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>>
Cc: Paraview (paraview at paraview.org<mailto:paraview at paraview.org>) <paraview at paraview.org<mailto:paraview at paraview.org>>
Subject: Re: [EXT] Re: [Paraview] More Customization of Python programmable Filter Panel
Hi Dennis,
What is your input to the Test Filter? I can apply it to a Sphere source input.
For your custom filter, the XML file should contain the following:
<InputProperty
name="Input"
command="SetInputConnection">
<ProxyGroupDomain name="groups">
<Group name="sources"/>
<Group name="filters"/>
</ProxyGroupDomain>
<DataTypeDomain name="input_type">
<DataType value="vtkMultiBlockDataSet"/>
</DataTypeDomain>
</InputProperty>
This tells ParaView to enable your filter when a multi-block data set is selected in the Pipeline browser. If it doesn't have this, then I believe the filter is not enabled for any input.
Hope that helps,
Cory
On Thu, Sep 24, 2015 at 4:30 PM, Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>> wrote:
All,
So, I can load the xml plugin but the filter is grayed out on the Filters menu. I have tried removing the InputDataSetType so that it should accept any type of input, but still gray. I am not sure how Paraview decides which filters are inappropriate (greyed-out) so I don’t have many ideas on how to overcome this.
I loaded the TestFilter.xml from the blog and that is also greyed-out. I loaded the DoubleHelixSource.xml and that is available in the Sources menu and runs.
Thanks
Dennis
From: Dennis Conklin
Sent: Thursday, September 24, 2015 3:18 PM
To: 'Cory Quammen' <cory.quammen at kitware.com<mailto:cory.quammen at kitware.com>>
Cc: Paraview (paraview at paraview.org<mailto:paraview at paraview.org>) <paraview at paraview.org<mailto:paraview at paraview.org>>
Subject: RE: [EXT] Re: [Paraview] More Customization of Python programmable Filter Panel
Cory,
I had just thought of this and tried it (successfully) about when your note came in.
I hate to quibble, but I would suggest that in the typeMap in the python_filter_generator.py vtkMultiBlockDataSet is listed as vtkMultiblockDataSet and I had to figure this out and use a small ‘b’ before it would work – so if you are going to publish this routine anywhere, you might want to edit that!
Thanks again – as soon as I figure out why it is grayed out on the Filter list I am going to test this thing out.
Dennis
From: Cory Quammen [mailto:cory.quammen at kitware.com]
Sent: Thursday, September 24, 2015 3:13 PM
To: Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>>
Cc: Paraview (paraview at paraview.org<mailto:paraview at paraview.org>) <paraview at paraview.org<mailto:paraview at paraview.org>>
Subject: Re: [EXT] Re: [Paraview] More Customization of Python programmable Filter Panel
Hi Dennis,
The converter evaluates your Python script and then uses some Python reflection features to extract the code in your RequestData function. But it does this only for the RequestData function (as well as a RequestInformation and RequestUpdateExtent functions, but these aren't always needed). The converter is simply ignoring your other functions.
To get around this, try defining your sub* functions as inner functions in RequestData(), e.g.,
Def RequestData():
Def sub1:
Do some stuff
Return var
Def sub2(var):
Do some stuff
Return newVar
Def sub3(var):
Do some stuff
Return newVar
X=sub1()
Y=sub2(X)
Z=sub3(Y)
Do something with Z
Best regards,
Cory
On Thu, Sep 24, 2015 at 2:39 PM, Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>> wrote:
Cory,
I’m pretending to be a real programmer, so my Programmable Filter script looks something like this:
Def sub1:
Do some stuff
Return var
Def sub2(var):
Do some stuff
Return newVar
Def sub3(var):
Do some stuff
Return newVar
Def RequestData():
X=sub1()
Y=sub2(X)
Z=sub3(Y)
Do something with Z
Everything except RequestData gets lost – should I just manually break everything down and insert at the beginning of the default_values in StringVectorProperty, or is there some way to trick it into reading the entire script?
Thanks
Dennis
From: Cory Quammen [mailto:cory.quammen at kitware.com<mailto:cory.quammen at kitware.com>]
Sent: Thursday, September 24, 2015 1:02 PM
To: Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>>
Cc: Paraview (paraview at paraview.org<mailto:paraview at paraview.org>) <paraview at paraview.org<mailto:paraview at paraview.org>>
Subject: Re: [EXT] Re: [Paraview] More Customization of Python programmable Filter Panel
Dennis,
Great! I'm glad it's what you are looking for.
You can hide any property by editing the XML file. In the property element, add an attribute called "panel_visibility" and set this to "never". This will hide the property from view. You can also set it to "advanced" so that it shows up only when the advanced option is enabled.
Here's an example:
<StringVectorProperty
panel_visibility="never"
name="Script"
command="SetScript"
number_of_elements="1"
default_values="my python script">
<Documentation>This property contains the text of a python program that
the programmable source runs.</Documentation>
</StringVectorProperty>
Cheers,
Cory
On Thu, Sep 24, 2015 at 12:47 PM, Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>> wrote:
One more question – the original article says that
Alternatively, the Script properties can be hidden completely from the properties panel.
How is this accomplished?
Thanks again
Dennis
From: Dennis Conklin
Sent: Thursday, September 24, 2015 12:20 PM
To: 'Cory Quammen' <cory.quammen at kitware.com<mailto:cory.quammen at kitware.com>>
Cc: Paraview (paraview at paraview.org<mailto:paraview at paraview.org>) <paraview at paraview.org<mailto:paraview at paraview.org>>
Subject: RE: [EXT] Re: [Paraview] More Customization of Python programmable Filter Panel
Cory,
Wow, that’s exactly what I need – now I just need to get some time to re-implement my filters using this!
Thanks again
Dennis
From: Cory Quammen [mailto:cory.quammen at kitware.com]
Sent: Thursday, September 24, 2015 11:07 AM
To: Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>>
Cc: Paraview (paraview at paraview.org<mailto:paraview at paraview.org>) <paraview at paraview.org<mailto:paraview at paraview.org>>
Subject: [EXT] Re: [Paraview] More Customization of Python programmable Filter Panel
Hi Dennis,
Answers inlined below.
On Wed, Sep 23, 2015 at 2:39 PM, Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>> wrote:
All,
Pat Marion discussed adding interactive Properties for a Programmable Filter here:
http://www.kitware.com/blog/home/post/534
I have a few questions about this:
1. Is this still valid for v4.4 with the original python_filter_generator.py?
Yes, I just tested it.
2. Have we added any other capability. For instance, I would love to present a list of variables to be calculated and let my user select or unselect each to decide exactly what he wants as output. With a numeric field with 0 as unselect and 1 as select, people will always manage to type something else in there. If this interface could have a checklist, or if fields could have a drop down list (Yes/No, etc) then this would greatly expand the utility of this technique.
You can do this if you have a fixed number of variables. Just list each variable option as a IntVectorProperty with a BooleanDomain in the XML. In the input file for the filter generator, just express these options with the default values, .e.g,
Properties = dict(
generate_var1 = True,
generate_var2 = False,
generate_var3 = False
)
The filter generator will convert each of these lines into XML of the following form:
<IntVectorProperty
name="generate_var1"
label="generate var1"
initial_string="generate_var1"
command="SetParameter"
animateable="1"
default_values="1"
number_of_elements="1">
<BooleanDomain name="bool" />
<Documentation></Documentation>
</IntVectorProperty>
These properties will appear as checkboxes in the UI of your filter.
Of course, you can tweak the XML files that are generated if it doesn't get the label attribute for the property right, for instance.
I hope that helps.
Cory
So, is anyone using this and perhaps knows how to do these extended things?
Thanks for any hints
Dennis
_______________________________________________
Powered by www.kitware.com<http://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:
http://public.kitware.com/mailman/listinfo/paraview
--
Cory Quammen
R&D Engineer
Kitware, Inc.
--
Cory Quammen
R&D Engineer
Kitware, Inc.
--
Cory Quammen
R&D Engineer
Kitware, Inc.
--
Cory Quammen
R&D Engineer
Kitware, Inc.
--
Cory Quammen
R&D Engineer
Kitware, Inc.
--
Cory Quammen
R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150925/6a8a747e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GdyrCoords.png
Type: image/png
Size: 39327 bytes
Desc: GdyrCoords.png
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150925/6a8a747e/attachment.png>
More information about the ParaView
mailing list