Skip to content

Commit

Permalink
ENH: Support saving and restoring SliceViewAnnotations display level
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Aug 18, 2023
1 parent 3ce7b54 commit 7ec1e62
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions Modules/Scripted/DataProbe/DataProbeLib/SliceViewAnnotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class SliceAnnotations(VTKObservationMixin):

DEFAULTS = {
'enabled': 1,
'displayLevel': 0,
'topLeft': 0,
'topRight': 0,
'bottomLeft': 1,
Expand Down Expand Up @@ -85,8 +86,6 @@ def __init__(self, layoutManager=None):
'9-SlabReconstructionType': {'text': '', 'category': 'A'}
})

self.annotationsDisplayAmount = 0

#
self.scene = slicer.mrmlScene
self.sliceViews = {}
Expand All @@ -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)
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 7ec1e62

Please sign in to comment.