Commit b87bcfe2df763331999df87dc66053ffcf35ae33
1 parent
2375c44f
Exists in
master
and in
68 other branches
ENH: Only apply cursor operations into the imagedata
Showing
1 changed file
with
16 additions
and
2 deletions
Show diff stats
invesalius/data/viewer_slice.py
@@ -17,6 +17,8 @@ | @@ -17,6 +17,8 @@ | ||
17 | # detalhes. | 17 | # detalhes. |
18 | #-------------------------------------------------------------------------- | 18 | #-------------------------------------------------------------------------- |
19 | 19 | ||
20 | +import itertools | ||
21 | + | ||
20 | import vtk | 22 | import vtk |
21 | from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor | 23 | from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor |
22 | import wx | 24 | import wx |
@@ -191,7 +193,8 @@ class Viewer(wx.Panel): | @@ -191,7 +193,8 @@ class Viewer(wx.Panel): | ||
191 | elif self._brush_cursor_op == 'Threshold': | 193 | elif self._brush_cursor_op == 'Threshold': |
192 | evt_msg = 'Edit mask pixel' | 194 | evt_msg = 'Edit mask pixel' |
193 | 195 | ||
194 | - pixels = self.cursor.GetPixels() | 196 | + pixels = itertools.ifilter(self.TestOperationPosition, |
197 | + self.cursor.GetPixels()) | ||
195 | for coord in pixels: | 198 | for coord in pixels: |
196 | ps.Publisher().sendMessage(evt_msg, coord) | 199 | ps.Publisher().sendMessage(evt_msg, coord) |
197 | 200 | ||
@@ -214,7 +217,8 @@ class Viewer(wx.Panel): | @@ -214,7 +217,8 @@ class Viewer(wx.Panel): | ||
214 | evt_msg = 'Edit mask pixel' | 217 | evt_msg = 'Edit mask pixel' |
215 | 218 | ||
216 | if self.mouse_pressed: | 219 | if self.mouse_pressed: |
217 | - pixels = self.cursor.GetPixels() | 220 | + pixels = itertools.ifilter(self.TestOperationPosition, |
221 | + self.cursor.GetPixels()) | ||
218 | for coord in pixels: | 222 | for coord in pixels: |
219 | ps.Publisher().sendMessage(evt_msg, coord) | 223 | ps.Publisher().sendMessage(evt_msg, coord) |
220 | self.interactor.Render() | 224 | self.interactor.Render() |
@@ -474,5 +478,15 @@ class Viewer(wx.Panel): | @@ -474,5 +478,15 @@ class Viewer(wx.Panel): | ||
474 | self.scroll.SetThumbPosition(index) | 478 | self.scroll.SetThumbPosition(index) |
475 | self.interactor.Render() | 479 | self.interactor.Render() |
476 | 480 | ||
481 | + def TestOperationPosition(self, coord): | ||
482 | + x, y, z = coord | ||
483 | + xi, yi, zi = 0, 0, 0 | ||
484 | + xf, yf, zf = self.imagedata.GetDimensions() | ||
485 | + if xi <= x <= xf \ | ||
486 | + and yi <= y <= yf\ | ||
487 | + and zi <= z <= zf: | ||
488 | + return True | ||
489 | + return False | ||
490 | + | ||
477 | 491 | ||
478 | 492 |