Esempio n. 1
0
 def __init__(self):
     super().__init__()
     # WINDOW
     self._widget = QWidget(self)
     self._widget.resize(500, 500)
     self.resize(500, 500)
     self.setCentralWidget(self._widget)
     self._widget.setAttribute(Qt.WA_AcceptTouchEvents
                               | Qt.WA_TranslucentBackground)
     self._widget.setWindowFlags(Qt.NoDropShadowWindowHint)
     # VTK
     self._vtk_widget = QVTKRenderWindowInteractor(self._widget)
     self._vtk_widget.SetInteractorStyle(
         vtk.vtkInteractorStyleMultiTouchCamera())
     self._vtk_widget.resize(500, 500)
     # WIDGET
     self._widget1 = QWidget(self._widget)
     self._widget1.resize(100, 100)
     self._widget1.setStyleSheet(
         'background-color: rgba(120, 120, 120, 100)')
     self._widget1.move(100, 100)
     self._test_btn1 = QPushButton('jaiodhjiajd1', self._widget1)
     self._test_btn1.resize(70, 30)
     self._test_btn1.move(50, 30)
     self._test_btn1.show()
     self._widget2 = QWidget(self._widget)
     self._widget2.resize(100, 100)
     self._widget2.setStyleSheet(
         'background-color: rgba(120, 120, 120, 100)')
     self._test_btn2 = QPushButton('sdoijajdiada', self._widget2)
     self._test_btn2.resize(70, 30)
     self._test_btn2.move(50, 50)
     self._widget2.move(150, 150)
     self._widget2.show()
     # UI
     self._btn = QPushButton('btn1', self._widget)
     self._btn.resize(30, 30)
     self._btn.move(300, 280)
     self._btn.clicked.connect(self._set_widget1_visible)
     self._btn.show()
     self._btn2 = QPushButton('btn2', self._widget)
     self._btn2.resize(30, 30)
     self._btn2.move(300, 300)
     self._btn2.clicked.connect(self._set_widget2_visible)
     self._btn2.show()
     # ATTR
     self._a = False
     self._b = False
     # RENDER
     self._render = vtk.vtkRenderer()
     self._ren_win = self._vtk_widget.GetRenderWindow()
     self._render.AddActor(self.axes())
Esempio n. 2
0
    def __init__(self, parent, dataPath=None):
        super(PCDviewer, self).__init__(parent)
        self.interactor = QVTKRenderWindowInteractor(self)
        self.layout = QtWidgets.QHBoxLayout()
        self.layout.addWidget(self.interactor)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(self.layout)
        self.pointCloud = VtkPointCloud()
        self.actors = []
        if dataPath != None:
            self.add_newData(dataPath)

    # Renderer
        renderer = vtk.vtkRenderer()
        renderer.AddActor(self.pointCloud.vtkActor)
        #cubeActor = self.addCubeAxesActor(renderer)
        #renderer.AddActor(cubeActor)
        # Scalar Bar

        #renderer.SetBackground(.2, .3, .4)
        #colors=vtk.vtkNamedColors()
        #colors.SetColor("BkgColor",[179,204,255,255])
        #renderer.SetBackground(colors.GetColor3d("BkgColor"))
        renderer.ResetCamera()
        #renderer.SetLayer(1)

        # Render Window
        renderWindow = self.interactor.GetRenderWindow()
        #renderWindow = vtk.vtkRenderWindow()
        print(renderWindow)
        #renderWindow.SetNumberOfLayers(2)
        renderWindow.AddRenderer(renderer)
        #renderWindow.AddRenderer(self.addLogo())

        # Interactor
        #renderWindowInteractor = vtk.vtkRenderWindowInteractor()
        self.interactor.SetRenderWindow(renderWindow)
        self.interactor.SetInteractorStyle(
            vtk.vtkInteractorStyleTrackballCamera())
        # Scalar Bar
        #self.addScalarBar(self.pointCloud.getLUT())
        #renderer.AddActor(self.addScalarBar(self.pointCloud.getLUT()))
        #renderWindow.SetInteractor(self.interactor)
        # Logo
        #self.addLogo()
        # Begin Interaction
        renderWindow.Render()
        renderWindow.SetWindowName("XYZ Data Viewer:" + "xyz")
        self.interactor.Start()
        #renderWindowInteractor.Start()
        # Pack to class
        self.renderer = renderer
 def __init__(self, file_names, mean_file_name):
     super(MyPyQT_Form, self).__init__()
     super(Ui_Form, self).__init__(file_names, mean_file_name)
     self.setupUi(self)
     self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
     self.ren = vtk.vtkRenderer()
     self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
     self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
     self.vtkWidget.resize(999, 1109)  # 设置vtk 交互窗口大小
     self.camera = vtk.vtkCamera()
     self.actor = vtk.vtkActor()
     self.loadActor()
     self.CreateScene()
Esempio n. 4
0
 def init_3drender(self):
     self.view3d.close()
     self.horizontalLayout.removeWidget(self.view3d)
     self.view3d = QVTKRenderWindowInteractor(self.centralwidget)
     self.view3d.setObjectName("vtkWidget")
     self.horizontalLayout.addWidget(self.view3d)
     self.ren = vtk.vtkRenderer()
     self.view3d.GetRenderWindow().AddRenderer(self.ren)
     self.iren = self.view3d.GetRenderWindow().GetInteractor()
     colors = vtk.vtkNamedColors()
     colors.SetColor("BkgColor", [0, 0, 0, 255])
     self.ren.SetBackground(colors.GetColor3d("BkgColor"))
     self.iren.Initialize()
Esempio n. 5
0
class VTK2d(QtWidgets.QFrame):
    def __init__(self, parent):
        super(VTK2d, self).__init__(parent)
        self.iren = QVTKRenderWindowInteractor()
        self.vl = QtWidgets.QHBoxLayout()
        self.vl.addWidget(self.iren)
        self.setLayout(self.vl)
        self.iren.Initialize()
        self.view = vtk.vtkContextView()
        self.chart_matrix = vtk.vtkChartMatrix()
        self.view.GetScene().AddItem(self.chart_matrix)
        self.ren = self.view.GetRenderer()
        self.iren.GetRenderWindow().AddRenderer(self.ren)
Esempio n. 6
0
    def window_initialization(self):
        vertical_layout = QVBoxLayout()
        vertical_layout.setContentsMargins(0,0,0,0)
        self.vtk_widget = QVTKRenderWindowInteractor(self)
        self.vtk_widget.setSizePolicy(QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored))
        vertical_layout.addWidget(self.vtk_widget)
        self.renderer = vtk.vtkRenderer()
        self.vtk_widget.GetRenderWindow().AddRenderer(self.renderer)
        self.renderer_interactor = self.vtk_widget.GetRenderWindow().GetInteractor()
        self.renderer.SetBackground(0,0,0)

        self.setLayout(vertical_layout)
        self.renderer_interactor.Initialize()
Esempio n. 7
0
class ViewExperimentalVTKTab(QTabWidget):
    """
    for debugging VTK stuff
    TODO: REMOVE THIS
    """
    def __init__(self, parent):
        super(QTabWidget, self).__init__(parent)
        layout = QVBoxLayout()
        self.setLayout(layout)

        test_gb = QGroupBox("test groupbox")
        layout.addWidget(test_gb)

        hbox = QHBoxLayout()
        test_gb.setLayout(hbox)

        # button_test = QRadioButton("test button")
        # hbox.addWidget(button_test)
        # button_test.toggled.connect(self.button_test)
        #
        # button_test2 = QRadioButton("test button2")
        # hbox.addWidget(button_test2)
        # button_test2.toggled.connect(self.button_test2)

        self.frame = QFrame()
        self.vl = QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)

        self.colors = vtk.vtkNamedColors()

        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(0, 0, 0)
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()

        test = VTKSpecificActor("torus", (1, 2, 3))
        self.ren.AddActor(test.actor)

        # set camera
        camera = vtk.vtkCamera()
        camera.SetFocalPoint(0, 0, 0)

        self.ren.SetActiveCamera(camera)

        self.frame.setLayout(self.vl)
        layout.addWidget(self.frame)

        self.show()
        self.iren.Initialize()
        self.iren.Start()
