Commit 57abf631 authored by payno's avatar payno Committed by Henri Payno
Browse files

[orangecontrib][NormIOW] add settings load / save and enableing / disabling interface

parent 007bb821
......@@ -158,8 +158,10 @@ class NormIOW(WidgetLongProcessing, SuperviseOW):
self._layout.addWidget(self._window)
self.loadSettings()
# connect signal / slot
# self._window.sigConfigurationChanged.connect(self._updateSettings)
self._window.sigConfigurationChanged.connect(self._updateSettings)
self.destroyed.connect(self._window.stop)
self._window._processing_stack.sigComputationStarted.connect(
self._startProcessing
......@@ -169,6 +171,9 @@ class NormIOW(WidgetLongProcessing, SuperviseOW):
def isLocked(self):
return self._window.isLocked()
def setLocked(self, locked):
self._window.setLocked(locked)
@Inputs.data_in
def process(self, scan: TomwerScanBase):
if not isinstance(scan, (TomwerScanBase, type(None))):
......@@ -204,3 +209,12 @@ class NormIOW(WidgetLongProcessing, SuperviseOW):
def clear(self):
self._window.clear()
def _updateSettings(self):
self._rpSetting = self._window.getConfiguration()
self._rpSetting["__lock__"] = self.isLocked()
def loadSettings(self):
self._window.setConfiguration(self._rpSetting)
if "__lock__" in self._rpSetting:
self.setLocked(self._rpSetting["__lock__"])
......@@ -54,6 +54,10 @@ import typing
class NormIntensityWindow(qt.QMainWindow):
sigConfigurationChanged = qt.Signal()
"""signal emit when the configuration change"""
def __init__(self, parent):
qt.QMainWindow.__init__(self, parent)
self._scan = None
......@@ -84,12 +88,16 @@ class NormIntensityWindow(qt.QMainWindow):
# connect signal / slot
self._optsWidget.sigModeChanged.connect(self._modeChanged)
self._optsWidget.sigValueUpdated.connect(self.setResult)
self._optsWidget.sigConfigurationChanged.connect(self._configurationChanged)
self._crtWidget.sigValidateRequest.connect(self._validated)
# set up
self._centralWidget._updateSinogramROI()
self._modeChanged()
def _configurationChanged(self):
self.sigConfigurationChanged.emit()
def _hideLockButton(self):
self._optsWidget._hideLockButton()
......@@ -155,6 +163,9 @@ class NormIntensityWindow(qt.QMainWindow):
def isLocked(self):
return self._optsWidget.isLocked()
def setLocked(self, locked):
self._optsWidget.setLocked(locked)
class _Viewer(qt.QTabWidget):
def __init__(self, parent):
......@@ -366,6 +377,9 @@ class _NormIntensityOptions(qt.QWidget):
sigValueUpdated = qt.Signal(object)
"""Signal emit when user defines manually the value"""
sigConfigurationChanged = qt.Signal()
"""Signal emit when the configuration changes"""
def __init__(self, parent):
if not isinstance(parent, NormIntensityWindow):
raise TypeError(
......@@ -413,12 +427,33 @@ class _NormIntensityOptions(qt.QWidget):
# connect signal / slot
self._modeCB.currentIndexChanged.connect(self._modeChanged)
self._modeCB.currentIndexChanged.connect(self._configurationChanged)
self._computeButton.released.connect(self._computationRequested)
self._scalarValueWidget.sigValueChanged.connect(self._valueUpdated)
self._scalarValueWidget.sigValueChanged.connect(self._configurationChanged)
self._datasetWidget.sigConfigurationChanged.connect(self._configurationChanged)
self._intensityCalcOpts.sigConfigurationChanged.connect(
self._configurationChanged
)
self._lockButton.toggled.connect(self._lockChanged)
self._lockButton.toggled.connect(self._configurationChanged)
def _configurationChanged(self):
self.sigConfigurationChanged.emit()
def _lockChanged(self):
self._scalarValueWidget.setEnabled(not self.isLocked())
self._datasetWidget.setEnabled(not self.isLocked())
self._intensityCalcOpts.setEnabled(not self.isLocked())
self._modeCB.setEnabled(not self.isLocked())
self._computeButton.setEnabled(not self.isLocked())
def isLocked(self):
return self._lockButton.isLocked()
def setLocked(self, locked):
self._lockButton.setChecked(locked)
def _hideLockButton(self):
self._lockButton.hide()
......@@ -486,6 +521,9 @@ class _NormIntensityOptions(qt.QWidget):
self._intensityCalcOpts.setCalculationArea(extra_infos["calc_area"])
if "calc_method" in extra_infos:
self._intensityCalcOpts.setCalculationMethod(extra_infos["calc_method"])
if params.method is Method.MANUAL_SCALAR:
if "value" in extra_infos:
self._scalarValueWidget.setValue(extra_infos["value"])
def setScan(self, scan):
self._datasetWidget.setScan(scan=scan)
......@@ -524,6 +562,9 @@ class _NormIntensityOptions(qt.QWidget):
class _NormIntensityCalcOpts(qt.QWidget):
"""Options to compute the norm intensity"""
sigConfigurationChanged = qt.Signal()
"""Signal emitted when configuration changes"""
def __init__(self, parent):
qt.QWidget.__init__(self, parent)
self.setLayout(qt.QFormLayout())
......@@ -546,6 +587,14 @@ class _NormIntensityCalcOpts(qt.QWidget):
# connect signal / slot
self._calculationAreaCB.currentTextChanged.connect(self._areaChanged)
self._calculationModeCB.currentIndexChanged.connect(self._configurationChanged)
self._calculationAreaCB.currentIndexChanged.connect(self._configurationChanged)
self._calculationMethodCB.currentIndexChanged.connect(
self._configurationChanged
)
def _configurationChanged(self):
self.sigConfigurationChanged.emit()
def getCalculationFct(self):
return _normParams._ValueCalculationFct.from_value(
......@@ -642,6 +691,8 @@ class _NormIntensityDatasetWidget(qt.QWidget):
_FILE_PATH_LOCAL_VALUE = "scan master file"
sigConfigurationChanged = qt.Signal()
def __init__(self, parent=None):
qt.QWidget.__init__(self, parent)
self._lastGlobalPath = None
......@@ -688,6 +739,12 @@ class _NormIntensityDatasetWidget(qt.QWidget):
self._buttonGrpBox.buttonToggled.connect(self._updateFilePathVisibility)
self._selectFileButton.released.connect(self._selectFile)
self._selectDataPathButton.released.connect(self._selectDataPath)
self._buttonGrpBox.buttonReleased.connect(self._configurationChanged)
self._filePathQLE.editingFinished.connect(self._configurationChanged)
self._dataPathQLE.editingFinished.connect(self._configurationChanged)
def _configurationChanged(self, *args, **kwargs):
self.sigConfigurationChanged.emit()
def setScan(self, scan):
if scan is not None:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment