コード例 #1
0
    def __init__(self, sr, pwxyz):
        """sr is a SurfRenderer"""
        gtk.Window.__init__(self)
        self.set_title('Surface renderer properties')

        self.sr = sr
        self.interactorStyle = self.sr.GetInteractorStyle()

        self.sr.AddObserver('KeyPressEvent', self.key_press)
        self.pwxyz = pwxyz

        self.notebook = gtk.Notebook()
        self.notebook.show()

        vbox = gtk.VBox()
        vbox.show()
        vbox.pack_start(self.notebook, True, True)
        self.add(vbox)

        self._make_intensity_frame()
        self._make_camera_control()
        self._make_seqment_props_frame()
        self._make_pipeline_frame()
        self._make_picker_frame()

        def hide(*args):
            self.hide()
            return True

        self.connect('delete_event', hide)

        # action area
        hbox = gtk.HBox()
        hbox.show()
        vbox.pack_start(hbox, True, True)

        button = gtk.Button(stock=gtk.STOCK_CANCEL)
        button.show()
        button.connect('clicked', hide)
        hbox.pack_start(button, True, True)

        button = ButtonAltLabel('Render', gtk.STOCK_EXECUTE)
        button.show()
        button.connect('clicked', self.render)
        hbox.pack_start(button, True, True)

        button = gtk.Button(stock=gtk.STOCK_OK)
        button.show()
        button.connect('clicked', hide)
        hbox.pack_start(button, True, True)
コード例 #2
0
    def __init__(self, sr, pwxyz):
        """sr is a SurfRenderer"""
        gtk.Window.__init__(self)
        self.set_title('Surface renderer properties')

        self.sr = sr
        self.interactorStyle = self.sr.GetInteractorStyle()

        self.sr.AddObserver('KeyPressEvent', self.key_press)
        self.pwxyz = pwxyz
        
        self.notebook = gtk.Notebook()
        self.notebook.show()

        vbox = gtk.VBox()
        vbox.show()
        vbox.pack_start(self.notebook, True, True)
        self.add(vbox)

        self._make_intensity_frame()
        self._make_camera_control()
        self._make_seqment_props_frame()
        self._make_pipeline_frame()
        self._make_picker_frame()


        def hide(*args):
            self.hide()
            return True
        self.connect('delete_event', hide)

        # action area
        hbox = gtk.HBox()
        hbox.show()
        vbox.pack_start(hbox, True, True)        


        button = gtk.Button(stock=gtk.STOCK_CANCEL)
        button.show()
        button.connect('clicked', hide)
        hbox.pack_start(button, True, True)        

            
        button = ButtonAltLabel('Render', gtk.STOCK_EXECUTE)
        button.show()
        button.connect('clicked', self.render)
        hbox.pack_start(button, True, True)        

        button = gtk.Button(stock=gtk.STOCK_OK)
        button.show()
        button.connect('clicked', hide)
        hbox.pack_start(button, True, True)        
コード例 #3
0
    def _make_camera_control(self):
        """
        Control the view of the rendered surface
        """

        frame = gtk.Frame('Camera views')
        frame.show()
        frame.set_border_width(5)

        label = gtk.Label('Views')
        label.show()
        self.notebook.append_page(frame, label)

        vbox = gtk.VBox()
        vbox.show()
        vbox.set_spacing(3)
        frame.add(vbox)


        def planes_to_surf_view(button):
            fpu = self.sr.get_camera_fpu()
            self.pwxyz.set_camera(fpu)
            self.pwxyz.Render()
            
        button = ButtonAltLabel('Snap planes to surf view', gtk.STOCK_GO_BACK)
        button.show()
        button.connect('clicked', planes_to_surf_view)
        vbox.pack_start(button, False, False)

        def surf_to_planes_view(button):
            fpu = self.pwxyz.get_camera_fpu()
            self.sr.set_camera(fpu)
            self.sr.Render()


        button = ButtonAltLabel('Snap surf to planes view', gtk.STOCK_GO_FORWARD)
        button.show()
        button.connect('clicked', surf_to_planes_view)
        vbox.pack_start(button, False, False)