Esempio n. 8
0
    def __init__(self, parent=None, **kw):
        QVTKRenderWindowInteractor.__init__(self, parent, **kw)
        """
         # create the widget
            widget = QVTKRenderWindowInteractor()
            widget.Initialize()
            widget.Start()
            # if you don't want the 'q' key to exit comment this.
            widget.AddObserver("ExitEvent", lambda o, e, a=app: a.quit())
        
            ren = vtk.vtkRenderer()
            widget.GetRenderWindow().AddRenderer(ren)
        
            cone = vtk.vtkConeSource()
            cone.SetResolution(8)
        
            coneMapper = vtk.vtkPolyDataMapper()
            coneMapper.SetInputConnection(cone.GetOutputPort())
        
            coneActor = vtk.vtkActor()
            coneActor.SetMapper(coneMapper)
        
            ren.AddActor(coneActor)

        """
        self.tracks = []
        self.Initialize()
        self.Start()
        self.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
        self.ren = vtk.vtkRenderer()
        self.actor = vtk.vtkActor()
        self.mapper = vtk.vtkPolyDataMapper()
        self.line_poly_data = vtk.vtkPolyData()

        # all you need to reset the tracks
        self.lines_cells = vtk.vtkCellArray()
        self.points = vtk.vtkPoints()
        self.colors = vtk.vtkUnsignedCharArray()
        self.point_actors = []
        self.text_actors = []

        self.GetRenderWindow().AddRenderer(self.ren)
        self.mapper.SetInputData(self.line_poly_data)

        self.actor.SetMapper(self.mapper)

        self.actor.GetProperty().SetLineWidth(3)
        self.actor.GetProperty().SetRenderLinesAsTubes(True)

        self.ren.AddActor(self.actor)
        self.ren.SetBackground(1, 1, 1)
Esempio n. 9
0
class MainWindow(Qt.QMainWindow):
    def __init__(self, parent=None):
        Qt.QMainWindow.__init__(self, parent)

        self.frame = Qt.QFrame()
        self.vl = Qt.QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)

        self.ren = vtk.vtkRenderer()
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()

        # Create source
        sphere = vtk.vtkSphereSource()
        sphere.SetCenter(0, 0, 0)
        sphere.SetRadius(1.0)
        sphere.SetPhiResolution(10)

        # Create a mapper
        sphere_mapper = vtk.vtkPolyDataMapper()
        sphere_mapper.SetInputConnection(sphere.GetOutputPort())

        # Create an actor
        sphere_actor = vtk.vtkActor()
        sphere_actor.SetMapper(sphere_mapper)

        cube = vtk.vtkCubeSource()
        cube.SetCenter(0, 0, 0)
        cube.SetXLength(1)
        cube.SetYLength(1)
        cube.SetZLength(5)

        cube_mapper = vtk.vtkPolyDataMapper()
        cube_mapper.SetInputConnection(cube.GetOutputPort())

        cube_actor = vtk.vtkActor()
        cube_actor.SetMapper(cube_mapper)

        self.vtkWidget.SetInteractorStyle(MouseInteractorStyle())

        self.ren.AddActor(sphere_actor)
        self.ren.AddActor(cube_actor)
        self.ren.SetBackground(0.1, 0.1, 0.1)
        self.ren.ResetCamera()
        self.frame.setLayout(self.vl)
        self.setCentralWidget(self.frame)

        self.show()
        self.iren.Initialize()
        self.iren.Start()
Esempio n. 10
0
    def __init__(self):
        super().__init__()
        # SIGNAL
        self._nuc = GuideRemote()
        self._nuc.sign_data.connect(self._data)
        self._nuc.sign_event.connect(self._event)
        self._nuc.sign_error.connect(self._error)

        # DATA
        self._lines = dict()
        self._lines[1] = OneLine([1, 0, 0], 3)
        self._lines[2] = OneLine([0, 0, 1], 3)
        self._lines[1].set_points([0.72, 0.63, 0.0], [0.72, 0.63, 4.8])
        self._lines[2].set_points([7.0, 0.63, 0.0], [7.0, 0.63, 4.8])

        # VTK
        self._vtk_widget = QVTKRenderWindowInteractor()
        self._render = vtk.vtkRenderer()
        self._render.AddActor(self._lines[1].actor)
        self._render.AddActor(self._lines[2].actor)
        self._render.SetBackground(1, 1, 1)
        self._ren_win = self._vtk_widget.GetRenderWindow()
        self._ren_win.AddRenderer(self._render)
        self._ren_win.GetInteractor().SetInteractorStyle(
            vtk.vtkInteractorStyleMultiTouchCamera())

        # TIMER
        self._ren_win.GetInteractor().AddObserver('TimerEvent',
                                                  self._render_timer)
        self._ren_win.GetInteractor().CreateRepeatingTimer(10)

        # QT
        self._ui = Ui_MainWindow()
        self._ui.setupUi(self)
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
                            | Qt.NoDropShadowWindowHint)
        self.setAttribute(Qt.WA_TranslucentBackground)  # 半透明
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool)
        self.setWindowOpacity(1)
        self.move(20, (QApplication.primaryScreen().size().height() -
                       self.size().height()) / 2)

        # LAUNCH
        self._ren_win.SetSize(700, 700)
        self._vtk_widget.Start()
        self._vtk_widget.showFullScreen()

        # QT BTN
        self._ui.tcp_works.stateChanged.connect(self._set_tcp_launch)
        self._ui.btn_quit.clicked.connect(self.exit)
Esempio n. 11
0
 def __init__(self):
     super().__init__()
     self._vtk_widget = QVTKRenderWindowInteractor()
     self._ren = vtk.vtkRenderer()
     self._ren_win = self._vtk_widget.GetRenderWindow()
     self._ren_win.AddRenderer(self._ren)
     self._ren_win.GetInteractor().SetInteractorStyle(
         vtk.vtkInteractorStyleMultiTouchCamera())
     self._ren_win.GetInteractor().AddObserver('TimerEvent',
                                               self._render_timer)
     self._ren_win.GetInteractor().CreateRepeatingTimer(100)
     # ADD ACTOR
     self._ren.AddActor(self.axes())
     self._ren_win.GetInteractor().Initialize()
     self._ren.SetTexturedBackground(True)
     # self._ren.SetBackgroundTexture()
     self._vtk_widget.Start()
     self._vtk_widget.showFullScreen()
     # UI
     self._ui = Ui_MainWindow()
     self._ui.setupUi(self)
     self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
                         | Qt.NoDropShadowWindowHint)
     self.setAttribute(Qt.WA_TranslucentBackground)  # 半透明
     self.move(20,
               int((QApplication.primaryScreen().size().height() -
                    self.size().height()) / 2))  # 距离左侧20中心
     # TEXT
     self._txt = Text(color=(1, 0, 0), size=250, bold=True)
     self._txt.set_input('forward')
     self._txt1 = Text(color=(0, 1, 0), size=150, bold=True)
     self._txt1.set_font_pos(500, 500)
     self._txt1.set_input('I am your dad')
     self._ren.AddActor(self._txt1.txt)
     win_size = self._vtk_widget.GetSize()
     self._txt.set_font_pos(int(win_size[0] / 2),
                            int(win_size[1] / 2 + 200))  # 设置字体在屏幕中间
     # BTN
     self._ui.btn_stop.clicked.connect(self.exit)
     self._ui.btn_welcome.clicked.connect(
         lambda: self._txt.set_input('welcome'))
     self._ui.btn_forward.clicked.connect(
         lambda: self._txt.set_input('forward'))
     self._ui.btn_back.clicked.connect(lambda: self._txt.set_input('back'))
     self._ui.btn_add_text.clicked.connect(
         lambda: self._ren.AddActor(self._txt.txt))
     self._ui.btn_del_text.clicked.connect(
         lambda: self._ren.RemoveActor(self._txt.txt))
     # SIGNAL
     signal.signal(signal.SIGINT, self.closeEvent)
Esempio n. 12
0
class RenderWidget:
    def __init__(self, renderer=None, parent=None):

        # Every QT app needs a QApplication
        self.app = QApplication.instance()
        if self.app is None:
            self.app = QApplication(sys.argv)

        # Create the widget
        if renderer is None:
            self.renderer = vtk.vtkRenderer()
        else:
            self.renderer = renderer

        self.widget = QVTKRenderWindowInteractor(parent)

        self.widget.Initialize()
        self.widget.Start()

        # Set the interactor style
        self.widget.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())

        # Get the render window from the widget
        self.renderWindow = self.widget.GetRenderWindow()
        self.renderWindow.AddRenderer(self.renderer)

        # show the widget
        self.widget.show()

    def exec_(self):
        self.widget.show()  #make sure we are shown
        self.app.exec_()
    def __init__(self, **kwargs):
        super(volumeWindow, self).__init__()
        self._filePath = kwargs.get('dirPath', None)
        initWidth = 300
        initHeight = 300
        self.setWindowTitle('AtomicMedical')
        self.gridLayout = QGridLayout()
        self.setGeometry(0, 0, initWidth, initHeight)

        self.vtkWidget = QVTKRenderWindowInteractor(self)
        self.vtkWidget.resize(initWidth, initHeight)

        self.gridLayout.addWidget(self.vtkWidget)
        self.initUI()
