Exemplo n.º 1
0
    def SetRenderWindow(self, w):
        """ SetRenderWindow(w: vtkRenderWindow)        
        Set a new render window to QVTKWidget and initialize the
        interactor as well
        
        """
        if w == self.mRenWin:
            return

        if self.mRenWin:
            if system.systemType != 'Linux':
                self.mRenWin.SetInteractor(None)
            if self.mRenWin.GetMapped():
                self.mRenWin.Finalize()

        self.mRenWin = w

        if self.mRenWin:
            self.mRenWin.Register(None)
            if self.mRenWin.GetMapped():
                self.mRenWin.Finalize()
            if system.systemType == 'Linux':
                try:
                    vp = '_%s_void_p' % (hex(int(
                        QtGui.QX11Info.display()))[2:])
                except TypeError:
                    #This was change for PyQt4.2
                    if isinstance(QtGui.QX11Info.display(), QtGui.Display):
                        display = sip.unwrapinstance(QtGui.QX11Info.display())
                        vp = '_%s_void_p' % (hex(display)[2:])
                self.mRenWin.SetDisplayId(vp)
                self.resizeWindow(1, 1)
            self.mRenWin.SetWindowInfo(str(int(self.winId())))
            if self.isVisible():
                self.mRenWin.Start()

            if not self.mRenWin.GetInteractor():
                iren = vtksnl.vtkRenderWindowInteractor()
                if system.systemType == 'Darwin':
                    iren.InstallMessageProcOff()
                iren.SetRenderWindow(self.mRenWin)
                iren.Initialize()
                if system.systemType == 'Linux':
                    system.XDestroyWindow(self.mRenWin.GetGenericDisplayId(),
                                          self.mRenWin.GetGenericWindowId())
                self.mRenWin.SetWindowInfo(str(int(self.winId())))
                self.resizeWindow(self.width(), self.height())
                self.mRenWin.SetPosition(self.x(), self.y())
Exemplo n.º 2
0
    def SetRenderWindow(self, w):
        """ SetRenderWindow(w: vtkRenderWindow)        
        Set a new render window to QVTKViewWidget and initialize the
        interactor as well
        
        """
        if w == self.mRenWin:
            return

        if self.mRenWin:
            if self.mRenWin.GetMapped():
                self.mRenWin.Finalize()

        self.mRenWin = w

        if self.mRenWin:
            self.mRenWin.Register(None)
            if system.systemType == 'Linux':
                try:
                    vp = '_%s_void_p' % (hex(int(
                        QtGui.QX11Info.display()))[2:])
                except TypeError:
                    #This was change for PyQt4.2
                    if isinstance(QtGui.QX11Info.display(), QtGui.Display):
                        display = sip.unwrapinstance(QtGui.QX11Info.display())
                        vp = '_%s_void_p' % (hex(display)[2:])
                self.mRenWin.SetDisplayId(vp)
                if not self.mRenWin.GetMapped():
                    self.mRenWin.GetInteractor().Initialize()
                    system.XDestroyWindow(self.mRenWin.GetGenericDisplayId(),
                                          self.mRenWin.GetGenericWindowId())
                    self.mRenWin.Finalize()
                self.mRenWin.SetWindowInfo(str(int(self.winId())))
            else:
                self.mRenWin.SetWindowInfo(str(int(self.winId())))
            if self.isVisible():
                self.mRenWin.Start()