Commit 9967768918e274a566b80de3a95c86a378908d92

Authored by tfmoraes
1 parent 366c43f4

ENH: Redoing the alterations to improve the performance from editor

invesalius/data/slice_.py
... ... @@ -112,16 +112,19 @@ class Slice(object):
112 112 self.ShowMask(index, value)
113 113 #---------------------------------------------------------------------------
114 114 def __erase_mask_pixel(self, pubsub_evt):
115   - position = pubsub_evt.data
116   - self.ErasePixel(position)
  115 + positions = pubsub_evt.data
  116 + for position in positions:
  117 + self.ErasePixel(position)
117 118  
118 119 def __edit_mask_pixel(self, pubsub_evt):
119   - position = pubsub_evt.data
120   - self.EditPixelBasedOnThreshold(position)
  120 + positions = pubsub_evt.data
  121 + for position in positions:
  122 + self.EditPixelBasedOnThreshold(position)
121 123  
122 124 def __add_mask_pixel(self, pubsub_evt):
123   - position = pubsub_evt.data
124   - self.DrawPixel(position)
  125 + positions = pubsub_evt.data
  126 + for position in positions:
  127 + self.DrawPixel(position)
125 128 #---------------------------------------------------------------------------
126 129 # END PUBSUB_EVT METHODS
127 130 #---------------------------------------------------------------------------
... ... @@ -205,7 +208,6 @@ class Slice(object):
205 208 colour = self.imagedata.GetScalarRange()[0]
206 209 imagedata = self.current_mask.imagedata
207 210 imagedata.SetScalarComponentFromDouble(x, y, z, 0, colour)
208   - imagedata.Update()
209 211 self.current_mask.edited_points[(x, y, z)] = colour
210 212  
211 213 def DrawPixel(self, position, colour=None):
... ... @@ -214,7 +216,6 @@ class Slice(object):
214 216 colour = self.imagedata.GetScalarRange()[1]
215 217 imagedata = self.current_mask.imagedata
216 218 imagedata.SetScalarComponentFromDouble(x, y, z, 0, colour)
217   - imagedata.Update()
218 219 self.current_mask.edited_points[(x, y, z)] = colour
219 220  
220 221 def EditPixelBasedOnThreshold(self, position):
... ...
invesalius/data/viewer_slice.py
... ... @@ -194,9 +194,7 @@ class Viewer(wx.Panel):
194 194  
195 195 pixels = itertools.ifilter(self.TestOperationPosition,
196 196 self.cursor.GetPixels())
197   - for coord in pixels:
198   - print coord
199   - ps.Publisher().sendMessage(msg, coord)
  197 + ps.Publisher().sendMessage(msg, pixels)
200 198  
201 199 # FIXME: This is idiot, but is the only way that brush operations are
202 200 # working when cross is disabled
... ... @@ -221,10 +219,10 @@ class Viewer(wx.Panel):
221 219 if self.mouse_pressed:
222 220 pixels = itertools.ifilter(self.TestOperationPosition,
223 221 self.cursor.GetPixels())
224   - for coord in pixels:
225   - ps.Publisher().sendMessage(evt_msg, coord)
226   - self.interactor.Render()
227   - ps.Publisher().sendMessage('Update slice viewer')
  222 + ps.Publisher().sendMessage(evt_msg, pixels)
  223 + ps.Publisher().sendMessage('Update slice viewer')
  224 + else:
  225 + self.interactor.Render()
228 226  
229 227 def OnCrossMove(self, obj, evt_vtk):
230 228 coord = self.GetCoordinate()
... ...