[Paraview] [EXT] Re: More Customization of Python programmable Filter Panel

Cory Quammen cory.quammen at kitware.com
Thu Sep 24 15:13:10 EDT 2015


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
> 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]
> *Sent:* Thursday, September 24, 2015 1:02 PM
> *To:* Dennis Conklin <dennis_conklin at goodyear.com>
> *Cc:* Paraview (paraview at paraview.org) <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> 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>
> *Cc:* Paraview (paraview at paraview.org) <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
> <cory.quammen at kitware.com>]
> *Sent:* Thursday, September 24, 2015 11:07 AM
> *To:* Dennis Conklin <dennis_conklin at goodyear.com>
> *Cc:* Paraview (paraview at paraview.org) <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> 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
>
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150924/aa915380/attachment.html>


More information about the ParaView mailing list