Commit 5c132b7aff93f96fc8877a16d869c779e0ce01dd
1 parent
ae891895
Exists in
master
and in
65 other branches
Fixed some inconsistencies in the undo/redo tool:
1. Only disabling undo and redo when user deletes a mask is visible 2. When user sets a new threshold the undo/redo history is cleared. This won't be needed when undo/redo will work with threshold changing. Squashed commit of the following: commit f49d8d6713b67807772958faad0e7f98d17d288c Author: Thiago Franco de Moraes <totonixsame@gmail.com> Date: Thu Oct 11 10:18:38 2012 -0300 When user sets a new threshold the undo/redo history is cleared commit 65e94cbd896e4df0c7d797ac98960e5e129c5f3e Author: Thiago Franco de Moraes <totonixsame@gmail.com> Date: Thu Oct 11 09:25:35 2012 -0300 Only disabling undo and redo when user deletes a mask is visible
Showing
2 changed files
with
28 additions
and
1 deletions
Show diff stats
invesalius/data/mask.py
@@ -174,6 +174,12 @@ class EditionHistory(object): | @@ -174,6 +174,12 @@ class EditionHistory(object): | ||
174 | Publisher.sendMessage("Enable undo", v_undo) | 174 | Publisher.sendMessage("Enable undo", v_undo) |
175 | Publisher.sendMessage("Enable redo", v_redo) | 175 | Publisher.sendMessage("Enable redo", v_redo) |
176 | 176 | ||
177 | + def clear_history(self): | ||
178 | + self.history = [] | ||
179 | + self.index = -1 | ||
180 | + Publisher.sendMessage("Enable undo", False) | ||
181 | + Publisher.sendMessage("Enable redo", False) | ||
182 | + | ||
177 | 183 | ||
178 | class Mask(): | 184 | class Mask(): |
179 | general_index = -1 | 185 | general_index = -1 |
@@ -288,5 +294,9 @@ class Mask(): | @@ -288,5 +294,9 @@ class Mask(): | ||
288 | shape = shape[0] + 1, shape[1] + 1, shape[2] + 1 | 294 | shape = shape[0] + 1, shape[1] + 1, shape[2] + 1 |
289 | self.matrix = numpy.memmap(self.temp_file, mode='w+', dtype='uint8', shape=shape) | 295 | self.matrix = numpy.memmap(self.temp_file, mode='w+', dtype='uint8', shape=shape) |
290 | 296 | ||
297 | + def clear_history(self): | ||
298 | + self.history.clear_history() | ||
299 | + | ||
291 | def __del__(self): | 300 | def __del__(self): |
292 | - self.history._config_undo_redo(False) | 301 | + if self.is_shown: |
302 | + self.history._config_undo_redo(False) |
invesalius/data/slice_.py
@@ -258,6 +258,23 @@ class Slice(object): | @@ -258,6 +258,23 @@ class Slice(object): | ||
258 | index = self.current_mask.index | 258 | index = self.current_mask.index |
259 | self.num_gradient += 1 | 259 | self.num_gradient += 1 |
260 | self.current_mask.matrix[:] = 0 | 260 | self.current_mask.matrix[:] = 0 |
261 | + self.current_mask.clear_history() | ||
262 | + | ||
263 | + # TODO: merge this code with apply_slice_buffer_to_mask | ||
264 | + b_mask = self.buffer_slices["AXIAL"].mask | ||
265 | + n = self.buffer_slices["AXIAL"].index + 1 | ||
266 | + self.current_mask.matrix[n, 1:, 1:] = b_mask | ||
267 | + self.current_mask.matrix[n, 0, 0] = 1 | ||
268 | + | ||
269 | + b_mask = self.buffer_slices["CORONAL"].mask | ||
270 | + n = self.buffer_slices["CORONAL"].index + 1 | ||
271 | + self.current_mask.matrix[1:, n, 1:] = b_mask | ||
272 | + self.current_mask.matrix[0, n, 0] = 1 | ||
273 | + | ||
274 | + b_mask = self.buffer_slices["SAGITAL"].mask | ||
275 | + n = self.buffer_slices["SAGITAL"].index + 1 | ||
276 | + self.current_mask.matrix[1:, 1:, n] = b_mask | ||
277 | + self.current_mask.matrix[0, 0, n] = 1 | ||
261 | 278 | ||
262 | def __set_current_mask_threshold_actual_slice(self, evt_pubsub): | 279 | def __set_current_mask_threshold_actual_slice(self, evt_pubsub): |
263 | threshold_range = evt_pubsub.data | 280 | threshold_range = evt_pubsub.data |