コード例 #4
0
    def _make_camera_control(self):
        """
        Control the view of the rendered surface
        """

        frame = gtk.Frame('Camera views')
        frame.show()
        frame.set_border_width(5)

        label = gtk.Label('Views')
        label.show()
        self.notebook.append_page(frame, label)

        vbox = gtk.VBox()
        vbox.show()
        vbox.set_spacing(3)
        frame.add(vbox)

        def planes_to_surf_view(button):
            fpu = self.sr.get_camera_fpu()
            self.pwxyz.set_camera(fpu)
            self.pwxyz.Render()

        button = ButtonAltLabel('Snap planes to surf view', gtk.STOCK_GO_BACK)
        button.show()
        button.connect('clicked', planes_to_surf_view)
        vbox.pack_start(button, False, False)

        def surf_to_planes_view(button):
            fpu = self.pwxyz.get_camera_fpu()
            self.sr.set_camera(fpu)
            self.sr.Render()

        button = ButtonAltLabel('Snap surf to planes view',
                                gtk.STOCK_GO_FORWARD)
        button.show()
        button.connect('clicked', surf_to_planes_view)
        vbox.pack_start(button, False, False)
コード例 #5
0
    def _make_intensity_frame(self):
        """
        Provides the following attributes
        self.collecting         # intensity collection on
        self.intensitySum = 0   # intensity sum
        self.intensityCnt = 0   # intensity cnt
        self.labelIntensity     # label for intensity entry
        self.entryIntensity     # intensity entry box
        """

        self.collecting = False
        self.intensitySum = 0
        self.intensityCnt = 0

        vbox = gtk.VBox()
        vbox.show()
        vbox.set_spacing(3)

        label = gtk.Label('Segmentation')
        label.show()
        self.notebook.append_page(vbox, label)

        frame = gtk.Frame('Set the segment intensity')
        frame.show()
        frame.set_border_width(5)
        vbox.pack_start(frame, False, False)

        vboxFrame = gtk.VBox()
        vboxFrame.show()
        vboxFrame.set_spacing(3)
        frame.add(vboxFrame)

        table = gtk.Table(1, 2)
        table.set_col_spacings(3)
        table.show()
        vboxFrame.pack_start(table, True, True)

        self.labelIntensity = gtk.Label('Value: ')
        self.labelIntensity.show()
        self.entryIntensity = gtk.Entry()
        self.entryIntensity.show()
        self.entryIntensity.set_text('%1.1f' % SurfParams.intensity)

        table.attach(self.labelIntensity,
                     0,
                     1,
                     0,
                     1,
                     xoptions=gtk.FILL,
                     yoptions=0)
        table.attach(self.entryIntensity,
                     1,
                     2,
                     0,
                     1,
                     xoptions=gtk.EXPAND | gtk.FILL,
                     yoptions=0)

        hbox = gtk.HBox()
        hbox.show()
        hbox.set_homogeneous(True)
        hbox.set_spacing(3)
        vboxFrame.pack_start(hbox, False, False)

        button = ButtonAltLabel('Capture', gtk.STOCK_ADD)
        button.show()
        button.connect('clicked', self.start_collect_intensity)
        hbox.pack_start(button, True, True)

        button = ButtonAltLabel('Stop', gtk.STOCK_STOP)
        button.show()
        button.connect('clicked', self.stop_collect_intensity)
        hbox.pack_start(button, True, True)

        button = ButtonAltLabel('Clear', gtk.STOCK_CLEAR)
        button.show()
        button.connect('clicked', self.clear_intensity)
        hbox.pack_start(button, True, True)

        frame = gtk.Frame('Segment properties')
        frame.show()
        frame.set_border_width(5)
        vbox.pack_start(frame, False, False)

        vboxFrame = gtk.VBox()
        vboxFrame.show()
        vboxFrame.set_spacing(3)
        frame.add(vboxFrame)

        table = gtk.Table(2, 2)
        table.set_col_spacings(3)
        table.set_row_spacings(3)
        table.show()
        vboxFrame.pack_start(table, True, True)

        self.labelName = gtk.Label('Label: ')
        self.labelName.show()
        self.labelName.set_alignment(xalign=1.0, yalign=0.5)
        self.entryName = gtk.Entry()
        self.entryName.show()
        self.entryName.set_text(SurfParams.label)

        table.attach(self.labelName, 0, 1, 0, 1, xoptions=gtk.FILL, yoptions=0)
        table.attach(self.entryName,
                     1,
                     2,
                     0,
                     1,
                     xoptions=gtk.EXPAND | gtk.FILL,
                     yoptions=0)

        def func(menuitem, s):
            if s == 'choose':
                self.lastColor = self.choose_color()
            else:
                self.entryName.set_text(s)
                self.lastColor = colord[s]

        colors = [name for name, color in colorSeq]
        colors.append('choose')
        label = gtk.Label('Color: ')
        label.show()
        label.set_alignment(xalign=1.0, yalign=0.5)
        optmenu = make_option_menu(colors, func)
        optmenu.show()
        table.attach(label, 0, 1, 1, 2, xoptions=gtk.FILL, yoptions=0)
        table.attach(optmenu,
                     1,
                     2,
                     1,
                     2,
                     xoptions=gtk.EXPAND | gtk.FILL,
                     yoptions=0)

        button = ButtonAltLabel('Add segment', gtk.STOCK_ADD)
        button.show()
        button.connect('clicked', self.add_segment)
        vbox.pack_start(button, False, False)
コード例 #6
0
    def make_prop_dialog(self):

        dlg = gtk.Dialog('Image data properties')

        vbox = dlg.vbox

        button = ButtonAltLabel('Info file', gtk.STOCK_OPEN)
        button.show()
        vbox.pack_start(button, False, False)
        button.connect('clicked', self.load_image_dialog)

        button = gtk.CheckButton('Interact with planes')
        button.show()
        vbox.pack_start(button, False, False)
        button.set_active(False)
        button.connect('toggled', self.set_interact)
        self.buttonInteract = button

        frame = gtk.Frame('Opacity')
        frame.show()
        frame.set_border_width(5)
        vbox.pack_start(frame, True, True)

        table = gtk.Table(4, 2)
        table.set_homogeneous(False)
        table.show()
        frame.add(table)

        table.set_col_spacings(3)
        table.set_row_spacings(3)
        table.set_border_width(3)

        class OpacityScrollbar(gtk.HScrollbar):
            render = True
            interactor = self.interactor
            SCROLLBARSIZE = self.SCROLLBARSIZE

            def __init__(self, labelStr, pw, row):
                self.pw = pw
                label = gtk.Label(labelStr)
                label.show()

                scrollbar = gtk.HScrollbar()
                scrollbar.show()
                scrollbar.set_range(0, 1)
                scrollbar.set_increments(0.05, 0.25)
                scrollbar.set_value(1)
                scrollbar.set_size_request(*self.SCROLLBARSIZE)
                self.scrollbar = scrollbar
                scrollbar.connect('value_changed', self.set_opacity)

                table.attach(label,
                             0,
                             1,
                             row,
                             row + 1,
                             xoptions=gtk.EXPAND,
                             yoptions=gtk.EXPAND)
                table.attach(scrollbar,
                             1,
                             2,
                             row,
                             row + 1,
                             xoptions=gtk.FILL,
                             yoptions=gtk.EXPAND)

            def set_opacity(self, *args):
                val = self.scrollbar.get_value()
                self.pw.GetTexturePlaneProperty().SetOpacity(val)
                self.pw.GetPlaneProperty().SetOpacity(val)
                if self.render: self.interactor.Render()

        xScroll = OpacityScrollbar('X', self.pwX, 0)
        yScroll = OpacityScrollbar('Y', self.pwY, 1)
        zScroll = OpacityScrollbar('Z', self.pwZ, 2)
        row = 3

        label = gtk.Label('All')
        label.show()

        scrollbar = gtk.HScrollbar()
        scrollbar.show()
        scrollbar.set_range(0, 1)
        scrollbar.set_increments(0.05, 0.25)
        scrollbar.set_value(1)

        def set_all_opacity(bar):
            xScroll.render = False
            yScroll.render = False
            zScroll.render = False
            val = bar.get_value()
            xScroll.scrollbar.set_value(val)
            yScroll.scrollbar.set_value(val)
            zScroll.scrollbar.set_value(val)
            xScroll.render = True
            yScroll.render = True
            zScroll.render = True
            self.interactor.Render()

        scrollbar.connect('value_changed', set_all_opacity)
        scrollbar.set_size_request(150, 20)

        table.attach(label,
                     0,
                     1,
                     row,
                     row + 1,
                     xoptions=gtk.EXPAND,
                     yoptions=gtk.EXPAND)
        table.attach(scrollbar,
                     1,
                     2,
                     row,
                     row + 1,
                     xoptions=gtk.FILL,
                     yoptions=gtk.EXPAND)

        def hide(button):
            dlg.hide()
            return True

        button = ButtonAltLabel('Hide', gtk.STOCK_CANCEL)
        button.show()
        button.connect('clicked', hide)
        vbox.pack_end(button, False, False)

        return dlg
