[vtkusers] reset camera not working with QVTKWidget

Eric E. Monson emonson at cs.duke.edu
Mon Jul 12 09:50:29 EDT 2010


Hey Prathamesh,

Make sure you are using vtkInteractorStyleImage, which will only allow 2D rotations if you also press the ctrl button with mouse movements. If you want to totally disable rotations you will probably have to make a new interactor style.

http://www.vtk.org/doc/nightly/html/classvtkInteractorStyleImage.html

You can get the "active camera" from the renderer being used in the render window

widget->GetRenderWindow()->GetRenderer()->GetActiveCamera();

and set it to use "parallel projection" for images

camera->ParallelProjectionOn();

Then, in your callback for the mouse click you can reset the camera "view up" vector along with the camera reset (which has an option to take the bounds of the objects you want to fit in the window) to undo any rotations that have been made:

renderer->ResetCamera(imageActor->GetBounds());
renderer->GetActiveCamera()->SetViewUp(0,1,0);

http://www.vtk.org/doc/nightly/html/classvtkCamera.html

This is at least what has worked for me,
-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Jul 12, 2010, at 5:53 AM, Jothy wrote:

> First Render or MyQVTKWidget->Show() and then reset the camera.
> 
> Jothy
> 
> On Mon, Jul 12, 2010 at 1:42 AM, Prathamesh Kulkarni <prathameshmkulkarni at gmail.com> wrote:
> 
> Hello all,
> 
> 
> I am trying to use the QVTKWidget to display an image and reset its view at the click of a button. I tried many ways but it only resets the translation and does not affect rotation. Following is what I am using:
> 
> MyQVTKWidget->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->ResetCamera();
> MyQVTKWidget->repaint();
> 
> OR
> 
> MyRendererConnectedToMyQVTKWidget()->ResetCamera();
> 
> 
> Am I missing something here? Also, even when I  do MyvtkImageActorConnectedToMyRenderer()->setPickable(1);  I am still able to rotate the Image.
> 
> I want to be able to turn off rotation of the vtkImageActor in some way and let it only scale and drag using the default mouse actions.
> 
> Any help will be highly appreciated.
> 
> 
> Thanks,
> Prathamesh
> 
> _______________________________________________
> 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
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 
> _______________________________________________
> 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
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100712/7fb2568d/attachment.htm>


More information about the vtkusers mailing list