Zoom by window. (Not so elegant solution)

Vamsidhar Juvvigunta vamsidha at merl.com
Wed Jul 7 09:32:10 EDT 1999


> Does anyone have an example of how to add a zoom by window to VTK.  I need
> the ability to zoom using a "rubber-band" window.  I can draw the window
> via Windows calls, I just need to know how to zoom to a given rectange in
> display coordinates.


  The RenderWindow has these functions.

  SetDisplayPoint
  DispalyToObject
  GetObjectCoordinates

 The names may not exactly be the same. But similar. look at the man pages
for vtkRenderWindow

  After you convert the four corners of your rubberband into object
coordinates, find their center. Now, disregard the depth returned as it
will be the z buffer depth. Set the center as the focus of the camera.
Keep the Z value of the oldFocus coordinate.

 Now if you want to keep the aspect ratio constant you'll need to modify
your rubberband coordinates such that they maintain the current aspect
ratio of the screen and you don't lose any information. Basically you
increase either the width or height of your rubberband till the aspect
ratio comes out the same. Easy to do. Do this before any of the above
mentioned transformations. 

 Now, get the camera's view angle. Construct a triangle with

   Width of your box
  ___________________




          *
   Camera position, such that the angle subtended by the width is the view
angle, compute the perpendicular distance between the camera and the width
and set this as the camera's distance. You can either do a SetPosition or
SetDistance with the appropriate coords/float. 

 Let me know if this works well. or if I have muddled up some part of
this. Using OpenGL there is a far simpler way of doing this in parallel
projections, but in vtk I am not sure if one can construct a projection
transform and input it to the camera? There might be one for all I know,
so if this sounds too complicated, you might want to wait till someone
sends in a simpler solution. 

-vamsi




-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list