From 89a5f0fa5bc32fbff4044290a70cb0b6d59a38f5 Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Fri, 27 Feb 2015 16:05:25 -0300 Subject: [PATCH] The use of ctrl and shift in the threshold pen --- invesalius/constants.py | 2 ++ invesalius/data/slice_.py | 8 ++++++-- invesalius/data/styles.py | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/invesalius/constants.py b/invesalius/constants.py index bb38a08..f5d0953 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -251,6 +251,8 @@ BRUSH_DRAW = 0 BRUSH_ERASE = 1 BRUSH_THRESH = 2 BRUSH_THRESH_ERASE = 3 +BRUSH_THRESH_ADD_ONLY = 4 +BRUSH_THRESH_ERASE_ONLY = 5 DEFAULT_BRUSH_OP = BRUSH_THRESH BRUSH_OP_NAME = [_("Draw"), _("Erase"), _("Threshold")] diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index d408b4a..106fb10 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -461,8 +461,12 @@ class Slice(object): roi_m[index] = (((roi_i[index] >= thresh_min) & (roi_i[index] <= thresh_max)) * 253) + 1 elif operation == const.BRUSH_THRESH_ERASE: - roi_m[index] = (((roi_i[index] >= thresh_min) - & (roi_i[index] <= thresh_max)) * 1) -1 + roi_m[index] = (((roi_i[index] < thresh_min) + | (roi_i[index] > thresh_max)) * 253) + 1 + elif operation == const.BRUSH_THRESH_ADD_ONLY: + roi_m[((index) & (roi_i >= thresh_min) & (roi_i <= thresh_max))] = 254 + elif operation == const.BRUSH_THRESH_ERASE_ONLY: + roi_m[((index) & ((roi_i < thresh_min) | (roi_i > thresh_max)))] = 1 elif operation == const.BRUSH_DRAW: roi_m[index] = 254 elif operation == const.BRUSH_ERASE: diff --git a/invesalius/data/styles.py b/invesalius/data/styles.py index e48466b..27afba0 100644 --- a/invesalius/data/styles.py +++ b/invesalius/data/styles.py @@ -563,8 +563,12 @@ class EditorInteractorStyle(DefaultInteractorStyle): operation = viewer._brush_cursor_op if operation == const.BRUSH_THRESH: if iren.GetControlKey(): - operation = const.BRUSH_THRESH_ERASE - + if iren.GetShiftKey(): + operation = const.BRUSH_THRESH_ERASE_ONLY + else: + operation = const.BRUSH_THRESH_ERASE + elif iren.GetShiftKey(): + operation = const.BRUSH_THRESH_ADD_ONLY viewer._set_editor_cursor_visibility(1) @@ -615,7 +619,12 @@ class EditorInteractorStyle(DefaultInteractorStyle): operation = viewer._brush_cursor_op if operation == const.BRUSH_THRESH: if iren.GetControlKey(): - operation = const.BRUSH_THRESH_ERASE + if iren.GetShiftKey(): + operation = const.BRUSH_THRESH_ERASE_ONLY + else: + operation = const.BRUSH_THRESH_ERASE + elif iren.GetShiftKey(): + operation = const.BRUSH_THRESH_ADD_ONLY # TODO: Improve! #for i in self.slice_data_list: -- libgit2 0.21.2