diff --git a/Modules/Scripted/DataProbe/DataProbeLib/SliceViewAnnotations.py b/Modules/Scripted/DataProbe/DataProbeLib/SliceViewAnnotations.py index 7819ba70774..93868b5b7b6 100644 --- a/Modules/Scripted/DataProbe/DataProbeLib/SliceViewAnnotations.py +++ b/Modules/Scripted/DataProbe/DataProbeLib/SliceViewAnnotations.py @@ -16,6 +16,7 @@ class SliceAnnotations(VTKObservationMixin): DEFAULTS = { 'enabled': 1, + 'displayLevel': 0, 'topLeft': 0, 'topRight': 0, 'bottomLeft': 1, @@ -85,8 +86,6 @@ def __init__(self, layoutManager=None): '9-SlabReconstructionType': {'text': '', 'category': 'A'} }) - self.annotationsDisplayAmount = 0 - # self.scene = slicer.mrmlScene self.sliceViews = {} @@ -98,6 +97,7 @@ def _defaultValue(key, **kwargs): self.sliceViewAnnotationsEnabled = _defaultValue('enabled', converter=int) + self.annotationsDisplayAmount = _defaultValue('displayLevel', converter=int) self.topLeft = _defaultValue('topLeft', converter=int) self.topRight = _defaultValue('topRight', converter=int) self.bottomLeft = _defaultValue('bottomLeft', converter=int) @@ -146,6 +146,8 @@ def create(self): self.level1RadioButton = find(window, 'level1RadioButton')[0] self.level2RadioButton = find(window, 'level2RadioButton')[0] self.level3RadioButton = find(window, 'level3RadioButton')[0] + radioButtons = [self.level1RadioButton, self.level2RadioButton, self.level3RadioButton] + radioButtons[self.annotationsDisplayAmount].checked = True self.fontPropertiesGroupBox = find(window, 'fontPropertiesGroupBox')[0] self.timesFontRadioButton = find(window, 'timesFontRadioButton')[0] @@ -177,9 +179,9 @@ def create(self): self.arialFontRadioButton.connect('clicked()', self.onFontFamilyRadioButton) self.fontSizeSpinBox.connect('valueChanged(int)', self.onFontSizeSpinBox) - self.level1RadioButton.connect('clicked()', self.updateSliceViewFromGUI) - self.level2RadioButton.connect('clicked()', self.updateSliceViewFromGUI) - self.level3RadioButton.connect('clicked()', self.updateSliceViewFromGUI) + self.level1RadioButton.connect('clicked()', self.onDisplayDisplayLevelRadioButton) + self.level2RadioButton.connect('clicked()', self.onDisplayDisplayLevelRadioButton) + self.level3RadioButton.connect('clicked()', self.onDisplayDisplayLevelRadioButton) self.backgroundPersistenceCheckBox.connect('clicked()', self.onBackgroundLayerPersistenceCheckBox) @@ -202,6 +204,20 @@ def onSliceViewAnnotationsCheckBox(self): self.updateEnabledButtons() self.updateSliceViewFromGUI() + def onDisplayDisplayLevelRadioButton(self): + if self.level1RadioButton.checked: + self.annotationsDisplayAmount = 0 + elif self.level2RadioButton.checked: + self.annotationsDisplayAmount = 1 + elif self.level3RadioButton.checked: + self.annotationsDisplayAmount = 2 + + settings = qt.QSettings() + settings.setValue('DataProbe/sliceViewAnnotations.displayLevel', + self.annotationsDisplayAmount) + + self.updateSliceViewFromGUI() + def onBackgroundLayerPersistenceCheckBox(self): if self.backgroundPersistenceCheckBox.checked: self.backgroundDICOMAnnotationsPersistence = 1 @@ -250,6 +266,10 @@ def restoreDefaultValues(self): def _defaultValue(key): return SliceAnnotations.DEFAULTS[key] + radioButtons = [self.level1RadioButton, self.level2RadioButton, self.level3RadioButton] + radioButtons[_defaultValue("displayLevel")].checked = True + self.annotationsDisplayAmount = _defaultValue("displayLevel") + self.topLeftCheckBox.checked = _defaultValue("topLeft") self.topLeft = _defaultValue("topLeft") @@ -304,14 +324,6 @@ def updateSliceViewFromGUI(self): if len(self.sliceViewNames) == 0: self.createCornerAnnotations() - # Updating Annotations Amount - if self.level1RadioButton.checked: - self.annotationsDisplayAmount = 0 - elif self.level2RadioButton.checked: - self.annotationsDisplayAmount = 1 - elif self.level3RadioButton.checked: - self.annotationsDisplayAmount = 2 - for sliceViewName in self.sliceViewNames: sliceWidget = self.layoutManager.sliceWidget(sliceViewName) if sliceWidget: