Commit 489a5ffe32ca65fe1734d7baf0ed55ccbb77403f
1 parent
8ebf6adf
Exists in
master
and in
2 other branches
Setting mouse cursor to none when enter in the viewer on watershed style
Showing
1 changed file
with
32 additions
and
32 deletions
Show diff stats
invesalius/data/styles.py
@@ -57,7 +57,7 @@ WATERSHED_OPERATIONS = {_("Erase"): BRUSH_ERASE, | @@ -57,7 +57,7 @@ WATERSHED_OPERATIONS = {_("Erase"): BRUSH_ERASE, | ||
57 | _("Background"): BRUSH_BACKGROUND,} | 57 | _("Background"): BRUSH_BACKGROUND,} |
58 | 58 | ||
59 | def get_LUT_value(data, window, level): | 59 | def get_LUT_value(data, window, level): |
60 | - return np.piecewise(data, | 60 | + return np.piecewise(data, |
61 | [data <= (level - 0.5 - (window-1)/2), | 61 | [data <= (level - 0.5 - (window-1)/2), |
62 | data > (level - 0.5 + (window-1)/2)], | 62 | data > (level - 0.5 + (window-1)/2)], |
63 | [0, 255, lambda data: ((data - (level - 0.5))/(window-1) + 0.5)*(255-0)]) | 63 | [0, 255, lambda data: ((data - (level - 0.5))/(window-1) + 0.5)*(255-0)]) |
@@ -100,8 +100,8 @@ class BaseImageInteractorStyle(vtk.vtkInteractorStyleImage): | @@ -100,8 +100,8 @@ class BaseImageInteractorStyle(vtk.vtkInteractorStyleImage): | ||
100 | 100 | ||
101 | class DefaultInteractorStyle(BaseImageInteractorStyle): | 101 | class DefaultInteractorStyle(BaseImageInteractorStyle): |
102 | """ | 102 | """ |
103 | - Interactor style responsible for Default functionalities: | ||
104 | - * Zoom moving mouse with right button pressed; | 103 | + Interactor style responsible for Default functionalities: |
104 | + * Zoom moving mouse with right button pressed; | ||
105 | * Change the slices with the scroll. | 105 | * Change the slices with the scroll. |
106 | """ | 106 | """ |
107 | def __init__(self, viewer): | 107 | def __init__(self, viewer): |
@@ -205,7 +205,7 @@ class CrossInteractorStyle(DefaultInteractorStyle): | @@ -205,7 +205,7 @@ class CrossInteractorStyle(DefaultInteractorStyle): | ||
205 | # Forcing focal point to be setted in the center of the pixel. | 205 | # Forcing focal point to be setted in the center of the pixel. |
206 | coord_cross = self.slice_actor.GetInput().GetPoint(position) | 206 | coord_cross = self.slice_actor.GetInput().GetPoint(position) |
207 | 207 | ||
208 | - coord = self.calcultate_scroll_position(position) | 208 | + coord = self.calcultate_scroll_position(position) |
209 | self.ScrollSlice(coord) | 209 | self.ScrollSlice(coord) |
210 | 210 | ||
211 | Publisher.sendMessage('Update cross position', coord_cross) | 211 | Publisher.sendMessage('Update cross position', coord_cross) |
@@ -213,7 +213,7 @@ class CrossInteractorStyle(DefaultInteractorStyle): | @@ -213,7 +213,7 @@ class CrossInteractorStyle(DefaultInteractorStyle): | ||
213 | coord_cross) | 213 | coord_cross) |
214 | Publisher.sendMessage('Set camera in volume', coord_cross) | 214 | Publisher.sendMessage('Set camera in volume', coord_cross) |
215 | Publisher.sendMessage('Render volume viewer') | 215 | Publisher.sendMessage('Render volume viewer') |
216 | - | 216 | + |
217 | iren.Render() | 217 | iren.Render() |
218 | 218 | ||
219 | 219 | ||
@@ -315,7 +315,7 @@ class WWWLInteractorStyle(DefaultInteractorStyle): | @@ -315,7 +315,7 @@ class WWWLInteractorStyle(DefaultInteractorStyle): | ||
315 | const.WINDOW_LEVEL['Manual'] = (self.acum_achange_window,\ | 315 | const.WINDOW_LEVEL['Manual'] = (self.acum_achange_window,\ |
316 | self.acum_achange_level) | 316 | self.acum_achange_level) |
317 | Publisher.sendMessage('Check window and level other') | 317 | Publisher.sendMessage('Check window and level other') |
318 | - Publisher.sendMessage('Update window level value',(self.acum_achange_window, | 318 | + Publisher.sendMessage('Update window level value',(self.acum_achange_window, |
319 | self.acum_achange_level)) | 319 | self.acum_achange_level)) |
320 | #Necessary update the slice plane in the volume case exists | 320 | #Necessary update the slice plane in the volume case exists |
321 | Publisher.sendMessage('Update slice viewer') | 321 | Publisher.sendMessage('Update slice viewer') |
@@ -362,7 +362,7 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | @@ -362,7 +362,7 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | ||
362 | slice_number = self.slice_data.number | 362 | slice_number = self.slice_data.number |
363 | self.picker.Pick(x, y, 0, render) | 363 | self.picker.Pick(x, y, 0, render) |
364 | x, y, z = self.picker.GetPickPosition() | 364 | x, y, z = self.picker.GetPickPosition() |
365 | - if self.picker.GetViewProp(): | 365 | + if self.picker.GetViewProp(): |
366 | Publisher.sendMessage("Add measurement point", | 366 | Publisher.sendMessage("Add measurement point", |
367 | ((x, y,z), const.LINEAR, | 367 | ((x, y,z), const.LINEAR, |
368 | ORIENTATIONS[self.orientation], | 368 | ORIENTATIONS[self.orientation], |
@@ -406,7 +406,7 @@ class AngularMeasureInteractorStyle(DefaultInteractorStyle): | @@ -406,7 +406,7 @@ class AngularMeasureInteractorStyle(DefaultInteractorStyle): | ||
406 | slice_number = self.slice_data.number | 406 | slice_number = self.slice_data.number |
407 | self.picker.Pick(x, y, 0, render) | 407 | self.picker.Pick(x, y, 0, render) |
408 | x, y, z = self.picker.GetPickPosition() | 408 | x, y, z = self.picker.GetPickPosition() |
409 | - if self.picker.GetViewProp(): | 409 | + if self.picker.GetViewProp(): |
410 | Publisher.sendMessage("Add measurement point", | 410 | Publisher.sendMessage("Add measurement point", |
411 | ((x, y,z), const.ANGULAR, | 411 | ((x, y,z), const.ANGULAR, |
412 | ORIENTATIONS[self.orientation], | 412 | ORIENTATIONS[self.orientation], |
@@ -457,7 +457,7 @@ class SpinInteractorStyle(DefaultInteractorStyle): | @@ -457,7 +457,7 @@ class SpinInteractorStyle(DefaultInteractorStyle): | ||
457 | ren = iren.FindPokedRenderer(mouse_x, mouse_y) | 457 | ren = iren.FindPokedRenderer(mouse_x, mouse_y) |
458 | cam = ren.GetActiveCamera() | 458 | cam = ren.GetActiveCamera() |
459 | if (self.left_pressed): | 459 | if (self.left_pressed): |
460 | - self.viewer.UpdateTextDirection(cam) | 460 | + self.viewer.UpdateTextDirection(cam) |
461 | obj.Spin() | 461 | obj.Spin() |
462 | obj.OnRightButtonDown() | 462 | obj.OnRightButtonDown() |
463 | 463 | ||
@@ -479,7 +479,7 @@ class ZoomInteractorStyle(DefaultInteractorStyle): | @@ -479,7 +479,7 @@ class ZoomInteractorStyle(DefaultInteractorStyle): | ||
479 | """ | 479 | """ |
480 | def __init__(self, viewer): | 480 | def __init__(self, viewer): |
481 | DefaultInteractorStyle.__init__(self, viewer) | 481 | DefaultInteractorStyle.__init__(self, viewer) |
482 | - | 482 | + |
483 | self.viewer = viewer | 483 | self.viewer = viewer |
484 | 484 | ||
485 | self.AddObserver("MouseMoveEvent", self.OnZoomMoveLeft) | 485 | self.AddObserver("MouseMoveEvent", self.OnZoomMoveLeft) |
@@ -634,7 +634,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | @@ -634,7 +634,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | ||
634 | self.viewer.slice_data.cursor.Show() | 634 | self.viewer.slice_data.cursor.Show() |
635 | self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) | 635 | self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) |
636 | self.viewer.interactor.Render() | 636 | self.viewer.interactor.Render() |
637 | - | 637 | + |
638 | def OnLeaveInteractor(self, obj, evt): | 638 | def OnLeaveInteractor(self, obj, evt): |
639 | self.viewer.slice_data.cursor.Show(0) | 639 | self.viewer.slice_data.cursor.Show(0) |
640 | self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) | 640 | self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) |
@@ -647,7 +647,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | @@ -647,7 +647,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | ||
647 | viewer = self.viewer | 647 | viewer = self.viewer |
648 | iren = viewer.interactor | 648 | iren = viewer.interactor |
649 | 649 | ||
650 | - operation = self.config.operation | 650 | + operation = self.config.operation |
651 | if operation == const.BRUSH_THRESH: | 651 | if operation == const.BRUSH_THRESH: |
652 | if iren.GetControlKey(): | 652 | if iren.GetControlKey(): |
653 | if iren.GetShiftKey(): | 653 | if iren.GetShiftKey(): |
@@ -664,7 +664,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | @@ -664,7 +664,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | ||
664 | operation = const.BRUSH_ERASE | 664 | operation = const.BRUSH_ERASE |
665 | 665 | ||
666 | viewer._set_editor_cursor_visibility(1) | 666 | viewer._set_editor_cursor_visibility(1) |
667 | - | 667 | + |
668 | mouse_x, mouse_y = iren.GetEventPosition() | 668 | mouse_x, mouse_y = iren.GetEventPosition() |
669 | render = iren.FindPokedRenderer(mouse_x, mouse_y) | 669 | render = iren.FindPokedRenderer(mouse_x, mouse_y) |
670 | slice_data = viewer.get_slice_data(render) | 670 | slice_data = viewer.get_slice_data(render) |
@@ -675,10 +675,10 @@ class EditorInteractorStyle(DefaultInteractorStyle): | @@ -675,10 +675,10 @@ class EditorInteractorStyle(DefaultInteractorStyle): | ||
675 | slice_data.cursor.Show() | 675 | slice_data.cursor.Show() |
676 | 676 | ||
677 | self.picker.Pick(mouse_x, mouse_y, 0, render) | 677 | self.picker.Pick(mouse_x, mouse_y, 0, render) |
678 | - | 678 | + |
679 | coord = self.get_coordinate_cursor() | 679 | coord = self.get_coordinate_cursor() |
680 | position = slice_data.actor.GetInput().FindPoint(coord) | 680 | position = slice_data.actor.GetInput().FindPoint(coord) |
681 | - | 681 | + |
682 | if position != -1: | 682 | if position != -1: |
683 | coord = slice_data.actor.GetInput().GetPoint(position) | 683 | coord = slice_data.actor.GetInput().GetPoint(position) |
684 | 684 | ||
@@ -704,12 +704,12 @@ class EditorInteractorStyle(DefaultInteractorStyle): | @@ -704,12 +704,12 @@ class EditorInteractorStyle(DefaultInteractorStyle): | ||
704 | iren = viewer.interactor | 704 | iren = viewer.interactor |
705 | 705 | ||
706 | viewer._set_editor_cursor_visibility(1) | 706 | viewer._set_editor_cursor_visibility(1) |
707 | - | 707 | + |
708 | mouse_x, mouse_y = iren.GetEventPosition() | 708 | mouse_x, mouse_y = iren.GetEventPosition() |
709 | render = iren.FindPokedRenderer(mouse_x, mouse_y) | 709 | render = iren.FindPokedRenderer(mouse_x, mouse_y) |
710 | slice_data = viewer.get_slice_data(render) | 710 | slice_data = viewer.get_slice_data(render) |
711 | 711 | ||
712 | - operation = self.config.operation | 712 | + operation = self.config.operation |
713 | if operation == const.BRUSH_THRESH: | 713 | if operation == const.BRUSH_THRESH: |
714 | if iren.GetControlKey(): | 714 | if iren.GetControlKey(): |
715 | if iren.GetShiftKey(): | 715 | if iren.GetShiftKey(): |
@@ -730,12 +730,12 @@ class EditorInteractorStyle(DefaultInteractorStyle): | @@ -730,12 +730,12 @@ class EditorInteractorStyle(DefaultInteractorStyle): | ||
730 | #i.cursor.Show(0) | 730 | #i.cursor.Show(0) |
731 | 731 | ||
732 | self.picker.Pick(mouse_x, mouse_y, 0, render) | 732 | self.picker.Pick(mouse_x, mouse_y, 0, render) |
733 | - | 733 | + |
734 | #if (self.pick.GetViewProp()): | 734 | #if (self.pick.GetViewProp()): |
735 | #self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) | 735 | #self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) |
736 | #else: | 736 | #else: |
737 | #self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) | 737 | #self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) |
738 | - | 738 | + |
739 | coord = self.get_coordinate_cursor() | 739 | coord = self.get_coordinate_cursor() |
740 | position = viewer.slice_data.actor.GetInput().FindPoint(coord) | 740 | position = viewer.slice_data.actor.GetInput().FindPoint(coord) |
741 | 741 | ||
@@ -746,7 +746,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | @@ -746,7 +746,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | ||
746 | coord = slice_data.actor.GetInput().GetPoint(position) | 746 | coord = slice_data.actor.GetInput().GetPoint(position) |
747 | slice_data.cursor.SetPosition(coord) | 747 | slice_data.cursor.SetPosition(coord) |
748 | #self.__update_cursor_position(slice_data, coord) | 748 | #self.__update_cursor_position(slice_data, coord) |
749 | - | 749 | + |
750 | if (self.left_pressed): | 750 | if (self.left_pressed): |
751 | cursor = slice_data.cursor | 751 | cursor = slice_data.cursor |
752 | position = slice_data.actor.GetInput().FindPoint(coord) | 752 | position = slice_data.actor.GetInput().FindPoint(coord) |
@@ -754,7 +754,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | @@ -754,7 +754,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | ||
754 | 754 | ||
755 | if position < 0: | 755 | if position < 0: |
756 | position = viewer.calculate_matrix_position(coord) | 756 | position = viewer.calculate_matrix_position(coord) |
757 | - | 757 | + |
758 | viewer.slice_.edit_mask_pixel(operation, cursor.GetPixels(), | 758 | viewer.slice_.edit_mask_pixel(operation, cursor.GetPixels(), |
759 | position, radius, self.orientation) | 759 | position, radius, self.orientation) |
760 | # TODO: To create a new function to reload images to viewer. | 760 | # TODO: To create a new function to reload images to viewer. |
@@ -978,12 +978,12 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | @@ -978,12 +978,12 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | ||
978 | if (self.viewer.slice_.buffer_slices[self.orientation].mask is None): | 978 | if (self.viewer.slice_.buffer_slices[self.orientation].mask is None): |
979 | return | 979 | return |
980 | self.viewer.slice_data.cursor.Show() | 980 | self.viewer.slice_data.cursor.Show() |
981 | - #self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) | 981 | + self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) |
982 | self.viewer.interactor.Render() | 982 | self.viewer.interactor.Render() |
983 | - | 983 | + |
984 | def OnLeaveInteractor(self, obj, evt): | 984 | def OnLeaveInteractor(self, obj, evt): |
985 | self.viewer.slice_data.cursor.Show(0) | 985 | self.viewer.slice_data.cursor.Show(0) |
986 | - #self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) | 986 | + self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) |
987 | self.viewer.interactor.Render() | 987 | self.viewer.interactor.Render() |
988 | 988 | ||
989 | def WOnScrollBackward(self, obj, evt): | 989 | def WOnScrollBackward(self, obj, evt): |
@@ -1030,7 +1030,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | @@ -1030,7 +1030,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | ||
1030 | iren = viewer.interactor | 1030 | iren = viewer.interactor |
1031 | 1031 | ||
1032 | viewer._set_editor_cursor_visibility(1) | 1032 | viewer._set_editor_cursor_visibility(1) |
1033 | - | 1033 | + |
1034 | mouse_x, mouse_y = iren.GetEventPosition() | 1034 | mouse_x, mouse_y = iren.GetEventPosition() |
1035 | render = iren.FindPokedRenderer(mouse_x, mouse_y) | 1035 | render = iren.FindPokedRenderer(mouse_x, mouse_y) |
1036 | slice_data = viewer.get_slice_data(render) | 1036 | slice_data = viewer.get_slice_data(render) |
@@ -1041,10 +1041,10 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | @@ -1041,10 +1041,10 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | ||
1041 | slice_data.cursor.Show() | 1041 | slice_data.cursor.Show() |
1042 | 1042 | ||
1043 | self.picker.Pick(mouse_x, mouse_y, 0, render) | 1043 | self.picker.Pick(mouse_x, mouse_y, 0, render) |
1044 | - | 1044 | + |
1045 | coord = self.get_coordinate_cursor() | 1045 | coord = self.get_coordinate_cursor() |
1046 | position = slice_data.actor.GetInput().FindPoint(coord) | 1046 | position = slice_data.actor.GetInput().FindPoint(coord) |
1047 | - | 1047 | + |
1048 | if position != -1: | 1048 | if position != -1: |
1049 | coord = slice_data.actor.GetInput().GetPoint(position) | 1049 | coord = slice_data.actor.GetInput().GetPoint(position) |
1050 | 1050 | ||
@@ -1090,7 +1090,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | @@ -1090,7 +1090,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | ||
1090 | iren = viewer.interactor | 1090 | iren = viewer.interactor |
1091 | 1091 | ||
1092 | viewer._set_editor_cursor_visibility(1) | 1092 | viewer._set_editor_cursor_visibility(1) |
1093 | - | 1093 | + |
1094 | mouse_x, mouse_y = iren.GetEventPosition() | 1094 | mouse_x, mouse_y = iren.GetEventPosition() |
1095 | render = iren.FindPokedRenderer(mouse_x, mouse_y) | 1095 | render = iren.FindPokedRenderer(mouse_x, mouse_y) |
1096 | slice_data = viewer.get_slice_data(render) | 1096 | slice_data = viewer.get_slice_data(render) |
@@ -1100,12 +1100,12 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | @@ -1100,12 +1100,12 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | ||
1100 | #i.cursor.Show(0) | 1100 | #i.cursor.Show(0) |
1101 | 1101 | ||
1102 | self.picker.Pick(mouse_x, mouse_y, 0, render) | 1102 | self.picker.Pick(mouse_x, mouse_y, 0, render) |
1103 | - | 1103 | + |
1104 | #if (self.pick.GetViewProp()): | 1104 | #if (self.pick.GetViewProp()): |
1105 | #self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) | 1105 | #self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) |
1106 | #else: | 1106 | #else: |
1107 | #self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) | 1107 | #self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) |
1108 | - | 1108 | + |
1109 | coord = self.get_coordinate_cursor() | 1109 | coord = self.get_coordinate_cursor() |
1110 | position = viewer.slice_data.actor.GetInput().FindPoint(coord) | 1110 | position = viewer.slice_data.actor.GetInput().FindPoint(coord) |
1111 | 1111 | ||
@@ -1116,7 +1116,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | @@ -1116,7 +1116,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | ||
1116 | coord = slice_data.actor.GetInput().GetPoint(position) | 1116 | coord = slice_data.actor.GetInput().GetPoint(position) |
1117 | slice_data.cursor.SetPosition(coord) | 1117 | slice_data.cursor.SetPosition(coord) |
1118 | #self.__update_cursor_position(slice_data, coord) | 1118 | #self.__update_cursor_position(slice_data, coord) |
1119 | - | 1119 | + |
1120 | if (self.left_pressed): | 1120 | if (self.left_pressed): |
1121 | cursor = slice_data.cursor | 1121 | cursor = slice_data.cursor |
1122 | position = slice_data.actor.GetInput().FindPoint(coord) | 1122 | position = slice_data.actor.GetInput().FindPoint(coord) |
@@ -1177,7 +1177,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | @@ -1177,7 +1177,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | ||
1177 | 1177 | ||
1178 | ww = self.viewer.slice_.window_width | 1178 | ww = self.viewer.slice_.window_width |
1179 | wl = self.viewer.slice_.window_level | 1179 | wl = self.viewer.slice_.window_level |
1180 | - | 1180 | + |
1181 | if BRUSH_BACKGROUND in markers and BRUSH_FOREGROUND in markers: | 1181 | if BRUSH_BACKGROUND in markers and BRUSH_FOREGROUND in markers: |
1182 | #w_algorithm = WALGORITHM[self.config.algorithm] | 1182 | #w_algorithm = WALGORITHM[self.config.algorithm] |
1183 | bstruct = generate_binary_structure(2, CON2D[self.config.con_2d]) | 1183 | bstruct = generate_binary_structure(2, CON2D[self.config.con_2d]) |