Migrating a custom application from PV 5.10 to 5.12.0-RC3, I am running into a problem with my code that generates an ID’s based selection from within a property panel. This is what my code is doing and what was working just fine so far:
// generate a new IDs selection source proxy object
vtkSMSessionProxyManager* pxm = pqActiveObjects::instance().activeServer()->proxyManager();
vtkSMSourceProxy* selSource = vtkSMSourceProxy::SafeDownCast(pxm->NewProxy("sources", "IDSelectionSource"));
pqSMAdaptor::setElementProperty(selSource->GetProperty("FieldType"), vtkSelectionNode::CELL);
// add an IDs property
vtkSMVectorProperty* vp = vtkSMVectorProperty::SafeDownCast(selSource->GetProperty("IDs"));
pqSMAdaptor::setMultipleElementProperty(vp, idsPadded);
selSource->UpdateVTKObjects();
// set the selection on our port - and delete the reference within this function scope
outPort->setSelectionInput(selSource, 0);
selSource->Delete();
This code worked so far just fine, but there is one thing to say that I am working with selections in a somewhat “illegal” way: Normally a selection is referring to the input port data object/proxy and then a filter is using it for some operation, but in my case I am simulating some kind of “interactive” workflow by having the selection on the output port data object. Meaning: once the filter is invoked, it starts with a “silent apply” that ensures that there is an output object from the beginning, and the “current selection” is restored from some properties. After that, the user can select/unselect, check the result etc. without always switching back and forth. On top of that, he can also do other things in the pipeline and come back later on, doing more adaptations in the selection. This just as an explaining side remark about what I am trying to achieve - or rather already achieved in the past.
However, now there is a new function in PV 5.12 pqFindDataCurrentSelectionFrame::showSelectedData()
(which did not exist yet in PV 5.10) that “crashes” at line 258 because selectionSource
is nullptr
: at line 243 it was not able to find a property named "Input"
in appendSelections
. On the other hand, the latter is in fact the same object as the newly generated selSource
in the above code, it does indeed not have a property "Input"
.
At this point I start swimming…
My reasoning: Maybe I do not go for that Input
object, but rather use appendSelections
directly because it already represents the object to which my selection applies!??
With this reasoning I changed the code in pqFindDataCurrentSelectionFrame.cxx:236
as follows:
// Checking only one of the inputs of the appendSelections is sufficient
// BCO 2024-03-08: We need to take care of the possibility that we do not have
// an Input property in the somewhat "special" selection usages in AthosGEO
vtkSMProxy* selectionSource = (nullptr != appendSelections->GetProperty("Input")) ?
vtkSMPropertyHelper(appendSelections, "Input").GetAsProxy(0) :
vtkSMProxy::SafeDownCast(appendSelections);
And indeed: the code is working now as before - no crash any more, but the functionality I used to see!
Still another similar adaptation in pqRenderViewSelectionReaction.cxx
avoids also another warning message that still appears.
So far so good, but still I am not sure whether there is not a better way to programmatically generate a selection on the output port object than what I did in the past, avoiding these patches in the PV code??