[Paraview-developers] Interaction with server data within client plugin

Sebastien Jourdain sebastien.jourdain at kitware.com
Wed May 8 10:33:55 EDT 2013


Hi Matthias,

you should use the following set of macro inside your vtkObject

public:
vtkSetVector3Macro(ActiveNodeCoord, double);
vtkGetVector3Macro(ActiveNodeCoord, double);

protected:
double ActiveNodeCoord[2];

This should solve your wrapping issue.


On Wed, May 8, 2013 at 9:39 AM, Matthias Schneider <
schneider at vision.ee.ethz.ch> wrote:

> Hi,
>
> Thanks for the useful hints. I have implemented the vtk class to interact
> with the vtk data object on the server side and use a proxy to interact
> with it from the client side as suggested by Sebastien - thanks! However,
> I'm still struggling with the proper xml definition for the proxy. Also
> there seems to be an issue with the Client/Server wrapper (see below).
>
> The pure vtk class has the interface:
>
> class vtkMyDataHandler: public vtkObject {
> public:
>         [...]
>         void SetInput(vtkAlgorithm* src);
>         void SetActiveNode(vtkIdType id);
>
>         double* GetActiveNodeCoord();
>         void GetActiveNodeCoord(double coord[3]);
>         [...]
> private:
>         [...]
>         vtkPolyData* m_data;
>         vtkIdType m_nodeId;
> };
>
> The Set* methods are used to define a vtkAlgorithm with a vtkPolyData
> output and a particular node/vertex id within the vtkPolyData. Eventually,
> the handler is supposed to return the node coordinates (x,y,z) of the
> selected vertex within the data set.
>
> The xml descriptor for the class looks like this:
>
> <ServerManagerConfiguration>
>   <ProxyGroup name="utility">
>    <Proxy name="MyProxy" class="vtkMyDataHandler" label="Data Handler">
>      <ProxyProperty name="Input"
>                     command="SetInput" />
>
>      <IdTypeVectorProperty name="ActiveNode"
>                         command="SetActiveNode"
>                         default_values="-1"
>                         number_of_elements="1" />
>
>       <DoubleVectorProperty command="GetActiveNodeCoord"
>
>                           default_values="0.0 0.0 0.0"
>                           information_only="1"
>                           name="ActiveNodeCoord"
>                           number_of_elements="3" />
>    </Proxy>
>  </ProxyGroup>
> </ServerManagerConfiguration>
>
> On the client side I do the following:
>
> // set up proxy on the client side
>
> vtkSMProxyManager *pxm = vtkSMProxyManager::**GetProxyManager();
> vtkSMProxy *proxy = pxm->NewProxy("utility", "MyProxy");
>
> // set internal state of proxy
> vtkSMPropertyHelper(proxy,"**Input").Set(properInputProxy);
> vtkSMPropertyHelper(proxy,"**ActiveNode").Set(1);
> proxy->UpdateVTKObjects();
>
> // obtain information from proxy
> proxy->UpdateProperty("**ActiveNodeCoord")
> double tmp[3] = { -1.0, -1.0, -1.0 };
> vtkSMPropertyHelper(proxy, "ActiveNodeCoord").Get(tmp, 3);
>
>
> Setting up the proxy and its initial state works perfectly fine. However,
> I am not able to update the desired property and invoke the call of
> vtkMyDataHandler::**GetActiveNodeCoord.
>
> There are two issues that I came accross here.
>
> 1) There seems to be a problem (?) with the Client/Server wrapper.
> For some reason the method without any argument
>
> double* GetActiveNodeCoord();
>
> does not get wrapped in vtkMyDataHandlerClientServer.**cxx
> This leads to an error if I change the update command to:
>
> proxy->**UpdatePropertyInformation(**proxy->GetProperty("**
> ActiveNodeCoord"));
>
> ERROR: In[...]/ParaView-3.98.1-**source/ParaViewCore/**
> ServerImplementation/Core/**vtkPVSessionCore.cxx, line 389
> vtkPVSessionCore (0x2aa9de0): Object type: vtkMyDataHandler, could not
> find requested method: "GetActiveNodeCoord"
> or the method was called with incorrect arguments.
>
> while processing
> Message 0 = Invoke
>   Argument 0 = vtk_object_pointer {vtkMyDataHandler (0x29cc970)}
>   Argument 1 = string_value {GetActiveNodeCoord}
>
> 2) With the update command used in the code snippet, the property values
> are set to the default values but the data handler function
> (GetActiveNodeCoord) doesn't get called as information only properties
> cannot be updated according to vtkSMProxy::UpdateProperty.
>
> So maybe I have a wrong understanding of information only properties?! I
> had a look at some of the xml examples in utilities.xml
> (ParaView-3.98.1-source/**ParaViewCore/ServerManager/**
> SMApplication/Resources/**utilities.xml) and it seemed to me like this is
> the way to go?!
>
> Removing the information_only tag from the xml property descriptor, the
> property obviously gets updated in proxy->UpdateVTKObjects(), which for
> obvious reasons results in an error as there is no method to *set* the node
> coordinates.
>
> So what am I missing here? I would be really happy about any kind of
> comments or hints how to do this.
>
> Best,
> Matthias
>
>
>
> On 04/05/2013 03:25 PM, Sebastien Jourdain wrote:
>
>> Hi Matthias,
>>
>>  However, getting access to the vtkPolyData object on the server will not
>>> be possible that easily I guess.
>>>
>>
>>  From the client side, not really unless you know that you will only run
>> in a built-in session.
>> That's precisely why you need to create a pure VTK class that will be
>> connected in some way to that object from the client side via proxy
>> while the real connection will happen on the server side.
>>
>>  I guess there is some kind of vtk algorithm required on the server side
>>>
>> to do the processing which is configured from the client via a proxy.
>>
>> Yes, although it doesn't need to be an algorithm if it is not a 'filter'
>> type of object.
>> But for instance you can create a VTK class that will provide an API
>> like that:
>>
>> SetMyVtkObjectToLookInto(**vtkObject* whatYouWant)
>> SetActiveNodeId(int id)
>> double* GetNewCenterOfRotation()
>>
>> And on the client side thanks to proxy (You will need to write a small
>> XML file for your VTK class) you will have to write something like that.
>>
>> myProxy = pxm.NewProxy('utility','**mySuperProxy');
>> vtkSMPropertyHelper(myProxy, 'ProxyPropName').Set(
>> yourProxyThatYouSelectedFromTh**eUI );
>> vtkSMPropertyHelper(myProxy, 'ActiveNode').Set( yourSelectedID );
>> myProxy->UpdateVTKObjects(); // This will push the changes to the server
>>
>> // Now it's time to retreive the info from the server
>> myProxy->**UpdateInformationProperty('**CenterOfRotation');
>> vtkSMPropertyHelper(myProxy, 'CenterOfRotation').Get(
>> localArrayToFillWithCenterOfRo**tation );
>>
>> Hope this give you a feeling on how the things works...
>>
>> Seb
>>
>> PS: I just wrote things from the top of my head, so names might not
>> exactly match but the idea is there.
>>
>>
>>
>> On Fri, Apr 5, 2013 at 8:48 AM, Matthias Schneider
>> <schneider at vision.ee.ethz.ch <mailto:schneider at vision.ee.**ethz.ch<schneider at vision.ee.ethz.ch>>>
>> wrote:
>>
>>     Hi Sebastian!
>>
>>     Thank you very much for you quick answer!
>>     I don't have any server side class yet.
>>
>>     I used the DockWidget example to setup a GUI (QDockWidget) along
>>     with some simple elements:
>>     pqOutputPortComboBox: define source
>>     QSpinBox: define node id
>>     QPushButton: trigger event
>>
>>     As I understand it the whole GUI processing takes place at the
>>     client side and has access to the server data via proxies only.
>>
>>     To stick with my simple example, I'd need a way to actually access
>>     the server source, which is a vtkPolyData in my case (originating
>>     from an exported graph, i.e., nodes connected by lines).
>>
>>     // Get source from pqOutputPortComboBox
>>     [...]
>>     vtkSMSourceProxy *source = ...
>>
>>     // obtain requested node id from GUI element
>>     vtkIdType nodeId = [...]
>>
>>     // If we had access to the vtkPolyData itself, we could do sth like...
>>     vtkPolyData *data = ...
>>     double coord[3];
>>     data->GetPoints()->GetPoint(__**nodeId, coord);
>>
>>
>>     // Set rotation center of current view to coord and render view
>>     [...]
>>
>>     However, getting access to the vtkPolyData object on the server will
>>     not be possible that easily I guess. I guess there is some kind of
>>     vtk algorithm required on the server side to do the processing which
>>     is configured from the client via a proxy (set the desired source
>>     and the node id). But as I said, I do not fully understand the
>>     ServerManager concept here and couldn't find any similar examples.
>>
>>     Hope this helps to clarify my problem...
>>
>>     Thanks for your help,
>>     Matthias
>>
>>
>>
>>     On 04/05/2013 01:47 PM, Sebastien Jourdain wrote:
>>
>>         Hi Matthias,
>>
>>         I guess, you already have your vtk class that will do the
>>         processing on
>>         the server side ?
>>         If so what are the methods that you want to get called and with
>> what
>>         arguments ?
>>
>>         Then once, I know more about your special use case, I can dive
>>         into the
>>         server manager part properly...
>>
>>         Seb
>>
>>
>>         On Fri, Apr 5, 2013 at 7:16 AM, Matthias Schneider
>>         <schneider at vision.ee.ethz.ch
>>         <mailto:schneider at vision.ee.**ethz.ch<schneider at vision.ee.ethz.ch>
>> >
>>         <mailto:schneider at vision.ee.__**ethz.ch <http://ethz.ch>
>>
>>         <mailto:schneider at vision.ee.**ethz.ch<schneider at vision.ee.ethz.ch>>>>
>> wrote:
>>
>>              Hi,
>>
>>              I'm trying to implement an extension for Paraview but I'm
>>         somewhat
>>              stuck with the client/server and ServerManager concepts used
>> in
>>              Paraview. Maybe someone could give a hint where to find
>>         some more
>>              information on that. I was looking at the plugin examples
>>         but that
>>              didn't help me too much.
>>
>>              What I do not understand is how to establish some kind of
>> data
>>              transfer between the server and the client. A very simple
>>         example
>>              that I was trying to implement is as follows: For a
>>         vtkPolyDataSet
>>              source define a point id via a GUI element and set the
>> rotation
>>              center of the active view to the coordinate of this point.
>>
>>              Based on the DockWidget example and the SelectionInspector
>>         I was
>>              able to create the GUI elements on the client side to select
>> an
>>              appropriate source on the server side and get access to the
>>         active
>>              view. What I do not understand is how to interact with the
>>         actual
>>              data of the source to read the spatial coordinates of the
>>              user-defined vertex.
>>
>>              On the client side I use a pqOutputPortComboBox to select
>>         the source
>>              which gives access to the current
>>         pqOutputPort/pqPipelineSource.
>>               >From this I get a
>>         vtkSMSourceProxy/____**vtkPVDataInformation which
>>
>>
>>              allows me to read basic information of the data as shown in
>>              Paraview's statistics inspector (no. of cells/points,
>>         memory size,
>>              bounds, ...).
>>
>>              Can anybody give me a hint how to do this properly? Any help
>> is
>>              appreciated very much.
>>
>>              Thanks,
>>              Matthias
>>
>>              ______________________________**_____________________
>>              Paraview-developers mailing list
>>              Paraview-developers at paraview._**___org
>>              <mailto:Paraview-developers at __**paraview.org<http://paraview.org>
>>         <mailto:Paraview-developers@**paraview.org<Paraview-developers at paraview.org>
>> >>
>>         http://public.kitware.com/____**mailman/listinfo/paraview-____**
>> developers<http://public.kitware.com/____mailman/listinfo/paraview-____developers>
>>         <http://public.kitware.com/__**mailman/listinfo/paraview-__**
>> developers<http://public.kitware.com/__mailman/listinfo/paraview-__developers>
>> >
>>
>>
>>         <http://public.kitware.com/__**mailman/listinfo/paraview-__**
>> developers<http://public.kitware.com/__mailman/listinfo/paraview-__developers>
>>         <http://public.kitware.com/**mailman/listinfo/paraview-**
>> developers<http://public.kitware.com/mailman/listinfo/paraview-developers>
>> >>
>>
>>
>>
>>     --
>>     Matthias Schneider
>>     Computer Vision Laboratory
>>
>>     ETH Zürich, ETF D114.1
>>     Sternwartstrasse 7
>>     8092 Zürich, Switzerland
>>
>>     fon: +41 44 63 20379 <tel:%2B41%2044%2063%2020379>
>>     fax: +41 44 63 21199 <tel:%2B41%2044%2063%2021199>
>>     www.vision.ee.ethz.ch/~__**schneima/<http://www.vision.ee.ethz.ch/~__schneima/>
>>     <http://www.vision.ee.ethz.ch/**~schneima/<http://www.vision.ee.ethz.ch/~schneima/>
>> >
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20130508/39ffb0f3/attachment-0001.htm>


More information about the Paraview-developers mailing list