コード例 #7
0
    def __init__(self, view3, tmin, tmax, twidth, scalarDisplay, quitHook=None):
        AutoPlayDialog.__init__(self, tmin, tmax, twidth, view3.newLength, scalarDisplay, quitHook)
        self.view3 = view3
        
        frame = gtk.Frame('Rotation')
        frame.show()
        self.vbox.pack_start(frame, False, False)
        frame.set_border_width(5)


        vboxFrame = gtk.VBox()
        vboxFrame.show()
        frame.add(vboxFrame)


                
        buttonUseRotation = gtk.CheckButton('Use rotation')
        buttonUseRotation.show()
        vboxFrame.pack_start(buttonUseRotation, False, False)
        buttonUseRotation.connect('toggled', self.use_rotation)
        buttonUseRotation.set_active(False)
        self.buttonUseRotation = buttonUseRotation

        self.rotationWidgets = []
        hbox = gtk.HBox()
        hbox.show()
        hbox.set_spacing(3)
        vboxFrame.pack_start(hbox, True, True)
        self.rotationWidgets.append(hbox)

        self.frames = []
            
        button = ButtonAltLabel('Clear', stock=gtk.STOCK_CUT)
        button.show()
        hbox.pack_start(button, True, True)
        button.connect('clicked', self.clear_frames)

        button = ButtonAltLabel('Add frame', stock=gtk.STOCK_ADD)
        button.show()
        hbox.pack_start(button, True, True)
        button.connect('clicked', self.add_frame)

        button = ButtonAltLabel('Interpolate', stock=gtk.STOCK_EXECUTE)
        button.show()
        hbox.pack_start(button, True, True)
        button.connect('clicked', self.interpolate_frames)

        self.labelFrames = gtk.Label()
        self.labelFrames.show()
        hbox.pack_start(self.labelFrames, True, True)


        hbox = gtk.HBox()
        hbox.show()
        hbox.set_spacing(3)
        vboxFrame.pack_start(hbox, True, True)
        self.rotationWidgets.append(hbox)
        
        labelPerTime = gtk.Label('Frames per time step')
        labelPerTime.show()
        hbox.pack_start(labelPerTime, False, False)



        entryPerTime = gtk.SpinButton()
        entryPerTime.show()
        hbox.pack_start(entryPerTime, False, False)
        #entryPerTime.set_width_chars(5)

        entryPerTime.set_range(0, 100)
        entryPerTime.set_increments(1, 5)
        entryPerTime.set_value(5)
        entryPerTime.set_numeric(True)
        entryPerTime.set_snap_to_ticks(True)
        entryPerTime.update()
        self.entryPerTime = entryPerTime

        self.update_frames_label()        
        self.use_rotation(self.buttonUseRotation)

        self.interpFrames = None
