I’ve been working on a ParaView plugin very recently. In the XML definition, I used the following widget:
When I instantiate the filter, its RequestInformation triggers. The RequestInformation extracts a field array containing a string that tells what size the StringVectorProperty must be and what it must contain. The property is then instantly populated.
Now, if I save that state file, disconnect and load the state, when RequestInformation triggers, the field array that must be read is absent, not something I would expect.
The only workaround I’ve found is to store the NumberOfParameters inside an XML property set with panel_visibility=“never” and populate the property inside RequestData. Any hints?
Thank you very much,
Are you saying that in
RequestInformation, you are accessing your input dataset and doing stuff with it? If that’s the case, that’s indeed incorrect. VTK filters cannot expect that their input datasets will be valid when
RequestInformation is called. When you’re doing this one filter at a time in the ParaView UI, each new filter gets created and updated and hence you end up with an acceptable dataset in the input in
RequestInformation. That won’t be the case generally.
I’ve recommend the VTK pipeline primer series of blogs for more details on the VTK pipeline.
Thank you for your prompt response, Utkarsh. I wasn’t too sure about that. I will read that documentation and adapt.
edit: Propagating new metadata keys downstream seems to be the solution.
In my source header (ReaderClass.h), I have defined the following key:
static vtkInformationIntegerKey* NUMBER_OF_IND_COORDINATES();
Then, I set that key into my output vtkInformation like this:
vtkInformation *outInfo0 = outputVector->GetInformationObject(0);
When I connect a filter onto that output, I can’t retrieve the key that has been stored:
vtkInformation *inInfo0 = inputVector->GetInformationObject(0);
std::cout << "Int value: " << inInfo0->Get(ReaderClass::NUMBER_OF_IND_COORDINATES()) << std::endl;
Printing inInfo0 gives me the usual keys but not mine.
Am I missing something?
EDIT: Ok, I managed to do it by adding the following line:
KEYS_TO_COPY() is indeed the way to add custom key. Glad it’s working.