def __init__(self):
        EventHandler().attach(self)
        self.nsurf=0

        gtk.VBox.__init__(self)
        self.show()
        self.set_homogeneous(False)

        toolbar = self.__create_toolbar()
        self.pack_start(toolbar,False,False)
        toolbar.show()

        self.scrolled_window = gtk.ScrolledWindow()
        self.scrolled_window.show()
        self.inner_vbox = gtk.VBox()
        self.inner_vbox.show()
        self.inner_vbox.set_spacing(20)
        self.scrolled_window.add_with_viewport(self.inner_vbox)
        #self.scrolled_window.show()
        #self.inner_vbox.show()
        self.pack_start(self.scrolled_window)

        self._make_segment_list()

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

        button = ButtonAltLabel('Render', gtk.STOCK_EXECUTE)
        button.show()
        button.connect('clicked', self.render)
        self.pack_start(button, False, False)        
示例#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)
    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)        
    def __init__(self):
        gtk.VBox.__init__(self)
        self.show()

        toolbar = self.__create_toolbar()
        self.pack_start(toolbar,False,False)

        self.scrolled_window = gtk.ScrolledWindow()

        self.inner_vbox = gtk.VBox()
        self.inner_vbox.set_spacing(20)
        self.scrolled_window.add_with_viewport(self.inner_vbox)
        self.pack_start(self.scrolled_window)
        self.scrolled_window.show_all()

        self._make_roi_list()
            
        button = ButtonAltLabel('Render', gtk.STOCK_EXECUTE)
        button.show()
        button.connect('clicked', self.render)
        self.pack_end(button, False, False)        
        self.__update_treeview_visibility()
    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)
示例#6
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)
示例#7
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)
示例#8
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)