Commit 0fb929271d5ae19435319d35ba7ab543e723c13b
1 parent
0474cbd4
Exists in
master
and in
46 other branches
Increasing and decreasing the cursor size with the mouse scroll
Showing
3 changed files
with
41 additions
and
0 deletions
Show diff stats
invesalius/constants.py
... | ... | @@ -258,6 +258,7 @@ BRUSH_OP_NAME = [_("Draw"), _("Erase"), _("Threshold")] |
258 | 258 | |
259 | 259 | BRUSH_COLOUR = (0,0,1.0) |
260 | 260 | BRUSH_SIZE = 30 |
261 | +BRUSH_MAX_SIZE = 100 | |
261 | 262 | |
262 | 263 | # Surface creation values. Each element's list contains: |
263 | 264 | # 0: imagedata reformat ratio | ... | ... |
invesalius/data/cursor_actors.py
... | ... | @@ -78,6 +78,7 @@ class CursorBase(object): |
78 | 78 | self.size = 15.0 |
79 | 79 | self.orientation = "AXIAL" |
80 | 80 | self.spacing = (1, 1, 1) |
81 | + self.position = (0, 0, 0) | |
81 | 82 | if vtk.vtkVersion().GetVTKVersion() > '5.8.0': |
82 | 83 | self.mapper = vtk.vtkImageSliceMapper() |
83 | 84 | cursor_property = vtk.vtkImageProperty() |
... | ... | @@ -108,6 +109,7 @@ class CursorBase(object): |
108 | 109 | def SetPosition(self, position): |
109 | 110 | # Overriding SetPosition method because in rectangles with odd |
110 | 111 | # dimensions there is no half position. |
112 | + self.position = position | |
111 | 113 | px, py, pz = position |
112 | 114 | sx, sy, sz = self.spacing |
113 | 115 | tx = self.actor.GetXRange()[1] - self.actor.GetXRange()[0] | ... | ... |
invesalius/data/styles.py
... | ... | @@ -540,6 +540,11 @@ class EditorInteractorStyle(DefaultInteractorStyle): |
540 | 540 | self.AddObserver("LeftButtonReleaseEvent", self.OnBrushRelease) |
541 | 541 | self.AddObserver("MouseMoveEvent", self.OnBrushMove) |
542 | 542 | |
543 | + self.RemoveObservers("MouseWheelForwardEvent") | |
544 | + self.RemoveObservers("MouseWheelBackwardEvent") | |
545 | + self.AddObserver("MouseWheelForwardEvent",self.EOnScrollForward) | |
546 | + self.AddObserver("MouseWheelBackwardEvent", self.EOnScrollBackward) | |
547 | + | |
543 | 548 | def OnEnterInteractor(self, obj, evt): |
544 | 549 | if (self.viewer.slice_.buffer_slices[self.orientation].mask is None): |
545 | 550 | return |
... | ... | @@ -683,6 +688,39 @@ class EditorInteractorStyle(DefaultInteractorStyle): |
683 | 688 | self.viewer.slice_.apply_slice_buffer_to_mask(self.orientation) |
684 | 689 | self.viewer._flush_buffer = False |
685 | 690 | |
691 | + def EOnScrollForward(self, evt, obj): | |
692 | + iren = self.viewer.interactor | |
693 | + if iren.GetControlKey(): | |
694 | + mouse_x, mouse_y = iren.GetEventPosition() | |
695 | + render = iren.FindPokedRenderer(mouse_x, mouse_y) | |
696 | + slice_data = self.viewer.get_slice_data(render) | |
697 | + cursor = slice_data.cursor | |
698 | + size = cursor.radius * 2 | |
699 | + | |
700 | + if size < 100: | |
701 | + Publisher.sendMessage('Set edition brush size', size + 1) | |
702 | + cursor.SetPosition(cursor.position) | |
703 | + self.viewer.interactor.Render() | |
704 | + | |
705 | + else: | |
706 | + self.OnScrollForward(obj, evt) | |
707 | + | |
708 | + def EOnScrollBackward(self, evt, obj): | |
709 | + iren = self.viewer.interactor | |
710 | + if iren.GetControlKey(): | |
711 | + mouse_x, mouse_y = iren.GetEventPosition() | |
712 | + render = iren.FindPokedRenderer(mouse_x, mouse_y) | |
713 | + slice_data = self.viewer.get_slice_data(render) | |
714 | + cursor = slice_data.cursor | |
715 | + size = cursor.radius * 2 | |
716 | + | |
717 | + if size > 0: | |
718 | + Publisher.sendMessage('Set edition brush size', size - 1) | |
719 | + cursor.SetPosition(cursor.position) | |
720 | + self.viewer.interactor.Render() | |
721 | + else: | |
722 | + self.OnScrollBackward(obj, evt) | |
723 | + | |
686 | 724 | def get_coordinate_cursor(self): |
687 | 725 | # Find position |
688 | 726 | x, y, z = self.picker.GetPickPosition() | ... | ... |