Esempio n. 14
0
    def __init__(self):
        QVTKRenderWindowInteractor.__init__(self)

        self.vtkWidget = QVTKRenderWindowInteractor()

        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(1, 1, 1)
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)

        # Create points
        self.points = vtk.vtkPoints()

        # Setup scales. This can also be an Int array
        # char is used since it takes the least memory
        self.colors = vtk.vtkUnsignedCharArray()
        self.colors.SetName("colors")
        self.colors.SetNumberOfComponents(4)

        # Combine into a polydata
        polyData = vtk.vtkPolyData()
        polyData.SetPoints(self.points)
        polyData.GetPointData().SetScalars(self.colors)

        # Create anything you want here, we will use a cube for the demo.
        cubeSource = vtk.vtkCubeSource()

        self.glyph3D = vtk.vtkGlyph3D()
        self.glyph3D.SetColorModeToColorByScalar()
        self.glyph3D.SetSourceConnection(cubeSource.GetOutputPort())
        self.glyph3D.SetInputData(polyData)
        self.glyph3D.ScalingOff(
        )  #Needed, otherwise only the red cube is visible
        self.glyph3D.Update()

        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(self.glyph3D.GetOutputPort())

        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        actor.RotateY(45.0)
        actor.RotateZ(45.0)
        actor.RotateX(-45.0)

        self.ren.AddActor(actor)
        self.ren.ResetCamera()

        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
        self.iren.Initialize()
        self.iren.Start()
        self.algo = Eval()
Esempio n. 15
0
    def setup():
        renderer = vtk.vtkRenderer()
        # renderer.SetBackground(1, 1, 1)
        frame = QtWidgets.QFrame()
        vtk_widget = QVTKRenderWindowInteractor()
        interactor = vtk_widget.GetRenderWindow().GetInteractor()
        render_window = vtk_widget.GetRenderWindow()

        frame.setAutoFillBackground(True)
        vtk_widget.GetRenderWindow().AddRenderer(renderer)
        render_window.AddRenderer(renderer)
        interactor.SetRenderWindow(render_window)
        interactor.SetInteractorStyle(CustomInteractorStyle())
        return renderer, frame, vtk_widget, interactor, render_window
    def __setupGUI(self):

        self.setWindowTitle("MeshViewer")
        self.resize(800, 600)
        
        # vtk window
        
        self.vtkwidget = QVTKRenderWindowInteractor(self) # "self" sinon, rien ne s'affiche
        self.vtkwidget.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, 
                                                  QSizePolicy.Expanding))
        self.vtkwidget.setMinimumSize(QSize(300, 300));
        self.vtkwidget.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
        
                      
        self.vtkwidget.Initialize() 
                       
        self.renderer = vtk.vtkRenderer()
        self.renderer.SetBackground(1.0, 1.0, 1.0)     
        self.vtkwidget.GetRenderWindow().AddRenderer(self.renderer) 
        
        style = vtk.vtkInteractorStyleTrackballCamera()
        self.vtkwidget.SetInteractorStyle(style) 


        hbox = QHBoxLayout()
        self.setLayout(hbox)
        hbox.addWidget(self.vtkwidget)
        
        pan = QFrame()
        pan.setMaximumSize(QSize(200,999999))
        hbox.addWidget(pan)
        
        vbox = QVBoxLayout()
        pan.setLayout(vbox)
        
        self.startBut = QPushButton(self.tr("start!"))
        self.startBut.clicked.connect(self.startSlot)
        vbox.addWidget(self.startBut)
        
        groupBox = QGroupBox("Infos")
        self.steplabel = QLabel("step # 0")
        self.loadlabel = QLabel("lambda = %2.8f" % 0)
        gbox = QVBoxLayout()
        groupBox.setLayout(gbox) 
        gbox.addWidget(self.steplabel)   
        gbox.addWidget(self.loadlabel)   
        vbox.addWidget(groupBox)
        
        vbox.addStretch(1)
Esempio n. 17
0
 def __init__(self):
     super().__init__()
     # WIDGET
     self._widget = QWidget(self)
     self._widget.setAttribute(Qt.WA_TranslucentBackground | Qt.SubWindow)
     self.setCentralWidget(self._widget)
     self.resize(900, 900)
     self._widget.event = types.MethodType(self._handle_event, self._widget)
     self._widget.setAttribute(Qt.WA_AcceptTouchEvents)  # 与半透明分开设置
     # VTK
     self._vtk_widget = QVTKRenderWindowInteractor(self._widget)
     self._vtk_widget.resize(900, 900)
     self._ren_win = self._vtk_widget.GetRenderWindow()
     # CAMERA
     self._interactor = self._ren_win.GetInteractor()
     self._vtk_widget.SetInteractorStyle(MyEvent())
     # RENDER
     self._renderer = vtk.vtkOpenGLRenderer()
     self._renderer.SetBackground((0, 0, 0))
     self._renderer.AddActor(self._axis_actor())
     self._ren_win.AddRenderer(self._renderer)
     # CAMERA
     self._camera = self._renderer.GetActiveCamera()
     # self._camera_angle = self._camera.GetViewAngle()
     # self._camera_last_angle = 30
     self._camera_pose = [0, 0, 13]
     self._last_camera_pose = [0, 0, 0]
     self.set_camera_pose(pos=[0, 0, 13.0], center=[0, 0, 0], view=[0, 0, 0])
     self._vtk_widget.Start()
     # BUTTON WIDGET
     widget = QWidget(self._widget)
     widget.resize(200, 200)
     widget.setStyleSheet('QWidget {background: red}')
     widget.setToolTip('button test')
     widget.show()
     button = QPushButton(widget)
     button.setStyleSheet('QPushButton {background: blue}')
     button.setText('test')
     button.pressed.connect(self._widget_display)
     button.show()
     # TIMER
     self._event_ena = False
     self._timer = QTimer(self)
     self._timer.setInterval(int(1000/100))
     self._timer.timeout.connect(self._detect_event)
     self._timer.start()
     self._high_timer = QTimer(self)
     self._high_timer.setInterval(int(1000/60))
     self._high_timer.timeout.connect(self._render_once)
Esempio n. 18
0
    def __init__(self):
        super(Canvas3D, self).__init__()
        self.shapes = []

        m = (0, 0, 0, 0)
        self.vl = QtWidgets.QVBoxLayout()
        self.vl.setContentsMargins(*m)
        self.iren = QVTKRenderWindowInteractor(self)
        self.vl.addWidget(self.iren)
        self.setLayout(self.vl)

        colors = vtk.vtkNamedColors()
        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(colors.GetColor3d("SkyBlue"))
        self.renWin().AddRenderer(self.ren)
Esempio n. 19
0
 def __init__(self, parent=None):
     self.app = QApplication(sys.argv)
     QMainWindow.__init__(self, parent)
     self.frame = QFrame()
     self.vl = QVBoxLayout()
     self.interactor = QVTKRenderWindowInteractor(self.frame)
     self.vl.addWidget(self.interactor)
     self.ren = vtk.vtkRenderer()
     self.ren.SetBackground(1, 1, 1)
     self.interactor.GetRenderWindow().AddRenderer(self.ren)
     self.iren = self.interactor.GetRenderWindow().GetInteractor()
     self.iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
     self.frame.setLayout(self.vl)
     self.setCentralWidget(self.frame)
     self.iren.Initialize()
Esempio n. 20
0
    def __init__(self):
        super().__init__()
        self.vtk_widget = QVTKRenderWindowInteractor(self)
        self.main_layout = QGridLayout()
        self.main_layout.addWidget(self.vtk_widget)
        self.setLayout(self.main_layout)

        self.vtk_renderer = vtk.vtkRenderer()
        self.vtk_render_win = self.vtk_widget.GetRenderWindow()
        self.vtk_render_win.AddRenderer(self.vtk_renderer)
        self.vtk_interactor = self.vtk_render_win.GetInteractor()
        self.vtk_interactor.Initialize()

        self.vtk_volume_mapper = vtk.vtkSmartVolumeMapper()
        pass
Esempio n. 21
0
    def __init__(self, size=None, **kwargs):
        super(VTKWindowPlugin, self).__init__(**kwargs)

        # Setup widget
        self.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
        self.setMainLayoutName('WindowLayout')

        # Create the QVTK interactor
        if self.devicePixelRatio() > 1:
            self.__qvtkinteractor = RetinaQVTKRenderWindowInteractor(self)
        else:
            self.__qvtkinteractor = QVTKRenderWindowInteractor(self)

        # Member variables
        self._highlight = None
        self._reader = None
        self._result = None
        self._filename = str()
        self._initialized = False
        self._run_start_time = None
        self._window = chigger.RenderWindow(vtkwindow=self.__qvtkinteractor.GetRenderWindow(), vtkinteractor=self.__qvtkinteractor.GetRenderWindow().GetInteractor(), size=size)

        # Set to True when the window needs to be reset (e.g., when the input file was changed)
        self._reset_required = False

        # If size is provided, restrict the window
        if size != None:
            self.setFixedSize(QtCore.QSize(*size))

        # Define timers for initialization and updating data
        self._timers = dict()
        for name in ['update', 'initialize']:
            self._timers[name] = QtCore.QTimer()
            self._timers[name].setInterval(1000)
        self._timers['update'].timeout.connect(self.onWindowRequiresUpdate)
        self._timers['initialize'].timeout.connect(self.onReloadWindow)

        # Create a "tight" layout and add the QVTK widget
        self._layout = QtWidgets.QHBoxLayout()
        self._layout.setContentsMargins(0, 0, 0, 0)
        self._layout.addWidget(self.__qvtkinteractor)
        self.setLayout(self._layout)

        # Display items for when no file exists
        self._peacock_logo = chigger.annotations.ImageAnnotation(filename='peacock.png', opacity=0.33)
        self._peacock_text = chigger.annotations.TextAnnotation(text='No file selected.', justification='center', font_size=18)

        self.setup()
