Пример #1
0
 def updateContents(self, input_ports):
     (data, keys) = input_ports
     layout = QtGui.QHBoxLayout()
     widg = Stack1DMainWindow(data_list=data, key_list=keys)
     layout.addWidget(widg)
     self.setLayout(layout)
     QCellWidget.updateContents(self, input_ports)
Пример #2
0
 def updateContents(self, input_ports):
     (data,keys) = input_ports
     layout = QtGui.QHBoxLayout()
     widg = Stack1DMainWindow(data_list=data, key_list=keys)
     layout.addWidget(widg)
     self.setLayout(layout)
     QCellWidget.updateContents(self, input_ports)
Пример #3
0
    def updateContents(self, inputPorts):
        """ updateContents(inputPorts: tuple)
        Updates the cell contents with new vtkRenderer
        
        """
        (renderView,) = inputPorts
        renWin = renderView.vtkInstance.GetRenderWindow()
        renWin.DoubleBufferOn()
        self.SetRenderWindow(renWin)
        renderView.vtkInstance.ResetCamera()
        self.addObserversToInteractorStyle()

        #        renWin = self.GetRenderWindow()
        #        renderers = [renderView.vtkInstance.GetRenderer()]
        #        iren = renWin.GetInteractor()
        # Update interactor style
        #         self.removeObserversFromInteractorStyle()
        #         if renderView==None:
        #             if iStyle==None:
        #                 iStyleInstance = vtk.vtkInteractorStyleTrackballCamera()
        #             else:
        #                 iStyleInstance = iStyle.vtkInstance
        #             iren.SetInteractorStyle(iStyleInstance)
        #         self.addObserversToInteractorStyle()
        # Capture window into history for playback
        # Call this at the end to capture the image after rendering
        QCellWidget.updateContents(self, inputPorts)
Пример #4
0
    def updateContents(self, inputPorts):
        """ updateContents(inputPorts: tuple)
        Updates the cell contents with new vtkRenderer
        
        """
        (renderView, ) = inputPorts
        renWin = renderView.vtkInstance.GetRenderWindow()
        renWin.DoubleBufferOn()
        self.SetRenderWindow(renWin)
        renderView.vtkInstance.ResetCamera()
        self.addObserversToInteractorStyle()
        
#        renWin = self.GetRenderWindow()
#        renderers = [renderView.vtkInstance.GetRenderer()]
#        iren = renWin.GetInteractor()
        # Update interactor style
#         self.removeObserversFromInteractorStyle()
#         if renderView==None:
#             if iStyle==None:
#                 iStyleInstance = vtk.vtkInteractorStyleTrackballCamera()
#             else:
#                 iStyleInstance = iStyle.vtkInstance
#             iren.SetInteractorStyle(iStyleInstance)
#         self.addObserversToInteractorStyle()
        # Capture window into history for playback
        # Call this at the end to capture the image after rendering
        QCellWidget.updateContents(self, inputPorts)
Пример #5
0
 def updateContents(self, input_ports):
     dict_list, = input_ports
     layout = QtGui.QHBoxLayout()
     widg = displaydict.DisplayDict()
     widg.set_tree(dict_list)
     layout.addWidget(widg)
     self.setLayout(layout)
     QCellWidget.updateContents(self, input_ports)
Пример #6
0
 def updateContents(self, input_ports):
     dict_list, = input_ports
     layout = QtGui.QHBoxLayout()
     widg = displaydict.DisplayDict()
     widg.set_tree(dict_list)
     layout.addWidget(widg)
     self.setLayout(layout)
     QCellWidget.updateContents(self, input_ports)
Пример #7
0
    def updateContents(self, inputPorts):
        """ updateContents(inputPorts: tuple) -> None
        Update the widget contents based on the input data
        
        """
        (fileValue, ) = inputPorts
        if fileValue:
            img = QtGui.QImage()
            if img.load(fileValue.name):
                self.originalPix = QtGui.QPixmap.fromImage(img)
                self.label.setPixmap(self.originalPix.scaled(self.label.size(),
                                                         QtCore.Qt.KeepAspectRatio,
                                                         QtCore.Qt.SmoothTransformation))
            else:
                self.label.setText("Invalid image file!")

        QCellWidget.updateContents(self, inputPorts)
