Commit b87bcfe2df763331999df87dc66053ffcf35ae33

Authored by tfmoraes
1 parent 2375c44f

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 17 # detalhes.
18 18 #--------------------------------------------------------------------------
19 19  
  20 +import itertools
  21 +
20 22 import vtk
21 23 from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
22 24 import wx
... ... @@ -191,7 +193,8 @@ class Viewer(wx.Panel):
191 193 elif self._brush_cursor_op == 'Threshold':
192 194 evt_msg = 'Edit mask pixel'
193 195  
194   - pixels = self.cursor.GetPixels()
  196 + pixels = itertools.ifilter(self.TestOperationPosition,
  197 + self.cursor.GetPixels())
195 198 for coord in pixels:
196 199 ps.Publisher().sendMessage(evt_msg, coord)
197 200  
... ... @@ -214,7 +217,8 @@ class Viewer(wx.Panel):
214 217 evt_msg = 'Edit mask pixel'
215 218  
216 219 if self.mouse_pressed:
217   - pixels = self.cursor.GetPixels()
  220 + pixels = itertools.ifilter(self.TestOperationPosition,
  221 + self.cursor.GetPixels())
218 222 for coord in pixels:
219 223 ps.Publisher().sendMessage(evt_msg, coord)
220 224 self.interactor.Render()
... ... @@ -474,5 +478,15 @@ class Viewer(wx.Panel):
474 478 self.scroll.SetThumbPosition(index)
475 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  
... ...