Commit 9b0c89c2 authored by payno's avatar payno
Browse files

[gradient] Move gradient operation to a thread.

- update also gradient orange widget.
parent 24159a10
......@@ -107,16 +107,17 @@ class ShiftCorrectionWidget(qt.QWidget):
self._operation_thread.init(operation=self._operation,
dry_run=True)
callback = partial(self._update_post_processing, _shift)
self._operation_thread.finished.connect(callback)
self._callback = partial(self._update_post_processing, _shift)
self._operation_thread.finished.connect(self._callback)
self._operation.sigProgress.connect(self.setProgress)
self._operation_thread.start()
def _update_post_processing(self, _shift):
self._stack.setStack(self._shiftedData)
self._sumPlot.addImage(self._shiftedData.sum(axis=0))
self._lastShift = _shift
self.setProgress(100)
self._operation_thread.finished.disconnect(self._callback)
self._stack.setStack(self._shiftedData)
self._sumPlot.addImage(self._shiftedData.sum(axis=0))
self._lastShift = _shift
self.setProgress(100)
def setExperiment(self, experiment):
if self._operation_thread.isRunning() is True:
......
......@@ -32,8 +32,10 @@ from Orange.widgets.widget import OWWidget
from Orange.canvas.registry.description import InputSignal, OutputSignal
from id06workflow.core.experiment import Experiment
from id06workflow.core.experiment.operation.mapping import IntensityMapping
from id06workflow.core.experiment.operation.ThreadedOperation import ThreadedOperation
from id06workflow.core.types import _Image
from id06workflow.gui.mapping import MappingPlot
from functools import partial
import logging
_logger = logging.getLogger(__file__)
......@@ -63,15 +65,33 @@ class MappingOW(OWWidget):
super().__init__()
layout = gui.vBox(self.mainArea, 'noise removal').layout()
self._progress = gui.ProgressBar(self, 100)
self._plot = MappingPlot(parent=self)
layout.addWidget(self._plot)
self._processing_thread = ThreadedOperation()
def _setProgressValue(self, value):
self._progress.widget.progressBarSet(value)
def _process(self, experiment):
if experiment is None:
return
if self._processing_thread.isRunning():
_logger.error('Mapping thread is already running, cannot take another'
'job yet')
return
operation = IntensityMapping(experiment=experiment)
operation.compute()
operation.sigProgress.connect(self._setProgressValue)
self._processing_thread.init(operation)
callback = partial(self._post_processing, operation, experiment)
self._processing_thread.finished.connect(callback)
self._processing_thread.start()
def _post_processing(self, operation, experiment):
self.send("image",
_Image(img=operation.intensity_map, name='intensity_map'))
self.send("image",
......
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