Commit 3c86425c authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[gui][magnification] Save magnification value

parent bfcf6468
......@@ -26,7 +26,7 @@
__authors__ = ["J. Garriga"]
__license__ = "MIT"
__date__ = "01/06/2021"
__date__ = "02/06/2021"
from silx.gui import qt
......@@ -48,8 +48,12 @@ class MagnificationWidget(qt.QMainWindow):
self._checkboxManual = qt.QCheckBox("Manual magnification:")
self._manualLE = qt.QLineEdit(parent=self)
self._manualLE.setEnabled(False)
validator = qt.QDoubleValidator()
validator.setBottom(0)
self._manualLE.setValidator(validator)
self._okButton = qt.QPushButton("Ok")
self._okButton.setEnabled(False)
self._okButton.pressed.connect(self._saveMagnification)
layout.addWidget(self._checkbox2x)
layout.addWidget(self._checkbox10x)
layout.addWidget(self._checkboxManual)
......@@ -60,6 +64,8 @@ class MagnificationWidget(qt.QMainWindow):
self._checkbox2x.stateChanged.connect(self._check2x)
self._checkbox10x.stateChanged.connect(self._check10x)
self._checkboxManual.stateChanged.connect(self._checkManual)
self._checkbox2x.setChecked(True)
widget.setLayout(layout)
self.setCentralWidget(widget)
......@@ -76,30 +82,44 @@ class MagnificationWidget(qt.QMainWindow):
self.bg_dataset = bg_dataset
self._okButton.setEnabled(True)
def getDataset(self):
return self.dataset, self.indices, self.bg_indices, self.bg_dataset
def _checkManual(self, checked):
if checked:
self._checkbox2x.setEnabled(False)
self._checkbox10x.setEnabled(False)
self._checkbox2x.setChecked(False)
self._checkbox10x.setChecked(False)
self._manualLE.setEnabled(True)
else:
self._checkbox2x.setEnabled(True)
self._checkbox10x.setEnabled(True)
self._manualLE.setEnabled(False)
def _check2x(self, checked):
if checked:
self._checkbox10x.setEnabled(False)
self._checkboxManual.setEnabled(False)
self._checkbox10x.setChecked(False)
self._checkboxManual.setChecked(False)
self._manualLE.setEnabled(False)
else:
self._checkbox10x.setEnabled(True)
self._checkboxManual.setEnabled(True)
def _check10x(self, checked):
if checked:
self._checkbox2x.setEnabled(False)
self._checkboxManual.setEnabled(False)
self._checkbox2x.setChecked(False)
self._checkboxManual.setChecked(False)
self._manualLE.setEnabled(False)
def _saveMagnification(self):
if self._checkbox2x.isChecked():
self.dataset.magnification = 0.00375
elif self._checkbox10x.isChecked():
self.dataset.magnification = 0.00075
else:
self._checkbox2x.setEnabled(True)
self._checkboxManual.setEnabled(True)
magnification = self._manualLE.text()
if magnification == "":
msg = qt.QMessageBox()
msg.setIcon(qt.QMessageBox.Warning)
msg.setText("Magnification value has to be entered when choosing manual")
msg.exec_()
return
else:
self.dataset.magnification = float(magnification)
self.sigComputed.emit()
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