Skip to content
Snippets Groups Projects
Commit 7607f09e authored by payno's avatar payno
Browse files

[gui][axis] add an apply button

parent 26cde56b
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,7 @@ from tomwer.core.process.reconstruction.axis import AxisProcess
from tomwer.synctools.ftseries import QReconsParams
from tomwer.gui.ftserie.axis import AxisWindow
from tomwer.core.scan.scanbase import TomoBase
import functools
import logging
logger = logging.getLogger(__name__)
......@@ -96,6 +96,21 @@ class AxisOW(widget.OWWidget, AxisProcess):
if _connect_handler:
self.settingsHandler.addCallback(self._updateSettingsVals)
# connect Signal / Slot
self._widget.sigComputationRequested.connect(self.__compute)
self._widget.sigApply.connect(self.__validate)
def __compute(self):
self.__lastAxisProcessParamsCache = self.recons_params.to_dict()
AxisProcess.process(self, self.__scan)
def __validate(self):
# if parameters has changed since last processing, reprocess axis method
if self.recons_params.to_dict() != self.__lastAxisProcessParamsCache:
self.__compute()
self.signalReady(self.__scan)
def signalReady(self, scanID):
assert isinstance(scanID, TomoBase)
self.send("data", scanID)
......@@ -110,6 +125,7 @@ class AxisOW(widget.OWWidget, AxisProcess):
assert scan.tomo_recons_params.axis is not None
self.signalReady(scan_res)
else:
self.__scan = scan
self.exec()
def _updateSettingsVals(self):
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import argparse
from silx.gui import qt
import logging
import signal
import functools
from tomwer.utils import getMainSplashScreen
from tomwer.gui.ftserie.axis.axis import AxisWindow
from tomwer.core.scan.scanfactory import ScanFactory
from tomwer.synctools.ftseries import QReconsParams
import os
import sys
from tomwer.core.process.reconstruction.axis import AxisProcess
class _AxisProcessGUI(AxisProcess, AxisWindow):
def __init__(self):
def __init__(self, scan):
recons_params = QReconsParams()
AxisProcess.__init__(self, recons_params=recons_params.axis)
AxisWindow.__init__(self, axis=recons_params)
self._lockBut.hide()
self._lockLabel.hide()
self._applyBut.hide()
# connect Signal / Slot
callback = functools.partial(self.process, scan)
self.sigComputationRequested.connect(callback)
def main(argv):
......@@ -59,8 +64,7 @@ def main(argv):
scan = ScanFactory.create_scan_object(scan_path=options.scan_path)
window = _AxisProcessGUI()
window.process(scan=scan)
window = _AxisProcessGUI(scan=scan)
splash.finish(window)
window.show()
app.exec_()
......
......@@ -69,6 +69,13 @@ class AxisWindow(qt.QMainWindow):
widget.setImages(imgA=imgA, imgB=imgB, flipB=False)
widget.show()
"""
sigComputationRequested = qt.Signal()
"""signal emitted when a computation is requested"""
sigApply = qt.Signal()
"""signal emitted when the axis reconstruction parameters are validated"""
def __init__(self, axis, parent=None):
qt.QMainWindow.__init__(self, parent)
if isinstance(axis, _QAxisRP):
......@@ -110,7 +117,6 @@ class AxisWindow(qt.QMainWindow):
self._buttons.layout().addWidget(self._lockBut)
self._lockLabel = qt.QLabel('lock axis position', parent=self)
self._buttons.layout().addWidget(self._lockLabel)
self._lockBut.toggled.connect(self._lockAxisPosition)
spacer = qt.QWidget(self)
spacer.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Minimum)
......@@ -118,12 +124,19 @@ class AxisWindow(qt.QMainWindow):
self._computeBut = qt.QPushButton('compute', parent=self)
self._buttons.layout().addWidget(self._computeBut)
style = qt.QApplication.style()
applyIcon = style.standardIcon(qt.QStyle.SP_DialogApplyButton)
self._applyBut = qt.QPushButton(applyIcon, 'validate', parent=self)
self._buttons.layout().addWidget(self._applyBut)
self._controlWidget.layout().addWidget(self._buttons)
# signal / slot connection
self._controlWidget.sigShiftChanged.connect(self._updateShift)
self._controlWidget.sigRoiChanged.connect(self._updateShift)
self._controlWidget.sigAuto.connect(self._updateAuto)
self._lockBut.toggled.connect(self._lockAxisPosition)
self._computeBut.pressed.connect(self._computationRequested)
# expose API
self.getXShift = self._controlWidget.getXShift
......@@ -141,6 +154,9 @@ class AxisWindow(qt.QMainWindow):
# adapt gui to the axis value
self.setReconsParams(axis=self.__recons_params)
def _computationRequested(self):
self.sigComputationRequested.emit()
def _lockAxisPosition(self, lock):
raise NotImplementedError()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment