Commit c90d26bb44c2c8ad147e317641ba3bee8f288f76

Authored by Thiago Franco de Moraes
1 parent 3749eea2
Exists in select_part

Showing the selected part

invesalius/data/slice_.py
... ... @@ -574,6 +574,14 @@ class Slice(object):
574 574 1: (0.0, 1.0, 0.0, 1.0),
575 575 2: (1.0, 0.0, 0.0, 1.0)})
576 576 final_image = self.do_blend(final_image, cimage)
  577 + elif self.to_show_aux and self.current_mask:
  578 + m = self.get_aux_slice(self.to_show_aux, orientation, slice_number)
  579 + tmp_vimage = converters.to_vtk(m, self.spacing, slice_number, orientation)
  580 + aux_image = self.do_custom_colour(tmp_vimage, {0: (0.0, 0.0, 0.0, 0.0),
  581 + 1: (0.0, 0.0, 0.0, 0.0),
  582 + 254: (1.0, 0.0, 0.0, 1.0),
  583 + 255: (1.0, 0.0, 0.0, 1.0)})
  584 + final_image = self.do_blend(final_image, aux_image)
577 585 return final_image
578 586  
579 587 def get_image_slice(self, orientation, slice_number, number_slices=1,
... ...
invesalius/data/styles.py
... ... @@ -1931,7 +1931,7 @@ class RemoveMaskPartsInteractorStyle(FloodFillMaskInteractorStyle):
1931 1931 class SelectPartConfig(object):
1932 1932 __metaclass__= utils.Singleton
1933 1933 def __init__(self):
1934   - self.matrix = None
  1934 + self.mask = None
1935 1935 self.con_3d = 6
1936 1936  
1937 1937  
... ... @@ -1956,7 +1956,10 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle):
1956 1956 self.AddObserver("LeftButtonPressEvent", self.OnSelect)
1957 1957  
1958 1958 def CleanUp(self):
1959   - self.config.matrix = None
  1959 + if self.config.mask:
  1960 + self.config.mask = None
  1961 + del self.viewer.slice_.aux_matrices['SELECT']
  1962 + self.viewer.slice_.to_show_aux = ''
1960 1963  
1961 1964 def OnSelect(self, obj, evt):
1962 1965 if (self.viewer.slice_.buffer_slices[self.orientation].mask is None):
... ... @@ -1986,10 +1989,15 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle):
1986 1989 bstruct = np.array(generate_binary_structure(3, CON3D[self.config.con_3d]), dtype='uint8')
1987 1990 self.viewer.slice_.do_threshold_to_all_slices()
1988 1991  
1989   - if self.config.matrix is None:
  1992 + if self.config.mask is None:
1990 1993 self._create_new_mask()
1991 1994  
1992   - floodfill.floodfill_threshold(mask, [[x, y, z]], self.t0, self.t1, self.fill_value, bstruct, self.config.matrix[1:, 1:, 1:])
  1995 + floodfill.floodfill_threshold(mask, [[x, y, z]], self.t0, self.t1, self.fill_value, bstruct, self.config.mask.matrix[1:, 1:, 1:])
  1996 + self.viewer.slice_.aux_matrices['SELECT'] = self.config.mask.matrix[1:, 1:, 1:]
  1997 + self.viewer.slice_.to_show_aux = 'SELECT'
  1998 +
  1999 + self.config.mask.was_edited = True
  2000 + Publisher.sendMessage('Reload actual slice')
1993 2001  
1994 2002 def _create_new_mask(self):
1995 2003 mask = self.viewer.slice_.create_new_mask(show=False)
... ... @@ -1998,7 +2006,7 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle):
1998 2006 mask.matrix[:, 0, :] = 1
1999 2007 mask.matrix[:, :, 0] = 1
2000 2008  
2001   - self.config.matrix = mask.matrix
  2009 + self.config.mask = mask
2002 2010  
2003 2011 def get_coordinate_cursor(self):
2004 2012 # Find position
... ...