From 1fbf17c3801c655d571baa7aa3823ee597309dc0 Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Tue, 8 Apr 2014 10:24:31 -0300 Subject: [PATCH] fixed the problems with the threshold events --- invesalius/data/slice_.py | 13 +++++++++++++ invesalius/gui/widgets/gradient.py | 17 ++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index 6a1fa1c..4816b96 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -306,6 +306,16 @@ class Slice(object): self.current_mask.matrix[:] = 0 self.current_mask.clear_history() + to_reload = False + if threshold_range != self.current_mask.threshold_range: + print "<<<<<<<<<<<<<<<< DIFERENT >>>>>>>>>>>>>>>>>>>>>>>" + to_reload = True + for orientation in self.buffer_slices: + self.buffer_slices[orientation].discard_vtk_mask() + self.SetMaskThreshold(index, threshold_range, + self.buffer_slices[orientation].index, + orientation) + # TODO: merge this code with apply_slice_buffer_to_mask b_mask = self.buffer_slices["AXIAL"].mask n = self.buffer_slices["AXIAL"].index + 1 @@ -322,6 +332,9 @@ class Slice(object): self.current_mask.matrix[1:, 1:, n] = b_mask self.current_mask.matrix[0, 0, n] = 1 + if to_reload: + Publisher.sendMessage('Reload actual slice') + def __set_current_mask_threshold_actual_slice(self, evt_pubsub): threshold_range = evt_pubsub.data index = self.current_mask.index diff --git a/invesalius/gui/widgets/gradient.py b/invesalius/gui/widgets/gradient.py index 5bab57f..3d44e42 100755 --- a/invesalius/gui/widgets/gradient.py +++ b/invesalius/gui/widgets/gradient.py @@ -381,10 +381,13 @@ class GradientCtrl(wx.Panel): def _FireSpinMinChange(self, evt): evt.Skip() value = int(self.spin_min.GetValue()) - if value != self.GetMinValue(): + if value < self.min_range or value > self.max_range: + self.spin_min.SetValue(self.minimun) + return + + if value != self.GetMinValue() or self.changed: self.SetMinValue(value) - self._GenerateEvent(myEVT_THRESHOLD_CHANGING) - print "VALLUUUEE", value + self._GenerateEvent(myEVT_THRESHOLD_CHANGED) def _FireSpinMinChanged(self, evt): if self.changed: @@ -393,9 +396,13 @@ class GradientCtrl(wx.Panel): def _FireSpinMaxChange(self, evt): evt.Skip() value = int(self.spin_max.GetValue()) - if value != self.GetMaxValue(): + if value < self.min_range or value > self.max_range: + self.spin_max.SetValue(self.maximun) + return + + if value != self.GetMaxValue() or self.changed: self.SetMaxValue(value) - self._GenerateEvent(myEVT_THRESHOLD_CHANGING) + self._GenerateEvent(myEVT_THRESHOLD_CHANGED) def _FireSpinMaxChanged(self, evt): if self.changed: -- libgit2 0.21.2