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