[vtkusers] About MouseEvents.py example
aborsic at ne-scientific.com
Fri Jun 17 07:16:23 EDT 2016
In C++, a callback can return "true" to stop event propagation:
// This method invokes an event and return whether the event was
// aborted or not. If the event was aborted, the return value is 1,
// otherwise it is 0.
int InvokeEvent(unsigned long event, void *callData);
int InvokeEvent(unsigned long event);
When this feature was added for C++, it wasn't added to
vtkPythonCommand.cxx (an oversight), so vtkPythonCommand.cxx would have
to be modified to add this behavior for Python.
Regarding calldata, see the following merge request (now merged):
If Hasting happens to be reading this, please note that commit messages
should be a wee bit more descriptive...
I can't say much about the rest. The interactors aren't my favorite
part of VTK.
> I'm also curious, if you don't mind me asking: Have you used a lot of
> PyQt+VTK? If so, did you use the interactor style system or did you
> forego using it completely?
> - David
I am not entirely sure this answer is relevant. One can customize the
response to particular events in this way:
1) by registering a call back command with a higher priority w.r.t. to
default observers, with a statement like:
cmd_id = interactor.AddObserver("LeftButtonPressEvent",
self.MouseButtonCallback, 0.5) # use a priority of 0.5 which should be
higher than default observers (0.0)
2) by inspecting / acting on the event within the call back command, and
if further processing of the event by other observers (for example the
default interactor) needs to be prevented, by using something like:
command = interactor.GetCommand(cmd_id)
the above should stop any further handling of the event.
This is therefore a possible way of overriding the default behavior of
the interactor associated with render window.
I am not entirely sure though whether this was the behavior your were
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers