Commit 1fbf17c3801c655d571baa7aa3823ee597309dc0
1 parent
15b0419c
Exists in
master
and in
54 other branches
fixed the problems with the threshold events
Showing
2 changed files
with
25 additions
and
5 deletions
Show diff stats
invesalius/data/slice_.py
@@ -306,6 +306,16 @@ class Slice(object): | @@ -306,6 +306,16 @@ class Slice(object): | ||
306 | self.current_mask.matrix[:] = 0 | 306 | self.current_mask.matrix[:] = 0 |
307 | self.current_mask.clear_history() | 307 | self.current_mask.clear_history() |
308 | 308 | ||
309 | + to_reload = False | ||
310 | + if threshold_range != self.current_mask.threshold_range: | ||
311 | + print "<<<<<<<<<<<<<<<< DIFERENT >>>>>>>>>>>>>>>>>>>>>>>" | ||
312 | + to_reload = True | ||
313 | + for orientation in self.buffer_slices: | ||
314 | + self.buffer_slices[orientation].discard_vtk_mask() | ||
315 | + self.SetMaskThreshold(index, threshold_range, | ||
316 | + self.buffer_slices[orientation].index, | ||
317 | + orientation) | ||
318 | + | ||
309 | # TODO: merge this code with apply_slice_buffer_to_mask | 319 | # TODO: merge this code with apply_slice_buffer_to_mask |
310 | b_mask = self.buffer_slices["AXIAL"].mask | 320 | b_mask = self.buffer_slices["AXIAL"].mask |
311 | n = self.buffer_slices["AXIAL"].index + 1 | 321 | n = self.buffer_slices["AXIAL"].index + 1 |
@@ -322,6 +332,9 @@ class Slice(object): | @@ -322,6 +332,9 @@ class Slice(object): | ||
322 | self.current_mask.matrix[1:, 1:, n] = b_mask | 332 | self.current_mask.matrix[1:, 1:, n] = b_mask |
323 | self.current_mask.matrix[0, 0, n] = 1 | 333 | self.current_mask.matrix[0, 0, n] = 1 |
324 | 334 | ||
335 | + if to_reload: | ||
336 | + Publisher.sendMessage('Reload actual slice') | ||
337 | + | ||
325 | def __set_current_mask_threshold_actual_slice(self, evt_pubsub): | 338 | def __set_current_mask_threshold_actual_slice(self, evt_pubsub): |
326 | threshold_range = evt_pubsub.data | 339 | threshold_range = evt_pubsub.data |
327 | index = self.current_mask.index | 340 | index = self.current_mask.index |
invesalius/gui/widgets/gradient.py
@@ -381,10 +381,13 @@ class GradientCtrl(wx.Panel): | @@ -381,10 +381,13 @@ class GradientCtrl(wx.Panel): | ||
381 | def _FireSpinMinChange(self, evt): | 381 | def _FireSpinMinChange(self, evt): |
382 | evt.Skip() | 382 | evt.Skip() |
383 | value = int(self.spin_min.GetValue()) | 383 | value = int(self.spin_min.GetValue()) |
384 | - if value != self.GetMinValue(): | 384 | + if value < self.min_range or value > self.max_range: |
385 | + self.spin_min.SetValue(self.minimun) | ||
386 | + return | ||
387 | + | ||
388 | + if value != self.GetMinValue() or self.changed: | ||
385 | self.SetMinValue(value) | 389 | self.SetMinValue(value) |
386 | - self._GenerateEvent(myEVT_THRESHOLD_CHANGING) | ||
387 | - print "VALLUUUEE", value | 390 | + self._GenerateEvent(myEVT_THRESHOLD_CHANGED) |
388 | 391 | ||
389 | def _FireSpinMinChanged(self, evt): | 392 | def _FireSpinMinChanged(self, evt): |
390 | if self.changed: | 393 | if self.changed: |
@@ -393,9 +396,13 @@ class GradientCtrl(wx.Panel): | @@ -393,9 +396,13 @@ class GradientCtrl(wx.Panel): | ||
393 | def _FireSpinMaxChange(self, evt): | 396 | def _FireSpinMaxChange(self, evt): |
394 | evt.Skip() | 397 | evt.Skip() |
395 | value = int(self.spin_max.GetValue()) | 398 | value = int(self.spin_max.GetValue()) |
396 | - if value != self.GetMaxValue(): | 399 | + if value < self.min_range or value > self.max_range: |
400 | + self.spin_max.SetValue(self.maximun) | ||
401 | + return | ||
402 | + | ||
403 | + if value != self.GetMaxValue() or self.changed: | ||
397 | self.SetMaxValue(value) | 404 | self.SetMaxValue(value) |
398 | - self._GenerateEvent(myEVT_THRESHOLD_CHANGING) | 405 | + self._GenerateEvent(myEVT_THRESHOLD_CHANGED) |
399 | 406 | ||
400 | def _FireSpinMaxChanged(self, evt): | 407 | def _FireSpinMaxChanged(self, evt): |
401 | if self.changed: | 408 | if self.changed: |