[Paraview] useful plugin: how to do it, really?

B.W.H. van Beest bwvb at xs4all.nl
Tue Sep 23 10:34:30 EDT 2014


Hello Utkarsh.

Thanks for your response. I will need some time to digest and practice, but
I will follow-up on your suggestions.

Kind Regards,
Bertwim
 
On 09/23/2014 03:01 PM, Utkarsh Ayachit wrote:
> Bertwim,
>
> I agree the developer docs are little scattered right now. My plan is
> to start writing blog posts that make this easier to digest. One of
> these, hopefully, I get around to it :). In the mean time, my replies
> are inline.
>
>
>> 1. Suppose I have created, interactively, a box, a sphere and a cone,
>> using the corresponding entries in the "Sources" menu.
>>
>> 2. Now I would like to *programmatically* (i.e. in  a c++ plugin) loop
>> over the sources (here: the box, sphere and cone) and for each of the
>> elements
>> get hold of the parameters that were used to define these sources (i.e.
>> the box dimensions, center, radii etc.). With these parameters I can
>> then do other things to build my own extension, but those details do not
>> matter here.
>
> Several ways for getting to the "proxies" for the sphere, box, etc.
> created. One way it using the vtkSMSessionProxyManager.
>
> a. Using vtkSMSessionProxyManager:
> a.1 Get access to the active session's proxy manager using
> pqActiveObjects::instance().proxyManager() [1]
> a.2 Use vtkSMProxyIterator[2] to iterate over the "sources" group.
>     vtkNew<vtkSMProxyIterator> iter;
>     iter->SetSessionProxyManager(pqActiveObjects::instance().proxyManager());
>     iter->SetModeToOneGroup();
>     for (iter->Begin("sources"); ! iter->IsAtEndt(); iter->Next())
>       {
>       iter->GetKey() ---> is the "label" for the proxy you see in the
> pipeline browser
>       iter->GetProxy() -- > will be the actual proxy object,
>       }
>
> To access parameters defined on them, you can access the "properties"
> on these proxies. If you know which property you're looking for using
> vtkSMPropertyHelper[3] to get the values e.g.
>
>    sphereProxy = ..
>    vtkSMPropertyHelper(sphereProxy, "Radius").GetAsDouble() --> the radius
>
> To iterate over all properties on the proxy, you can use
> vtkSMProxy::NewPropertyIterator [4] which will give you a new iterator
> (don't forget to call iter->Delete() once you're done with the
> iterator). You can use that to iterate over all properties on the
> proxy,
>
> Hope that helps,
> Utkarsh
>
> [1] http://www.paraview.org/ParaView3/Doc/Nightly/www/cxx-doc/classpqActiveObjects.html#a547a93dececb0d5ac7a35f373e5c68ab
> [2] http://www.paraview.org/ParaView3/Doc/Nightly/www/cxx-doc/classvtkSMProxyIterator.html
> [3] http://www.paraview.org/ParaView3/Doc/Nightly/www/cxx-doc/classvtkSMPropertyHelper.html
> [4] http://www.paraview.org/ParaView3/Doc/Nightly/www/cxx-doc/classvtkSMProxy.html#ab0eee37fc2a021334964e9ffcd682a4c
>
>



More information about the ParaView mailing list