コード例 #8
0
    def make_prop_dialog(self):

        dlg = gtk.Dialog('Image data properties')

        vbox = dlg.vbox

        button = ButtonAltLabel('Info file', gtk.STOCK_OPEN)
        button.show()
        vbox.pack_start(button, False, False)
        button.connect('clicked', self.load_image_dialog)


        button = gtk.CheckButton('Interact with planes')
        button.show()
        vbox.pack_start(button, False, False)
        button.set_active(False)
        button.connect('toggled', self.set_interact)
        self.buttonInteract = button

        frame = gtk.Frame('Opacity')
        frame.show()
        frame.set_border_width(5)
        vbox.pack_start(frame, True, True)



        table = gtk.Table(4,2)
        table.set_homogeneous(False)
        table.show()
        frame.add(table)
        
        table.set_col_spacings(3)
        table.set_row_spacings(3)
        table.set_border_width(3)
        
        class OpacityScrollbar(gtk.HScrollbar):
            render = True
            interactor = self.interactor
            SCROLLBARSIZE = self.SCROLLBARSIZE
            def __init__(self, labelStr, pw, row):
                self.pw = pw
                label = gtk.Label(labelStr)
                label.show()

                scrollbar = gtk.HScrollbar()
                scrollbar.show()
                scrollbar.set_range(0, 1)
                scrollbar.set_increments(0.05,0.25)
                scrollbar.set_value(1)
                scrollbar.set_size_request(*self.SCROLLBARSIZE)
                self.scrollbar = scrollbar
                scrollbar.connect('value_changed', self.set_opacity)

                table.attach(label, 0, 1, row, row+1,
                             xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
                table.attach(scrollbar, 1, 2, row, row+1,
                             xoptions=gtk.FILL, yoptions=gtk.EXPAND)

            def set_opacity(self, *args):
                val = self.scrollbar.get_value()
                self.pw.GetTexturePlaneProperty().SetOpacity(val)
                self.pw.GetPlaneProperty().SetOpacity(val)
                if self.render: self.interactor.Render()

        xScroll = OpacityScrollbar('X', self.pwX, 0)
        yScroll = OpacityScrollbar('Y', self.pwY, 1)
        zScroll = OpacityScrollbar('Z', self.pwZ, 2)
        row = 3


        label = gtk.Label('All')
        label.show()

        scrollbar = gtk.HScrollbar()
        scrollbar.show()
        scrollbar.set_range(0, 1)
        scrollbar.set_increments(0.05,0.25)
        scrollbar.set_value(1)

        def set_all_opacity(bar):
            xScroll.render=False
            yScroll.render=False
            zScroll.render=False
            val = bar.get_value()
            xScroll.scrollbar.set_value(val)
            yScroll.scrollbar.set_value(val)
            zScroll.scrollbar.set_value(val)
            xScroll.render=True
            yScroll.render=True
            zScroll.render=True
            self.interactor.Render()
            
        scrollbar.connect('value_changed', set_all_opacity)
        scrollbar.set_size_request(150,20)

        table.attach(label, 0, 1, row, row+1,
                     xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
        table.attach(scrollbar, 1, 2, row, row+1,
                     xoptions=gtk.FILL, yoptions=gtk.EXPAND)



        def hide(button):
            dlg.hide()
            return True
        
        button = ButtonAltLabel('Hide', gtk.STOCK_CANCEL)
        button.show()
        button.connect('clicked', hide)
        vbox.pack_end(button, False, False)        

        return dlg
コード例 #9
0
    def _make_intensity_frame(self):
        """
        Provides the following attributes
        self.collecting         # intensity collection on
        self.intensitySum = 0   # intensity sum
        self.intensityCnt = 0   # intensity cnt
        self.labelIntensity     # label for intensity entry
        self.entryIntensity     # intensity entry box
        """

        self.collecting = False
        self.intensitySum = 0
        self.intensityCnt = 0


        vbox = gtk.VBox()
        vbox.show()
        vbox.set_spacing(3)
        
        label = gtk.Label('Segmentation')
        label.show()
        self.notebook.append_page(vbox, label)

        frame = gtk.Frame('Set the segment intensity')
        frame.show()
        frame.set_border_width(5)
        vbox.pack_start(frame, False, False)
        
        vboxFrame = gtk.VBox()
        vboxFrame.show()
        vboxFrame.set_spacing(3)
        frame.add(vboxFrame)

        table = gtk.Table(1,2)
        table.set_col_spacings(3)
        table.show()
        vboxFrame.pack_start(table, True, True)        

        self.labelIntensity = gtk.Label('Value: ')
        self.labelIntensity.show()
        self.entryIntensity = gtk.Entry()
        self.entryIntensity.show()
        self.entryIntensity.set_text('%1.1f' % SurfParams.intensity)


        table.attach(self.labelIntensity, 0, 1, 0, 1,
                     xoptions=gtk.FILL, yoptions=0)
        table.attach(self.entryIntensity, 1, 2, 0, 1,
                     xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)



        hbox = gtk.HBox()
        hbox.show()
        hbox.set_homogeneous(True)
        hbox.set_spacing(3)
        vboxFrame.pack_start(hbox, False, False)
            
        button = ButtonAltLabel('Capture', gtk.STOCK_ADD)
        button.show()
        button.connect('clicked', self.start_collect_intensity)
        hbox.pack_start(button, True, True)

        button = ButtonAltLabel('Stop', gtk.STOCK_STOP)
        button.show()
        button.connect('clicked', self.stop_collect_intensity)
        hbox.pack_start(button, True, True)

        button = ButtonAltLabel('Clear', gtk.STOCK_CLEAR)
        button.show()
        button.connect('clicked', self.clear_intensity)
        hbox.pack_start(button, True, True)



        frame = gtk.Frame('Segment properties')
        frame.show()
        frame.set_border_width(5)
        vbox.pack_start(frame, False, False)
        
        vboxFrame = gtk.VBox()
        vboxFrame.show()
        vboxFrame.set_spacing(3)
        frame.add(vboxFrame)
        
        

        table = gtk.Table(2,2)
        table.set_col_spacings(3)
        table.set_row_spacings(3)
        table.show()
        vboxFrame.pack_start(table, True, True)                

        self.labelName = gtk.Label('Label: ')
        self.labelName.show()
        self.labelName.set_alignment(xalign=1.0, yalign=0.5)
        self.entryName = gtk.Entry()
        self.entryName.show()
        self.entryName.set_text(SurfParams.label)

        table.attach(self.labelName, 0, 1, 0, 1,
                     xoptions=gtk.FILL, yoptions=0)
        table.attach(self.entryName, 1, 2, 0, 1,
                     xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)


        def func(menuitem, s):
            if s=='choose':
                self.lastColor = self.choose_color()
            else:
                self.entryName.set_text(s)
                self.lastColor = colord[s]
                            

        colors = [ name for name, color in colorSeq]
        colors.append('choose')
        label = gtk.Label('Color: ')
        label.show()
        label.set_alignment(xalign=1.0, yalign=0.5)
        optmenu = make_option_menu(
            colors, func)
        optmenu.show()
        table.attach(label, 0, 1, 1, 2,
                     xoptions=gtk.FILL, yoptions=0)
        table.attach(optmenu, 1, 2, 1, 2,
                     xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        

        button = ButtonAltLabel('Add segment', gtk.STOCK_ADD)
        button.show()
        button.connect('clicked', self.add_segment)
        vbox.pack_start(button, False, False)