Esempio n. 1
1
            def __init__(self, parent=None):
                logging.debug("In SimpleTest::_QVtkWidgetCone::__init__()")
                super(_QVtkWidgetCone, self).__init__(parent)

                self.setWindowTitle("Test QVtkWidget with QMainWindow")
                self.setGeometry(QtCore.QRect(500, 500, 200, 200))

                centralwidget = QtGui.QWidget(self)
                centralwidget.setObjectName("centralwidget")
                gridLayout = QtGui.QGridLayout(centralwidget)
                gridLayout.setObjectName("gridLayout")
                self.setCentralWidget(centralwidget)

                ren = vtk.vtkRenderer()

                widget = QVtkWidget(centralwidget)
                widget.setWindowTitle("Test QVtkWidget with QMainWindow")
                widget.setGeometry(QtCore.QRect(1, 30, 200, 200))
                widget.GetRenderWindow().AddRenderer(ren)
                widget.GetRenderWindow().SetSize(200, 200)

                cone = vtk.vtkConeSource()
                cone.SetResolution(8)

                coneMapper = vtk.vtkPolyDataMapper()
                coneMapper.SetInput(cone.GetOutput())

                coneActor = vtk.vtkActor()
                coneActor.SetMapper(coneMapper)

                ren.AddActor(coneActor)
Esempio n. 2
0
    def test_image_plane_image_actor_with_vti(self):
        logging.debug("In VtkAxialSceneTest::test_image_plane_image_actor_with_vti()")
        from PySide import QtCore, QtGui
        
        from bloodstone.scenes.gui.qt.component.qvtkwidget import QVtkWidget

        reader = reader_vti(self.vtidir2)
        imagedata = reader_to_imagedata(reader)
        
        app = QtGui.QApplication(sys.argv)
        
        actions = {}
        actions["Slice"] = 0
        
        widget = QVtkWidget()
        widget.setWindowTitle("Test VtkAxial with image actor")
        widget.AddObserver("ExitEvent", lambda o, e, a=app: a.quit())
    
        scene = VtkImagePlane(widget)
        scene.input = reader
        scene.interactorStyle = vtk.vtkInteractorStyleTrackballCamera()
        scene.planeOrientation = VtkImagePlane.PLANE_ORIENTATION_AXIAL
        scene.enabled()
            
        def slotMouseWheelForwardEvent(obj, event, scene):
            #scene.pushByScalar += scene._imageData.GetSpacing()[2]*1
            #transform = vtk.vtkTransform()
            #transform.RotateWXYZ(356.084381104, -0.0432691946626, -0.052828669548, 0.0)
            #scene.transform = transform
            scene.updatePlane()
            scene.highlightPlane(True)
            scene.activateMargins(True)
            scene.updateMargins()
            scene.buildRepresentation()
            scene.window.Render()
            
        def slotMouseWheelBackwardEvent(obj, event, scene):
            scene.pushByScalar -= scene._imageData.GetSpacing()[2]*1
            scene.updatePlane()
            scene.highlightPlane(True)
            scene.activateMargins(True)
            scene.updateMargins()
            scene.buildRepresentation()
            scene.window.Render()
            
        #scene.interactorStyle = vtk.vtkInteractorStyleTrackballCamera()
        scene.interactorStyle.AddObserver('MouseWheelForwardEvent', 
            lambda o, e, i=scene: slotMouseWheelForwardEvent(o, e, i))
        scene.interactorStyle.AddObserver('MouseWheelBackwardEvent', 
            lambda o, e, i=scene: slotMouseWheelBackwardEvent(o, e, i))
        
        widget.show()
        
        app.exec_()
Esempio n. 3
0
    def test_qvtkwidget(self):
        logging.debug("In SimpleTest::test_qvtkwidget()")
        app = QtGui.QApplication(sys.argv)

        ren = vtk.vtkRenderer()
        ren.AddActor(self.coneActor)

        win = QVtkWidget()
        win.setWindowTitle("Test QVtkWidget")
        win.AddObserver("ExitEvent", lambda o, e, a=app: a.quit())
        win.GetRenderWindow().AddRenderer(ren)
        win.Initialize()
        win.Start()
        win.show()

        app.exec_()
Esempio n. 4
0
 def test_scene(self):
     logging.debug("In VtkSceneTest::test_scene()")
     from PySide import QtCore, QtGui
     
     from bloodstone.scenes.gui.qt.component.qvtkwidget import QVtkWidget
     
     app = QtGui.QApplication(sys.argv)
 
     widget = QVtkWidget()
     widget.setWindowTitle("Test VtkScene")
     widget.AddObserver("ExitEvent", lambda o, e, a=app: a.quit())
     
     scene = VtkScene(widget)
     scene.actor = self.coneActor
     scene.renderer.ResetCamera()
     scene.initialize()
     
     widget.show()
     
     app.exec_()