Commit d99aa7ccebb1005f8eefc846c90351f705a3b6ff
1 parent
9674812b
Exists in
master
and in
68 other branches
ADD: Duplicate masks on data notebook
Showing
3 changed files
with
46 additions
and
12 deletions
Show diff stats
invesalius/data/slice_.py
... | ... | @@ -93,7 +93,9 @@ class Slice(object): |
93 | 93 | |
94 | 94 | ps.Publisher().subscribe(self.OnEnableStyle, 'Enable style') |
95 | 95 | ps.Publisher().subscribe(self.OnDisableStyle, 'Disable style') |
96 | + | |
96 | 97 | ps.Publisher().subscribe(self.OnRemoveMasks, 'Remove masks') |
98 | + ps.Publisher().subscribe(self.OnDuplicateMasks, 'Duplicate masks') | |
97 | 99 | |
98 | 100 | |
99 | 101 | def OnRemoveMasks(self, pubsub_evt): |
... | ... | @@ -110,6 +112,25 @@ class Slice(object): |
110 | 112 | self.blend_filter.Update() |
111 | 113 | ps.Publisher().sendMessage('Update slice viewer') |
112 | 114 | |
115 | + def OnDuplicateMasks(self, pubsub_evt): | |
116 | + selected_items = pubsub_evt.data | |
117 | + proj = Project() | |
118 | + mask_dict = proj.mask_dict | |
119 | + for index in selected_items: | |
120 | + original_mask = mask_dict[index] | |
121 | + # compute copy name | |
122 | + name = original_mask.name | |
123 | + names_list = [mask_dict[i].name for i in mask_dict.keys()] | |
124 | + new_name = utils.next_copy_name(name, names_list) | |
125 | + # create new mask | |
126 | + self.CreateMask(imagedata = original_mask.imagedata, | |
127 | + name = new_name, | |
128 | + colour = original_mask.colour, | |
129 | + opacity = original_mask.opacity, | |
130 | + threshold_range = original_mask.threshold_range, | |
131 | + edition_threshold_range = original_mask.edition_threshold_range, | |
132 | + edited_points = original_mask.edited_points) | |
133 | + | |
113 | 134 | |
114 | 135 | def OnEnableStyle(self, pubsub_evt): |
115 | 136 | state = pubsub_evt.data |
... | ... | @@ -538,18 +559,28 @@ class Slice(object): |
538 | 559 | |
539 | 560 | widget.SetInput(flip.GetOutput()) |
540 | 561 | |
541 | - | |
542 | - def CreateMask(self, imagedata=None, name=None): | |
562 | + | |
563 | + def CreateMask(self, imagedata=None, name=None, colour=None, | |
564 | + opacity=None, threshold_range=None, | |
565 | + edition_threshold_range = None, | |
566 | + edited_points=None): | |
543 | 567 | |
544 | 568 | future_mask = Mask() |
569 | + if colour: | |
570 | + future_mask.colour = colour | |
571 | + if opacity: | |
572 | + future_mask.opacity = opacity | |
573 | + if threshold_range: | |
574 | + future_mask.threshold_range = threshold_range | |
575 | + if edition_threshold_range: | |
576 | + future_mask.edition_threshold_range = edition_threshold_range | |
577 | + if edited_points: | |
578 | + future_mask.edited_points = edited_points | |
545 | 579 | |
546 | 580 | # this is not the first mask, so we will import data from old imagedata |
547 | 581 | if imagedata is None: |
548 | - | |
549 | 582 | old_mask = self.current_mask |
550 | - | |
551 | 583 | imagedata = old_mask.imagedata |
552 | - | |
553 | 584 | future_mask.threshold_range = old_mask.threshold_range |
554 | 585 | |
555 | 586 | # if not defined in the method call, this will have been computed on | ... | ... |
invesalius/gui/data_notebook.py
... | ... | @@ -70,12 +70,12 @@ class MaskPage(wx.Panel): |
70 | 70 | """ |
71 | 71 | def __init__(self, parent): |
72 | 72 | wx.Panel.__init__(self, parent, pos=wx.Point(0, 50), |
73 | - size=wx.Size(256, 120)) | |
73 | + size=wx.Size(256, 140)) | |
74 | 74 | self.__init_gui() |
75 | 75 | |
76 | 76 | def __init_gui(self): |
77 | 77 | # listctrl were existing masks will be listed |
78 | - self.listctrl = MasksListCtrlPanel(self, size=wx.Size(256, 80)) | |
78 | + self.listctrl = MasksListCtrlPanel(self, size=wx.Size(256, 100)) | |
79 | 79 | # button control with tools (eg. remove, add new, etc) |
80 | 80 | self.buttonctrl = ButtonControlPanel(self) |
81 | 81 | |
... | ... | @@ -93,7 +93,7 @@ class ButtonControlPanel(wx.Panel): |
93 | 93 | """ |
94 | 94 | def __init__(self, parent): |
95 | 95 | wx.Panel.__init__(self, parent, pos=wx.Point(0, 50), |
96 | - size=wx.Size(256, 20)) | |
96 | + size=wx.Size(256, 22)) | |
97 | 97 | self.parent = parent |
98 | 98 | self.__init_gui() |
99 | 99 | |
... | ... | @@ -111,13 +111,16 @@ class ButtonControlPanel(wx.Panel): |
111 | 111 | button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT |
112 | 112 | button_new = pbtn.PlateButton(self, BTN_NEW, "", |
113 | 113 | BMP_NEW, |
114 | - style=button_style) | |
114 | + style=button_style, | |
115 | + size = wx.Size(18, 18)) | |
115 | 116 | button_remove = pbtn.PlateButton(self, BTN_REMOVE, "", |
116 | 117 | BMP_REMOVE, |
117 | - style=button_style) | |
118 | + style=button_style, | |
119 | + size = wx.Size(18, 18)) | |
118 | 120 | button_duplicate = pbtn.PlateButton(self, BTN_DUPLICATE, "", |
119 | 121 | BMP_DUPLICATE, |
120 | - style=button_style) | |
122 | + style=button_style, | |
123 | + size = wx.Size(18, 18)) | |
121 | 124 | |
122 | 125 | # Add all controls to gui |
123 | 126 | sizer = wx.BoxSizer(wx.HORIZONTAL) | ... | ... |
invesalius/gui/default_tasks.py
... | ... | @@ -111,7 +111,7 @@ class LowerTaskPanel(wx.Panel): |
111 | 111 | def __init__(self, parent): |
112 | 112 | wx.Panel.__init__(self, parent, pos=wx.Point(5, 5), |
113 | 113 | # size=wx.Size(280, 700)) |
114 | - size=wx.Size(280, 400)) | |
114 | + size=wx.Size(280, 420)) | |
115 | 115 | |
116 | 116 | fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, |
117 | 117 | self.GetSize(),fpb.FPB_DEFAULT_STYLE, | ... | ... |