diff --git a/invesalius/constants.py b/invesalius/constants.py index f5d0953..6fcdc48 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -258,6 +258,7 @@ BRUSH_OP_NAME = [_("Draw"), _("Erase"), _("Threshold")] BRUSH_COLOUR = (0,0,1.0) BRUSH_SIZE = 30 +BRUSH_MAX_SIZE = 100 # Surface creation values. Each element's list contains: # 0: imagedata reformat ratio diff --git a/invesalius/data/cursor_actors.py b/invesalius/data/cursor_actors.py index 601da24..5dba5f9 100644 --- a/invesalius/data/cursor_actors.py +++ b/invesalius/data/cursor_actors.py @@ -78,6 +78,7 @@ class CursorBase(object): self.size = 15.0 self.orientation = "AXIAL" self.spacing = (1, 1, 1) + self.position = (0, 0, 0) if vtk.vtkVersion().GetVTKVersion() > '5.8.0': self.mapper = vtk.vtkImageSliceMapper() cursor_property = vtk.vtkImageProperty() @@ -108,6 +109,7 @@ class CursorBase(object): def SetPosition(self, position): # Overriding SetPosition method because in rectangles with odd # dimensions there is no half position. + self.position = position px, py, pz = position sx, sy, sz = self.spacing tx = self.actor.GetXRange()[1] - self.actor.GetXRange()[0] diff --git a/invesalius/data/styles.py b/invesalius/data/styles.py index 9c71407..ca93b3e 100644 --- a/invesalius/data/styles.py +++ b/invesalius/data/styles.py @@ -540,6 +540,11 @@ class EditorInteractorStyle(DefaultInteractorStyle): self.AddObserver("LeftButtonReleaseEvent", self.OnBrushRelease) self.AddObserver("MouseMoveEvent", self.OnBrushMove) + self.RemoveObservers("MouseWheelForwardEvent") + self.RemoveObservers("MouseWheelBackwardEvent") + self.AddObserver("MouseWheelForwardEvent",self.EOnScrollForward) + self.AddObserver("MouseWheelBackwardEvent", self.EOnScrollBackward) + def OnEnterInteractor(self, obj, evt): if (self.viewer.slice_.buffer_slices[self.orientation].mask is None): return @@ -683,6 +688,39 @@ class EditorInteractorStyle(DefaultInteractorStyle): self.viewer.slice_.apply_slice_buffer_to_mask(self.orientation) self.viewer._flush_buffer = False + def EOnScrollForward(self, evt, obj): + iren = self.viewer.interactor + if iren.GetControlKey(): + mouse_x, mouse_y = iren.GetEventPosition() + render = iren.FindPokedRenderer(mouse_x, mouse_y) + slice_data = self.viewer.get_slice_data(render) + cursor = slice_data.cursor + size = cursor.radius * 2 + + if size < 100: + Publisher.sendMessage('Set edition brush size', size + 1) + cursor.SetPosition(cursor.position) + self.viewer.interactor.Render() + + else: + self.OnScrollForward(obj, evt) + + def EOnScrollBackward(self, evt, obj): + iren = self.viewer.interactor + if iren.GetControlKey(): + mouse_x, mouse_y = iren.GetEventPosition() + render = iren.FindPokedRenderer(mouse_x, mouse_y) + slice_data = self.viewer.get_slice_data(render) + cursor = slice_data.cursor + size = cursor.radius * 2 + + if size > 0: + Publisher.sendMessage('Set edition brush size', size - 1) + cursor.SetPosition(cursor.position) + self.viewer.interactor.Render() + else: + self.OnScrollBackward(obj, evt) + def get_coordinate_cursor(self): # Find position x, y, z = self.picker.GetPickPosition() -- libgit2 0.21.2