vtkEventData based classes are not Python-wrapped

We would like to process virtual reality events in Python. However, event data is sent along with the event as a vtkEventDataDevice3D object (derived from vtkEventDataForDevice->vtkEventData->vtkObjectBase).

(Edit: this problem is solved now - If we specify @vtk.calldata_type(vtk.VTK_OBJECT) hint for the callback function then the application crashes in vtkPythonUtil::GetObjectFromPointer method call in vtkPythonCommand::Execute. Should it be possible to get vtkObjectBase derived events as calldata?)

Also, it seems that vtkEventDataDevice3D class is not Python-wrapped. Is there some fundamental issue with Python-wrapping classes derived from vtkObjectBase or it should work and there is just a bug somewhere that could be fixed?


I think that direct vtkObjectBase-derived classes need special support in the wrappers. Though I don’t see special bits for vtkInformationKey, so maybe that assumption isn’t accurate.

I did some more testing found that the crash was due to passing an incorrect object as calldata. So, the first problem is solved (I’ll edit the question above). However, I receive is something like (vtkCommonCorePython.vtkObjectBase)0000019A19C29D68 instead of a vtkEventData based object, I guess to the missing Python wrapping.

So, the main question is: Why vtkEventDataDevice3D is not Python-wrapped and what could be done about it? If there is no chance that this class will be Python-wrapped then I can implement workarounds (add a vtkObject based wrapper around it) or maybe get its base class changed to vtkObject.

The vtkEventDataDevice3D class isn’t wrapped because vtkEventData.h isn’t listed in CMakeLists.txt, and therefore the wrappers aren’t even aware that the class exists. The header won’t be installed by “make install”, either.

If you add vtkEventData.h to the “headers” in CMakeLists.txt, that should be sufficient.

1 Like

Also means it is/was not installed either. It wasn’t mentioned in the old build system which is how it got missed (the conversion for source lists was largely mechanical).

Ah, I see that this header produces a parse error for the wrappers:

vtkWrapHierarchy: In Common/Core/vtkEventData.h:35: syntax is ambiguous.
const int vtkEventDataNumberOfInputs =

A solution, of course, is to place “#ifndef __VTK_WRAP__” around the troublesome lines of code.

The wrappers produce this error because they don’t keep track of context well enough to distinguish between template args vs. comparison operators in all situations. I could add specific rules for “static_cast<>” etc. so that this code will get through.

Edit: It doesn’t need #ifndef, I can use parentheses to resolve the ambiguity:

const int vtkEventDataNumberOfDevices =

I’ll put together an MR for this.

1 Like

Thanks a lot for the quick answer. After making the proposed changes locally I can successfully retrieve the vtkEventData object from the calldata of the event!

I’ve pushed !5598 as a wrapping fix. This wraps the classes, but I’m not seeing the class methods for some reason.

I instantiated an object of a derived class (vtkEventDataForDevice) and I could see events of that.