Esempio n. 22
0
    def __init__(self, parent = None):
        Qt.QMainWindow.__init__(self, parent)
        
        #--Window and Renderer Setting
        
        #Main Window Initialization
        self.frame = Qt.QFrame()
        self.vl = Qt.QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)

        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(255, 255, 255)
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
        
        #Renderer Setting
        self.ren.ResetCamera()
        self.frame.setLayout(self.vl)
        self.setCentralWidget(self.frame)
        
        #Start Renderer
        self.iren.Initialize()
        self.show()      
        #----------------------------------
        
        #--Menu & Functions 
        
        #Menu Bar to Wrap All Menu
        mainMenu = self.menuBar()
        
        #Menu on Menu Bar
        fileMenu = mainMenu.addMenu('Meshgrid')
        
        #Submenu Show Meshgrid
        addmeshgrid = Qt.QAction('Add Meshgrid', self)
        addmeshgrid.setShortcut('Ctrl+M')
        addmeshgrid.triggered.connect(self.add_mesh)
        fileMenu.addAction(addmeshgrid)
        
        #Submenu Add Section
        add_section = Qt.QAction("Add Section", self)
        add_section.triggered.connect(self.add_section)
        fileMenu.addAction(add_section)           
        #-----------------------------------
        
        #--Data        
        self.meshgrid = np.loadtxt("meshgrid.txt")
Esempio n. 23
0
class MainWindow(Qt.QMainWindow):
    def __init__(self, parent=None):

        Qt.QMainWindow.__init__(self, parent)
        self.frame = Qt.QFrame()
        self.vl = Qt.QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)

        vp = Plotter(qtWidget=self.vtkWidget, axes=2, N=2)

        cn = Cone()
        cc = Cube().pos(1, 1, 1).color("pink")
        ss = Torus()
        vp.show(cn, cc, at=0)
        vp.show(ss, at=1, viewup="z")

        self.start(vp)

    def start(self, vp):

        for r in vp.renderers:
            self.vtkWidget.GetRenderWindow().AddRenderer(r)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()

        self.iren.AddObserver("LeftButtonPressEvent", vp._mouseleft)
        self.iren.AddObserver("RightButtonPressEvent", vp._mouseright)
        self.iren.AddObserver("MiddleButtonPressEvent", vp._mousemiddle)

        def keypress(obj, e):
            vp._keypress(obj, e)
            if self.iren.GetKeySym() in ["q", "space"]:
                self.iren.ExitCallback()
                exit()

        self.iren.AddObserver("KeyPressEvent", keypress)

        self.frame.setLayout(self.vl)
        self.setCentralWidget(self.frame)
        self.show()  # qt not Plotter method
        r.ResetCamera()
        self.iren.Start()

    def onClose(self):
        print(
            "Disable the interactor before closing to prevent it from trying to act on a already deleted items"
        )
        self.vtkWidget.close()
Esempio n. 24
0
class TerrainUI(Qt.QMainWindow):
    # ============================================================================
    # = Constructor                                                              =
    # = ------------------------------------------------------------------------ =
    # = description:                                                             =
    # = Creates a new UI instance.                                               =
    # ============================================================================
    def __init__(
        self,             # (Ref) Reference to class, required by all members
        col    = Color(), # (Color) the color to set the vtk window background as
        parent = None     # (Ref) Reference to container object this object
                          # belongs to
    ):
        Qt.QMainWindow.__init__(self, parent)
        # Set window size and title
        self.resize(800,600)
        self.setWindowTitle("Open MapGen")

        # Create the embedded window
        self.__frame = Qt.QFrame()
        self.__layout = Qt.QHBoxLayout()
        self.__frame.setLayout(self.__layout)
        self.setCentralWidget(self.__frame)
        self.__interactor = QVTKRenderWindowInteractor(self.__frame)
        self.__interactor.Initialize()
        self.__layout.addWidget(self.__interactor)

        self.geometry = Geometry(col)

        self.__interactor.GetRenderWindow().AddRenderer(self.geometry.renderer)
        self.__iren = self.__interactor.GetRenderWindow().GetInteractor()

    # ============================================================================
    # = Start Method                                                             =
    # = ------------------------------------------------------------------------ =
    # = description:                                                             =
    # = Used to make the window visible to the user and start the graphics       =
    # = component rendering                                                      =
    # ============================================================================
    def Start(
        self
    ):
        self.show()
        self.__iren.Initialize()
        self.geometry.renderer.ResetCamera()
        self.geometry.renderer.GetActiveCamera().Zoom(1.5)
        self.__iren.Render()
        self.__iren.Start()
Esempio n. 25
0
class myMainWindow(QtWidgets.QMainWindow):

    def __init__(self, parent=None):
        QtWidgets.QMainWindow.__init__(self, parent)

        self.frame = QtWidgets.QFrame()

        self.vl = QtWidgets.QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)

        self.ren = vtk.vtkRenderer()
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()

        # Create source
        source = vtk.vtkConeSource()
        source.SetCenter(0, 0, 0)
        source.SetRadius(0.1)

        source1 = vtk.vtkSphereSource()
        source1.SetCenter(0, 0, 0)
        source1.SetRadius(0.5)

        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(source.GetOutputPort())

        mapper1 = vtk.vtkPolyDataMapper()
        mapper1.SetInputConnection(source1.GetOutputPort())

        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)

        actor1 = vtk.vtkActor()
        actor1.SetMapper(mapper1)

        self.ren.AddActor(actor)
        self.ren.AddActor(actor1)

        self.ren.ResetCamera()

        self.frame.setLayout(self.vl)
        self.setCentralWidget(self.frame)

        self.show()
        self.iren.Initialize()
Esempio n. 26
0
 def setupUi(self, MainWindow):
     MainWindow.setObjectName("MainWindow")
     MainWindow.resize(603, 553)
     self.centralWidget = QtWidgets.QWidget(MainWindow)
     self.gridlayout = QtWidgets.QGridLayout(self.centralWidget)
     self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)
     self.gridlayout.addWidget(self.vtkWidget, 0, 0, 1, 1)
Esempio n. 27
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName('The Main Window')
        MainWindow.setWindowTitle('Vector Planes Visualization')

        self.centralWidget = QWidget(MainWindow)
        self.gridlayout = QGridLayout(self.centralWidget)
        self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)

        self.push_screenshot = QPushButton()
        self.push_screenshot.setText('Save Screenshot')
        self.push_camera = QPushButton()
        self.push_camera.setText('Update Camera Info')
        self.push_quit = QPushButton()
        self.push_quit.setText('Quit')

        self.camera_info = QTextEdit()
        self.camera_info.setReadOnly(True)
        self.camera_info.setAcceptRichText(True)
        self.camera_info.setHtml(
            "<div style='font-weight: bold'>Camera Settings</div>")

        self.log = QTextEdit()
        self.log.setReadOnly(True)

        self.gridlayout.addWidget(self.vtkWidget, 0, 0, 4, 4)
        self.gridlayout.addWidget(self.push_screenshot, 0, 4, 1, 1)
        self.gridlayout.addWidget(self.push_camera, 0, 5, 1, 1)
        self.gridlayout.addWidget(self.camera_info, 2, 4, 1, 2)
        self.gridlayout.addWidget(self.log, 3, 4, 1, 2)
        MainWindow.setCentralWidget(self.centralWidget)
Esempio n. 28
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(2560, 1600)
        # 生成组件
        self.centralWidget = QtWidgets.QWidget(MainWindow)
        self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)
        self.btn_select = QtWidgets.QPushButton("选择DICOM目录")
        self.btn_select.clicked.connect(self.btn1_clicked)
        # self.buttonRight = QtWidgets.QPushButton("Right")
        # self.buttonUp = QtWidgets.QPushButton("Up")
        # self.buttonDown = QtWidgets.QPushButton("Down")
        self.checkbox = QtWidgets.QCheckBox()
        # 创建VTK布局
        self.childLayout_vtk = QtWidgets.QGridLayout()
        self.childLayout_vtk.addWidget(self.vtkWidget)

        # 创建区域子布局
        self.childLayout_button = QtWidgets.QVBoxLayout()
        self.childLayout_button.addStretch()
        self.childLayout_button.addWidget(self.btn_select)
        # self.childLayout_button.addWidget(self.buttonRight)
        # self.childLayout_button.addWidget(self.buttonUp)
        # self.childLayout_button.addWidget(self.buttonDown)
        self.childLayout_button.addStretch()
        self.childLayout_button.setSpacing(MainWindow.height() / 10)

        # 创建父布局
        MainWindow.setCentralWidget(self.centralWidget)
        self.parentLayout = QtWidgets.QGridLayout(self.centralWidget)
        self.parentLayout.addLayout(self.childLayout_button, 0, 0, 1, 1)
        self.parentLayout.addLayout(self.childLayout_vtk, 0, 2, 1, 3)
