I added to the vtkAlgorithm class an attribute “bool MyAttribute” with its getters and setters.
Basically, I need this attribute to be saved in the state files. I could add the property manually to every sources/filters xml definition but it’s not an option here because of having a large number of xml definitions.
I tried multiple things (e.g.: proxy SetAnnotation) and… I finally think that the best way to achieve this would be to add for each filter/source proxy a new property “MyAttribute” when the proxy has just been registered.
So I connect to the signal pqServerManagerObserver::proxyRegistered to a custom callback.
Within the callback I didn’t find a way to extend the proxy definition. Any suggestion?
I found the class vtkSMSelfGeneratingSourceProxy which allows to extend a proxy definition but couldn’t find a way to make it work with ParaView.
Here is how I implemented it:
void aProxyRegistrationReaction::onProxyRegistered(const QString& group, const QString& name, vtkSMProxy* proxy)
{
if(std::strcmp(proxy->GetXMLGroup(), "sources") == 0 || std::strcmp(proxy->GetXMLGroup(), "filters") == 0)
{
std::string extension =
" <Proxy> "
" <Property"
" command='SetMyAttribute'"
" default_values='0'"
" name='MyAttribute'"
" number_of_elements='1'"
" panel_visibility='never'>"
" </Property>"
" </Proxy> ";
vtkSmartPointer<vtkSMSelfGeneratingSourceProxy> sgProxy =
vtkSmartPointer<vtkSMSelfGeneratingSourceProxy>::New();
sgProxy->InitializeAndCopyFromProxy(proxy);
if (!sgProxy->ExtendDefinition(extension.c_str()))
{
std::cerr << "Failed to extend proxy definition!" << endl;
}
sgProxy->UpdateVTKObjects();
}
}
And at run time, I got the errors like:
ERROR: In c:\git\paraview\paraviewcore\servermanager\core\vtksmproxy.cxx, line 2297
vtkSMSelfGeneratingSourceProxy (000002E41553C500): Proxies on different sessions.
Thanks in advance.