2003-12-08 20:23:28 -05:00
|
|
|
# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
|
|
|
#
|
|
|
|
# o Updated for wx namespace
|
|
|
|
# o No idea what this does.
|
|
|
|
#
|
|
|
|
|
|
|
|
import wx
|
|
|
|
import wx.lib.vtk as vtk
|
2000-07-15 15:51:35 -04:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
2003-12-08 20:23:28 -05:00
|
|
|
class VtkFrame(wx.Frame):
|
2000-07-15 15:51:35 -04:00
|
|
|
"""
|
|
|
|
Simple example VTK window that contains a cone.
|
|
|
|
"""
|
|
|
|
def __init__(self, parent, id, title):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.Frame.__init__(self, parent, id, title, size=(450, 300))
|
|
|
|
win = vtk.VTKRenderWindow(self, -1)
|
2000-07-15 15:51:35 -04:00
|
|
|
|
|
|
|
renWin = win.GetRenderWindow()
|
|
|
|
|
|
|
|
ren = vtk.vtkRenderer()
|
|
|
|
renWin.AddRenderer(ren)
|
|
|
|
cone = vtk.vtkConeSource()
|
|
|
|
coneMapper = vtk.vtkPolyDataMapper()
|
|
|
|
coneMapper.SetInput(cone.GetOutput())
|
|
|
|
coneActor = vtk.vtkActor()
|
|
|
|
coneActor.SetMapper(coneMapper)
|
|
|
|
ren.AddActor(coneActor)
|
2001-05-18 17:59:59 -04:00
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
#---------------------------------------------------------------------------
|
2003-12-08 20:23:28 -05:00
|
|
|
# Using new event binder
|
|
|
|
wx_EVT_ADD_CONE = wx.NewEventType()
|
|
|
|
EVT_ADD_CONE = wx.PyEventBinder(wx_EVT_ADD_CONE, 1)
|
2001-05-18 17:59:59 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class AddCone(wx.PyEvent):
|
2000-07-15 15:51:35 -04:00
|
|
|
def __init__(self):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.PyEvent.__init__(self)
|
|
|
|
self.SetEventType(wx_EVT_ADD_CONE)
|
2000-07-15 15:51:35 -04:00
|
|
|
|
2001-05-18 17:59:59 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class HiddenCatcher(wx.Frame):
|
2000-07-15 15:51:35 -04:00
|
|
|
"""
|
|
|
|
The "catcher" frame in the second thread.
|
|
|
|
It is invisible. It's only job is to receive
|
2001-05-18 17:59:59 -04:00
|
|
|
Events from the main thread, and create
|
2000-07-15 15:51:35 -04:00
|
|
|
the appropriate windows.
|
2001-05-18 17:59:59 -04:00
|
|
|
"""
|
2000-07-15 15:51:35 -04:00
|
|
|
def __init__(self):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.Frame.__init__(self, None, -1, '')
|
|
|
|
self.Bind(EVT_ADD_CONE, self.AddCone)
|
2000-07-15 15:51:35 -04:00
|
|
|
|
2001-05-18 17:59:59 -04:00
|
|
|
def AddCone(self,evt):
|
2000-07-15 15:51:35 -04:00
|
|
|
add_cone()
|
2001-05-18 17:59:59 -04:00
|
|
|
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
#---------------------------------------------------------------------------
|
2001-05-18 17:59:59 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class SecondThreadApp(wx.App):
|
2000-07-15 15:51:35 -04:00
|
|
|
"""
|
|
|
|
wxApp that lives in the second thread.
|
2001-05-18 17:59:59 -04:00
|
|
|
"""
|
2000-07-15 15:51:35 -04:00
|
|
|
def OnInit(self):
|
|
|
|
catcher = HiddenCatcher()
|
|
|
|
#self.SetTopWindow(catcher)
|
2003-12-08 20:23:28 -05:00
|
|
|
self.catcher = catcher
|
2003-03-25 01:35:27 -05:00
|
|
|
return True
|
2001-05-18 17:59:59 -04:00
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2001-05-18 17:59:59 -04:00
|
|
|
def add_cone():
|
|
|
|
frame = VtkFrame(None, -1, "Cone")
|
2003-03-25 01:35:27 -05:00
|
|
|
frame.Show(True)
|
2001-05-18 17:59:59 -04:00
|
|
|
|