Esempio n. 29
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.setCentralWidget(QVTKRenderWindowInteractor())
        self.renderWindow = self.centralWidget().GetRenderWindow()

        #Set REnderer
        self.renderer = vtk.vtkRenderer()
        self.renderWindow.GetInteractor().SetInteractorStyle(
            vtk.vtkInteractorStyleTrackballCamera())
        self.renderWindow.AddRenderer(self.renderer)

        self.txtActor = vtk.vtkTextActor()
        self.txtActor.SetInput("Preparing...")
        self.txtActor.GetTextProperty().SetFontFamilyToArial()
        self.txtActor.GetTextProperty().SetFontSize(46)
        self.txtActor.GetTextProperty().SetColor(1, 1, 0)
        self.txtActor.SetDisplayPosition(100, 900)
        self.renderer.AddActor(self.txtActor)

        input_actor = utils.MakeActor(input_poly)
        self.renderer.AddActor(input_actor)
        self.renderer.GetActiveCamera().Pitch(-45)
        self.renderer.ResetCamera()

        self.renderWindow.Render()

        #Thread
        self.thread = TrainingThread()
        self.thread.signal_log.connect(self.onLog)
        self.thread.start()
Esempio n. 30
0
    def __init__(self, parent=None):
        QtWidgets.QMainWindow.__init__(self, parent)

        self.frame = QtWidgets.QFrame()

        self.setup_menubar()

        self.main_vlayout = QtWidgets.QVBoxLayout()
        Settings.vtk_widget = QVTKRenderWindowInteractor(self.frame)
        self.main_vlayout.addWidget(Settings.vtk_widget)

        # Setup Sliders
        self.setup_mode_slider()
        self.setup_omega_slider()

        # Setup Play/Pause Button
        self.control_button = QtWidgets.QPushButton("Pause")
        self.control_button.pressed.connect(self.play_pause_button)

        self.main_vlayout.addWidget(self.control_button)

        # Set up attach camera UI
        self.attach_camera_layout = QtWidgets.QHBoxLayout()

        self.attach_camera_button = QtWidgets.QPushButton(
            "Attach Camera To Node")
        self.attach_camera_button.pressed.connect(self.attach_camera)
        self.attach_camera_layout.addWidget(self.attach_camera_button)

        self.attach_cam_label = QtWidgets.QLabel()
        self.attach_cam_label.setText("")
        self.attach_camera_layout.addWidget(self.attach_cam_label)

        self.main_vlayout.addLayout(self.attach_camera_layout)

        # Setup Camera Delta Value Input
        self.setup_camera_delta_layout()

        # Add Camera Position Reset Button
        self.reset_button = QtWidgets.QPushButton("Reset Camera Position")
        self.reset_button.pressed.connect(self.reset_camera_position)
        self.main_vlayout.addWidget(self.reset_button)

        # Setup Window with layout
        self.renderer = vtk.vtkRenderer()
        Settings.vtk_widget.GetRenderWindow().AddRenderer(self.renderer)
        self.interactor = Settings.vtk_widget.GetRenderWindow().GetInteractor()
        self.ren_window = Settings.vtk_widget.GetRenderWindow()

        self.frame.setLayout(self.main_vlayout)
        self.setCentralWidget(self.frame)

        style = MouseKeyboardInteractor(self)
        style.SetDefaultRenderer(self.renderer)
        self.interactor.SetInteractorStyle(style)

        self.interactor.Initialize()
        self.interactor.Start()
        self.interactor.Render()
        self.show()
Esempio n. 31
0
 def __init__(self, input=None, MinOpacity=0.0, MaxOpacity=0.1) :
   import qt
   import vtk
   from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
   self.__MinOpacity__ = MinOpacity
   self.__MaxOpacity__ = MaxOpacity
   # every QT app needs an app
   self.__app__ = qt.QApplication(['itkviewer'])
   # create the widget
   self.__widget__ = QVTKRenderWindowInteractor()
   self.__ren__ = vtk.vtkRenderer()
   self.__widget__.GetRenderWindow().AddRenderer(self.__ren__)
   self.__itkvtkConverter__ = None
   self.__volumeMapper__ = vtk.vtkVolumeTextureMapper2D()
   self.__volume__ = vtk.vtkVolume()
   self.__volumeProperty__ = vtk.vtkVolumeProperty()
   self.__volume__.SetMapper(self.__volumeMapper__)
   self.__volume__.SetProperty(self.__volumeProperty__)
   self.__ren__.AddVolume(self.__volume__)
   self.__outline__ = None
   self.__outlineMapper__ = None
   self.__outlineActor__ = None
   self.AdaptColorAndOpacity(0, 255)
   if input :
     self.SetInput(input)
     self.AdaptColorAndOpacity()
Esempio n. 32
0
	def setupUi(self, MainWindow):
		MainWindow.setWindowTitle(("pyCM - Point editor v%s" %__version__))
		self.centralWidget = QtWidgets.QWidget(MainWindow)
		if hasattr(MainWindow,'setCentralWidget'):
			MainWindow.setCentralWidget(self.centralWidget)
		else:
			self.centralWidget=MainWindow
		self.mainlayout=QtWidgets.QGridLayout(self.centralWidget)

		self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)
		
		mainUiBox = QtWidgets.QGridLayout()

		self.vtkWidget.setMinimumSize(QtCore.QSize(1050, 600))
		sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
		sizePolicy.setHorizontalStretch(10)
		sizePolicy.setVerticalStretch(10)
		sizePolicy.setHeightForWidth(self.vtkWidget.sizePolicy().hasHeightForWidth())
		self.vtkWidget.setSizePolicy(sizePolicy)


		self.statLabel=QtWidgets.QLabel("Idle")
		self.statLabel.setWordWrap(True)
		self.statLabel.setFont(QtGui.QFont("Helvetica",italic=True))
		self.statLabel.setMinimumWidth(100)
		sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum)
		sizePolicy.setHorizontalStretch(0)
		sizePolicy.setVerticalStretch(0)
		sizePolicy.setHeightForWidth(self.statLabel.sizePolicy().hasHeightForWidth())
		self.statLabel.setSizePolicy(sizePolicy)

		headFont=QtGui.QFont("Helvetica [Cronyx]",weight=QtGui.QFont.Bold)
		
		
		#define buttons/widgets
		self.reloadButton = QtWidgets.QPushButton('New profile')
		scalingLabel=QtWidgets.QLabel("Active axis for scaling")
		scalingLabel.setFont(headFont)
		self.xsButton=QtWidgets.QRadioButton("x")
		self.ysButton=QtWidgets.QRadioButton("y")
		self.zsButton=QtWidgets.QRadioButton("z")
		self.zsButton.setChecked(True)
		self.scalingButtonGroup = QtWidgets.QButtonGroup()
		self.scalingButtonGroup.addButton(self.xsButton)
		self.scalingButtonGroup.addButton(self.ysButton)
		self.scalingButtonGroup.addButton(self.zsButton)
		self.scalingButtonGroup.setExclusive(True)
		scaleBoxlayout = QtWidgets.QGridLayout()
		scaleBoxlayout.addWidget(self.xsButton,1,1)
		scaleBoxlayout.addWidget(self.ysButton,1,2)
		scaleBoxlayout.addWidget(self.zsButton,1,3)
		self.levelButton=QtWidgets.QRadioButton("Translate to mean z value")
		svdLabel=QtWidgets.QLabel("Perform SVD reorientation")
		svdLabel.setFont(headFont)
				
		self.rxButton_pos=QtWidgets.QRadioButton("Rx+")
		self.ryButton_pos=QtWidgets.QRadioButton("Ry+")
		self.rxButton_neg=QtWidgets.QRadioButton("Rx-")
		self.ryButton_neg=QtWidgets.QRadioButton("Ry-")
		
		svdButtonGroup = QtWidgets.QButtonGroup()
		svdButtonGroup.addButton(self.rxButton_pos)
		svdButtonGroup.addButton(self.ryButton_pos)
		svdButtonGroup.addButton(self.rxButton_neg)
		svdButtonGroup.addButton(self.ryButton_neg)
		svdButtonGroup.setExclusive(False)
		svdBoxlayout = QtWidgets.QGridLayout()
		svdBoxlayout.addWidget(self.rxButton_pos,1,1)
		svdBoxlayout.addWidget(self.rxButton_neg,1,2)
		svdBoxlayout.addWidget(self.ryButton_pos,1,3)
		svdBoxlayout.addWidget(self.ryButton_neg,1,4)
		
		self.reduce = QtWidgets.QSpinBox()
		self.reduce.setValue(0)
		self.reduceButton = QtWidgets.QPushButton('Reduce')
		self.revertButton = QtWidgets.QPushButton('Undo all/reload')

		reduceBoxlayout= QtWidgets.QGridLayout()
		reduceBoxlayout.addWidget(self.reduce,1,1)
		reduceBoxlayout.addWidget(self.reduceButton,1,2)
		
		horizLine1=QtWidgets.QFrame()
		horizLine1.setFrameStyle(QtWidgets.QFrame.HLine)
		pickLabel=QtWidgets.QLabel("Pick options")
		pickLabel.setFont(headFont)

		self.pickHelpLabel=QtWidgets.QLabel("Press R to activate")
		self.pickActiveLabel=QtWidgets.QLabel("Pick active")
		self.pickActiveLabel.setStyleSheet("QLabel { background-color : gray; color : darkGray; }")
		self.pickActiveLabel.setFont(QtGui.QFont("Helvetica",italic=True))
		self.undoLastPickButton=QtWidgets.QPushButton('Undo last pick')
		horizLine2=QtWidgets.QFrame()
		horizLine2.setFrameStyle(QtWidgets.QFrame.HLine)
		outputLabel=QtWidgets.QLabel("Write output")
		outputLabel.setFont(headFont)
		self.refButton=QtWidgets.QRadioButton("Reference")
		
		self.floatButton=QtWidgets.QRadioButton("Floating")
		
		self.refButton.setChecked(True)
		self.writeButtonGroup = QtWidgets.QButtonGroup()
		self.writeButtonGroup.addButton(self.floatButton)
		self.writeButtonGroup.addButton(self.refButton)
		self.writeButtonGroup.setExclusive(True)
		self.writeButton=QtWidgets.QPushButton('Write')
		horizLine3=QtWidgets.QFrame()
		horizLine3.setFrameStyle(QtWidgets.QFrame.HLine)
		showLabel=QtWidgets.QLabel("Load result")
		showLabel.setFont(headFont)
		self.showRefButton=QtWidgets.QRadioButton("Reference")
		self.showRefButton.setChecked(True)
		self.showFloatButton=QtWidgets.QRadioButton("Floating")
		self.showButtonGroup = QtWidgets.QButtonGroup()
		self.showButtonGroup.addButton(self.showFloatButton)
		self.showButtonGroup.addButton(self.showRefButton)
		self.showButtonGroup.setExclusive(True)
		
		self.showButton=QtWidgets.QPushButton("View")
		horizLine4=QtWidgets.QFrame()
		horizLine4.setFrameStyle(QtWidgets.QFrame.HLine)

		#add widgets to ui
		mainUiBox.addWidget(self.reloadButton,0,0,1,2)
		mainUiBox.addWidget(scalingLabel,1,0,1,2)
		mainUiBox.addLayout(scaleBoxlayout,2,0,1,2)
		mainUiBox.addWidget(self.levelButton,3,0,1,2)

		mainUiBox.addWidget(horizLine1,4,0,1,2)
		mainUiBox.addWidget(pickLabel,5,0,1,2)
		mainUiBox.addLayout(reduceBoxlayout,6,0,1,2)
		mainUiBox.addWidget(self.pickHelpLabel,7,0,1,1)
		mainUiBox.addWidget(self.pickActiveLabel,7,1,1,1)
		mainUiBox.addWidget(self.undoLastPickButton,8,0,1,2)
		mainUiBox.addWidget(svdLabel,9,0,1,2)
		mainUiBox.addLayout(svdBoxlayout,10,0,1,2)
		mainUiBox.addWidget(self.revertButton,11,0,1,2)
		mainUiBox.addWidget(horizLine2,12,0,1,2)
		mainUiBox.addWidget(outputLabel,13,0,1,2)
		mainUiBox.addWidget(self.refButton,14,0,1,1)
		mainUiBox.addWidget(self.floatButton,14,1,1,1)
		mainUiBox.addWidget(self.writeButton,15,0,1,2)
		mainUiBox.addWidget(horizLine3,16,0,1,2)
		mainUiBox.addWidget(showLabel,17,0,1,2)
		mainUiBox.addWidget(self.showRefButton,18,0,1,1)
		mainUiBox.addWidget(self.showFloatButton,18,1,1,1)
		mainUiBox.addWidget(self.showButton,19,0,1,2)
		mainUiBox.addWidget(horizLine4,20,0,1,2)

		lvLayout=QtWidgets.QVBoxLayout()
		lvLayout.addLayout(mainUiBox)
		lvLayout.addStretch(1)
		
		self.mainlayout.addWidget(self.vtkWidget,0,0,1,1)
		self.mainlayout.addLayout(lvLayout,0,1,1,1)
		self.mainlayout.addWidget(self.statLabel,1,0,1,2)
