I was wondering if there is a convenient way to define custom vtk events (preferably at a high level) and thereafter attach a data payload to them?
As an analogous example, the qt slider widget has a valueChanged signal that has an attached payload containing the new value. In the context of vtk, one could then do something along the lines of (perhaps as a static variable):
Handling the event is possible in Python as well (see example for connecting and using), but I’m not sure if you can define such an event from Python.
For most data types in Slicer, a vtkObject is actually returned as a wrapped version of whatever concrete subclass was passed in the payload, so it actually covers all slicer events that come from nodes or the scene or other classes.
You can also call InvokeEvent from python with a calldata (payload) argument.
In practice it’s often the case in Slicer that you don’t need calldata because knowing the caller is enough to get the information you want because what would otherwise be the payload data has already been set in the corresponding instance variable of the caller.