[vtkusers] Render "problem" when moving from QT 4.3 to QT 4.6.

Luis Roberto P. Paula luisrpp at gmail.com
Wed Jul 7 01:47:12 EDT 2010


Hi All,

I'm getting a strange behavior since I moved from QT 4.3 to QT 4.6 (Mac Snow
Leopard and Ubuntu 64bit).

To display an image in the GUI, I'm using QVTKWidget with vtkImageViewer2.

I need that every time the user clicks on the image with the mouse, a new
image will be displayed.

To do that, I'm doing this:

-----------------------------------------------------
   // Create Viewer
   viewer = vtkImageViewer2::New();
   viewer->SetInput(IMAGE);
   viewer->SetupInteractor(vtkWidget->GetRenderWindow()->GetInteractor());

   vtkWidget->SetRenderWindow(viewer->GetRenderWindow());

   vtkInteractorStyleImage *imageStyle = vtkInteractorStyleImage::New();
   vtkPointPicker* picker = vtkPointPicker::New();
   vtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(picker);

   // Create callback
   vtkImageInteractionCallback *callback =
vtkImageInteractionCallback::New();
   callback->SetInteractor(vtkWidget->GetRenderWindow()->GetInteractor());
   callback->SetPicker(picker);
   callback->SetImageViewer(viewer); // Send a reference to callback
   imageStyle->AddObserver(vtkCommand::MouseMoveEvent, callback);
   imageStyle->AddObserver(vtkCommand::LeftButtonPressEvent, callback);
   imageStyle->AddObserver(vtkCommand::LeftButtonReleaseEvent, callback);


vtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(imageStyle);
   viewer->GetRenderer()->ResetCamera();

-----------------------------------------------------

The Execute method of the vtkImageInteractionCallback class basically
performs this:

   viewer->SetInput(NEW_IMAGE);
   viewer->Render();

In other words, this is what happens every time the user clicks on the
image.

It is working fine, but the problem is that the first click performs a ZOOM
OUT on the image. And it is always the first click!!

This is only happening in the first time the method Execute
(vtkImageInteractionCallback : vtkCommand) call viewer->Render(). When I
call Render() outside vtkImageInteractionCallback, the "problem" does NOT
happen.

Does anyone have an idea on what is going on? How can I fix this?

Any help will be appreciated!

Thanks & Regards,
Luis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100707/0bc16792/attachment.htm>


More information about the vtkusers mailing list