Esempio n. 33
0
	def setupUi(self, MainWindow):
		MainWindow.setWindowTitle("pyCM - Alignment and averaging tool v%s" %__version__)
		self.centralWidget = QtWidgets.QWidget(MainWindow)
		if hasattr(MainWindow,'setCentralWidget'):
			MainWindow.setCentralWidget(self.centralWidget)
		else:
			self.centralWidget=MainWindow
		self.mainlayout=QtWidgets.QGridLayout(self.centralWidget)
		
		self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)
		
		mainUiBox = QtWidgets.QGridLayout()
		
		self.vtkWidget.setMinimumSize(QtCore.QSize(1050, 600))
		sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
		sizePolicy.setHorizontalStretch(10)
		sizePolicy.setVerticalStretch(10)
		sizePolicy.setHeightForWidth(self.vtkWidget.sizePolicy().hasHeightForWidth())
		self.vtkWidget.setSizePolicy(sizePolicy)
		
		self.statLabel=QtWidgets.QLabel("Idle")
		self.statLabel.setWordWrap(True)
		self.statLabel.setFont(QtGui.QFont("Helvetica",italic=True))
		self.statLabel.setMinimumWidth(100)
		sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum)
		sizePolicy.setHorizontalStretch(0)
		sizePolicy.setVerticalStretch(0)
		sizePolicy.setHeightForWidth(self.statLabel.sizePolicy().hasHeightForWidth())
		self.statLabel.setSizePolicy(sizePolicy)

		headFont=QtGui.QFont("Helvetica [Cronyx]",weight=QtGui.QFont.Bold)

		
		# #define buttons/widgets
		# self.reloadButton = QtWidgets.QPushButton('Load')
		scalingLabel=QtWidgets.QLabel("Active axis for scaling")
		scalingLabel.setFont(headFont)
		self.xsButton=QtWidgets.QRadioButton("x")
		self.ysButton=QtWidgets.QRadioButton("y")
		self.zsButton=QtWidgets.QRadioButton("z")
		self.zsButton.setChecked(True)
		self.scalingButtonGroup = QtWidgets.QButtonGroup()
		self.scalingButtonGroup.addButton(self.xsButton)
		self.scalingButtonGroup.addButton(self.ysButton)
		self.scalingButtonGroup.addButton(self.zsButton)
		self.scalingButtonGroup.setExclusive(True)
		scaleBoxlayout = QtWidgets.QGridLayout()
		scaleBoxlayout.addWidget(self.xsButton,1,1)
		scaleBoxlayout.addWidget(self.ysButton,1,2)
		scaleBoxlayout.addWidget(self.zsButton,1,3)
		
		horizLine1=QtWidgets.QFrame()
		horizLine1.setFrameStyle(QtWidgets.QFrame.HLine)
		mirrorLabel=QtWidgets.QLabel("Mirroring")
		mirrorLabel.setFont(headFont)
		self.mirrorXbutton = QtWidgets.QPushButton('ZY')
		self.mirrorYbutton = QtWidgets.QPushButton('ZX')

		horizLine2=QtWidgets.QFrame()
		horizLine2.setFrameStyle(QtWidgets.QFrame.HLine)
		alignLabel=QtWidgets.QLabel("Alignment")
		alignLabel.setFont(headFont)
		self.centRefButton=QtWidgets.QPushButton("Move reference centroid to origin")
		self.centFloatButton=QtWidgets.QPushButton("Move float centroid to origin")

		self.transXlabel=QtWidgets.QLabel("Translate x:")
		self.transX = QtWidgets.QDoubleSpinBox()
		self.transX.setValue(0)
		self.transX.setMaximum(300)
		self.transX.setMinimum(-300)
		self.transYlabel=QtWidgets.QLabel("Translate y:")
		self.transY = QtWidgets.QDoubleSpinBox()
		self.transY.setValue(0)
		self.transY.setMaximum(300)
		self.transY.setMinimum(-300)
		self.rotateZlabel=QtWidgets.QLabel("Rotate about z (deg):")
		self.rotateZ= QtWidgets.QDoubleSpinBox()
		self.rotateZ.setValue(0)
		self.rotateZ.setMaximum(180)
		self.rotateZ.setMinimum(-180)
		self.transButton=QtWidgets.QPushButton('Transform floating')
		self.numPntsOutline = QtWidgets.QSpinBox()
		self.numPntsOutline.setMaximum(10000)
		self.reduceOutlineButton = QtWidgets.QPushButton('Decimate outlines')

		
		alignAlgoButtonGroup = QtWidgets.QButtonGroup()
		self.useVTKalignButton=QtWidgets.QRadioButton("VTK ICP")
		self.useICPalignButton=QtWidgets.QRadioButton("K-neighbour ICP")
		self.useVTKalignButton.setChecked(True)
		alignAlgoButtonGroup.addButton(self.useVTKalignButton)
		alignAlgoButtonGroup.addButton(self.useICPalignButton)
		alignAlgoButtonGroup.setExclusive(True)
		self.X180Button = QtWidgets.QPushButton("Flip X")
		self.Y180Button = QtWidgets.QPushButton("Flip Y")
		self.alignButton = QtWidgets.QPushButton("Align")
		self.acceptAlignButton = QtWidgets.QPushButton("Accept")
		
		self.alignButton.setStyleSheet("background-color : None ")
		
		horizLine3=QtWidgets.QFrame()
		horizLine3.setFrameStyle(QtWidgets.QFrame.HLine)
		averageLabel=QtWidgets.QLabel("Averaging")
		averageLabel.setFont(headFont)
		
		#widgets for setting grid
		gridLabel=QtWidgets.QLabel("Grid spacing:")
		self.gridInd = QtWidgets.QDoubleSpinBox()
		self.gridInd.setValue(0)
		self.gridInd.setMaximum(5)
		self.gridInd.setMinimum(0.001)
		
		self.averageButton = QtWidgets.QPushButton('Average')
		self.averageButton.setStyleSheet("background-color : None ")
		
		horizLine4=QtWidgets.QFrame()
		horizLine4.setFrameStyle(QtWidgets.QFrame.HLine)
		self.writeButton=QtWidgets.QPushButton('Write')
		
		horizLine5=QtWidgets.QFrame()
		horizLine5.setFrameStyle(QtWidgets.QFrame.HLine)


		#add widgets to ui
		mainUiBox.addWidget(scalingLabel,0,0,1,2)
		mainUiBox.addLayout(scaleBoxlayout,1,0,1,2)
		mainUiBox.addWidget(horizLine1,2,0,1,2)
		mainUiBox.addWidget(mirrorLabel,3,0,1,2)
		mainUiBox.addWidget(self.mirrorYbutton,4,0,1,1)
		mainUiBox.addWidget(self.mirrorXbutton,4,1,1,1)
		mainUiBox.addWidget(horizLine2,5,0,1,2)
		mainUiBox.addWidget(alignLabel,6,0,1,2)
		mainUiBox.addWidget(self.centRefButton,7,0,1,2)
		mainUiBox.addWidget(self.centFloatButton,8,0,1,2)
		mainUiBox.addWidget(self.transXlabel,9,0,1,1)
		mainUiBox.addWidget(self.transX,9,1,1,1)
		mainUiBox.addWidget(self.transYlabel,10,0,1,1)
		mainUiBox.addWidget(self.transY,10,1,1,1)
		mainUiBox.addWidget(self.rotateZlabel,11,0,1,1)
		mainUiBox.addWidget(self.rotateZ,11,1,1,1)
		mainUiBox.addWidget(self.transButton,12,0,1,2)
		mainUiBox.addWidget(self.X180Button,13,0,1,1)
		mainUiBox.addWidget(self.Y180Button,13,1,1,1)
		mainUiBox.addWidget(self.numPntsOutline,14,0,1,1)
		mainUiBox.addWidget(self.reduceOutlineButton,14,1,1,1)
		
		mainUiBox.addWidget(self.useVTKalignButton,15,0,1,1)
		mainUiBox.addWidget(self.useICPalignButton,15,1,1,1)

		mainUiBox.addWidget(self.alignButton,16,0,1,1)
		mainUiBox.addWidget(self.acceptAlignButton,16,1,1,1)
		mainUiBox.addWidget(horizLine3,17,0,1,2)
		mainUiBox.addWidget(averageLabel,18,0,1,2)
		mainUiBox.addWidget(gridLabel,19,0,1,1)
		mainUiBox.addWidget(self.gridInd,19,1,1,1)
		mainUiBox.addWidget(self.averageButton,20,0,1,2)
		mainUiBox.addWidget(horizLine4,21,0,1,2)
		mainUiBox.addWidget(self.writeButton,22,0,1,2)
		mainUiBox.addWidget(horizLine5,23,0,1,2)
		# mainUiBox.addWidget(self.statusLabel,18,0,1,2)

		mainUiBox.setColumnMinimumWidth(0,mainUiBox.columnMinimumWidth(0))
		mainUiBox.setColumnMinimumWidth(1,mainUiBox.columnMinimumWidth(0))
		
		lvLayout=QtWidgets.QVBoxLayout()
		lhLayout=QtWidgets.QHBoxLayout()
		lvLayout.addLayout(mainUiBox)
		lvLayout.addStretch(1)
		lhLayout.addLayout(lvLayout)
		lhLayout.addStretch(2)



		self.mainlayout.addWidget(self.vtkWidget,0,0,1,1)
		self.mainlayout.addLayout(lhLayout,0,1,1,1)
		self.mainlayout.addWidget(self.statLabel,1,0,1,2)
