[vtkusers] Zoom to window problem

vidyadhar vidyadhar at lucidindia.net
Sun Sep 25 23:18:20 EDT 2005


Hi,
This needs to be done in two parts - 1) pan camera to center of selected window and 2) change camera's view angle. Method used for changing view angle depends on camera's projection type (parallel/perspective) Zoom and SetParallelScale work only for parallel projection. For perspective projection use SetViewAngle method.
Some more details
Renderer/viewport has methods to transform coordinates from display to world and back. Display coordinates must be 3D, (x,y) from the reported mouse position. In parallel projection value of z does not matter for this task. In perspective projection this value should be depth of corresponding to focal point. camera->GetFocalPoint(), transform world to display and use z component of transform point.
Transform window center to world and difference between this and camera focal point. Move both position and focal point by this displacement vector. This will pan camera to appropriate position.
You have distance from camera' position to focal point. Using the earlier transformed coordinates of display window find world height of selected window. From this you can find the required angle to be used with SetViewAngle. This should work for perspective projection. If Zoom is not working for you, I assume you are using perspective projection. In parallel projection, the equivalent thing is parallel scale but I have not worked with that and I do not know how to calculate it.
HTH
Vidyadhar
  ----- Original Message ----- 
  From: Bharati 
  To: vtkusers at vtk.org 
  Sent: Friday, September 23, 2005 2:27 PM
  Subject: [vtkusers] Zoom to window problem


  Hi,

   

  I am using Qt 3.2.3. I have a class derived from QVTKWidget in my Qt project. I want to implement zoom to window facility. I have trapped the mouse events and got the coordinates of mousePress and mouseRelease. With this data which vtk structures associated with QVTKWidget should be used to zoom the area selected by the user? I tried changing 'zoom' factor of active camera, but I could not calculate the proper zoom factor and adjust the view window as per selection by mouse.  

   

  Can somebody help me to solve this?

   

  With regards,

  Bharati Page.

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


More information about the vtkusers mailing list