[Paraview] custom filter doesn't update property in the Paraview UI

Cory Quammen cory.quammen at kitware.com
Mon Aug 8 14:29:32 EDT 2016


Hi Corinna,

Utkarsh addressed the updating of properties in his earlier response
about the directionality of property changes in ParaView:

"
2. ParaView's properties are not bi-directional. They are only
intended to be set on the UI side and pushed to the VTK side. There
are of course exceptions to this, and you can add what's called a
"information_only" property that instead reads a value from the VTK
side and provides it on the "client" side, but for such properties,
often there's no UI. They are instead, used to define the "domain" for
the property which controls things like range for the slider, for
example.
"

So, in short, ParaView is not really designed to do this. However, it
may be possible to define a custom panel for your NPoints property
that, when clicked, updates the property value to the current scalar
range. For example, there is a custom panel widget in the Threshold
filter that lets you update the ranges based on the range of the
currently selected scalar array. You would need this kind of custom
panel widget for your NPoints property. The only catch is you would
need to update the value manually, or perhaps you could use a QTimer
to periodically refresh the value.

HTH,
Cory

On Mon, Aug 8, 2016 at 2:14 PM, corinna reuter
<corinnareuter75 at gmail.com> wrote:
> Dear Cory,
> I wonder, if you still have an idea how to implement a filter that
> initializes its properties from upstream objects and updates these
> properties when those objects change.
> Isn't the whole ParaView designed such that changes are propagated along the
> pipeline? Why is it so complicated to render propagated changes in the
> filter parameters visible?
>
>
> Thank you
> Corinna
>
>
> On Tue, Aug 2, 2016 at 4:55 PM, corinna reuter <corinnareuter75 at gmail.com>
> wrote:
>>
>> Dear Cory, dear all,
>> sorry for not getting back to this topic earlier. Your solution works
>> perfectly for the described problem. When I create e.g. a SphereSource and
>> attach the TestProperty filter with its NPoints property, this property is
>> initialized with the correct number of points in the sphere.
>>
>> However, I have another requirement which is that the property should also
>> be updated, when the input changes. I thought the same mechanism for
>> initializing the property would also take care of updating the property upon
>> modified input.
>>
>> If I modify the SphereSource from above by changing the ThetaResolution or
>> PhiResolution, then vtkTestProperty::RequestInformation is called as
>> expected, and the included print statements show the new number of points,
>> but the NPoints property won't reflect this new value. Do you know of
>> another short trick, how to fix this? You mentioned that you found the need
>> for a domain element in the ParaView source code. Where exactly? If I
>> understand what prevented the property initialization, I might be able to
>> find out what prevents the update.
>>
>> The complete filter sources, updated to include your corrections, are
>> attached.
>>
>> Thank you
>> Corinna
>>
>> On Fri, Jul 15, 2016 at 6:02 PM, Cory Quammen <cory.quammen at kitware.com>
>> wrote:
>>>
>>> Corinna,
>>>
>>> Looking at the ParaView source code, I believe that vector properties
>>> with information properties must have a domain associated with them.
>>> In your case, you can add an IntRangeDomain with only a minimum
>>> defined:
>>>
>>> <IntVectorProperty name="NPoints"
>>>                         command="SetNPoints"
>>>                         information_property="NPointsInfo"
>>>                         number_of_elements="1"
>>>                         default_values="42">
>>>     <IntRangeDomain name="range" min="0" />
>>> </IntVectorProperty>
>>>
>>> 0 seems like a reasonable minimum in your case.
>>>
>>> Keep your information_only property as it is. You'll need to change
>>> where your NPoints is set, though - moving this to the
>>> RequestInformation() member function should work.
>>>
>>> Cory
>>>
>>>
>>> On Fri, Jul 15, 2016 at 3:46 AM, corinna reuter
>>> <corinnareuter75 at gmail.com> wrote:
>>> > Cory, thanks for mentioning the TIFFReader proxy. I tried to modify my
>>> > previously attached code such that the NPoints property links to a
>>> > NPointsInfo property. Plus, I have removed the call
>>> > "this->SetNPoints(nset);" inside vtkTestProperty::RequestData as
>>> > suggested
>>> > by Utkarsh. The NPoints property is still showing the default "42",
>>> > though,
>>> > and not initialized or updated from the number of points of the input
>>> > dataset. I am obviously missing another important step in addition to
>>> > changing the xml definitions, but which one?
>>> >
>>> > Here is the detailed modification of TestProperty.xml compared to the
>>> > earlier attachment:
>>> > replace
>>> > "<IntVectorProperty name="NPoints"
>>> >                         command="SetNPoints"
>>> >                         number_of_elements="1"
>>> >                         default_values="42">
>>> >   </IntVectorProperty>"
>>> > with:
>>> > "<IntVectorProperty name="NPoints"
>>> >                         command="SetNPoints"
>>> >                         information_property="NPointsInfo"
>>> >                         number_of_elements="1"
>>> >                         default_values="42">
>>> >   </IntVectorProperty>
>>> >   <IntVectorProperty name="NPointsInfo"
>>> >                         command="GetNPoints"
>>> >                         information_only="1">
>>> >     <SimpleIntInformationHelper />
>>> >   </IntVectorProperty>"
>>> >
>>> > Thank you
>>> > Corinna
>>> >
>>> >
>>> > On Thu, Jul 14, 2016 at 5:24 PM, Cory Quammen
>>> > <cory.quammen at kitware.com>
>>> > wrote:
>>> >>
>>> >> Corinna,
>>> >>
>>> >> Take a look at the TIFFReader SourceProxy in
>>> >> ParaViewCore/ServerManager/SMApplication/Resources/readers.xml. It has
>>> >> a CustomDataSpacing property that enables you to set voxel spacing,
>>> >> and has an associated information property CustomDataSpacingInfo that
>>> >> should initially populate the spacing property when the reader is
>>> >> created.
>>> >>
>>> >> HTH,
>>> >> Cory
>>> >>
>>> >> On Thu, Jul 14, 2016 at 11:17 AM, Utkarsh Ayachit
>>> >> <utkarsh.ayachit at kitware.com> wrote:
>>> >> >> I'll check the meaning of MTime.
>>> >> >
>>> >> > See the implementation of vtkSetMacro() in vtkSetGet.h. Every time
>>> >> > the
>>> >> > value changes, it call this->Modified() which updates the MTime.
>>> >> > Since
>>> >> > VTK is a demand-driven pipeline, changes to MTime is what tells the
>>> >> > pipeline that the algorithm has been modified and needs reexecution.
>>> >> > If one modifies the MTime in RequestData() (the method called by the
>>> >> > pipeline to process the input to produce output), the pipeline
>>> >> > thinks
>>> >> > the filter is always dirty and that can cause unexpected side
>>> >> > effects.
>>> >> >
>>> >> >
>>> >> >> I'd need something similar to an image resize filter. The output
>>> >> >> size
>>> >> >> should
>>> >> >> be identical to the input size, when the filter is first attached
>>> >> >> to
>>> >> >> the
>>> >> >> input. The output size should be shown in the UI and the user
>>> >> >> should be
>>> >> >> able
>>> >> >> to enter a different output size.
>>> >> >
>>> >> > This is possible. Let me see if I can find you a simple example for
>>> >> > the same. I'll get back to you.
>>> >> > _______________________________________________
>>> >> > 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.


More information about the ParaView mailing list