From b87bcfe2df763331999df87dc66053ffcf35ae33 Mon Sep 17 00:00:00 2001 From: tfmoraes Date: Fri, 24 Jul 2009 12:34:48 +0000 Subject: [PATCH] ENH: Only apply cursor operations into the imagedata --- invesalius/data/viewer_slice.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index fa2269f..afcbcda 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -17,6 +17,8 @@ # detalhes. #-------------------------------------------------------------------------- +import itertools + import vtk from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor import wx @@ -191,7 +193,8 @@ class Viewer(wx.Panel): elif self._brush_cursor_op == 'Threshold': evt_msg = 'Edit mask pixel' - pixels = self.cursor.GetPixels() + pixels = itertools.ifilter(self.TestOperationPosition, + self.cursor.GetPixels()) for coord in pixels: ps.Publisher().sendMessage(evt_msg, coord) @@ -214,7 +217,8 @@ class Viewer(wx.Panel): evt_msg = 'Edit mask pixel' if self.mouse_pressed: - pixels = self.cursor.GetPixels() + pixels = itertools.ifilter(self.TestOperationPosition, + self.cursor.GetPixels()) for coord in pixels: ps.Publisher().sendMessage(evt_msg, coord) self.interactor.Render() @@ -474,5 +478,15 @@ class Viewer(wx.Panel): self.scroll.SetThumbPosition(index) self.interactor.Render() + def TestOperationPosition(self, coord): + x, y, z = coord + xi, yi, zi = 0, 0, 0 + xf, yf, zf = self.imagedata.GetDimensions() + if xi <= x <= xf \ + and yi <= y <= yf\ + and zi <= z <= zf: + return True + return False + -- libgit2 0.21.2