2022-12-30 14:07:38 +01:00
|
|
|
from nmreval.math import apodization
|
|
|
|
from nmreval.lib.importer import find_models
|
|
|
|
from nmreval.utils.text import convert
|
2022-03-08 10:27:40 +01:00
|
|
|
|
|
|
|
from ...Qt import QtCore, QtWidgets, QtGui
|
|
|
|
from ...lib.forms import FormWidget
|
|
|
|
from ..._py.editsignalwidget import Ui_Form
|
|
|
|
|
|
|
|
|
|
|
|
class EditSignalWidget(QtWidgets.QWidget, Ui_Form):
|
|
|
|
do_something = QtCore.pyqtSignal(str, tuple)
|
|
|
|
get_values = QtCore.pyqtSignal()
|
|
|
|
preview_triggered = QtCore.pyqtSignal(str)
|
|
|
|
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent=parent)
|
|
|
|
self.setupUi(self)
|
|
|
|
|
|
|
|
self.apodlist = find_models(apodization)
|
|
|
|
|
2023-01-07 19:13:13 +01:00
|
|
|
self.ls_lineEdit.hide()
|
|
|
|
self.ls_lineEdit.setValidator(QtGui.QDoubleValidator())
|
2022-03-08 10:27:40 +01:00
|
|
|
|
|
|
|
for ap in self.apodlist:
|
|
|
|
self.apodcombobox.addItem(str(ap().name))
|
|
|
|
self.change_apodization(0)
|
|
|
|
|
|
|
|
self.baselinebutton.clicked.connect(lambda: self.apply_changes('bl'))
|
|
|
|
self.zfbutton.clicked.connect(lambda: self.apply_changes('zf'))
|
|
|
|
self.phasebutton.clicked.connect(lambda: self.apply_changes('ph'))
|
|
|
|
self.apodbutton.clicked.connect(lambda: self.apply_changes('ap'))
|
|
|
|
self.leftshiftbutton.clicked.connect(lambda: self.apply_changes('ls'))
|
|
|
|
self.fourierutton.clicked.connect(lambda: self.apply_changes('ft'))
|
|
|
|
|
2023-01-07 19:13:13 +01:00
|
|
|
self.apod_prev_button.clicked.connect(lambda: self.preview_triggered.emit('ap'))
|
|
|
|
self.phase_prev_button.clicked.connect(lambda: self.preview_triggered.emit('ph'))
|
2022-03-08 10:27:40 +01:00
|
|
|
|
|
|
|
@QtCore.pyqtSlot(str)
|
|
|
|
def apply_changes(self, sender):
|
|
|
|
if sender in ['bl', 'zf', 'ft']:
|
|
|
|
self.do_something.emit(sender, tuple())
|
|
|
|
|
|
|
|
elif sender == 'ls':
|
2023-01-07 19:13:13 +01:00
|
|
|
if self.leftshift_comboBox.currentIndex() == 0:
|
|
|
|
_nop = int(self.ls_spinBox.text())
|
2022-03-08 10:27:40 +01:00
|
|
|
stype = 'pts'
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
_nop = float(self.lineEdit.text())
|
|
|
|
except ValueError:
|
|
|
|
_nop = 0.0
|
|
|
|
stype = 'time'
|
|
|
|
self.do_something.emit(sender, (_nop, stype))
|
|
|
|
|
|
|
|
elif sender == 'ap':
|
|
|
|
apodmodel = self.apodlist[self.apodcombobox.currentIndex()]
|
2023-01-07 19:13:13 +01:00
|
|
|
p = [float(x.text()) for x in self.apod_box.findChildren(QtWidgets.QLineEdit)]
|
2022-03-08 10:27:40 +01:00
|
|
|
self.do_something.emit(sender, (p, apodmodel))
|
|
|
|
|
|
|
|
elif sender == 'ph':
|
|
|
|
pvt = float(self.pivot_lineedit.text())
|
2023-01-07 19:13:13 +01:00
|
|
|
if self.autophase_check.isChecked():
|
|
|
|
self.do_something.emit('autoph', (pvt,))
|
|
|
|
else:
|
|
|
|
ph0 = float(self.ph0slider.value())
|
|
|
|
ph1 = float(self.ph1slider.value())
|
|
|
|
self.do_something.emit(sender, (ph0, ph1, pvt))
|
2022-03-08 10:27:40 +01:00
|
|
|
|
|
|
|
else:
|
|
|
|
print('You should never reach this by accident.')
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot(int, name='on_apodcombobox_currentIndexChanged')
|
|
|
|
def change_apodization(self, index):
|
|
|
|
apod_func = self.apodlist[index]
|
2023-01-07 19:13:13 +01:00
|
|
|
self.apod_name_label.setText(convert(apod_func.equation))
|
2022-03-08 10:27:40 +01:00
|
|
|
|
2023-01-07 19:13:13 +01:00
|
|
|
while self.apod_layout.count():
|
|
|
|
item = self.apod_layout.takeAt(0)
|
2022-03-08 10:27:40 +01:00
|
|
|
try:
|
|
|
|
item.widget().deleteLater()
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
for k, v in enumerate(apod_func.params):
|
|
|
|
widgt = FormWidget(name=v)
|
2023-01-07 19:13:13 +01:00
|
|
|
self.apod_layout.addWidget(widgt)
|
2022-03-08 10:27:40 +01:00
|
|
|
|
2023-01-07 19:13:13 +01:00
|
|
|
@QtCore.pyqtSlot(int, name='on_leftshift_comboBox_currentIndexChanged')
|
2022-03-08 10:27:40 +01:00
|
|
|
def change_ls(self, idx):
|
|
|
|
if idx:
|
2023-01-07 19:13:13 +01:00
|
|
|
self.ls_lineEdit.show()
|
|
|
|
self.ls_spinBox.hide()
|
2022-03-08 10:27:40 +01:00
|
|
|
else:
|
2023-01-07 19:13:13 +01:00
|
|
|
self.ls_lineEdit.hide()
|
|
|
|
self.ls_spinBox.show()
|