Commit 89a5f0fa5bc32fbff4044290a70cb0b6d59a38f5

Authored by Thiago Franco de Moraes
1 parent 52fc0bb0

The use of ctrl and shift in the threshold pen

invesalius/constants.py
@@ -251,6 +251,8 @@ BRUSH_DRAW = 0 @@ -251,6 +251,8 @@ BRUSH_DRAW = 0
251 BRUSH_ERASE = 1 251 BRUSH_ERASE = 1
252 BRUSH_THRESH = 2 252 BRUSH_THRESH = 2
253 BRUSH_THRESH_ERASE = 3 253 BRUSH_THRESH_ERASE = 3
  254 +BRUSH_THRESH_ADD_ONLY = 4
  255 +BRUSH_THRESH_ERASE_ONLY = 5
254 DEFAULT_BRUSH_OP = BRUSH_THRESH 256 DEFAULT_BRUSH_OP = BRUSH_THRESH
255 BRUSH_OP_NAME = [_("Draw"), _("Erase"), _("Threshold")] 257 BRUSH_OP_NAME = [_("Draw"), _("Erase"), _("Threshold")]
256 258
invesalius/data/slice_.py
@@ -461,8 +461,12 @@ class Slice(object): @@ -461,8 +461,12 @@ class Slice(object):
461 roi_m[index] = (((roi_i[index] >= thresh_min) 461 roi_m[index] = (((roi_i[index] >= thresh_min)
462 & (roi_i[index] <= thresh_max)) * 253) + 1 462 & (roi_i[index] <= thresh_max)) * 253) + 1
463 elif operation == const.BRUSH_THRESH_ERASE: 463 elif operation == const.BRUSH_THRESH_ERASE:
464 - roi_m[index] = (((roi_i[index] >= thresh_min)  
465 - & (roi_i[index] <= thresh_max)) * 1) -1 464 + roi_m[index] = (((roi_i[index] < thresh_min)
  465 + | (roi_i[index] > thresh_max)) * 253) + 1
  466 + elif operation == const.BRUSH_THRESH_ADD_ONLY:
  467 + roi_m[((index) & (roi_i >= thresh_min) & (roi_i <= thresh_max))] = 254
  468 + elif operation == const.BRUSH_THRESH_ERASE_ONLY:
  469 + roi_m[((index) & ((roi_i < thresh_min) | (roi_i > thresh_max)))] = 1
466 elif operation == const.BRUSH_DRAW: 470 elif operation == const.BRUSH_DRAW:
467 roi_m[index] = 254 471 roi_m[index] = 254
468 elif operation == const.BRUSH_ERASE: 472 elif operation == const.BRUSH_ERASE:
invesalius/data/styles.py
@@ -563,8 +563,12 @@ class EditorInteractorStyle(DefaultInteractorStyle): @@ -563,8 +563,12 @@ class EditorInteractorStyle(DefaultInteractorStyle):
563 operation = viewer._brush_cursor_op 563 operation = viewer._brush_cursor_op
564 if operation == const.BRUSH_THRESH: 564 if operation == const.BRUSH_THRESH:
565 if iren.GetControlKey(): 565 if iren.GetControlKey():
566 - operation = const.BRUSH_THRESH_ERASE  
567 - 566 + if iren.GetShiftKey():
  567 + operation = const.BRUSH_THRESH_ERASE_ONLY
  568 + else:
  569 + operation = const.BRUSH_THRESH_ERASE
  570 + elif iren.GetShiftKey():
  571 + operation = const.BRUSH_THRESH_ADD_ONLY
568 572
569 viewer._set_editor_cursor_visibility(1) 573 viewer._set_editor_cursor_visibility(1)
570 574
@@ -615,7 +619,12 @@ class EditorInteractorStyle(DefaultInteractorStyle): @@ -615,7 +619,12 @@ class EditorInteractorStyle(DefaultInteractorStyle):
615 operation = viewer._brush_cursor_op 619 operation = viewer._brush_cursor_op
616 if operation == const.BRUSH_THRESH: 620 if operation == const.BRUSH_THRESH:
617 if iren.GetControlKey(): 621 if iren.GetControlKey():
618 - operation = const.BRUSH_THRESH_ERASE 622 + if iren.GetShiftKey():
  623 + operation = const.BRUSH_THRESH_ERASE_ONLY
  624 + else:
  625 + operation = const.BRUSH_THRESH_ERASE
  626 + elif iren.GetShiftKey():
  627 + operation = const.BRUSH_THRESH_ADD_ONLY
619 628
620 # TODO: Improve! 629 # TODO: Improve!
621 #for i in self.slice_data_list: 630 #for i in self.slice_data_list: