[wxVTK] vtkImageViewer2
Brought to you by:
malat
From: Suyang M. <suy...@ya...> - 2009-10-16 15:57:23
|
Hi, all - I am new to wxVTK even VTK world. I need to implement a 2D slicer to display 2D slices from a 3D volume by using wxWidget, python & VTK. By searching the web, I am planning to use vtkImageViewer2 to implement it, is this a good choice? any suggestion? Here is the sample codes I am working on (I use a 2D slice to start with, the 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, wxPython 2.8.9.1, and I am in linux. Any suggestions will be helpful, thanks. Suyang |