vtkImageInteractorStyle and MouseWheelEvent

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

vtkImageInteractorStyle and MouseWheelEvent

Romain LEGUAY
Hi everyone,

I try to use the mouse wheel on a vtkResliceImageViewer in a Qt window.

I try to add a callback to the vtkImageInteractorStyle like this:


QtVTKExample::QtVTKExample(QWidget *parent) : QWidget(parent)
{
	m_layout = new QVBoxLayout;
	m_window = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
	m_widget = new QVTKOpenGLWidget(this);
	m_widget->SetRenderWindow(m_window);
	m_image = vtkSmartPointer<vtkImageData>::New();
	m_mapper = vtkSmartPointer<vtkImageResliceMapper>::New();
	m_mapper->SetInputData(m_image);
	m_viewer = vtkSmartPointer<vtkResliceImageViewer>::New();
	m_viewer->SetRenderWindow(m_window);
	m_viewer->SetupInteractor(m_window->GetInteractor());
	m_viewer->GetImageActor()->SetMapper(m_mapper);
	addObservers();
	m_layout->addWidget(m_widget);
	setLayout(m_layout);
}

void WheelBackwardFunction (vtkObject*, long unsigned int, void*, void*)
{
	std::cout << "wheel backward" << std::endl;
}

void WheelForwardFunction (vtkObject*, long unsigned int, void*, void*)
{
	std::cout << "wheel forward" << std::endl;
}
void QtVTKExample::addObservers()
{
	m_wheelForward = vtkSmartPointer<vtkCallbackCommand>::New();
	m_wheelBackward = vtkSmartPointer<vtkCallbackCommand>::New();
	m_wheelForward->SetCallback(WheelForwardFunction);
	m_wheelBackward->SetCallback(WheelBackwardFunction);
	m_viewer->GetInteractorStyle()->AddObserver(vtkCommand::MouseWheelForwardEvent, m_wheelForward);
	m_viewer->GetInteractorStyle()->AddObserver(vtkCommand::MouseWheelBackwardEvent, m_wheelBackward);
}


The window opens, with no warnings but the callback function are never called.

What did I do wrong?

Thank you,

Romain


_______________________________________________
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:
https://public.kitware.com/mailman/listinfo/vtkusers