Commit 2ff84914ea0ee7232705069d9411e9e1b92cbfa5

Authored by Thiago Franco de Moraes
1 parent 7a8a4f1b
Exists in select_part

Appending the mask only after the proccess is over

invesalius/data/slice_.py
... ... @@ -1039,6 +1039,7 @@ class Slice(object):
1039 1039 opacity=None,
1040 1040 threshold_range=None,
1041 1041 edition_threshold_range=None,
  1042 + add_to_project=True,
1042 1043 show=True):
1043 1044 """
1044 1045 Creates a new mask and add it to project.
... ... @@ -1073,7 +1074,8 @@ class Slice(object):
1073 1074 if threshold_range:
1074 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 1080 return future_mask
1079 1081  
... ...
invesalius/data/styles.py
... ... @@ -1934,6 +1934,7 @@ class SelectPartConfig(object):
1934 1934 self.mask = None
1935 1935 self.con_3d = 6
1936 1936 self.dlg_visible = False
  1937 + self.mask_name = ''
1937 1938  
1938 1939  
1939 1940 class SelectMaskPartsInteractorStyle(DefaultInteractorStyle):
... ... @@ -1958,6 +1959,10 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle):
1958 1959  
1959 1960 def SetUp(self):
1960 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 1966 self.config.dlg_visible = True
1962 1967 self.dlg= dialogs.SelectPartsOptionsDialog(self.config)
1963 1968 self.dlg.Show()
... ... @@ -1969,6 +1974,8 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle):
1969 1974 self.dlg = None
1970 1975  
1971 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 1979 self.viewer.slice_.SelectCurrentMask(self.config.mask.index)
1973 1980 Publisher.sendMessage('Change mask selected', self.config.mask.index)
1974 1981 self.config.mask = None
... ... @@ -1989,6 +1996,8 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle):
1989 1996 bstruct = np.array(generate_binary_structure(3, CON3D[self.config.con_3d]), dtype='uint8')
1990 1997 self.viewer.slice_.do_threshold_to_all_slices()
1991 1998  
  1999 + print bstruct
  2000 +
1992 2001 if self.config.mask is None:
1993 2002 self._create_new_mask()
1994 2003  
... ... @@ -2004,7 +2013,7 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle):
2004 2013 Publisher.sendMessage('Reload actual slice')
2005 2014  
2006 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 2017 mask.was_edited = True
2009 2018 mask.matrix[0, :, :] = 1
2010 2019 mask.matrix[:, 0, :] = 1
... ...
invesalius/gui/dialogs.py
... ... @@ -1953,11 +1953,8 @@ class SelectPartsOptionsDialog(wx.Dialog):
1953 1953 self._init_gui()
1954 1954  
1955 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 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 1959 # Connectivity 3D
1963 1960 self.conect3D_6 = wx.RadioButton(self, -1, "6", style=wx.RB_GROUP)
... ... @@ -1989,16 +1986,21 @@ class SelectPartsOptionsDialog(wx.Dialog):
1989 1986 sizer.Fit(self)
1990 1987 self.Layout()
1991 1988  
  1989 + self.target_name.Bind(wx.EVT_CHAR, self.OnChar)
1992 1990 self.Bind(wx.EVT_RADIOBUTTON, self.OnSetRadio)
1993 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 1997 def OnSetRadio(self, evt):
1996 1998 if self.conect3D_6.GetValue():
1997 1999 self.config.con_3d = 6
1998 2000 elif self.conect3D_18.GetValue():
1999 2001 self.config.con_3d = 18
2000 2002 elif self.conect3D_26.GetValue():
2001   - self.config.con_3d = 2
  2003 + self.config.con_3d = 26
2002 2004  
2003 2005 def OnClose(self, evt):
2004 2006 if self.config.dlg_visible:
... ...