Пример #8
0
    def updateContents(self, inputPorts, cameralist = None):
        """ updateContents(inputPorts: tuple)
        Updates the cell contents with new vtkRenderer
        
        """
        renWin = self.GetRenderWindow()
        for iHandler in self.iHandlers:
            if iHandler.observer:
                iHandler.observer.vtkInstance.SetInteractor(None)
            iHandler.clear()

        # Remove old renderers first
        oldRenderers = self.getRendererList()
        for renderer in oldRenderers:
            renWin.RemoveRenderer(renderer)
            renderer.SetRenderWindow(None)
        del oldRenderers

        (renderers, renderView, self.iHandlers, iStyle, picker) = inputPorts
        if renderView:
            renderView.vtkInstance.SetupRenderWindow(renWin)
            renderers = [renderView.vtkInstance.GetRenderer()]
        self.renderer_maps = {}
        self.usecameras = False
        if cameralist != None and len(cameralist) == len(renderers):
            self.usecameras = True
        j = 0
        for renderer in renderers:
            if renderView==None:
                vtkInstance = renderer.vtkInstance
                renWin.AddRenderer(vtkInstance)
                self.renderer_maps[vtkInstance] = renderer.moduleInfo['moduleId']
            else:
                vtkInstance = renderer
            if hasattr(vtkInstance, 'IsActiveCameraCreated'):
                if self.usecameras:
                    vtkInstance.SetActiveCamera(cameralist[j])
                    j = j + 1
                if not vtkInstance.IsActiveCameraCreated():
                    vtkInstance.ResetCamera()
                else:
                    vtkInstance.ResetCameraClippingRange()
            
        iren = renWin.GetInteractor()
        if picker:
            iren.SetPicker(picker.vtkInstance)
            
        # Update interactor style
        self.removeObserversFromInteractorStyle()
        if renderView==None:
            if iStyle==None:
                iStyleInstance = vtk.vtkInteractorStyleTrackballCamera()
            else:
                iStyleInstance = iStyle.vtkInstance
            iren.SetInteractorStyle(iStyleInstance)
        self.addObserversToInteractorStyle()
        
        for iHandler in self.iHandlers:
            if iHandler.observer:
                iHandler.observer.vtkInstance.SetInteractor(iren)
        renWin.Render()

        # Capture window into history for playback
        # Call this at the end to capture the image after rendering
        QCellWidget.updateContents(self, inputPorts)
Пример #9
0
    def updateContents(self, inputPorts, cameralist=None):
        """ updateContents(inputPorts: tuple)
        Updates the cell contents with new vtkRenderer
        
        """
        renWin = self.GetRenderWindow()
        for iHandler in self.iHandlers:
            if iHandler.observer:
                iHandler.observer.vtkInstance.SetInteractor(None)
            iHandler.clear()

        # Remove old renderers first
        oldRenderers = self.getRendererList()
        for renderer in oldRenderers:
            renWin.RemoveRenderer(renderer)
            renderer.SetRenderWindow(None)
        del oldRenderers

        (renderers, renderView, self.iHandlers, iStyle, picker) = inputPorts
        if renderView:
            renderView.vtkInstance.SetRenderWindow(renWin)
            renderView.vtkInstance.ResetCamera()
            self.addObserversToInteractorStyle()
            renderers = [renderView.vtkInstance.GetRenderer()]
        self.renderer_maps = {}
        self.usecameras = False
        if cameralist is not None and len(cameralist) == len(renderers):
            self.usecameras = True
        j = 0
        for renderer in renderers:
            if renderView == None:
                vtkInstance = renderer
                # Check deprecated vtkInstance
                if hasattr(renderer, 'vtkInstance'):
                    vtkInstance = renderer.vtkInstance
                    # Old scripts may call this without setting module_id
                    if hasattr(renderer, 'module_id'):
                        self.renderer_maps[id(
                            vtkInstance)] = renderer.module_id
                renWin.AddRenderer(vtkInstance)
            else:
                vtkInstance = renderer
            if hasattr(vtkInstance, 'IsActiveCameraCreated'):
                if self.usecameras:
                    vtkInstance.SetActiveCamera(cameralist[j])
                    j = j + 1
                if not vtkInstance.IsActiveCameraCreated():
                    vtkInstance.ResetCamera()
                else:
                    vtkInstance.ResetCameraClippingRange()

        iren = renWin.GetInteractor()
        if picker:
            if hasattr(picker, 'vtkInstance'):
                picker = picker.vtkInstance
            iren.SetPicker(picker)

        # Update interactor style
        self.removeObserversFromInteractorStyle()
        if renderView == None:
            if iStyle == None:
                iStyleInstance = vtk.vtkInteractorStyleTrackballCamera()
            else:
                iStyleInstance = iStyle
                # Check deprecated vtkInstance
                if hasattr(iStyleInstance, 'vtkInstance'):
                    iStyleInstance = iStyleInstance.vtkInstance
            iren.SetInteractorStyle(iStyleInstance)
        self.addObserversToInteractorStyle()

        for i in xrange(len(self.iHandlers)):
            iHandler = self.iHandlers[i]
            if hasattr(iHandler, 'vtkInstance'):
                iHandler = iHandler.vtkInstance
                self.iHandler[i] = iHandler
            if iHandler.observer:
                observer = iHandler.observer
                if hasattr(observer, 'vtkInstance'):
                    observer = observer.vtkInstance
                observer.SetInteractor(iren)
        renWin.Render()

        # Capture window into history for playback
        # Call this at the end to capture the image after rendering
        QCellWidget.updateContents(self, inputPorts)