Commit 52fc0bb0ff2ee8367624b50b5b8e5bdf976dfc52
1 parent
be816908
Exists in
master
and in
46 other branches
Inverting the threshold pen when the control is pressed
Showing
3 changed files
with
18 additions
and
2 deletions
Show diff stats
invesalius/constants.py
invesalius/data/slice_.py
| ... | ... | @@ -460,6 +460,9 @@ class Slice(object): |
| 460 | 460 | # (1 * 253 + 1) and out ones gets value 1 (0 * 253 + 1). |
| 461 | 461 | roi_m[index] = (((roi_i[index] >= thresh_min) |
| 462 | 462 | & (roi_i[index] <= thresh_max)) * 253) + 1 |
| 463 | + elif operation == const.BRUSH_THRESH_ERASE: | |
| 464 | + roi_m[index] = (((roi_i[index] >= thresh_min) | |
| 465 | + & (roi_i[index] <= thresh_max)) * 1) -1 | |
| 463 | 466 | elif operation == const.BRUSH_DRAW: |
| 464 | 467 | roi_m[index] = 254 |
| 465 | 468 | elif operation == const.BRUSH_ERASE: | ... | ... |
invesalius/data/styles.py
| ... | ... | @@ -556,9 +556,16 @@ class EditorInteractorStyle(DefaultInteractorStyle): |
| 556 | 556 | if (self.viewer.slice_.buffer_slices[self.orientation].mask is None): |
| 557 | 557 | return |
| 558 | 558 | |
| 559 | + | |
| 559 | 560 | viewer = self.viewer |
| 560 | 561 | iren = viewer.interactor |
| 561 | 562 | |
| 563 | + operation = viewer._brush_cursor_op | |
| 564 | + if operation == const.BRUSH_THRESH: | |
| 565 | + if iren.GetControlKey(): | |
| 566 | + operation = const.BRUSH_THRESH_ERASE | |
| 567 | + | |
| 568 | + | |
| 562 | 569 | viewer._set_editor_cursor_visibility(1) |
| 563 | 570 | |
| 564 | 571 | mouse_x, mouse_y = iren.GetEventPosition() |
| ... | ... | @@ -585,7 +592,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): |
| 585 | 592 | if position < 0: |
| 586 | 593 | position = viewer.calculate_matrix_position(coord) |
| 587 | 594 | |
| 588 | - viewer.slice_.edit_mask_pixel(viewer._brush_cursor_op, cursor.GetPixels(), | |
| 595 | + viewer.slice_.edit_mask_pixel(operation, cursor.GetPixels(), | |
| 589 | 596 | position, radius, viewer.orientation) |
| 590 | 597 | viewer._flush_buffer = True |
| 591 | 598 | |
| ... | ... | @@ -605,6 +612,11 @@ class EditorInteractorStyle(DefaultInteractorStyle): |
| 605 | 612 | render = iren.FindPokedRenderer(mouse_x, mouse_y) |
| 606 | 613 | slice_data = viewer.get_slice_data(render) |
| 607 | 614 | |
| 615 | + operation = viewer._brush_cursor_op | |
| 616 | + if operation == const.BRUSH_THRESH: | |
| 617 | + if iren.GetControlKey(): | |
| 618 | + operation = const.BRUSH_THRESH_ERASE | |
| 619 | + | |
| 608 | 620 | # TODO: Improve! |
| 609 | 621 | #for i in self.slice_data_list: |
| 610 | 622 | #i.cursor.Show(0) |
| ... | ... | @@ -635,7 +647,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): |
| 635 | 647 | if position < 0: |
| 636 | 648 | position = viewer.calculate_matrix_position(coord) |
| 637 | 649 | |
| 638 | - viewer.slice_.edit_mask_pixel(viewer._brush_cursor_op, cursor.GetPixels(), | |
| 650 | + viewer.slice_.edit_mask_pixel(operation, cursor.GetPixels(), | |
| 639 | 651 | position, radius, self.orientation) |
| 640 | 652 | # TODO: To create a new function to reload images to viewer. |
| 641 | 653 | viewer.OnScrollBar(update3D=False) | ... | ... |