Commit 344e09a0 authored by Henri Payno's avatar Henri Payno
Browse files

[ewoks integration] add static_input to OW

parent b78a4c35
Pipeline #53190 failed with stages
in 1 minute and 46 seconds
......@@ -62,10 +62,6 @@ class _ParameterWindowContainer(qt.QWidget):
# setup
self._manualUpdatePB.setVisible(False)
# expose API
self.setParameters = self._mainwidget.setParameters
self.getParameters = self._mainwidget.getParameters
# connect signal / slot
self._autoCB.toggled.connect(self._manualUpdatePB.setVisible)
self._manualUpdatePB.pressed.connect(self._update)
......@@ -93,3 +89,9 @@ class _ParameterWindowContainer(qt.QWidget):
def _update(self, *args, **kwargs):
self.sigChanged.emit()
def getParameters(self):
return self._mainwidget.getParameters()
def setParameters(self, params):
self._mainwidget.setParameters(params=params)
......@@ -158,7 +158,9 @@ class AutobkOW(_ProcessForOrangeMixIn, OWWidget):
allows_cycle = False
_larchSettings = Setting(dict())
"""Store the configuration of the PyMca XASClass"""
# kept for compatibility
static_input = Setting({"xas_obj": None, "autobk": None})
"""Store the configuration of the larch configuration"""
ewokstaskclass = est.core.process.larch.autobk.Larch_autobk
......@@ -182,8 +184,11 @@ class AutobkOW(_ProcessForOrangeMixIn, OWWidget):
self._window.xasObjViewer.setWindowTitle("spectra")
# manage settings
if self._larchSettings != dict():
self._window._parametersWindow.setParameters(self._larchSettings)
larch_settings = static_input.get("autobk", None)
if larch_settings is None:
larch_settings = self._larchSettings
if larch_settings != dict():
self._window._parametersWindow.setParameters(larch_settings)
# connect signals / slots
self._window._parametersWindow.sigChanged.connect(self._updateProcess)
......@@ -206,6 +211,10 @@ class AutobkOW(_ProcessForOrangeMixIn, OWWidget):
def _update_settings(self):
self._larchSettings = self._window._parametersWindow.getParameters()
self.static_input = {
"autobk": self._window._parametersWindow.getParameters(),
"xas_obj": None,
}
@Inputs.data_table
def processFrmDataTable(self, data_table):
......
......@@ -134,6 +134,8 @@ class MbackOW(_ProcessForOrangeMixIn, OWWidget):
allows_cycle = False
_larchSettings = Setting(dict())
# kept for compatibility
static_input = Setting({"mback": None})
"""Store the configuration of the larch configuration"""
ewokstaskclass = est.core.process.larch.mback.Larch_mback
......@@ -158,8 +160,11 @@ class MbackOW(_ProcessForOrangeMixIn, OWWidget):
self._window.xasObjViewer.setWindowTitle("spectra")
# manage settings
if self._larchSettings != dict():
self._window._parametersWindow.setParameters(self._larchSettings)
larch_settings = self.static_input.get("mback", None)
if larch_settings is None:
larch_settings = self._larchSettings
if larch_settings != dict():
self._window._parametersWindow.setParameters(larch_settings)
# connect signals / slots
self._window._parametersWindow.sigChanged.connect(self._updateProcess)
......@@ -180,6 +185,10 @@ class MbackOW(_ProcessForOrangeMixIn, OWWidget):
def _update_settings(self):
self._larchSettings = self._window._parametersWindow.getParameters()
self.static_input = {
"mback": self._window._parametersWindow.getParameters(),
"xas_obj": None,
}
@Inputs.data_table
def processFrmDataTable(self, data_table):
......
......@@ -138,6 +138,8 @@ class Mback_normOW(
ewokstaskclass = est.core.process.larch.mback_norm.Larch_mback_norm
_larchSettings = Setting(dict())
"""Kept for compatiblity"""
static_input = Setting({"mback_norm": None})
"""Store the configuration of the larch configuration"""
class Inputs:
......@@ -160,8 +162,11 @@ class Mback_normOW(
self._window.xasObjViewer.setWindowTitle("spectra")
# manage settings
if self._larchSettings != dict():
self._window._parametersWindow.setParameters(self._larchSettings)
larch_settings = static_input.get("mback_norm", None)
if larch_settings is None:
larch_settings = self._larchSettings
if larch_settings != dict():
self._window._parametersWindow.setParameters(larch_settings)
# connect signals / slots
self._window._parametersWindow.sigChanged.connect(self._updateProcess)
......@@ -182,6 +187,10 @@ class Mback_normOW(
def _update_settings(self):
self._larchSettings = self._window._parametersWindow.getParameters()
self.static_input = {
"mback_norm": self._window._parametersWindow.getParameters(),
"xas_obj": None,
}
@Inputs.data_table
def processFrmDataTable(self, data_table):
......
......@@ -157,6 +157,8 @@ class PreEdgeOW(
ewokstaskclass = est.core.process.larch.pre_edge.Larch_pre_edge
_larchSettings = Setting(dict())
# kept for compatibility
static_input = Setting({"pre_edge": None})
"""Store the configuration of the larch configuration"""
class Inputs:
......@@ -179,8 +181,11 @@ class PreEdgeOW(
self._window.xasObjViewer.setWindowTitle("spectra")
# manage settings
if self._larchSettings != dict():
self._window._parametersWindow.setParameters(self._larchSettings)
larch_settings = self.static_input.get("pre_edge", None)
if larch_settings is None:
larch_settings = self._larchSettings
if larch_settings != dict():
self._window._parametersWindow.setParameters(larch_settings)
# connect signals / slots
self._window._parametersWindow.sigChanged.connect(self._updateProcess)
......@@ -201,6 +206,10 @@ class PreEdgeOW(
def _update_settings(self):
self._larchSettings = self._window._parametersWindow.getParameters()
self.static_input = {
"pre_edge": self._window._parametersWindow.getParameters(),
"xas_obj": None,
}
@Inputs.data_table
def processFrmDataTable(self, data_table):
......
......@@ -174,6 +174,8 @@ class XFTFOW(
ewokstaskclass = est.core.process.larch.xftf.Larch_xftf
_larchSettings = Setting(dict())
# kept for compatibility
static_input = Setting({"xftf": None, "xas_obj": None})
"""Store the configuration of the larch configuration"""
class Inputs:
......@@ -196,8 +198,11 @@ class XFTFOW(
self._window.xasObjViewer.setWindowTitle("spectra")
# manage settings
if self._larchSettings != dict():
self._window._parametersWindow.setParameters(self._larchSettings)
larch_settings = self.static_input.get("xftf", None)
if larch_settings is None:
larch_settings = self._larchSettings
if larch_settings != dict():
self._window._parametersWindow.setParameters(larch_settings)
# connect signals / slots
self._window._parametersWindow.sigChanged.connect(self._updateProcess)
......@@ -219,6 +224,10 @@ class XFTFOW(
def _update_settings(self):
self._larchSettings = self._window._parametersWindow.getParameters()
self.static_input = {
"xftf": self._window._parametersWindow.getParameters(),
"xas_obj": None,
}
@Inputs.data_table
def processFrmDataTable(self, data_table):
......
......@@ -138,6 +138,8 @@ class ExafsOW(
ewokstaskclass = est.core.process.pymca.exafs.PyMca_exafs
_larchSettings = Setting(dict())
# kept for compatibility
static_input = Setting({"xas_obj": None, "exafs": None})
"""Store the configuration of the PyMca XASClass"""
class Inputs:
......@@ -164,8 +166,11 @@ class ExafsOW(
)
# manage settings
if self._larchSettings != dict():
self._window._pymcaWindow.setParameters(self._larchSettings)
pymca_settings = self.static_input.get("exafs", None)
if pymca_settings is None:
pymca_settings = self._larchSettings
if pymca_settings != dict():
self._window._pymcaWindow.setParameters(pymca_settings)
# signal / slot connection
self._window._pymcaWindow.sigChanged.connect(self._updateProcess)
......@@ -179,6 +184,10 @@ class ExafsOW(
def _update_settings(self):
self._larchSettings = self._window._pymcaWindow.getParameters()
self.static_input = {
"xas_obj": None,
"exafs": self._window._pymcaWindow.getParameters(),
}
@Inputs.data_table
def processFrmDataTable(self, data_table):
......
......@@ -157,6 +157,8 @@ class FTOW(
ewokstaskclass = est.core.process.pymca.ft.PyMca_ft
_pymcaSettings = Setting(dict())
# kept for compatibility
static_input = dict({"ft": None, "xas_obj": None})
"""Store the configuration of the PyMca XASClass"""
class Inputs:
......@@ -181,8 +183,11 @@ class FTOW(
self._progress = gui.ProgressBar(self, 100)
# manage settings
if self._pymcaSettings != dict():
self._window._pymcaWindow.setParameters(self._pymcaSettings)
pymca_settings = self.static_input.get("ft", None)
if pymca_settings is None:
pymca_settings = self._pymcaSettings
if pymca_settings != dict():
self._window._pymcaWindow.setParameters(pymca_settings)
# signal / slot connection
# connect signals / slots
......@@ -235,6 +240,10 @@ class FTOW(
def _update_settings(self):
self._pymcaSettings = self._window._pymcaWindow.getParameters()
self.static_input = {
"xas_obj": None,
"ft": self._window._pymcaWindow.getParameters(),
}
def _setProgressValue(self, value):
self._progress.widget.progressBarSet(value)
......
......@@ -87,6 +87,8 @@ class KWeightOW(
ewokstaskclass = est.core.process.pymca.k_weight.PyMca_k_weight
_kWeightSetting = Setting(int(3))
# kept for compatibility
static_input = Setting({"xas_obj": None, "k_weight": 3})
"""Store the configuration of the PyMca XASClass"""
class Inputs:
......@@ -111,8 +113,11 @@ class KWeightOW(
self._progress = gui.ProgressBar(self, 100)
# manage settings
if self._kWeightSetting != 3:
self._window._k_spin_box.setValue(self._kWeightSetting)
k_weight = self.static_input.get("k_weight")
if k_weight == 3:
k_weight = self._kWeightSetting
if k_weight != 3:
self._window._k_spin_box.setValue(k_weight)
# signal / slot connection
self._window._k_spin_box.valueChanged.connect(self._updateProcess)
......@@ -163,6 +168,10 @@ class KWeightOW(
def _update_settings(self):
self._kWeightSetting = self._window._k_spin_box.value()
self.static_input = {
"xas_obj": None,
"k_weight": self._window._k_spin_box.value(),
}
def _setProgressValue(self, value):
self._progress.widget.progressBarSet(value)
......
......@@ -205,6 +205,8 @@ class NormalizationOW(
ewokstaskclass = est.core.process.pymca.normalization.PyMca_normalization
_pymcaSettings = Setting(dict())
# Kept for compatibility
static_input = Setting({"xas_obj": None, "normalization": None})
"""Store the configuration of the PyMca XASClass"""
class Inputs:
......@@ -230,8 +232,11 @@ class NormalizationOW(
self.setE0 = self._window.setE0
# manage settings
if self._pymcaSettings != dict():
self._window._pymcaWindow.setParameters(self._pymcaSettings)
pymca_settings = self.static_input.get("normalization", None)
if pymca_settings is None:
pymca_settings = self._pymcaSettings
if pymca_settings != dict():
self._window._pymcaWindow.setParameters(pymca_settings)
# connect signals / slots
pymcaWindowContainer = self._window._pymcaWindow
......@@ -248,6 +253,10 @@ class NormalizationOW(
def _update_settings(self):
self._pymcaSettings = self._window._pymcaWindow.getParameters()
self.static_input = {
"xas_obj": None,
"normalization": self._window._pymcaWindow.getParameters(),
}
@Inputs.data_table
def processFrmDataTable(self, data_table):
......
......@@ -75,10 +75,12 @@ class EnergyRoiOW(
allows_cycle = False
_energy_roi = Setting(dict())
# kept for compatibility
static_input = Setting({"xas_obj": None, "energy_roi": None})
class Inputs:
xas_obj = Input("xas_obj", XASObject, default=True)
# simple compatibility for some Orange widget and especialy the
# simple compatibility for some Orange widget and especially the
# 'spectroscopy add-on'
data_table = Input("Data", Orange.data.Table)
......@@ -105,11 +107,20 @@ class EnergyRoiOW(
# connect signal / slot
self._buttons.accepted.connect(self.validate)
# expose API
self.setROI = self._widget.setROI
self.getROI = self._widget.getROI
energy_roi_params = self.static_input.get("energy_roi", None)
if energy_roi_params is not None:
try:
minE = energy_roi_params["minE"]
maxE = energy_roi_params["maxE"]
self.setROI((minE, maxE))
except Exception:
pass
# self.handleNewSignals()
def getROI(self):
return self._widget.getROI()
def setROI(self, roi):
self._widget.setROI(roi=roi)
@Inputs.data_table
def processFrmDataTable(self, data_table):
......@@ -161,3 +172,11 @@ class EnergyRoiOW(
"minE": minE,
"maxE": maxE,
}
self.static_input = {
"xas_obj": None,
"energy_roi": {
"minE": minE,
"maxE": maxE,
},
}
......@@ -76,6 +76,8 @@ class NoiseOW(
e_min = Setting(int(-1))
e_max = Setting(int(-1))
static_input = Setting({"xas_obj": None, "noise": None})
class Inputs:
xas_obj = Input("xas_obj", XASObject, default=True)
# simple compatibility for some Orange widget and especialy the
......@@ -120,11 +122,8 @@ class NoiseOW(
)
# signal / slot connection
# connect signals / slots
self._window.sigChanged.connect(self._updateProcess)
# self.handleNewSignals()
def _updateProcess(self, *arv, **kwargs):
self._update_settings()
if self._latest_xas_obj:
......@@ -172,6 +171,20 @@ class NoiseOW(
self.e_min = self._window.getEMin()
self.e_max = self._window.getEMax()
self.static_input = {
"xas_obj": None,
"noise": {
"window_size": self.window_size,
"polynomial_order": self.polynomial_order,
"e_min": self.e_min,
"e_max": self.e_max,
},
}
window_size = Setting(int(-1))
polynomial_order = Setting(int(-1))
e_min = Setting(int(-1))
e_max = Setting(int(-1))
def _setProgressValue(self, value):
self._progress.widget.progressBarSet(value)
......
......@@ -69,6 +69,8 @@ class RoiSelectionOW(
_roi_origin = Setting(tuple())
_roi_size = Setting(tuple())
static_input = Setting({"xas_obj": None, "roi": None})
class Inputs:
xas_obj = Input("xas_obj", XASObject, default=True)
# simple compatibility for some Orange widget and especialy the
......@@ -143,3 +145,11 @@ class RoiSelectionOW(
# as dim are named tuple we have to cast them to dict
self._roi_origin = tuple(self._widget.getROI().getOrigin())
self._roi_size = tuple(self._widget.getROI().getSize())
self.static_input = {
"xas_obj": None,
"roi": {
"origin": tuple(self._widget.getROI().getOrigin()),
"size": tuple(self._widget.getROI().getSize()),
},
}
Markdown is supported
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