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