From 5c132b7aff93f96fc8877a16d869c779e0ce01dd Mon Sep 17 00:00:00 2001 From: tfmoraes Date: Thu, 11 Oct 2012 13:22:45 +0000 Subject: [PATCH] Fixed some inconsistencies in the undo/redo tool: --- invesalius/data/mask.py | 12 +++++++++++- invesalius/data/slice_.py | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/invesalius/data/mask.py b/invesalius/data/mask.py index 3a03a8a..9e88062 100644 --- a/invesalius/data/mask.py +++ b/invesalius/data/mask.py @@ -174,6 +174,12 @@ class EditionHistory(object): Publisher.sendMessage("Enable undo", v_undo) Publisher.sendMessage("Enable redo", v_redo) + def clear_history(self): + self.history = [] + self.index = -1 + Publisher.sendMessage("Enable undo", False) + Publisher.sendMessage("Enable redo", False) + class Mask(): general_index = -1 @@ -288,5 +294,9 @@ class Mask(): shape = shape[0] + 1, shape[1] + 1, shape[2] + 1 self.matrix = numpy.memmap(self.temp_file, mode='w+', dtype='uint8', shape=shape) + def clear_history(self): + self.history.clear_history() + def __del__(self): - self.history._config_undo_redo(False) + if self.is_shown: + self.history._config_undo_redo(False) diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index 37f50d7..6be41e9 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -258,6 +258,23 @@ class Slice(object): index = self.current_mask.index self.num_gradient += 1 self.current_mask.matrix[:] = 0 + self.current_mask.clear_history() + + # TODO: merge this code with apply_slice_buffer_to_mask + b_mask = self.buffer_slices["AXIAL"].mask + n = self.buffer_slices["AXIAL"].index + 1 + self.current_mask.matrix[n, 1:, 1:] = b_mask + self.current_mask.matrix[n, 0, 0] = 1 + + b_mask = self.buffer_slices["CORONAL"].mask + n = self.buffer_slices["CORONAL"].index + 1 + self.current_mask.matrix[1:, n, 1:] = b_mask + self.current_mask.matrix[0, n, 0] = 1 + + b_mask = self.buffer_slices["SAGITAL"].mask + n = self.buffer_slices["SAGITAL"].index + 1 + self.current_mask.matrix[1:, 1:, n] = b_mask + self.current_mask.matrix[0, 0, n] = 1 def __set_current_mask_threshold_actual_slice(self, evt_pubsub): threshold_range = evt_pubsub.data -- libgit2 0.21.2