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

[gui][intensity-normalization] start addint automation

parent 1f729dad
......@@ -68,26 +68,28 @@ class NormIntensityWindow(_NormIntensityWindow):
assert isinstance(parent, NormIOW)
super().__init__(parent)
self._parentValidate = self.parent()._validate
self._isLocked = self.parent().isLocked
self._processing_stack = INormalizationProcessStack(process_id=process_id)
# connect signal / slot
self._optsWidget.sigProcessingRequested.connect(self._launchProcessing)
self._optsWidget.sigProcessingRequested.connect(self._processCurrentScan)
def _validated(self):
scan = self.getScan()
self._parentValidate(scan)
def _launchProcessing(self):
def _processCurrentScan(self):
scan = self.getScan()
if scan is None:
return
self._processScan(scan)
def _processScan(self, scan):
self._processing_stack.add(
scan=scan,
configuration=self.getConfiguration(),
callback=functools.partial(
self._mightUpdateResult,
scan,
self._isLocked(),
self.isLocked(),
),
)
......@@ -165,7 +167,7 @@ class NormIOW(WidgetLongProcessing, SuperviseOW):
self._window._processing_stack.sigComputationEnded.connect(self._endProcessing)
def isLocked(self):
return False
return self._window.isLocked()
@Inputs.data_in
def process(self, scan: TomwerScanBase):
......@@ -177,10 +179,9 @@ class NormIOW(WidgetLongProcessing, SuperviseOW):
if scan is None:
return
self._window.setScan(scan=scan)
if self.isLocked():
raise NotImplementedError("Missing processing")
else:
self._window.setScan(scan=scan)
self._window._processScan(scan=scan)
def _validate(self, scan):
self.Outputs.data_out.send(scan)
......@@ -200,3 +201,6 @@ class NormIOW(WidgetLongProcessing, SuperviseOW):
details = "Was pending and has been replaced by another scan."
self.notify_skip(scan=scan, details=details)
self.Outputs.data_out.send(scan)
def clear(self):
self._window.clear()
......@@ -55,6 +55,7 @@ class NormIntensityWindow(_NormIntensityWindow):
def __init__(self, parent=None):
_NormIntensityWindow.__init__(self, parent)
self._processingThread = IntensityNormalizationThread()
self._hideLockButton()
# connect signal / slot
self._optsWidget.sigProcessingRequested.connect(self._launchProcessing)
......
......@@ -48,6 +48,7 @@ from tomwer.gui.visualization.sinogramviewer import SinogramViewer as _SinogramV
from tomwer.core.process.reconstruction.normalization.normalization import Method
from tomwer.core.process.reconstruction.normalization import params as _normParams
from tomoscan.normalization import Method as TomoScanMethod
from tomwer.gui.utils.buttons import PadlockButton
import weakref
import typing
......@@ -89,6 +90,9 @@ class NormIntensityWindow(qt.QMainWindow):
self._centralWidget._updateSinogramROI()
self._modeChanged()
def _hideLockButton(self):
self._optsWidget._hideLockButton()
def _validated(self):
pass
......@@ -140,7 +144,7 @@ class NormIntensityWindow(qt.QMainWindow):
# once computed update scan normalization values (
# update scalar value for example)
scan = self.getScan()
if self.getCurrentMethod().value in TomoScanMethod.values():
if scan and self.getCurrentMethod().value in TomoScanMethod.values():
scan.intensity_normalization = self.getCurrentMethod().value
scan.intensity_normalization.set_extra_infos(self.getExtraArgs())
self._crtWidget.setResult(result)
......@@ -148,6 +152,9 @@ class NormIntensityWindow(qt.QMainWindow):
def clear(self):
self._crtWidget.clear()
def isLocked(self):
return self._optsWidget.isLocked()
class _Viewer(qt.QTabWidget):
def __init__(self, parent):
......@@ -366,18 +373,22 @@ class _NormIntensityOptions(qt.QWidget):
)
qt.QWidget.__init__(self, parent)
self._getROI = self.parent().getROI
self.setLayout(qt.QFormLayout())
self.setLayout(qt.QGridLayout())
# mode
self._modeCB = qt.QComboBox(self)
for mode in Method:
self._modeCB.addItem(mode.value)
self.layout().addRow("mode:", self._modeCB)
self.layout().addWidget(qt.QLabel("mode:", self), 0, 0, 1, 1)
self.layout().addWidget(self._modeCB, 0, 1, 1, 1)
self._lockButton = PadlockButton(self)
self._lockButton.setFixedWidth(25)
self.layout().addWidget(self._lockButton, 0, 2, 1, 1)
# method
self._optsMethod = qt.QGroupBox(self)
self._optsMethod.setTitle("options")
self._optsMethod.setLayout(qt.QVBoxLayout())
self.layout().addRow(self._optsMethod)
self.layout().addWidget(self._optsMethod, 1, 0, 1, 3)
# intensity calculation options
self._intensityCalcOpts = _NormIntensityCalcOpts(self)
self._optsMethod.layout().addWidget(self._intensityCalcOpts)
......@@ -386,7 +397,7 @@ class _NormIntensityOptions(qt.QWidget):
self._optsMethod.layout().addWidget(self._datasetWidget)
# scalar value
self._scalarValueWidget = _NormIntensityScalarValue(self)
self.layout().addRow(self._scalarValueWidget)
self.layout().addWidget(self._scalarValueWidget, 2, 0, 1, 3)
# buttons
self._buttonsGrp = qt.QWidget(self)
self._buttonsGrp.setLayout(qt.QGridLayout())
......@@ -396,7 +407,7 @@ class _NormIntensityOptions(qt.QWidget):
spacer = qt.QWidget(self)
spacer.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Minimum)
self._buttonsGrp.layout().addWidget(spacer)
self.layout().addRow(self._buttonsGrp)
self.layout().addWidget(self._buttonsGrp, 3, 0, 1, 3)
self._modeChanged()
......@@ -405,6 +416,12 @@ class _NormIntensityOptions(qt.QWidget):
self._computeButton.released.connect(self._computationRequested)
self._scalarValueWidget.sigValueChanged.connect(self._valueUpdated)
def isLocked(self):
return self._lockButton.isLocked()
def _hideLockButton(self):
self._lockButton.hide()
def getCurrentMethod(self):
return Method.from_value(self._modeCB.currentText())
......
......@@ -48,9 +48,6 @@ class PadlockButton(qt.QPushButton):
self.setIcon(self._unlockIcon)
self.setCheckable(True)
# add some speakfull API
self.isLocked = self.isChecked
# connect signals
self.toggled.connect(self._updateDisplay)
......@@ -63,6 +60,9 @@ class PadlockButton(qt.QPushButton):
self.setIcon(_icon)
self.sigLockChanged.emit(checked)
def isLocked(self):
return self.isChecked()
class TabBrowsersButtons(qt.QWidget):
"""Simple widget containing buttons to go to 'next' or 'previous'"""
......
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