Commit 6de82a64065534f164f0222e4a413c42f5c207c1
1 parent
0354b116
Exists in
master
and in
6 other branches
FIX: Select custom threshold on mask thresh combo (fix #129)
Showing
2 changed files
with
15 additions
and
5 deletions
Show diff stats
invesalius/control.py
@@ -319,6 +319,7 @@ class Controller(): | @@ -319,6 +319,7 @@ class Controller(): | ||
319 | 319 | ||
320 | const.THRESHOLD_OUTVALUE = proj.threshold_range[0] | 320 | const.THRESHOLD_OUTVALUE = proj.threshold_range[0] |
321 | const.THRESHOLD_INVALUE = proj.threshold_range[1] | 321 | const.THRESHOLD_INVALUE = proj.threshold_range[1] |
322 | + | ||
322 | const.WINDOW_LEVEL[_('Default')] = (proj.window, proj.level) | 323 | const.WINDOW_LEVEL[_('Default')] = (proj.window, proj.level) |
323 | const.WINDOW_LEVEL[_('Manual')] = (proj.window, proj.level) | 324 | const.WINDOW_LEVEL[_('Manual')] = (proj.window, proj.level) |
324 | 325 | ||
@@ -340,6 +341,8 @@ class Controller(): | @@ -340,6 +341,8 @@ class Controller(): | ||
340 | if len(proj.mask_dict): | 341 | if len(proj.mask_dict): |
341 | mask_index = len(proj.mask_dict) -1 | 342 | mask_index = len(proj.mask_dict) -1 |
342 | ps.Publisher().sendMessage('Show mask', (mask_index, True)) | 343 | ps.Publisher().sendMessage('Show mask', (mask_index, True)) |
344 | + | ||
345 | + proj.presets.thresh_ct[_('Custom')] = proj.threshold_range | ||
343 | ps.Publisher().sendMessage('End busy cursor') | 346 | ps.Publisher().sendMessage('End busy cursor') |
344 | 347 | ||
345 | def CreateAnalyzeProject(self, imagedata): | 348 | def CreateAnalyzeProject(self, imagedata): |
invesalius/gui/task_slice.py
@@ -158,7 +158,6 @@ class InnerTaskPanel(wx.Panel): | @@ -158,7 +158,6 @@ class InnerTaskPanel(wx.Panel): | ||
158 | print "win64 - wx._core.PyAssertionError" | 158 | print "win64 - wx._core.PyAssertionError" |
159 | op = True | 159 | op = True |
160 | 160 | ||
161 | - print "TODO: Send Signal - New mask" | ||
162 | if (op): | 161 | if (op): |
163 | mask_name = dlg.GetValue() | 162 | mask_name = dlg.GetValue() |
164 | ps.Publisher().sendMessage('Create new mask', mask_name) | 163 | ps.Publisher().sendMessage('Create new mask', mask_name) |
@@ -389,6 +388,15 @@ class MaskProperties(wx.Panel): | @@ -389,6 +388,15 @@ class MaskProperties(wx.Panel): | ||
389 | self.gradient.SetMinValue(thresh_min) | 388 | self.gradient.SetMinValue(thresh_min) |
390 | self.gradient.SetMaxValue(thresh_max) | 389 | self.gradient.SetMaxValue(thresh_max) |
391 | self.bind_evt_gradient = True | 390 | self.bind_evt_gradient = True |
391 | + thresh = (thresh_min, thresh_max) | ||
392 | + if thresh in Project().presets.thresh_ct.values(): | ||
393 | + preset_name = Project().presets.thresh_ct.get_key(thresh)[0] | ||
394 | + index = self.threshold_modes_names.index(preset_name) | ||
395 | + self.combo_thresh.SetSelection(index) | ||
396 | + else: | ||
397 | + index = self.threshold_modes_names.index(_("Custom")) | ||
398 | + self.combo_thresh.SetSelection(index) | ||
399 | + Project().presets.thresh_ct[_("Custom")] = (thresh_min, thresh_max) | ||
392 | 400 | ||
393 | def SetThresholdValues2(self, pubsub_evt): | 401 | def SetThresholdValues2(self, pubsub_evt): |
394 | thresh_min, thresh_max = pubsub_evt.data | 402 | thresh_min, thresh_max = pubsub_evt.data |
@@ -402,6 +410,7 @@ class MaskProperties(wx.Panel): | @@ -402,6 +410,7 @@ class MaskProperties(wx.Panel): | ||
402 | else: | 410 | else: |
403 | index = self.threshold_modes_names.index(_("Custom")) | 411 | index = self.threshold_modes_names.index(_("Custom")) |
404 | self.combo_thresh.SetSelection(index) | 412 | self.combo_thresh.SetSelection(index) |
413 | + Project().presets.thresh_ct[_("Custom")] = (thresh_min, thresh_max) | ||
405 | 414 | ||
406 | def SetItemsColour(self, evt_pubsub): | 415 | def SetItemsColour(self, evt_pubsub): |
407 | colour = evt_pubsub.data | 416 | colour = evt_pubsub.data |
@@ -427,7 +436,6 @@ class MaskProperties(wx.Panel): | @@ -427,7 +436,6 @@ class MaskProperties(wx.Panel): | ||
427 | self.combo_thresh.SetItems(thresh_modes_names) | 436 | self.combo_thresh.SetItems(thresh_modes_names) |
428 | self.threshold_modes_names = thresh_modes_names | 437 | self.threshold_modes_names = thresh_modes_names |
429 | proj = Project() | 438 | proj = Project() |
430 | - | ||
431 | if isinstance(default_thresh, int): | 439 | if isinstance(default_thresh, int): |
432 | self.combo_thresh.SetSelection(default_thresh) | 440 | self.combo_thresh.SetSelection(default_thresh) |
433 | (thresh_min, thresh_max) =\ | 441 | (thresh_min, thresh_max) =\ |
@@ -441,12 +449,12 @@ class MaskProperties(wx.Panel): | @@ -441,12 +449,12 @@ class MaskProperties(wx.Panel): | ||
441 | index = self.threshold_modes_names.index(_("Custom")) | 449 | index = self.threshold_modes_names.index(_("Custom")) |
442 | self.combo_thresh.SetSelection(index) | 450 | self.combo_thresh.SetSelection(index) |
443 | thresh_min, thresh_max = default_thresh | 451 | thresh_min, thresh_max = default_thresh |
452 | + proj.presets.thresh_ct[_("Custom")] = (thresh_min, thresh_max) | ||
444 | 453 | ||
445 | self.gradient.SetMinValue(thresh_min) | 454 | self.gradient.SetMinValue(thresh_min) |
446 | self.gradient.SetMaxValue(thresh_max) | 455 | self.gradient.SetMaxValue(thresh_max) |
447 | 456 | ||
448 | def SetThresholdBounds(self, pubsub_evt): | 457 | def SetThresholdBounds(self, pubsub_evt): |
449 | - print ">>>Threshold Limits", pubsub_evt.data | ||
450 | thresh_min = pubsub_evt.data[0] | 458 | thresh_min = pubsub_evt.data[0] |
451 | thresh_max = pubsub_evt.data[1] | 459 | thresh_max = pubsub_evt.data[1] |
452 | self.gradient.SetMinRange(thresh_min) | 460 | self.gradient.SetMinRange(thresh_min) |
@@ -458,14 +466,13 @@ class MaskProperties(wx.Panel): | @@ -458,14 +466,13 @@ class MaskProperties(wx.Panel): | ||
458 | ps.Publisher().sendMessage('Change mask selected', mask_index) | 466 | ps.Publisher().sendMessage('Change mask selected', mask_index) |
459 | 467 | ||
460 | def OnComboThresh(self, evt): | 468 | def OnComboThresh(self, evt): |
461 | - (thresh_min, thresh_max) = self.threshold_modes[evt.GetString()] | 469 | + (thresh_min, thresh_max) = Project().presets.thresh_ct[evt.GetString()] |
462 | self.gradient.SetMinValue(thresh_min) | 470 | self.gradient.SetMinValue(thresh_min) |
463 | self.gradient.SetMaxValue(thresh_max) | 471 | self.gradient.SetMaxValue(thresh_max) |
464 | 472 | ||
465 | def OnSlideChanged(self, evt): | 473 | def OnSlideChanged(self, evt): |
466 | thresh_min = self.gradient.GetMinValue() | 474 | thresh_min = self.gradient.GetMinValue() |
467 | thresh_max = self.gradient.GetMaxValue() | 475 | thresh_max = self.gradient.GetMaxValue() |
468 | - print "OnSlideChanged", thresh_min, thresh_max | ||
469 | if self.bind_evt_gradient: | 476 | if self.bind_evt_gradient: |
470 | ps.Publisher().sendMessage('Set threshold values', | 477 | ps.Publisher().sendMessage('Set threshold values', |
471 | (thresh_min, thresh_max)) | 478 | (thresh_min, thresh_max)) |