Commit 8ef69a7a authored by Carsten Richter's avatar Carsten Richter

Merge branch 'save-qspace-earlier' into 'master'

Add link to qspace in project earlier

See merge request !111
parents d91d9756 759f5389
Pipeline #7086 canceled with stages
......@@ -25,6 +25,7 @@
from __future__ import absolute_import
import functools
import os
from silx.gui import qt as Qt
......@@ -181,6 +182,14 @@ class XsocsGui(Qt.QMainWindow):
# Qt.Qt.IgnoreAspectRatio)
# view.resize(size)
def __qspaceProcessDone(self, output_f):
"""Handle end of QSpace processing, add link to output file
:param str output_f: The HDF5 file name storing the result
"""
self.__project.qspaceGroup().addQSpace(output_f)
self.model().refresh()
def __intensityRoiApplied(self, event):
xsocsFile = os.path.basename(self.__project.xsocsFile)
xsocsPrefix = xsocsFile.rpartition('.')[0]
......@@ -194,12 +203,13 @@ class XsocsGui(Qt.QMainWindow):
parent=self.sender(),
shiftH5File=event.shiftFile,
normalizer=self.sender().getNormalizer())
widget.sigProcessDone.connect(
functools.partial(self.__qspaceProcessDone, output_f))
widget.exec_()
if widget.status == QSpaceWidget.StatusCompleted:
qspaceF = widget.qspaceH5
qspaceGroup = self.__project.qspaceGroup()
qspaceItem = qspaceGroup.addQSpace(qspaceF)
self.model().refresh()
# Select and display the QSpace
qspaceItem = self.__project.qspaceGroup().getQspaceItems()[-1]
index = self.tree.pathToIndex(qspaceItem.path)
if index.isValid():
self.tree.setCurrentIndex(index)
......
......@@ -441,14 +441,16 @@ class ConversionParamsWidget(Qt.QWidget):
class QSpaceWidget(Qt.QDialog):
sigProcessDone = Qt.Signal(object)
sigProcessDone = Qt.Signal()
"""Signal emitted when the processing is done,
but before closing the progress dialog.
"""
(StatusUnknown, StatusInit,
StatusRunning, StatusCompleted,
StatusAborted, StatusCanceled) = StatusList = range(6)
__sigConvertDone = Qt.Signal()
def __init__(self,
xsocH5File,
outQSpaceH5,
......@@ -784,6 +786,7 @@ class QSpaceWidget(Qt.QDialog):
self.__converter = converter
procDialog = _ConversionProcessDialog(converter, parent=self)
procDialog.sigProcessDone.connect(self.sigProcessDone.emit)
procDialog.accepted.connect(self.__slotConvertDone)
procDialog.rejected.connect(self.__slotConvertDone)
self._setStatus(self.StatusRunning)
......@@ -806,7 +809,6 @@ class QSpaceWidget(Qt.QDialog):
self.__qspaceH5 = converter.results
self._setStatus(self.StatusCompleted)
self.hide()
self.sigProcessDone.emit(self.__qspaceH5)
elif status == QSpaceConverter.CANCELED:
self._setStatus(self.StatusAborted)
else:
......@@ -890,8 +892,13 @@ class QSpaceWidget(Qt.QDialog):
class _ConversionProcessDialog(Qt.QDialog):
# Used internally for executing code in main thread
__sigConvertDone = Qt.Signal()
sigProcessDone = Qt.Signal()
"""Signal emitted once the processing is done"""
def __init__(self, converter,
parent=None,
**kwargs):
......@@ -956,6 +963,7 @@ class _ConversionProcessDialog(Qt.QDialog):
self.__qtimer.stop()
self.__qtimer = None
self.__onProgress()
abortBn = self.__bn_box.button(Qt.QDialogButtonBox.Abort)
converter = self.__converter
......@@ -980,5 +988,7 @@ class _ConversionProcessDialog(Qt.QDialog):
'done.</font>')
okBn.setText('Close')
self.sigProcessDone.emit()
status = property(lambda self: 0 if self.__aborted else 1)
"""Status of the process."""
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