Commit ed78f654 authored by Charl Botha's avatar Charl Botha
Browse files

wxVTKRW and wxVTKRWI can now be reparented. Requires SetNextWindowInfo()

in vtkRenderWindow, i.e. VTK CVS newer than 20030326.

Based on a patch by Benoit Regrain.
parent a5321d50
......@@ -7,6 +7,7 @@ Find wxPython info at http://wxPython.org
Created by David Gobbi, December 2001
Based on vtkTkRenderWindget.py
"""
"""
......@@ -66,6 +67,11 @@ _LastX, _LastY: The (x,y) coordinates of the previous event
_CurrentRenderer: The renderer that was most recently clicked in
_CurrentCamera: The camera for the current renderer
----------------------------------------
Private Members:
__Handle: Handle to the window containing the vtkRenderWindow
"""
# import usual libraries
......@@ -161,7 +167,10 @@ class wxVTKRenderWindow(baseClass):
position = kw['position']
del kw['position']
size = wxDefaultSize
try:
size = parent.GetSize()
except AttributeError:
size = wxDefaultSize
if kw.has_key('size'):
size = kw['size']
......@@ -204,11 +213,11 @@ class wxVTKRenderWindow(baseClass):
self._RenderWindow.StereoCapableWindowOn()
self._RenderWindow.SetStereoTypeToCrystalEyes()
self.__Created = 0
self.__handle = None
# Tell the RenderWindow to render inside the wxWindow.
if self.GetHandle():
self.__Created = 1
self._RenderWindow.SetWindowInfo(str(self.GetHandle()))
self.__handle = self.GetHandle()
self._RenderWindow.SetWindowInfo(str(self.__handle))
# refresh window by doing a Render
EVT_PAINT(self, self.OnPaint)
......@@ -270,8 +279,8 @@ class wxVTKRenderWindow(baseClass):
height = event.GetSize().height
self._RenderWindow.SetSize(width, height)
self.OnSize(event)
if self.__Created:
self._RenderWindow.Render()
self.Render()
def OnSize(self, event):
pass
......@@ -439,11 +448,16 @@ class wxVTKRenderWindow(baseClass):
light.SetPosition(self._CurrentCamera.GetPosition())
light.SetFocalPoint(self._CurrentCamera.GetFocalPoint())
if self.__Created:
if self.__handle and self.__handle == self.GetHandle():
self._RenderWindow.Render()
elif self.GetHandle():
self._RenderWindow.SetWindowInfo(str(self.GetHandle()))
self.__Created = 1
# this means the user has reparented us
# let's adapt to the new situation by doing the WindowRemap dance
self._RenderWindow.SetNextWindowInfo(str(self.GetHandle()))
self._RenderWindow.WindowRemap()
# store the new situation
self.__handle = self.GetHandle()
self._RenderWindow.Render()
def UpdateRenderer(self,event):
......
......@@ -157,10 +157,10 @@ class wxVTKRenderWindowInteractor(baseClass):
self._RenderWindow.StereoCapableWindowOn()
self._RenderWindow.SetStereoTypeToCrystalEyes()
self.__Created = 0
self.__handle = None
# Tell the RenderWindow to render inside the wxWindow.
if self.GetHandle():
self.__Created = 1
self.__handle = self.GetHandle()
self._RenderWindow.SetWindowInfo(str(self.GetHandle()))
self._Iren = vtk.vtkGenericRenderWindowInteractor()
......@@ -226,7 +226,7 @@ class wxVTKRenderWindowInteractor(baseClass):
height = event.GetSize().height
self._Iren.SetSize(width, height)
self._Iren.ConfigureEvent()
# this will check for __Created
# this will check for __handle
self.Render()
def OnMotion(self, event):
......@@ -326,8 +326,18 @@ class wxVTKRenderWindowInteractor(baseClass):
# if it's not enabeld, RenderAllowed will be false
RenderAllowed = topParent.IsEnabled()
if self.__Created and RenderAllowed:
self._RenderWindow.Render()
if RenderAllowed:
if self.__handle and self.__handle == self.GetHandle():
self._RenderWindow.Render()
elif self.GetHandle():
# this means the user has reparented us; let's adapt to the
# new situation by doing the WindowRemap dance
self._RenderWindow.SetNextWindowInfo(str(self.GetHandle()))
self._RenderWindow.WindowRemap()
# store the new situation
self.__handle = self.GetHandle()
self._RenderWindow.Render()
def SetRenderWhenDisabled(self, newValue):
"""Change value of __RenderWhenDisabled ivar.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment