diff --git a/invesalius/constants.py b/invesalius/constants.py index 8e70ef7..4c1e06f 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -501,6 +501,7 @@ SLICE_STATE_EDITOR = 3008 SLICE_STATE_WATERSHED = 3009 SLICE_STATE_REORIENT = 3010 SLICE_STATE_MASK_FFILL = 3011 +SLICE_STATE_REMOVE_MASK_PARTS = 3012 VOLUME_STATE_SEED = 2001 # STATE_LINEAR_MEASURE = 3001 @@ -519,6 +520,7 @@ SLICE_STYLES.append(STATE_DEFAULT) SLICE_STYLES.append(SLICE_STATE_EDITOR) SLICE_STYLES.append(SLICE_STATE_WATERSHED) SLICE_STYLES.append(SLICE_STATE_MASK_FFILL) +SLICE_STYLES.append(SLICE_STATE_REMOVE_MASK_PARTS) VOLUME_STYLES = TOOL_STATES + [VOLUME_STATE_SEED, STATE_MEASURE_DISTANCE, STATE_MEASURE_ANGLE] @@ -528,6 +530,7 @@ VOLUME_STYLES.append(STATE_DEFAULT) STYLE_LEVEL = {SLICE_STATE_EDITOR: 1, SLICE_STATE_WATERSHED: 1, SLICE_STATE_MASK_FFILL: 2, + SLICE_STATE_REMOVE_MASK_PARTS: 2, SLICE_STATE_CROSS: 2, SLICE_STATE_SCROLL: 2, SLICE_STATE_REORIENT: 2, diff --git a/invesalius/data/styles.py b/invesalius/data/styles.py index 4428a2e..4b858bf 100644 --- a/invesalius/data/styles.py +++ b/invesalius/data/styles.py @@ -1774,6 +1774,10 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): self.config = FFillConfig() self.dlg_ffill = None + self.t0 = 0 + self.t1 = 1 + self.fill_value = 254 + self.AddObserver("LeftButtonPressEvent", self.OnFFClick) def SetUp(self): @@ -1831,16 +1835,7 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): mask = self.viewer.slice_.current_mask.matrix[1:, 1:, 1:] cp_mask = mask - if iren.GetControlKey(): - t0 = 254 - t1 = 255 - fill = 1 - else: - t0 = 0 - t1 = 1 - fill = 254 - - floodfill.floodfill_threshold(cp_mask, [[x, y, z]], t0, t1, fill, bstruct, mask) + floodfill.floodfill_threshold(cp_mask, [[x, y, z]], self.t0, self.t1, self.fill_value, bstruct, mask) self.viewer.slice_.buffer_slices['AXIAL'].discard_mask() self.viewer.slice_.buffer_slices['CORONAL'].discard_mask() @@ -1891,6 +1886,14 @@ class FloodFillMaskInteractorStyle(DefaultInteractorStyle): return sagital, coronal, axial +class RemoveMaskPartsInteractorStyle(FloodFillMaskInteractorStyle): + def __init__(self, viewer): + FloodFillMaskInteractorStyle.__init__(self, viewer) + self.t0 = 254 + self.t1 = 255 + self.fill_value = 1 + + def get_style(style): STYLES = { const.STATE_DEFAULT: DefaultInteractorStyle, @@ -1907,6 +1910,7 @@ def get_style(style): const.SLICE_STATE_WATERSHED: WaterShedInteractorStyle, const.SLICE_STATE_REORIENT: ReorientImageInteractorStyle, const.SLICE_STATE_MASK_FFILL: FloodFillMaskInteractorStyle, + const.SLICE_STATE_REMOVE_MASK_PARTS: RemoveMaskPartsInteractorStyle, } return STYLES[style] diff --git a/invesalius/gui/frame.py b/invesalius/gui/frame.py index 37c9428..2e61155 100644 --- a/invesalius/gui/frame.py +++ b/invesalius/gui/frame.py @@ -569,7 +569,7 @@ class Frame(wx.Frame): Publisher.sendMessage('Enable style', const.SLICE_STATE_MASK_FFILL) def OnRemoveMaskParts(self): - Publisher.sendMessage('Enable style', const.SLICE_STATE_MASK_FFILL) + Publisher.sendMessage('Enable style', const.SLICE_STATE_REMOVE_MASK_PARTS) # ------------------------------------------------------------------ # ------------------------------------------------------------------ -- libgit2 0.21.2