Commit 7d6feaac authored by Henri Payno's avatar Henri Payno
Browse files

[orangecontrib][larch] add a _USE_THREAD variable to skip processing on thread...

[orangecontrib][larch] add a _USE_THREAD variable to skip processing on thread for larch orangewidget for debugging
parent 9ae67ef4
......@@ -45,6 +45,8 @@ from orangecontrib.xas.progress import QProgress
_logger = logging.getLogger(__file__)
_USE_THREAD = True
def _plot_spectrum(spectrum):
assert isinstance(spectrum, Spectrum)
......@@ -182,18 +184,24 @@ class AutobkOW(_ProcessForOrangeMixIn, OWWidget):
self._startProcess()
# setup the normalization process
process_obj = QLarch_autobk()
process_obj._advancement.sigProgress.connect(self._setProgressValue)
process_obj.setProperties({
'_larchSettings': self._window._parametersWindow.getParameters()})
# update the processing thread
thread = self.getProcessingThread()
thread.init(process_obj=process_obj, xas_obj=xas_obj)
self._callback_finish = functools.partial(self._endProcess, xas_obj)
thread.finished.connect(self._callback_finish)
# start processing
thread.start(priority=qt.QThread.LowPriority)
if _USE_THREAD is False:
process_obj = xas.core.process.larch.autobk.Larch_autobk()
self._callback_finish = None
process_obj.process(self._latest_xas_obj)
self._endProcess(self._latest_xas_obj)
else:
process_obj = QLarch_autobk()
process_obj._advancement.sigProgress.connect(self._setProgressValue)
process_obj.setProperties({
'_larchSettings': self._window._parametersWindow.getParameters()})
# update the processing thread
thread = self.getProcessingThread()
thread.init(process_obj=process_obj, xas_obj=self._latest_xas_obj)
self._callback_finish = functools.partial(self._endProcess, self._latest_xas_obj)
thread.finished.connect(self._callback_finish)
# start processing
thread.start(priority=qt.QThread.LowPriority)
class QLarch_autobk(xas.core.process.larch.autobk.Larch_autobk):
......
......@@ -46,6 +46,8 @@ from xas.gui.XasObjectViewer import _plot_norm, _plot_raw, _plot_fpp, _plot_f2
_logger = logging.getLogger(__file__)
_USE_THREAD = True
class MbackWindow(qt.QMainWindow):
def __init__(self, parent=None):
......@@ -157,17 +159,23 @@ class MbackOW(_ProcessForOrangeMixIn, OWWidget):
self._startProcess()
# setup the normalization process
process_obj = QLarch_mback()
process_obj._advancement.sigProgress.connect(self._setProgressValue)
process_obj.setProperties({
'_larchSettings': self._window._parametersWindow.getParameters()})
# update the processing thread
thread = self.getProcessingThread()
thread.init(process_obj=process_obj, xas_obj=xas_obj)
self._callback_finish = functools.partial(self._endProcess, xas_obj)
thread.finished.connect(self._callback_finish)
# start processing
thread.start(priority=qt.QThread.LowPriority)
if _USE_THREAD is False:
process_obj = xas.core.process.larch.mback.Larch_mback()
self._callback_finish = None
process_obj.process(xas_obj=self._latest_xas_obj)
self._endProcess(self._latest_xas_obj)
else:
process_obj = QLarch_mback()
process_obj._advancement.sigProgress.connect(self._setProgressValue)
process_obj.setProperties({
'_larchSettings': self._window._parametersWindow.getParameters()})
# update the processing thread
thread = self.getProcessingThread()
thread.init(process_obj=process_obj, xas_obj=self._latest_xas_obj)
self._callback_finish = functools.partial(self._endProcess, self._latest_xas_obj)
thread.finished.connect(self._callback_finish)
# start processing
thread.start(priority=qt.QThread.LowPriority)
class QLarch_mback(xas.core.process.larch.mback.Larch_mback):
......
......@@ -46,6 +46,8 @@ from orangecontrib.xas.progress import QProgress
_logger = logging.getLogger(__file__)
_USE_THREAD = True
class Mback_normWindow(qt.QMainWindow):
def __init__(self, parent=None):
......@@ -154,17 +156,23 @@ class Mback_normOW(_ProcessForOrangeMixIn, OWWidget):
self._startProcess()
# setup the normalization process
process_obj = QLarch_mback()
process_obj._advancement.sigProgress.connect(self._setProgressValue)
process_obj.setProperties({
'_larchSettings': self._window._parametersWindow.getParameters()})
# update the processing thread
thread = self.getProcessingThread()
thread.init(process_obj=process_obj, xas_obj=xas_obj)
self._callback_finish = functools.partial(self._endProcess, xas_obj)
thread.finished.connect(self._callback_finish)
# start processing
thread.start(priority=qt.QThread.LowPriority)
if _USE_THREAD is False:
process_obj = xas.core.process.larch.mback_norm.Larch_mback_norm()
self._callback_finish = None
process_obj.process(self._latest_xas_obj)
self._endProcess(self._latest_xas_obj)
else:
process_obj = QLarch_mback()
process_obj._advancement.sigProgress.connect(self._setProgressValue)
process_obj.setProperties({
'_larchSettings': self._window._parametersWindow.getParameters()})
# update the processing thread
thread = self.getProcessingThread()
thread.init(process_obj=process_obj, xas_obj=self._latest_xas_obj)
self._callback_finish = functools.partial(self._endProcess, self._latest_xas_obj)
thread.finished.connect(self._callback_finish)
# start processing
thread.start(priority=qt.QThread.LowPriority)
class QLarch_mback(xas.core.process.larch.mback_norm.Larch_mback_norm):
......
......@@ -48,6 +48,9 @@ from orangecontrib.xas.progress import QProgress
_logger = logging.getLogger(__file__)
_USE_THREAD = True
class _PreEdgeWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
......@@ -166,17 +169,25 @@ class PreEdgeOW(_ProcessForOrangeMixIn, OWWidget):
self._startProcess()
# setup the normalization process
process_obj = QLarch_pre_edge()
process_obj._advancement.sigProgress.connect(self._setProgressValue)
process_obj.setProperties({
'_larchSettings': self._window._parametersWindow.getParameters()})
# update the processing thread
thread = self.getProcessingThread()
thread.init(process_obj=process_obj, xas_obj=xas_obj)
self._callback_finish = functools.partial(self._endProcess, xas_obj)
thread.finished.connect(self._callback_finish)
# start processing
thread.start(priority=qt.QThread.LowPriority)
if _USE_THREAD:
process_obj = QLarch_pre_edge()
process_obj.process(self._latest_xas_obj)
process_obj._advancement.sigProgress.connect(self._setProgressValue)
process_obj.setConfiguration({
'_larchSettings': self._window._parametersWindow.getParameters()})
# update the processing thread
thread = self.getProcessingThread()
thread.init(process_obj=process_obj, xas_obj=self._latest_xas_obj)
self._callback_finish = functools.partial(self._endProcess,
self._latest_xas_obj)
thread.finished.connect(self._callback_finish)
# start processing
thread.start(priority=qt.QThread.LowPriority)
else:
process_obj = xas.core.process.larch.pre_edge.Larch_pre_edge()
process_obj.process(self._latest_xas_obj)
self._callback_finish = None
self._endProcess(self._latest_xas_obj)
class QLarch_pre_edge(xas.core.process.larch.pre_edge.Larch_pre_edge):
......
......@@ -45,6 +45,8 @@ from orangecontrib.xas.progress import QProgress
_logger = logging.getLogger(__file__)
_USE_THREAD = True
def _get_title(dgroup, title=None):
"""get best title for group"""
......@@ -205,17 +207,24 @@ class XFTFOW(_ProcessForOrangeMixIn, OWWidget):
self._startProcess()
# setup the normalization process
process_obj = QLarch_xftf()
process_obj._advancement.sigProgress.connect(self._setProgressValue)
process_obj.setProperties({
'_larchSettings': self._window._parametersWindow.getParameters()})
# update the processing thread
thread = self.getProcessingThread()
thread.init(process_obj=process_obj, xas_obj=xas_obj)
self._callback_finish = functools.partial(self._endProcess, xas_obj)
thread.finished.connect(self._callback_finish)
# start processing
thread.start(priority=qt.QThread.LowPriority)
if _USE_THREAD is False:
process_obj = xas.core.process.larch.xftf.Larch_xftf()
self._callback_finish = None
process_obj.process(self._latest_xas_obj)
self._endProcess(self._latest_xas_obj)
else:
process_obj = QLarch_xftf()
process_obj._advancement.sigProgress.connect(self._setProgressValue)
process_obj.setProperties({
'_larchSettings': self._window._parametersWindow.getParameters()})
# update the processing thread
thread = self.getProcessingThread()
thread.init(process_obj=process_obj, xas_obj=self._latest_xas_obj)
self._callback_finish = functools.partial(self._endProcess,
self._latest_xas_obj)
thread.finished.connect(self._callback_finish)
# start processing
thread.start(priority=qt.QThread.LowPriority)
class QLarch_xftf(xas.core.process.larch.xftf.Larch_xftf):
......
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