Commit 1ad0fb64 authored by Thomas Vincent's avatar Thomas Vincent

Allow to specify a ROI to save during merge

parent 9ccda136
......@@ -672,6 +672,47 @@ class MergeWidget(Qt.QDialog):
grpLayout.addWidget(_vLine())
# ###########
# Image ROI
# ###########
self.__imageROIGbx = GroupBox("Image ROI")
self.layout().addWidget(self.__imageROIGbx,
2, 0, Qt.Qt.AlignLeft | Qt.Qt.AlignTop)
layout = Qt.QGridLayout(self.__imageROIGbx)
layout.addWidget(Qt.QLabel('Offset:'), 0, 0)
label = Qt.QLabel('Row:')
label.setToolTip('Row offset from image origin of the image ROI\n'
'to be saved during merge')
layout.addWidget(label, 0, 1)
self.__imageROIRowLineEdit = Qt.QLineEdit('0')
self.__imageROIRowLineEdit.setValidator(Qt.QIntValidator(0, 10000))
layout.addWidget(self.__imageROIRowLineEdit, 0, 2)
label = Qt.QLabel('Column:')
label.setToolTip('Column offset from image origin of the image ROI\n'
'to be saved during merge')
layout.addWidget(label, 0, 3)
self.__imageROIColumnLineEdit = Qt.QLineEdit('0')
self.__imageROIColumnLineEdit.setValidator(Qt.QIntValidator(0, 10000))
layout.addWidget(self.__imageROIColumnLineEdit, 0, 4)
layout.addWidget(Qt.QLabel('Size:'), 1, 0)
label = Qt.QLabel('Height:')
label.setToolTip('Height of the image ROI to be saved during merge\n'
'Default: Whole image')
layout.addWidget(label, 1, 1)
self.__imageROIHeightLineEdit = Qt.QLineEdit()
self.__imageROIHeightLineEdit.setValidator(Qt.QIntValidator(0, 10000))
layout.addWidget(self.__imageROIHeightLineEdit, 1, 2)
label = Qt.QLabel('Width:')
label.setToolTip('Width of the image ROI to be saved during merge\n'
'Default: Whole image')
layout.addWidget(label, 1, 3)
self.__imageROIWidthLineEdit = Qt.QLineEdit()
self.__imageROIWidthLineEdit.setValidator(Qt.QIntValidator(0, 10000))
layout.addWidget(self.__imageROIWidthLineEdit, 1, 4)
# ################
# parameters
# ################
......@@ -680,7 +721,7 @@ class MergeWidget(Qt.QDialog):
self.__acqParamWid = acqParamWid = AcqParamsWidget()
self.layout().addWidget(acqParamsGbx,
2, 0,
3, 0,
Qt.Qt.AlignLeft | Qt.Qt.AlignTop)
grpLayout.addWidget(acqParamWid)
......@@ -691,7 +732,7 @@ class MergeWidget(Qt.QDialog):
self.__outputGbx = outputGbx = GroupBox("Output")
layout = Qt.QGridLayout(outputGbx)
self.layout().addWidget(outputGbx,
3, 0,
4, 0,
Qt.Qt.AlignTop)
# ===========
......@@ -736,7 +777,7 @@ class MergeWidget(Qt.QDialog):
cancelBn = Qt.QPushButton('Cancel')
hLayout = Qt.QHBoxLayout()
self.layout().addLayout(hLayout,
4, 0,
5, 0,
1, 1,
Qt.Qt.AlignHCenter | Qt.Qt.AlignTop)
hLayout.addWidget(mergeBn)
......@@ -905,6 +946,19 @@ class MergeWidget(Qt.QDialog):
raise ValueError('parameter is mandatory.')
merger.output_dir = str(outDir)
name = 'Image ROI'
row = int(self.__imageROIRowLineEdit.text() or '0')
column = int(self.__imageROIColumnLineEdit.text() or '0')
height = self.__imageROIHeightLineEdit.text()
height = int(height) if height else None
width = self.__imageROIWidthLineEdit.text()
width = int(width) if width else None
if row == 0 and column == 0 and height is None and width is None:
merger.image_roi = None # No ROI
else:
merger.image_roi = row, column, height, width
except Exception as ex:
Qt.QMessageBox.critical(self, 'Error',
'{0} : {1}.'.format(name, str(ex)))
......@@ -989,6 +1043,7 @@ class MergeWidget(Qt.QDialog):
- clears the scan widget
"""
self.__scansGbx.setEnabled(False)
self.__imageROIGbx.setEnabled(False)
self.__acqParamsGbx.setEnabled(False)
self.__outputGbx.setEnabled(False)
self.__mergeBn.setEnabled(False)
......@@ -1165,14 +1220,14 @@ class MergeWidget(Qt.QDialog):
# Retrieve calibration from selected ids
self.__scansGbx.setEnabled(enable)
self.__acqParamsGbx.setEnabled(len(selected_ids) > 0)
self.__acqParamsGbx.setEnabled(len(matched_ids) > 0)
# Set-up default values from first selected scan
if len(selected_ids) > 0:
calib = self.__merger.get_calibration(selected_ids[0])
if len(matched_ids) > 0:
calib = self.__merger.get_calibration(matched_ids[0])
if calib:
_logger.info("Load calibration information from scan %s",
selected_ids[0])
matched_ids[0])
if 'mononrj' in calib:
# Convert from keV to eV
self.__acqParamWid.beam_energy = calib['mononrj'] * 1000
......
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