diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index 16b18ef..11b274d 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -93,7 +93,9 @@ class Slice(object): ps.Publisher().subscribe(self.OnEnableStyle, 'Enable style') ps.Publisher().subscribe(self.OnDisableStyle, 'Disable style') + ps.Publisher().subscribe(self.OnRemoveMasks, 'Remove masks') + ps.Publisher().subscribe(self.OnDuplicateMasks, 'Duplicate masks') def OnRemoveMasks(self, pubsub_evt): @@ -110,6 +112,25 @@ class Slice(object): self.blend_filter.Update() ps.Publisher().sendMessage('Update slice viewer') + def OnDuplicateMasks(self, pubsub_evt): + selected_items = pubsub_evt.data + proj = Project() + mask_dict = proj.mask_dict + for index in selected_items: + original_mask = mask_dict[index] + # compute copy name + name = original_mask.name + names_list = [mask_dict[i].name for i in mask_dict.keys()] + new_name = utils.next_copy_name(name, names_list) + # create new mask + self.CreateMask(imagedata = original_mask.imagedata, + name = new_name, + colour = original_mask.colour, + opacity = original_mask.opacity, + threshold_range = original_mask.threshold_range, + edition_threshold_range = original_mask.edition_threshold_range, + edited_points = original_mask.edited_points) + def OnEnableStyle(self, pubsub_evt): state = pubsub_evt.data @@ -538,18 +559,28 @@ class Slice(object): widget.SetInput(flip.GetOutput()) - - def CreateMask(self, imagedata=None, name=None): + + def CreateMask(self, imagedata=None, name=None, colour=None, + opacity=None, threshold_range=None, + edition_threshold_range = None, + edited_points=None): future_mask = Mask() + if colour: + future_mask.colour = colour + if opacity: + future_mask.opacity = opacity + if threshold_range: + future_mask.threshold_range = threshold_range + if edition_threshold_range: + future_mask.edition_threshold_range = edition_threshold_range + if edited_points: + future_mask.edited_points = edited_points # this is not the first mask, so we will import data from old imagedata if imagedata is None: - old_mask = self.current_mask - imagedata = old_mask.imagedata - future_mask.threshold_range = old_mask.threshold_range # if not defined in the method call, this will have been computed on diff --git a/invesalius/gui/data_notebook.py b/invesalius/gui/data_notebook.py index eb7499d..ab4d1e8 100644 --- a/invesalius/gui/data_notebook.py +++ b/invesalius/gui/data_notebook.py @@ -70,12 +70,12 @@ class MaskPage(wx.Panel): """ def __init__(self, parent): wx.Panel.__init__(self, parent, pos=wx.Point(0, 50), - size=wx.Size(256, 120)) + size=wx.Size(256, 140)) self.__init_gui() def __init_gui(self): # listctrl were existing masks will be listed - self.listctrl = MasksListCtrlPanel(self, size=wx.Size(256, 80)) + self.listctrl = MasksListCtrlPanel(self, size=wx.Size(256, 100)) # button control with tools (eg. remove, add new, etc) self.buttonctrl = ButtonControlPanel(self) @@ -93,7 +93,7 @@ class ButtonControlPanel(wx.Panel): """ def __init__(self, parent): wx.Panel.__init__(self, parent, pos=wx.Point(0, 50), - size=wx.Size(256, 20)) + size=wx.Size(256, 22)) self.parent = parent self.__init_gui() @@ -111,13 +111,16 @@ class ButtonControlPanel(wx.Panel): button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT button_new = pbtn.PlateButton(self, BTN_NEW, "", BMP_NEW, - style=button_style) + style=button_style, + size = wx.Size(18, 18)) button_remove = pbtn.PlateButton(self, BTN_REMOVE, "", BMP_REMOVE, - style=button_style) + style=button_style, + size = wx.Size(18, 18)) button_duplicate = pbtn.PlateButton(self, BTN_DUPLICATE, "", BMP_DUPLICATE, - style=button_style) + style=button_style, + size = wx.Size(18, 18)) # Add all controls to gui sizer = wx.BoxSizer(wx.HORIZONTAL) diff --git a/invesalius/gui/default_tasks.py b/invesalius/gui/default_tasks.py index 8d388a4..526689e 100755 --- a/invesalius/gui/default_tasks.py +++ b/invesalius/gui/default_tasks.py @@ -111,7 +111,7 @@ class LowerTaskPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, pos=wx.Point(5, 5), # size=wx.Size(280, 700)) - size=wx.Size(280, 400)) + size=wx.Size(280, 420)) fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, self.GetSize(),fpb.FPB_DEFAULT_STYLE, -- libgit2 0.21.2