[vtkusers] About MouseEvents.py example
Elvis Stansvik
elvis.stansvik at orexplore.com
Fri Jun 17 08:09:37 EDT 2016
2016-06-17 13:16 GMT+02:00 Andrea Borsic <aborsic at ne-scientific.com>:
>
> In C++, a callback can return "true" to stop event propagation:
>
> // Description:
> // 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):
> https://gitlab.kitware.com/vtk/vtk/merge_requests/1543/commits
> 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?
>
> Elvis
>
>
>> - David
>>
>
>
>
>
> Hi Elvis,
>
> 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)
> command.SetAbortFlag(1)
>
> 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
> looking for.
>
Thanks a lot. I think in a way this is as close as I'm going to get to what
I wanted, but for one thing: I wanted to be able to modify the event (say
the x/y of a mouse event) before "passing it on" for further processing,
which I don't think is possible.
But I think I've realized now that this is probably a bad way of anchieving
my goal, and I'm not working on a completely custom interactor style
instead (using vtkInteractorStyleUser).
Elvis
>
> Best,
>
> Andrea
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160617/5cecf259/attachment.html>
More information about the vtkusers
mailing list