[vtkusers] ImageViewer2 extent problem

Sebastien BARRE sebastien at barre.nom.fr
Sat Sep 10 16:39:38 EDT 2005


At 9/9/2005 05:06 PM, David Borland wrote:
>Thanks.  That did the trick.  Need to make sure UpdateInformaton is called 
>on the input image also.
>
>David
>
>Mark Wyszomierski wrote:
>
>>I had this problem too, vtkImageViewer2 is just a wrapper around a few 
>>classes that put it all together, the one you need to alter is the 
>>underlying image actor object. So get it, call SetDisplayExtent() with 
>>the new image dimensions on the image actor, and reset your camera. This 
>>worked for me. Goodluck,
>>
>>Mark

David, Mark

Thanks for the feedback. As Mark stated, vtkImageViewer2 is a wrapper 
around a few classes. Calling SetDisplayExtent can do the trick, but you 
have to be careful about it, since you have to set the display extent 
correctly depending on the Slice and SliceOrientation parameters of the 
viewer (I added SliceOrientation recently). This is done automatically for 
you (as well as resetting the camera) each time you change the Input of the 
viewer, but of course, most of the time the input of this class is likely 
to remain the same, i.e. connected to the output of a filter, or an image 
reader. When the input of this filter is changed, an error message is 
displayed since the current display extent is probably outside the new 
whole extent. That's what you saw David.

To make your life easier, I moved the UpdateDisplayExtent method from the 
protected to the public section of the class. Everytime you change the 
input of a filter upstream in the pipeline, you can simply call this 
method, which will set the display extent properly and try to set a 
reasonable camera clipping range (you may still have to call ResetCamera on 
the Renderer to center the image afterwards, since there was probably no 
reason to force it in UpdateDisplayExtent).




More information about the vtkusers mailing list