[Paraview-developers] Selecting blocks from drop down list
Jorge Bañuls
jorgebanuls at gmail.com
Sun Jul 17 07:34:22 EDT 2016
Hi, for those interested, I've come up with an easy partial solution, being
this the implementation:
<IntVectorProperty
clean_command="ClearParameter"
command="SetParameter"
name="BlockIndices"
label="Block Indices"
initial_string="BlockIndices"
animateable="1"
default_values="1"
number_of_elements_per_command="1"
repeat_command="0" >
<CompositeTreeDomain
mode="all"
name="tree">
<RequiredProperties>
<Property function="Input"
name="Input" />
</RequiredProperties>
</CompositeTreeDomain>
<Documentation></Documentation>
</IntVectorProperty>
This property allows the user to select only ONE block from the composite
tree domain. After digging into the vtkPythonProgrammableFilter class I
discovered that the method AddParameter(), which would be ideal for this
case, takes only string values as arguments, whereas the
vtkCompositeTreeDomain only works within a vtkIntVectorProperty (integer
values), hence it's not possible to use it.
On the other hand, the method SetParameter() only allows more than one
value (up to three) in the arguments if they are of the type double. In the
case of integer values, only one value is accepted. Therefore, even if the
user checks more than one block, only the last index is stored. In the
snippet of code above the user is not allowed to check more than one block
by setting repeat_command to 0.
I hope that this will be useful for future enquiries, and if someone comes
up with a better workaround that actually allows selecting as many blocks
as desired please let me know!
Jorge
On 16 July 2016 at 13:40, Andy Bauer <andy.bauer at kitware.com> wrote:
> You need to add in those methods. Look at the vtkExtractBlock.cxx/h class
> to see how those methods are being used in ParaView.
>
> On Fri, Jul 15, 2016 at 11:31 AM, Jorge Bañuls <jorgebanuls at gmail.com>
> wrote:
>
>> I've tried to implement the property in this way:
>>
>> <IntVectorProperty clean_command="RemoveAllIndices"
>> command="AddIndex"
>> name="BlockIndices"
>> number_of_elements_per_command="1"
>> panel_visibility="default"
>> repeat_command="1">
>> <CompositeTreeDomain mode="all"
>> name="tree">
>> <RequiredProperties>
>> <Property function="Input"
>> name="Input" />
>> </RequiredProperties>
>> </CompositeTreeDomain>
>> <Documentation></Documentation>
>> </IntVectorProperty>
>>
>> but I get the following error:
>>
>> ERROR: In
>> M:\b\paraview\src\paraview\ParaViewCore\ServerImplementation\Core\vtkPVSessionCore.cxx,
>> line 390
>>
>> vtkPVSessionCore (00000000035C2B60): Object type:
>> vtkPythonProgrammableFilter, could not find requested method:
>> "RemoveAllIndices"
>>
>> or the method was called with incorrect arguments.
>>
>>
>> while processing
>>
>> Message 0 = Invoke
>>
>> Argument 0 = vtk_object_pointer {vtkPythonProgrammableFilter
>> (000000000B5222A0)}
>>
>> Argument 1 = string_value {RemoveAllIndices}
>>
>>
>>
>>
>> ERROR: In
>> M:\b\paraview\src\paraview\ParaViewCore\ServerImplementation\Core\vtkPVSessionCore.cxx,
>> line 391
>>
>> vtkPVSessionCore (00000000035C2B60): Aborting execution for debugging
>> purposes.
>>
>>
>>
>> ERROR: In
>> M:\b\paraview\src\paraview\ParaViewCore\ServerImplementation\Core\vtkSIProxy.cxx,
>> line 134
>>
>> vtkSISourceProxy (000000000B4FDA70): Error pushing property state:
>> BlockIndices
>>
>>
>> if I omit clean_command="RemoveAllIndices", then the error appears for
>> command="AddIndex". I've tried to use other commands, such as
>> SetParameter or AddParameter, but no combination seems to work.
>>
>>
>> On 15 July 2016 at 12:27, Andy Bauer <andy.bauer at kitware.com> wrote:
>>
>>> In ./ParaViewCore/ServerManager/SMApplication/Resources/filters.xml in
>>> the source code there's the following section which gives the options and
>>> GUI layout:
>>> <SourceProxy class="vtkExtractBlock"
>>> label="Extract Block"
>>> name="ExtractBlock">
>>> <Documentation long_help="This filter extracts a range of blocks
>>> from a multiblock dataset."
>>> short_help="Extract block.">This filter extracts a
>>> range
>>> of groups from a multiblock dataset</Documentation>
>>> <InputProperty command="SetInputConnection"
>>> name="Input">
>>> <ProxyGroupDomain name="groups">
>>> <Group name="sources" />
>>> <Group name="filters" />
>>> </ProxyGroupDomain>
>>> <DataTypeDomain name="input_type">
>>> <DataType value="vtkMultiBlockDataSet" />
>>> </DataTypeDomain>
>>> <Documentation>This property specifies the input to the Extract
>>> Group
>>> filter.</Documentation>
>>> </InputProperty>
>>> <IntVectorProperty clean_command="RemoveAllIndices"
>>> command="AddIndex"
>>> name="BlockIndices"
>>> number_of_elements_per_command="1"
>>> panel_visibility="default"
>>> repeat_command="1">
>>> <CompositeTreeDomain mode="all"
>>> name="tree">
>>> <RequiredProperties>
>>> <Property function="Input"
>>> name="Input" />
>>> </RequiredProperties>
>>> </CompositeTreeDomain>
>>> <Hints>
>>> <WidgetHeight number_of_rows="20" />
>>> </Hints>
>>> <Documentation>This property lists the ids of the blocks to
>>> extract
>>> from the input multiblock dataset.</Documentation>
>>> </IntVectorProperty>
>>> <IntVectorProperty command="SetPruneOutput"
>>> default_values="1"
>>> name="PruneOutput"
>>> number_of_elements="1">
>>> <BooleanDomain name="bool" />
>>> <Documentation>When set, the output mutliblock dataset will be
>>> pruned
>>> to remove empty nodes. On by default.</Documentation>
>>> </IntVectorProperty>
>>> <IntVectorProperty command="SetMaintainStructure"
>>> default_values="0"
>>> name="MaintainStructure"
>>> number_of_elements="1">
>>> <BooleanDomain name="bool" />
>>> <Documentation>This is used only when PruneOutput is ON. By
>>> default,
>>> when pruning the output i.e. remove empty blocks, if node has
>>> only 1
>>> non-null child block, then that node is removed. To preserve
>>> these
>>> parent nodes, set this flag to true.</Documentation>
>>> </IntVectorProperty>
>>> <!-- End ExtractBlock -->
>>> </SourceProxy>
>>>
>>> Creating something similar for you may work. If you search the code for
>>> things like vtkSMIntVectorProperty.cxx/h you should find information on how
>>> the corresponding IntVectorProperty.
>>>
>>> On Fri, Jul 15, 2016 at 7:18 AM, Jorge Bañuls <jorgebanuls at gmail.com>
>>> wrote:
>>>
>>>> Hi Andy,
>>>>
>>>> Indeed, the vtkExtractBlock filter is what I'm using in my script to
>>>> extract the blocks, which are currently specified by the user in the
>>>> properties panel as a string with the name of the block(s). Now that you
>>>> mention it though, it could be useful to see how this filter creates the
>>>> checklist. Is there a way to access the code behind this filter?
>>>>
>>>> Thanks a lot for your help,
>>>>
>>>> Jorge Bañuls
>>>>
>>>> On 15 July 2016 at 12:06, Andy Bauer <andy.bauer at kitware.com> wrote:
>>>>
>>>>> Have you looked at the Extract Blocks filter? That may already be
>>>>> doing what you need and if not, it at least shows how to check the boxes
>>>>> for blocks that you want.
>>>>>
>>>>> On Fri, Jul 15, 2016 at 6:53 AM, Jorge Bañuls <jorgebanuls at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I'm developing a filter for Paraview and I need to be able to select
>>>>>> blocks from the properties panel (the input is a vtkMultiBlockDataSet). The
>>>>>> approach I'm using right now is to write the name of the block(s) and then
>>>>>> process that string within the script, but I would like to be able to check
>>>>>> the blocks I need from a list. I've seen many examples of how to do this,
>>>>>> but only for variables arrays (e.g. the list displays the cell arrays
>>>>>> existing in the input). Any ideas on how to apply this to display and
>>>>>> select the blocks?
>>>>>>
>>>>>> Thanks in advance for your help,
>>>>>>
>>>>>> Jorge Bañuls
>>>>>>
>>>>>> _______________________________________________
>>>>>> Powered by www.kitware.com
>>>>>>
>>>>>> Visit other Kitware open-source projects at
>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>
>>>>>> Search the list archives at:
>>>>>> http://markmail.org/search/?q=Paraview-developers
>>>>>>
>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>> http://public.kitware.com/mailman/listinfo/paraview-developers
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20160717/7febea8b/attachment-0001.html>
More information about the Paraview-developers
mailing list