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 251 BRUSH_ERASE = 1
252 252 BRUSH_THRESH = 2
253 253 BRUSH_THRESH_ERASE = 3
  254 +BRUSH_THRESH_ADD_ONLY = 4
  255 +BRUSH_THRESH_ERASE_ONLY = 5
254 256 DEFAULT_BRUSH_OP = BRUSH_THRESH
255 257 BRUSH_OP_NAME = [_("Draw"), _("Erase"), _("Threshold")]
256 258  
... ...
invesalius/data/slice_.py
... ... @@ -461,8 +461,12 @@ class Slice(object):
461 461 roi_m[index] = (((roi_i[index] >= thresh_min)
462 462 & (roi_i[index] <= thresh_max)) * 253) + 1
463 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 470 elif operation == const.BRUSH_DRAW:
467 471 roi_m[index] = 254
468 472 elif operation == const.BRUSH_ERASE:
... ...
invesalius/data/styles.py
... ... @@ -563,8 +563,12 @@ class EditorInteractorStyle(DefaultInteractorStyle):
563 563 operation = viewer._brush_cursor_op
564 564 if operation == const.BRUSH_THRESH:
565 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 573 viewer._set_editor_cursor_visibility(1)
570 574  
... ... @@ -615,7 +619,12 @@ class EditorInteractorStyle(DefaultInteractorStyle):
615 619 operation = viewer._brush_cursor_op
616 620 if operation == const.BRUSH_THRESH:
617 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 629 # TODO: Improve!
621 630 #for i in self.slice_data_list:
... ...