Ejemplo n.º 1
0
    def OnButtonNextTask(self, evt):
        overwrite = self.check_box.IsChecked()
        algorithm = 'Default'
        options = {}
        to_generate = True
        if self.GetMaskSelected() != -1:
            sl = slice_.Slice()
            if sl.current_mask.was_edited:
                dlgs = dlg.SurfaceDialog()
                if dlgs.ShowModal() == wx.ID_OK:
                    algorithm = dlgs.GetAlgorithmSelected()
                    options = dlgs.GetOptions()
                else:
                    to_generate = False

                dlgs.Destroy()

            if to_generate:
                mask_index = sl.current_mask.index
                method = {'algorithm': algorithm,
                          'options': options}
                srf_options = {"index": mask_index,
                               "name": '',
                               "quality": _('Optimal *'),
                               "fill": False,
                               "keep_largest": False,
                               "overwrite": overwrite}

                Publisher.sendMessage('Create surface from index',
                                      surface_parameters={'method': method, 'options': srf_options})
                Publisher.sendMessage('Fold surface task')

        else:
            dlg.InexistentMask()
Ejemplo n.º 2
0
    def OnLinkNewSurface(self, evt=None):
        
        is_pubsub = True

        try:
            evt = evt.data
            evt = None
        except:
            pass
        
        #import invesalius.gui.dialogs as dlg
        sl = slice_.Slice()

        if sl.current_mask == None:
            dlg.InexistentMask()
            return

        dialog = dlg.SurfaceCreationDialog(None, -1,
                            _('New surface'),
                            mask_edited=sl.current_mask.was_edited)

        try:
            if dialog.ShowModal() == wx.ID_OK:
                ok = 1
            else:
                ok = 0
        except(wx._core.PyAssertionError): #TODO FIX: win64
            ok = 1

        if (ok):
            ## Retrieve information from dialog
            #(mask_index, surface_name, surface_quality, fill_holes,\
            #keep_largest) = dialog.GetValue()

            ## Retrieve information from mask
            #proj = prj.Project()
            #mask = proj.mask_dict[mask_index]

            ## Send all information so surface can be created
            #surface_data = [proj.imagedata,
                            #mask.colour,
                            #mask.threshold_range,
                            #mask.edited_points,
                            #False, # overwrite
                            #surface_name,
                            #surface_quality,
                            #fill_holes,
                            #keep_largest]


            surface_options = dialog.GetValue()

            Publisher.sendMessage('Create surface from index',
                                  surface_parameters=surface_options)
        dialog.Destroy()
        if evt:
            evt.Skip()