[vtkusers] Multiple wxVTKRenderWindow: Segmentation fault (core dumped)

Uwe Rempler rempler at mechbau.uni-stuttgart.de
Thu Jan 22 05:32:52 EST 2004


<mailto:vtkusers at vtk.org>hi list,

i'm having big problems starting multiple instances of wxVTKRenderWindow():
opening a second wxFrame() including a wxVTKRenderWindow() or a 
wxVTKRenderWindowInteractor always produces a core dump (see sample code 
below)
is it innately not possible using multiple VTKRenderWindows or do i have 
an error in reasoning?
is here anybody who accomplished opening more than one VTKRenderWindow() 
from inside one application (whatever language or GUI you are using)?
already had a similar problem using Tkinter() for GUI...
PLEASE HELP - don't know how to handle this  error - i'm really totally 
at a loss

my configuration:
** python: Python 2.3.3 (#2, Jan  4 2004, 12:24:16)
[GCC 3.3.3 20031229 (prerelease) (Debian)] on linux2
** wxpython: 2.4.2.4
** vtk: 4.2.4-3

greetings
uwe


#!/usr/bin/python


# 
------------------------------------------------------------------------------
from wxPython.wx import *
import vtk
from vtk.wx.wxVTKRenderWindowInteractor import *
from vtk.wx.wxVTKRenderWindow import *


# 
------------------------------------------------------------------------------
[wxID_PANMAINWIN, wxID_PANMAINWINBUTTON1,
 wxID_PANMAINWINBUTTON2,
] = map(lambda _init_ctrls: wxNewId(), range(3))
[wxID_PANVISWIN, wxID_PANVISWINBTNCLOSE,
] = map(lambda _init_ctrls: wxNewId(), range(2))


# 
------------------------------------------------------------------------------
class PanVisWin(wxFrame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wxFrame.__init__(self, id=wxID_PANVISWIN,
              name='PanVisualizeWindows', parent=prnt, pos=wxPoint(640, 
393),
              size=wxSize(606, 624), style=wxDEFAULT_FRAME_STYLE,
              title='PanVisWin')
        self.SetClientSize(wxSize(606, 624))
        self.button1 = wxButton(id=wxID_PANVISWINBTNCLOSE, label='Close',
              name='button1', parent=self, pos=wxPoint(0, 0), 
size=wxSize(80,
              29), style=0)
        EVT_BUTTON(self.button1, wxID_PANVISWINBTNCLOSE,
              self.OncloseButton)
        # ----------------------------- VTK BEGIN 
------------------------------
        self.widget = wxVTKRenderWindow(self, -1)
        self.ren = vtkRenderer()
        self.widget.GetRenderWindow().AddRenderer(self.ren)
        self.cone = vtkConeSource()
        self.cone.SetResolution(8)
        self.coneMapper = vtkPolyDataMapper()
        self.coneMapper.SetInput(self.cone.GetOutput())
        self.coneActor = vtkActor()
        self.coneActor.SetMapper(self.coneMapper)
        self.ren.AddActor(self.coneActor)
        # ------------------------------- VTK END 
------------------------------

    def __init__(self, parent):
        self._init_ctrls(parent)

    def OncloseButton(self, event):
        self.VisWinClose()

    def VisWinClose(self):
        self.Destroy()
        self.Close()


# 
------------------------------------------------------------------------------
class PanMainWin(wxFrame):
    def _init_ctrls(self, prnt):
        wxFrame.__init__(self, id=wxID_PANMAINWIN,
              name='PanMainWin', parent=prnt, pos=wxPoint(374, 482),
              size=wxSize(1008, 60), style=wxDEFAULT_FRAME_STYLE,
              title='pan at develop')
        self.SetClientSize(wxSize(1008, 29))
        self.button1 = wxButton(id=wxID_PANMAINWINBUTTON1, label='New',
              name='button1', parent=self, pos=wxPoint(0, 0), 
size=wxSize(80,
              29), style=0)
        self.button2 = wxButton(id=wxID_PANMAINWINBUTTON2, label='Exit',
              name='button2', parent=self, pos=wxPoint(80, 0), 
size=wxSize(80,
              29), style=0)
        EVT_BUTTON(self.button1, wxID_PANMAINWINBUTTON1,
              self.OnnewButton)
        EVT_BUTTON(self.button2, wxID_PANMAINWINBUTTON2,
              self.OnexitButton)

    def __init__(self, parent, app):
        self.app = app
        self._init_ctrls(parent)

    def OnnewButton(self, event):
        self.MainWinNew()

    def OnexitButton(self, event):
        self.MainWinQuit()

    def MainWinNew(self):
    self.app.NewRenderWindow()

    def MainWinQuit(self):
        self.app.PanQuit()


# 
------------------------------------------------------------------------------
class PanApp(wxApp):
    def OnInit(self):
        wxInitAllImageHandlers()
        self.main = create(None, self)
        self.SetTopWindow(self.main)
        self.main.Show();self.main.Hide();self.main.Show()
        return True

    def PanQuit(self):
        self.ExitMainLoop()

    def NewRenderWindow(self):
        self.VisWin = createVisWin(None)
        self.VisWin.Show();self.main.Hide();self.main.Show()


# 
------------------------------------------------------------------------------
def main():
    application = PanApp(0)
    application.MainLoop()

def create(parent, app):
    return PanMainWin(parent, app)

def createVisWin(parent):
    return PanVisWin(parent)


# 
------------------------------------------------------------------------------
if __name__ == '__main__':
    main()



More information about the vtkusers mailing list