Commit 2ff84914ea0ee7232705069d9411e9e1b92cbfa5
1 parent
7a8a4f1b
Exists in
select_part
Appending the mask only after the proccess is over
Showing
3 changed files
with
20 additions
and
7 deletions
Show diff stats
invesalius/data/slice_.py
@@ -1039,6 +1039,7 @@ class Slice(object): | @@ -1039,6 +1039,7 @@ class Slice(object): | ||
1039 | opacity=None, | 1039 | opacity=None, |
1040 | threshold_range=None, | 1040 | threshold_range=None, |
1041 | edition_threshold_range=None, | 1041 | edition_threshold_range=None, |
1042 | + add_to_project=True, | ||
1042 | show=True): | 1043 | show=True): |
1043 | """ | 1044 | """ |
1044 | Creates a new mask and add it to project. | 1045 | Creates a new mask and add it to project. |
@@ -1073,7 +1074,8 @@ class Slice(object): | @@ -1073,7 +1074,8 @@ class Slice(object): | ||
1073 | if threshold_range: | 1074 | if threshold_range: |
1074 | future_mask.threshold_range = threshold_range | 1075 | future_mask.threshold_range = threshold_range |
1075 | 1076 | ||
1076 | - self._add_mask_into_proj(future_mask, show=show) | 1077 | + if add_to_project: |
1078 | + self._add_mask_into_proj(future_mask, show=show) | ||
1077 | 1079 | ||
1078 | return future_mask | 1080 | return future_mask |
1079 | 1081 |
invesalius/data/styles.py
@@ -1934,6 +1934,7 @@ class SelectPartConfig(object): | @@ -1934,6 +1934,7 @@ class SelectPartConfig(object): | ||
1934 | self.mask = None | 1934 | self.mask = None |
1935 | self.con_3d = 6 | 1935 | self.con_3d = 6 |
1936 | self.dlg_visible = False | 1936 | self.dlg_visible = False |
1937 | + self.mask_name = '' | ||
1937 | 1938 | ||
1938 | 1939 | ||
1939 | class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): | 1940 | class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): |
@@ -1958,6 +1959,10 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): | @@ -1958,6 +1959,10 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): | ||
1958 | 1959 | ||
1959 | def SetUp(self): | 1960 | def SetUp(self): |
1960 | if not self.config.dlg_visible: | 1961 | if not self.config.dlg_visible: |
1962 | + import data.mask as mask | ||
1963 | + default_name = const.MASK_NAME_PATTERN %(mask.Mask.general_index+2) | ||
1964 | + | ||
1965 | + self.config.mask_name = default_name | ||
1961 | self.config.dlg_visible = True | 1966 | self.config.dlg_visible = True |
1962 | self.dlg= dialogs.SelectPartsOptionsDialog(self.config) | 1967 | self.dlg= dialogs.SelectPartsOptionsDialog(self.config) |
1963 | self.dlg.Show() | 1968 | self.dlg.Show() |
@@ -1969,6 +1974,8 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): | @@ -1969,6 +1974,8 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): | ||
1969 | self.dlg = None | 1974 | self.dlg = None |
1970 | 1975 | ||
1971 | if self.config.mask: | 1976 | if self.config.mask: |
1977 | + self.config.mask.name = self.config.mask_name | ||
1978 | + self.viewer.slice_._add_mask_into_proj(self.config.mask) | ||
1972 | self.viewer.slice_.SelectCurrentMask(self.config.mask.index) | 1979 | self.viewer.slice_.SelectCurrentMask(self.config.mask.index) |
1973 | Publisher.sendMessage('Change mask selected', self.config.mask.index) | 1980 | Publisher.sendMessage('Change mask selected', self.config.mask.index) |
1974 | self.config.mask = None | 1981 | self.config.mask = None |
@@ -1989,6 +1996,8 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): | @@ -1989,6 +1996,8 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): | ||
1989 | bstruct = np.array(generate_binary_structure(3, CON3D[self.config.con_3d]), dtype='uint8') | 1996 | bstruct = np.array(generate_binary_structure(3, CON3D[self.config.con_3d]), dtype='uint8') |
1990 | self.viewer.slice_.do_threshold_to_all_slices() | 1997 | self.viewer.slice_.do_threshold_to_all_slices() |
1991 | 1998 | ||
1999 | + print bstruct | ||
2000 | + | ||
1992 | if self.config.mask is None: | 2001 | if self.config.mask is None: |
1993 | self._create_new_mask() | 2002 | self._create_new_mask() |
1994 | 2003 | ||
@@ -2004,7 +2013,7 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): | @@ -2004,7 +2013,7 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): | ||
2004 | Publisher.sendMessage('Reload actual slice') | 2013 | Publisher.sendMessage('Reload actual slice') |
2005 | 2014 | ||
2006 | def _create_new_mask(self): | 2015 | def _create_new_mask(self): |
2007 | - mask = self.viewer.slice_.create_new_mask(show=False) | 2016 | + mask = self.viewer.slice_.create_new_mask(show=False, add_to_project=False) |
2008 | mask.was_edited = True | 2017 | mask.was_edited = True |
2009 | mask.matrix[0, :, :] = 1 | 2018 | mask.matrix[0, :, :] = 1 |
2010 | mask.matrix[:, 0, :] = 1 | 2019 | mask.matrix[:, 0, :] = 1 |
invesalius/gui/dialogs.py
@@ -1953,11 +1953,8 @@ class SelectPartsOptionsDialog(wx.Dialog): | @@ -1953,11 +1953,8 @@ class SelectPartsOptionsDialog(wx.Dialog): | ||
1953 | self._init_gui() | 1953 | self._init_gui() |
1954 | 1954 | ||
1955 | def _init_gui(self): | 1955 | def _init_gui(self): |
1956 | - import data.mask as mask | ||
1957 | - | ||
1958 | - default_name = const.MASK_NAME_PATTERN %(mask.Mask.general_index+2) | ||
1959 | self.target_name = wx.TextCtrl(self, -1) | 1956 | self.target_name = wx.TextCtrl(self, -1) |
1960 | - self.target_name.SetValue(default_name) | 1957 | + self.target_name.SetValue(self.config.mask_name) |
1961 | 1958 | ||
1962 | # Connectivity 3D | 1959 | # Connectivity 3D |
1963 | self.conect3D_6 = wx.RadioButton(self, -1, "6", style=wx.RB_GROUP) | 1960 | self.conect3D_6 = wx.RadioButton(self, -1, "6", style=wx.RB_GROUP) |
@@ -1989,16 +1986,21 @@ class SelectPartsOptionsDialog(wx.Dialog): | @@ -1989,16 +1986,21 @@ class SelectPartsOptionsDialog(wx.Dialog): | ||
1989 | sizer.Fit(self) | 1986 | sizer.Fit(self) |
1990 | self.Layout() | 1987 | self.Layout() |
1991 | 1988 | ||
1989 | + self.target_name.Bind(wx.EVT_CHAR, self.OnChar) | ||
1992 | self.Bind(wx.EVT_RADIOBUTTON, self.OnSetRadio) | 1990 | self.Bind(wx.EVT_RADIOBUTTON, self.OnSetRadio) |
1993 | self.Bind(wx.EVT_CLOSE, self.OnClose) | 1991 | self.Bind(wx.EVT_CLOSE, self.OnClose) |
1994 | 1992 | ||
1993 | + def OnChar(self, evt): | ||
1994 | + evt.Skip() | ||
1995 | + self.config.mask_name = self.target_name.GetValue() | ||
1996 | + | ||
1995 | def OnSetRadio(self, evt): | 1997 | def OnSetRadio(self, evt): |
1996 | if self.conect3D_6.GetValue(): | 1998 | if self.conect3D_6.GetValue(): |
1997 | self.config.con_3d = 6 | 1999 | self.config.con_3d = 6 |
1998 | elif self.conect3D_18.GetValue(): | 2000 | elif self.conect3D_18.GetValue(): |
1999 | self.config.con_3d = 18 | 2001 | self.config.con_3d = 18 |
2000 | elif self.conect3D_26.GetValue(): | 2002 | elif self.conect3D_26.GetValue(): |
2001 | - self.config.con_3d = 2 | 2003 | + self.config.con_3d = 26 |
2002 | 2004 | ||
2003 | def OnClose(self, evt): | 2005 | def OnClose(self, evt): |
2004 | if self.config.dlg_visible: | 2006 | if self.config.dlg_visible: |