Esempio n. 34
0
	def setupUi(self, MainWindow):
		"""
		Performs the Qt setup of GUI
		Creates a windows and adds button interaction
		"""

		MainWindow.setWindowTitle("pyCM - FEA postprocessing v%s" %__version__)
		if hasattr(MainWindow,'setCentralWidget'):
			MainWindow.setCentralWidget(self.centralWidget)
		else:
			self.centralWidget=MainWindow
		self.mainlayout=QtWidgets.QGridLayout(self.centralWidget)

		self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)
		
		mainUiBox = QtWidgets.QGridLayout()
		
		self.vtkWidget.setMinimumSize(QtCore.QSize(1050, 600))
		sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
		sizePolicy.setHorizontalStretch(10)
		sizePolicy.setVerticalStretch(10)
		sizePolicy.setHeightForWidth(self.vtkWidget.sizePolicy().hasHeightForWidth())
		self.vtkWidget.setSizePolicy(sizePolicy)

		horiz_line1 = QtWidgets.QFrame()
		horiz_line1.setFrameStyle(QtWidgets.QFrame.HLine)
		horiz_line2 = QtWidgets.QFrame()
		horiz_line2.setFrameStyle(QtWidgets.QFrame.HLine)
		horiz_line3 = QtWidgets.QFrame()
		horiz_line3.setFrameStyle(QtWidgets.QFrame.HLine)
		horiz_line4 = QtWidgets.QFrame()
		horiz_line4.setFrameStyle(QtWidgets.QFrame.HLine)
		headFont=QtGui.QFont("Helvetica [Cronyx]",weight=QtGui.QFont.Bold)

		display_label = QtWidgets.QLabel("Display")
		display_label.setFont(headFont)
		self.extract_button = QtWidgets.QPushButton('Extract')
		self.display_button33 = QtWidgets.QPushButton('S33 - Longitudinal')
		self.display_button11 = QtWidgets.QPushButton('S11')
		self.display_button22 = QtWidgets.QPushButton('S22')

		stress_label = QtWidgets.QLabel("Contours")
		stress_label.setFont(headFont)
		stress_label.setWordWrap(True)
		stress_label.setMinimumWidth(50)

		# enter minimum stress to update the display
		inp_min_stress_label = QtWidgets.QLabel("Min:")
		self.inp_min_stress = QtWidgets.QLineEdit()
		self.inp_min_stress.setMinimumWidth(50)
		
		num_contours_label = QtWidgets.QLabel("Number:")
		self.numContour = QtWidgets.QSpinBox()
		self.numContour.setMinimum(3)
		self.numContour.setMaximum(20)
		self.numContour.setValue(5)

		# enter maximum stress to update the display
		inp_max_stress_label = QtWidgets.QLabel("Max:")
		self.inp_max_stress = QtWidgets.QLineEdit()
		self.inp_max_stress.setMinimumWidth(50)
		

		# stress update button
		self.updateButton = QtWidgets.QPushButton('Update')
		self.updateButton.setMinimumWidth(50)

		# line extraction from surface
		extract_data_label = QtWidgets.QLabel("Extract")
		extract_data_label.setFont(headFont)
		extract_data_label.setWordWrap(True)
		extract_data_label.setMinimumWidth(50)

		# enter x and y of first point
		point1_label = QtWidgets.QLabel("Point 1")
		point1_label.setFont(headFont)
		point1_label.setWordWrap(True)
		point1_label.setMinimumWidth(50)
		point1_x_label = QtWidgets.QLabel("X:")
		self.point1_x_coord = QtWidgets.QLineEdit()
		self.point1_x_coord.setMinimumWidth(50)
		point1_y_label = QtWidgets.QLabel("Y:")
		self.point1_y_coord = QtWidgets.QLineEdit()
		self.point1_y_coord.setMinimumWidth(50)

		# enter x and y of second point
		point2_label = QtWidgets.QLabel("Point 2")
		point2_label.setFont(headFont)
		point2_label.setWordWrap(True)
		point2_label.setMinimumWidth(50)
		point2_x_label = QtWidgets.QLabel("X:")
		self.point2_x_coord = QtWidgets.QLineEdit()
		self.point2_x_coord.setMinimumWidth(50)
		point2_y_label = QtWidgets.QLabel("Y:")
		self.point2_y_coord = QtWidgets.QLineEdit()
		self.point2_y_coord.setMinimumWidth(50)

		# extract plot button
		self.extractPlot = QtWidgets.QPushButton('Plot')
		self.extractPlot.setMinimumWidth(50)

		self.statLabel = QtWidgets.QLabel("Idle")
		self.statLabel.setWordWrap(True)
		self.statLabel.setFont(QtGui.QFont("Helvetica", italic=True))
		self.statLabel.setMinimumWidth(50)

		mainUiBox.addWidget(self.extract_button,0,0,1,2)
		mainUiBox.addWidget(display_label,1,0,1,2)
		mainUiBox.addWidget(self.display_button33,2,0,1,2)
		mainUiBox.addWidget(self.display_button11,3,0,1,1)
		mainUiBox.addWidget(self.display_button22,3,1,1,1)
		mainUiBox.addWidget(horiz_line1,4,0,1,2)
		mainUiBox.addWidget(stress_label,5,0,1,2)
		mainUiBox.addWidget(inp_max_stress_label,6,0,1,1)
		mainUiBox.addWidget(self.inp_max_stress,6,1,1,1)
		mainUiBox.addWidget(inp_min_stress_label,7,0,1,1)
		mainUiBox.addWidget(self.inp_min_stress,7,1,1,1)
		mainUiBox.addWidget(num_contours_label,8,0,1,1)
		mainUiBox.addWidget(self.numContour,8,1,1,1)
		mainUiBox.addWidget(self.inp_max_stress,9,1,1,1)
		mainUiBox.addWidget(self.updateButton,9,0,1,2)
		mainUiBox.addWidget(horiz_line2,10,0,1,2)
		mainUiBox.addWidget(extract_data_label,11,0,1,1)
		mainUiBox.addWidget(point1_label,12,0,1,1)
		mainUiBox.addWidget(point1_x_label,13,0,1,1)
		mainUiBox.addWidget(self.point1_x_coord,13,1,1,1)
		mainUiBox.addWidget(point1_y_label,14,0,1,1)
		mainUiBox.addWidget(self.point1_y_coord,14,1,1,1)
		mainUiBox.addWidget(point2_label,15,0,1,1)
		mainUiBox.addWidget(point2_x_label,16,0,1,1)
		mainUiBox.addWidget(self.point2_x_coord,16,1,1,1)
		mainUiBox.addWidget(point2_y_label,17,0,1,1)
		mainUiBox.addWidget(self.point2_y_coord,17,1,1,1)
		mainUiBox.addWidget(self.extractPlot,18,0,1,2)

		lvLayout=QtWidgets.QVBoxLayout()
		lvLayout.addLayout(mainUiBox)
		lvLayout.addStretch(1)
		
		self.mainlayout.addWidget(self.vtkWidget,0,0,1,1)
		self.mainlayout.addLayout(lvLayout,0,1,1,1)
		self.mainlayout.addWidget(self.statLabel,1,0,1,2)

		def initialize(self):
			self.vtkWidget.start()
