Commit 827aff91ea7783327680686dc5d5a47f14df59c1

Authored by tfmoraes
1 parent 897031ca

FIX: The edition was not applied when the user edits a slice and scrolls without…

… release the mouse button
Showing 1 changed file with 12 additions and 1 deletions   Show diff stats
invesalius/data/viewer_slice.py
@@ -100,6 +100,7 @@ class Viewer(wx.Panel): @@ -100,6 +100,7 @@ class Viewer(wx.Panel):
100 self.__bind_events_wx() 100 self.__bind_events_wx()
101 101
102 self._warped = False 102 self._warped = False
  103 + self._flush_buffer = False
103 104
104 def __init_gui(self): 105 def __init_gui(self):
105 self.interactor = wxVTKRenderWindowInteractor(self, -1, size=self.GetSize()) 106 self.interactor = wxVTKRenderWindowInteractor(self, -1, size=self.GetSize())
@@ -740,6 +741,7 @@ class Viewer(wx.Panel): @@ -740,6 +741,7 @@ class Viewer(wx.Panel):
740 741
741 self.slice_.edit_mask_pixel(self._brush_cursor_op, cursor.GetPixels(), 742 self.slice_.edit_mask_pixel(self._brush_cursor_op, cursor.GetPixels(),
742 position, radius, self.orientation) 743 position, radius, self.orientation)
  744 + self._flush_buffer = True
743 745
744 # TODO: To create a new function to reload images to viewer. 746 # TODO: To create a new function to reload images to viewer.
745 self.OnScrollBar() 747 self.OnScrollBar()
@@ -783,7 +785,6 @@ class Viewer(wx.Panel): @@ -783,7 +785,6 @@ class Viewer(wx.Panel):
783 785
784 self.slice_.edit_mask_pixel(self._brush_cursor_op, cursor.GetPixels(), 786 self.slice_.edit_mask_pixel(self._brush_cursor_op, cursor.GetPixels(),
785 position, radius, self.orientation) 787 position, radius, self.orientation)
786 -  
787 # TODO: To create a new function to reload images to viewer. 788 # TODO: To create a new function to reload images to viewer.
788 self.OnScrollBar(update3D=False) 789 self.OnScrollBar(update3D=False)
789 790
@@ -792,6 +793,7 @@ class Viewer(wx.Panel): @@ -792,6 +793,7 @@ class Viewer(wx.Panel):
792 793
793 def OnBrushRelease(self, evt, obj): 794 def OnBrushRelease(self, evt, obj):
794 self.slice_.apply_slice_buffer_to_mask(self.orientation) 795 self.slice_.apply_slice_buffer_to_mask(self.orientation)
  796 + self._flush_buffer = False
795 797
796 def OnCrossMouseClick(self, evt, obj): 798 def OnCrossMouseClick(self, evt, obj):
797 self.ChangeCrossPosition() 799 self.ChangeCrossPosition()
@@ -1361,6 +1363,8 @@ class Viewer(wx.Panel): @@ -1361,6 +1363,8 @@ class Viewer(wx.Panel):
1361 else: 1363 else:
1362 self.interactor.Render() 1364 self.interactor.Render()
1363 if evt: 1365 if evt:
  1366 + if self._flush_buffer:
  1367 + self.slice_.apply_slice_buffer_to_mask(self.orientation)
1364 evt.Skip() 1368 evt.Skip()
1365 1369
1366 def OnScrollBarRelease(self, evt): 1370 def OnScrollBarRelease(self, evt):
@@ -1373,6 +1377,9 @@ class Viewer(wx.Panel): @@ -1373,6 +1377,9 @@ class Viewer(wx.Panel):
1373 min = 0 1377 min = 0
1374 max = self.slice_.GetMaxSliceNumber(self.orientation) 1378 max = self.slice_.GetMaxSliceNumber(self.orientation)
1375 1379
  1380 + if self._flush_buffer:
  1381 + self.slice_.apply_slice_buffer_to_mask(self.orientation)
  1382 +
1376 if (evt.GetKeyCode() == wx.WXK_UP and pos > min): 1383 if (evt.GetKeyCode() == wx.WXK_UP and pos > min):
1377 self.OnScrollForward() 1384 self.OnScrollForward()
1378 self.OnScrollBar() 1385 self.OnScrollBar()
@@ -1392,6 +1399,8 @@ class Viewer(wx.Panel): @@ -1392,6 +1399,8 @@ class Viewer(wx.Panel):
1392 min = 0 1399 min = 0
1393 1400
1394 if(pos > min): 1401 if(pos > min):
  1402 + if self._flush_buffer:
  1403 + self.slice_.apply_slice_buffer_to_mask(self.orientation)
1395 pos = pos - 1 1404 pos = pos - 1
1396 self.scroll.SetThumbPosition(pos) 1405 self.scroll.SetThumbPosition(pos)
1397 self.OnScrollBar() 1406 self.OnScrollBar()
@@ -1401,6 +1410,8 @@ class Viewer(wx.Panel): @@ -1401,6 +1410,8 @@ class Viewer(wx.Panel):
1401 max = self.slice_.GetMaxSliceNumber(self.orientation) 1410 max = self.slice_.GetMaxSliceNumber(self.orientation)
1402 1411
1403 if(pos < max): 1412 if(pos < max):
  1413 + if self._flush_buffer:
  1414 + self.slice_.apply_slice_buffer_to_mask(self.orientation)
1404 pos = pos + 1 1415 pos = pos + 1
1405 self.scroll.SetThumbPosition(pos) 1416 self.scroll.SetThumbPosition(pos)
1406 self.OnScrollBar() 1417 self.OnScrollBar()