[vtkusers] How to be notified when an interaction style is set (from Python)?

David Gobbi david.gobbi at gmail.com
Mon Jun 20 10:12:33 EDT 2016


On Mon, Jun 20, 2016 at 7:02 AM, Elvis Stansvik <
elvis.stansvik at orexplore.com> wrote:

> Hi all,
>
> In my custom interaction style (derived from vtkInteractionStyleUser), I
> have a need to be notified when the interaction style is set on an
> interactor.
>
> The reason I need this is that the purpose of my interaction style is to
> lock the camera position to a cylinder around my subject: The user should
> be able to zoom in/out, rotate around the subject on a circle, change the
> azimuth, and pan up/down along the subject (which has the shape of standing
> cylinder), but not perform other camera movements. The focal point should
> always be on the axis through the middle of my subject which is parallel to
> the Y ("vertical") axis. I therefore would like to do some initialization
> of the camera when the interactor is first set on the interactor style
> (and, I guess equivalently, when the interaction style is set on the
> interactor).
>
> In C++ I think I could override SetInteractor on the interactor style, but
> in Python that won't work. Is there some event I could listen for which
> fires when the interaction style gets a new interactor?
>

Only the ModifiedEvent, but it fires a lot and therefore observing it is
inefficient.  If you have your own interactor class (and if you use it
throughout your application), then you can override its
SetInteractorStyle() method since that method is called from the Python
side.

 - David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160620/be104f7e/attachment.html>


More information about the vtkusers mailing list