Hi,
I’m using Activiz with C# and want to use a custom interactor style. To this end I subclassed vtkInteractorStyleTrackballCamera and overriden the OnLeftButtonDown function. However, the overriden method is never called. I can use other interactor styles, e.g. vtkInteractorStyleImage, without any problems, so the problem must lie with the new class itself. Is there anything else I have to do, so my custom interactor style works? I’m using the newest version 9.1.
class MCVTKInteractor : vtkInteractorStyleTrackballCamera
{
public override void OnLeftButtonDown()
{
base.OnLeftButtonDown();
}
}
Thanks, I have a follow-up question. What I’m trying to do is provide a custom interaction, e.g. I want to pan with the right mouse button.
I used a vtkInteractionStyleUser and the MouseDown / MouseUp handlers are called without any problems. I then tried to implement the behaviour by taking vtkInteractorStyleTrackballCamera as an example, so I call StartPan in MouseDown, Pan in MouseMove and EndPan in MouseUp. This doesn’t work however, the object is not getting moved.
My suspicion is that this is due to a missing call to “GrabFocus”, but I can instantiate its parameters of type vtkCallbackCommand, the type is not available in Activiz.
public void Start(ViewModeEnum fAction)
{
interactorStyle.FindPokedRenderer(Renderer.GetRenderWindow().GetInteractor().GetEventPosition()[0], Renderer.GetRenderWindow().GetInteractor().GetEventPosition()[1]);
switch (fAction)
{
case ViewModeEnum.Panning:
interactorStyle.StartPan();
break;
}
}
public void Move()
{
int x = Renderer.GetRenderWindow().GetInteractor().GetEventPosition()[0];
int y = Renderer.GetRenderWindow().GetInteractor().GetEventPosition()[1];
switch ((MCVTKInteractorState)interactorStyle.GetState())
{
case MCVTKInteractorState.VTKIS_PAN:
interactorStyle.FindPokedRenderer(x, y);
interactorStyle.Pan();
interactorStyle.InvokeEvent((uint)vtkCommand.EventIds.InteractionEvent, IntPtr.Zero);
break;
}
}
public void End()
{
switch ((MCVTKInteractorState)interactorStyle.GetState())
{
case MCVTKInteractorState.VTKIS_PAN:
interactorStyle.EndPan();
break;
}
}
EDIT: Okay I see it now, the Pan() function is virtual and has an empty implementation. I managed to get it to work by providing an implementation similar to vtkInteractorStyleTrackballCamera’s Pan
I confirm the solution shared by @toddy is the right one. In addition, I think adding handlers on the RightButtonPressEvt/RightButtonReleaseEvt to call StartPan/EndPan should be enough if you remove the event handler on MouseMoveEvt. You don’t have to reimplement Pan() in this case.