[vtkusers] wxWidget Python vtkImageViewer2
Suyang Mei
suyang_mei at yahoo.com
Thu Oct 15 19:06:20 EDT 2009
Hi, all -
I am new to VTK world.
My co-worker built a prototype using wxWidget, Pyhton & VTK for viewing 3D CT image. She finished 3D volume rendering and I am taking over her task and continue the development work of displaying the 2D slices from a 3D volume.
I am planning to use vtkImageViewer2, here is the sample codes I am working on (I use a 2D slice to start with, teh Forest4.png with the size of 192 & 256)) -
####################################
import vtk
from vtk.util.misc import vtkGetDataRoot
from vtk.wx.wxVTKRenderWindowInteractor import *
from wxPython.wx import *
app = wxPySimpleApp()
frame = wxFrame(None, -1, "wxRenderWindow", size=wxSize(400,400))
frame.Show(1)
reader = vtk.vtkPNGReader ()
reader.SetDataSpacing (1.0, 1.0, 1.0)
reader.SetFileName ( "Forest4.png")
iren = wxVTKRenderWindowInteractor(frame, -1)
iren.AddObserver("ExitEvent", lambda o,e,f=frame: f.Close())
viewer = vtk.vtkImageViewer2()
viewer.SetInput ( reader.GetOutput() )
viewer.SetupInteractor (iren)
#viewer.GetRenderer().ResetCameraClippingRange()
app.MainLoop()
####################################
When I run this *.py file, I got the image displayed at the upper left corner of the view port, only occupied a small portion. How do I correctly set the zoom factor?
I googled vtkImageViewer2, back to 2003, there were many posts about bugs inside vtkImageViewer2 when using wxWidget -
http://public.kitware.com/pipermail/vtkusers/2003-September/069419.html
Is this problem fixed? I am using VTK version 5.2.
Any suggestions will be helpful, thanks.
Suyang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091015/46378bb7/attachment.htm>
More information about the vtkusers
mailing list