[vtkusers] wxVTKRenderWindowInteractor + vtkImageViewer2

Mathieu Malaterre Mathieu.Malaterre at creatis.insa-lyon.fr
Wed Sep 3 08:43:59 EDT 2003


Hi all,

	I only realize since a few days that the python version of 
wxVTKRenderWindowInteractor could not be used with a vtkImageViewer2. I 
did some changes(*) to the wxVTKRWI.py python code so that it could 
works. These changes were done to match my C++ version(**), but I am 
open to any other suggestion.

	To sum up quickly the problem, wxWindows need a special vtkRenderWindow 
which is build within wxVTKRWI. Whereas vtkImageViewer2 built its own 
too and override the one previously build. I first thought of adding a 
method: vtkImageViewer2::SetWindowInfo, but I found it ugly for 
vtk-users -furthermore it would introduce differences between a standart 
vtkRWI-.

	Therefore I change the wxVTKRWI.py code so that it uses the 
vtkRenderWindow from the vtkGenericRWI, even if it has been set by 
another filter, for example vtkImageViewer2.


Here is a python script to reproduce the bug (you'll get 2 windows under 
X11, don't know about Window$):

####################################
import vtk
from vtk.util.misc import vtkGetDataRoot
from vtk.wx.wxVTKRenderWindowInteractor import *
VTK_DATA_ROOT = vtkGetDataRoot()

app = wxPySimpleApp()

frame = wxFrame(None, -1, "wxRenderWindow", size=wxSize(400,400))
frame.Show(1)

reader = vtk.vtkPNGReader()
reader.SetDataSpacing(0.8, 0.8, 1.5)
reader.SetFileName(VTK_DATA_ROOT + "/Data/fullhead15.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)

app.MainLoop()
####################################



(*) And you'll find a patch here:

http://www.creatis.insa-lyon.fr/~malaterre/vtk/wxrwi.patch

(**) And the C++ version I am talking about is here:

http://www.creatis.insa-lyon.fr/~malaterre/wxVTK/

mathieu
Ps: my c++ wxVTKRWI is working without problem with vtkImageViewer2, it 
would be nice if both behavior could match.




More information about the vtkusers mailing list