Esempio n. 35
0
class show3D :
  def __init__(self, input=None, MinOpacity=0.0, MaxOpacity=0.1) :
    import qt
    import vtk
    from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
    self.__MinOpacity__ = MinOpacity
    self.__MaxOpacity__ = MaxOpacity
    # every QT app needs an app
    self.__app__ = qt.QApplication(['itkviewer'])
    # create the widget
    self.__widget__ = QVTKRenderWindowInteractor()
    self.__ren__ = vtk.vtkRenderer()
    self.__widget__.GetRenderWindow().AddRenderer(self.__ren__)
    self.__itkvtkConverter__ = None
    self.__volumeMapper__ = vtk.vtkVolumeTextureMapper2D()
    self.__volume__ = vtk.vtkVolume()
    self.__volumeProperty__ = vtk.vtkVolumeProperty()
    self.__volume__.SetMapper(self.__volumeMapper__)
    self.__volume__.SetProperty(self.__volumeProperty__)
    self.__ren__.AddVolume(self.__volume__)
    self.__outline__ = None
    self.__outlineMapper__ = None
    self.__outlineActor__ = None
    self.AdaptColorAndOpacity(0, 255)
    if input :
      self.SetInput(input)
      self.AdaptColorAndOpacity()
      
  def Render(self):
    self.__ren__.Render()
    
  def GetWidget(self) :
    return self.__widget__
  
  def GetRenderer(self) :
    return self.__ren__
  
  def GetConverter(self) :
    return self.__itkvtkConverter__
  
  def GetVolumeMapper(self) :
    return self.__volumeMapper__
  
  def GetVolume(self) :
    return self.__volume__
  
  def GetVolumeProperty(self) :
    return self.__volumeProperty__
  
  def Show(self) :
    self.__widget__.show()
    
  def Hide(self) :
    self.__widget__.hide()
    
  def SetInput(self, input) :
    import itk
    img = itk.output(input)
    self.__input__ = img
    if img :
      # Update to try to avoid to exit if a c++ exception is throwed
      # sadely, it will not prevent the program to exit later...
      # a real fix would be to wrap c++ exception in vtk
      img.UpdateOutputInformation()
      img.Update()
      
      # flip the image to get the same representation than the vtk one
      self.__flipper__ = itk.FlipImageFilter[img].New(Input=img)
      axes = self.__flipper__.GetFlipAxes()
      axes.SetElement(1, True)
      self.__flipper__.SetFlipAxes(axes)
      
      # change the spacing while still keeping the ratio to workaround vtk bug
      # when spacing is very small
      spacing_ = itk.spacing(img)
      normSpacing = []
      for i in range(0, spacing_.Size()):
        normSpacing.append( spacing_.GetElement(i) / spacing_.GetElement(0) )
      self.__changeInfo__ = itk.ChangeInformationImageFilter[img].New(self.__flipper__, OutputSpacing=normSpacing, ChangeSpacing=True)
      
      # now really convert the data
      self.__itkvtkConverter__ = itk.ImageToVTKImageFilter[img].New(self.__changeInfo__)
      self.__volumeMapper__.SetInput(self.__itkvtkConverter__.GetOutput())
      # needed to avoid warnings
      # self.__itkvtkConverter__.GetOutput() must be callable
      
      import vtk
      if not self.__outline__ :
	  self.__outline__ = vtk.vtkOutlineFilter()
	  self.__outline__.SetInput(self.__itkvtkConverter__.GetOutput())
	  self.__outlineMapper__ = vtk.vtkPolyDataMapper()
	  self.__outlineMapper__.SetInput(self.__outline__.GetOutput())
	  self.__outlineActor__ = vtk.vtkActor()
	  self.__outlineActor__.SetMapper(self.__outlineMapper__)
	  self.__ren__.AddActor(self.__outlineActor__)
      else :
	  self.__outline__.SetInput(self.__itkvtkConverter__.GetOutput())

    self.Render()
    
  def GetInput(self):
    return self.__input__
  
  def AdaptColorAndOpacity(self, minVal=None, maxVal=None):
    if minVal == None or maxVal == None :
      m, M = self.GetRange()
      if minVal == None :
        minVal = m
      if maxVal == None :
        maxVal = M
    self.AdaptOpacity(minVal, maxVal)
    self.AdaptColor(minVal, maxVal)
    
  def AdaptOpacity(self, minVal=None, maxVal=None) :
    import vtk
    if minVal == None or maxVal == None :
      m, M = self.GetRange()
      if minVal == None :
        minVal = m
      if maxVal == None :
        maxVal = M
    opacityTransferFunction = vtk.vtkPiecewiseFunction()
    opacityTransferFunction.AddPoint(minVal, self.__MinOpacity__)
    opacityTransferFunction.AddPoint(maxVal, self.__MaxOpacity__)
    self.__volumeProperty__.SetScalarOpacity(opacityTransferFunction)
    
  def AdaptColor(self, minVal=None, maxVal=None):
    import vtk
    if minVal == None or maxVal == None :
      m, M = self.GetRange()
      if minVal == None :
        minVal = m
      if maxVal == None :
        maxVal = M
    colorTransferFunction = vtk.vtkColorTransferFunction()
    colorTransferFunction.AddHSVPoint(minVal, 0.0, 0.0, 0.0)
    colorTransferFunction.AddHSVPoint((maxVal-minVal)*0.25, 0.66, 1.0, 1.0)
    colorTransferFunction.AddHSVPoint((maxVal-minVal)*0.5,  0.44, 1.0, 1.0)
    colorTransferFunction.AddHSVPoint((maxVal-minVal)*0.75, 0.22, 1.0, 1.0)
    colorTransferFunction.AddHSVPoint(maxVal,               0.0,  1.0, 1.0)
    self.__volumeProperty__.SetColor(colorTransferFunction)
    self.Render()
    
  def GetRange(self) :
    conv = self.GetConverter()
    conv.Update()
    return conv.GetOutput().GetScalarRange()
  
  def GetMaxOpacity(self) :
    return self.__MaxOpacity__
  
  def GetMinOpacity(self) :
    return self.__MinOpacity__
  
  def SetMaxOpacity(self, val) :
    self.__MaxOpacity__ = val
    self.AdaptColorAndOpacity()
    
  def SetMinOpacity(self, val) :
    self.__MinOpacity__ = val
    self.AdaptColorAndOpacity()