[vtkusers] self defined Mousewheel event handler does not work with Activiz VTK 7.0
Liu_tj
tjlp at netease.com
Tue Mar 15 08:56:37 EDT 2016
Hi, VTK guys,
Now I upgrade from Activiz for VTK 5.8 to 7.0. And I define the vtkInteractorStyleImage::MouseWheelForwardEvt and MouseWheelBackwardEvt for slice switch. With VTK 5.8, it works but now it doesn't work for 7.0. With VTK 7.0, these 2 event handlers keep the old behavior which zooms in or out. It does not call the function I define to switch the slice number. My code is as follow:
private void Display(vtkRenderWindow aRenderWindow, vtkAlgorithmOutput aData)
{
if (aData == null)
return;
m_imageViewer = vtkImageViewer2.New();
m_imageViewer.SetInputConnection(aData);
switch (m_sliceDirection)
{
case Direction.AXIAL:
m_imageViewer.SetSliceOrientationToXY();
break;
case Direction.CORONAL:
m_imageViewer.SetSliceOrientationToYZ();
break;
case Direction.SAGITTAL:
m_imageViewer.SetSliceOrientationToXZ();
break;
default:
break;
}
m_imageViewer.GetSliceRange(ref m_minSliceNumber, ref m_maxSliceNumber);
m_interactorStyle = vtkInteractorStyleImage.New();
m_moveforward = new vtkObject.vtkObjectEventHandler(interactor_MouseWheelForwardEvt);
m_movebackward = new vtkObject.vtkObjectEventHandler(interactor_MouseWheelBackwardEvt);
m_interactorStyle.MouseWheelForwardEvt += m_moveforward;
m_interactorStyle.MouseWheelBackwardEvt += m_movebackward;
vtkObject.vtkObjectEventHandler(interactor_MouseWheelBackwardEvt);
aRenderWindow.GetRenderers().InitTraversal();
m_renderer = aRenderWindow.GetRenderers().GetFirstRenderer();
m_renderer.SetBackground(0.0, 0.0, 0.0);
m_imageViewer.SetRenderWindow(aRenderWindow);
vtkRenderWindowInteractor interactor = aRenderWindow.GetInteractor();
interactor.SetInteractorStyle(m_interactorStyle);
m_imageViewer.SetupInteractor(interactor);
m_currentSlice = m_minSliceNumber + (m_maxSliceNumber - m_minSliceNumber) / 2;
m_imageViewer.SetSlice(m_currentSlice);
m_imageViewer.Render();
}
What's wrong with the code?
Thanks
Liu Peng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160315/886c2ae7/attachment.html>
More information about the vtkusers
mailing list