1
0
forked from IPKM/nmreval

add log to edit signal

This commit is contained in:
Dominik Demuth 2023-11-05 15:20:40 +01:00
parent 5a8ef8c9c7
commit 9e9751cd9d
6 changed files with 255 additions and 47 deletions

View File

@ -24,6 +24,9 @@ class Ui_ApodEdit(object):
self.gridLayout.setContentsMargins(9, 9, 9, 9)
self.gridLayout.setSpacing(3)
self.gridLayout.setObjectName("gridLayout")
self.freq_graph = NMRPlotWidget(ApodEdit)
self.freq_graph.setObjectName("freq_graph")
self.gridLayout.addWidget(self.freq_graph, 2, 2, 1, 1)
self.time_graph = NMRPlotWidget(ApodEdit)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
@ -32,14 +35,6 @@ class Ui_ApodEdit(object):
self.time_graph.setSizePolicy(sizePolicy)
self.time_graph.setObjectName("time_graph")
self.gridLayout.addWidget(self.time_graph, 2, 1, 1, 1)
self.freq_graph = NMRPlotWidget(ApodEdit)
self.freq_graph.setObjectName("freq_graph")
self.gridLayout.addWidget(self.freq_graph, 2, 2, 1, 1)
self.buttonBox = QtWidgets.QDialogButtonBox(ApodEdit)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 4, 1, 1, 2)
self.widget = QtWidgets.QWidget(ApodEdit)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
@ -175,6 +170,38 @@ class Ui_ApodEdit(object):
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
self.gridLayout.addWidget(self.widget, 2, 0, 1, 1)
self.buttonBox = QtWidgets.QDialogButtonBox(ApodEdit)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 4, 1, 1, 2)
self.log_freq_widget = QtWidgets.QWidget(ApodEdit)
self.log_freq_widget.setObjectName("log_freq_widget")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.log_freq_widget)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem1)
self.logx_freq = QtWidgets.QCheckBox(self.log_freq_widget)
self.logx_freq.setObjectName("logx_freq")
self.horizontalLayout_3.addWidget(self.logx_freq)
self.logy_freq = QtWidgets.QCheckBox(self.log_freq_widget)
self.logy_freq.setObjectName("logy_freq")
self.horizontalLayout_3.addWidget(self.logy_freq)
self.gridLayout.addWidget(self.log_freq_widget, 3, 2, 1, 1)
self.logtime_widget = QtWidgets.QWidget(ApodEdit)
self.logtime_widget.setObjectName("logtime_widget")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.logtime_widget)
self.horizontalLayout_2.setContentsMargins(-1, 1, -1, -1)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem2)
self.logx_time = QtWidgets.QCheckBox(self.logtime_widget)
self.logx_time.setObjectName("logx_time")
self.horizontalLayout_2.addWidget(self.logx_time)
self.logy_time = QtWidgets.QCheckBox(self.logtime_widget)
self.logy_time.setObjectName("logy_time")
self.horizontalLayout_2.addWidget(self.logy_time)
self.gridLayout.addWidget(self.logtime_widget, 3, 1, 1, 1)
self.retranslateUi(ApodEdit)
self.buttonBox.accepted.connect(ApodEdit.accept) # type: ignore
@ -202,4 +229,8 @@ class Ui_ApodEdit(object):
self.ft_box.setTitle(_translate("ApodEdit", "Fourier transform"))
self.phase_before_button.setText(_translate("ApodEdit", "before phase correction"))
self.phase_after_button.setText(_translate("ApodEdit", "after phase correction"))
self.logx_freq.setText(_translate("ApodEdit", "Log X"))
self.logy_freq.setText(_translate("ApodEdit", "Log Y"))
self.logx_time.setText(_translate("ApodEdit", "Log X"))
self.logy_time.setText(_translate("ApodEdit", "Log Y"))
from ..lib.graph_items import NMRPlotWidget

View File

@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_ascii_reader(object):
def setupUi(self, ascii_reader):
ascii_reader.setObjectName("ascii_reader")
ascii_reader.resize(627, 703)
ascii_reader.resize(627, 1245)
self.verticalLayout = QtWidgets.QVBoxLayout(ascii_reader)
self.verticalLayout.setObjectName("verticalLayout")
self.tabWidget = QtWidgets.QTabWidget(ascii_reader)
@ -156,7 +156,39 @@ class Ui_ascii_reader(object):
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout_2.addItem(spacerItem1, 4, 1, 1, 1)
self.horizontalLayout_4.addLayout(self.gridLayout_2)
self.verticalLayout_4 = QtWidgets.QVBoxLayout()
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.horizontalLayout_4.addLayout(self.verticalLayout_4)
self.verticalLayout_3.addWidget(self.groupBox)
self.dsdfsf = QtWidgets.QLabel(self.tabWidgetPage1)
self.dsdfsf.setObjectName("dsdfsf")
self.verticalLayout_3.addWidget(self.dsdfsf)
self.label_8 = QtWidgets.QLabel(self.tabWidgetPage1)
self.label_8.setObjectName("label_8")
self.verticalLayout_3.addWidget(self.label_8)
self.radioButton = QtWidgets.QRadioButton(self.tabWidgetPage1)
self.radioButton.setObjectName("radioButton")
self.buttonGroup_2 = QtWidgets.QButtonGroup(ascii_reader)
self.buttonGroup_2.setObjectName("buttonGroup_2")
self.buttonGroup_2.addButton(self.radioButton)
self.verticalLayout_3.addWidget(self.radioButton)
self.lineEdit = QtWidgets.QLineEdit(self.tabWidgetPage1)
self.lineEdit.setObjectName("lineEdit")
self.verticalLayout_3.addWidget(self.lineEdit)
self.radioButton_2 = QtWidgets.QRadioButton(self.tabWidgetPage1)
self.radioButton_2.setObjectName("radioButton_2")
self.buttonGroup_2.addButton(self.radioButton_2)
self.verticalLayout_3.addWidget(self.radioButton_2)
self.lineEdit_2 = QtWidgets.QLineEdit(self.tabWidgetPage1)
self.lineEdit_2.setObjectName("lineEdit_2")
self.verticalLayout_3.addWidget(self.lineEdit_2)
self.radioButton_3 = QtWidgets.QRadioButton(self.tabWidgetPage1)
self.radioButton_3.setObjectName("radioButton_3")
self.buttonGroup_2.addButton(self.radioButton_3)
self.verticalLayout_3.addWidget(self.radioButton_3)
self.spinBox = QtWidgets.QSpinBox(self.tabWidgetPage1)
self.spinBox.setObjectName("spinBox")
self.verticalLayout_3.addWidget(self.spinBox)
self.groupBox_2 = QtWidgets.QGroupBox(self.tabWidgetPage1)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(0)
@ -250,16 +282,11 @@ class Ui_ascii_reader(object):
self.horizontalLayout_3.addLayout(self.formLayout)
self.tabWidget.addTab(self.tabWidgetPage2, "")
self.verticalLayout.addWidget(self.tabWidget)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem3)
self.verticalLayout.addLayout(self.horizontalLayout)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setContentsMargins(-1, 0, -1, -1)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem4)
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem3)
self.skippy_checkbox = QtWidgets.QCheckBox(ascii_reader)
self.skippy_checkbox.setObjectName("skippy_checkbox")
self.horizontalLayout_2.addWidget(self.skippy_checkbox)
@ -302,6 +329,11 @@ class Ui_ascii_reader(object):
self.x_lineedit.setToolTip(_translate("ascii_reader", "<html><head/><body><p>Specify which column is used as x-value.</p></body></html>"))
self.label_5.setText(_translate("ascii_reader", "<html><head/><body><p>Δy</p></body></html>"))
self.x_label.setText(_translate("ascii_reader", "x"))
self.dsdfsf.setText(_translate("ascii_reader", "Numerical value"))
self.label_8.setText(_translate("ascii_reader", "Filename"))
self.radioButton.setText(_translate("ascii_reader", "Regex"))
self.radioButton_2.setText(_translate("ascii_reader", "Custom value"))
self.radioButton_3.setText(_translate("ascii_reader", "Position in filename"))
self.groupBox_2.setTitle(_translate("ascii_reader", "Preview"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabWidgetPage1), _translate("ascii_reader", "Data"))
self.label_2.setText(_translate("ascii_reader", "Number of delays"))

View File

@ -53,6 +53,8 @@ class QPreviewDialog(QtWidgets.QDialog, Ui_ApodEdit):
pl.hideButtons()
pl.setMenuEnabled(False)
self.time_graph.setLogMode(x=True)
self._all_time = None
self._all_freq = None
@ -392,6 +394,28 @@ class QPreviewDialog(QtWidgets.QDialog, Ui_ApodEdit):
self.zerofill_box.setVisible(self._all_time)
self.apod_box.setVisible(self._all_time)
self.shift_box.setVisible(self._all_time)
self.time_graph.setVisible(self._all_time)
self.logtime_widget.setVisible(self._all_time)
@QtCore.pyqtSlot(int, name='on_logx_time_stateChanged')
@QtCore.pyqtSlot(int, name='on_logy_time_stateChanged')
@QtCore.pyqtSlot(int, name='on_logx_freq_stateChanged')
@QtCore.pyqtSlot(int, name='on_logy_freq_stateChanged')
def set_log(self, state: int):
switch = {
self.logx_time: lambda _x: self.time_graph.setLogMode(x=_x),
self.logy_time: lambda _x: self.time_graph.setLogMode(y=_x),
self.logx_freq: lambda _x: self.freq_graph.setLogMode(x=_x),
self.logy_freq: lambda _x: self.freq_graph.setLogMode(y=_x),
}[self.sender()]
switch(state == QtCore.Qt.Checked)
vb = self.freq_graph.getPlotItem().getViewBox()
vb.disableAutoRange(axis=vb.YAxis)
vb = self.time_graph.getPlotItem().getViewBox()
vb.disableAutoRange(axis=vb.YAxis)
self._temp_baseline = self._temp_baseline_time if self._all_time else self._temp_baseline_freq
self._temp_fft = self._temp_fft_time if self._all_time else self._temp_fft_freq

View File

@ -1,4 +1,9 @@
from __future__ import annotations
from pathlib import Path
from nmreval.io.asciireader import AsciiReader
from nmreval.utils import NUMBER_RE
from ..Qt import QtGui, QtCore, QtWidgets
from .._py.asciidialog import Ui_ascii_reader
@ -57,6 +62,8 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader):
self.skippy_checkbox.setCheckState(QtCore.Qt.Unchecked)
self.skippy_checkbox.blockSignals(False)
self.check_filename(fname)
return self
def set_gui(self):
@ -215,3 +222,8 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader):
@QtCore.pyqtSlot(int, name='on_skippy_checkbox_stateChanged')
def skip_next_dial(self, _: int):
self.skip = self.skippy_checkbox.isChecked()
def check_filename(self, filename: str | Path):
self.label_8.setText(str(filename.stem))
for i in NUMBER_RE.finditer(str(filename.stem)):
print(i)

View File

@ -35,6 +35,9 @@
<property name="spacing">
<number>3</number>
</property>
<item row="2" column="2">
<widget class="NMRPlotWidget" name="freq_graph"/>
</item>
<item row="2" column="1">
<widget class="NMRPlotWidget" name="time_graph">
<property name="sizePolicy">
@ -45,19 +48,6 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="NMRPlotWidget" name="freq_graph"/>
</item>
<item row="4" column="1" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
@ -415,6 +405,85 @@
</layout>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QWidget" name="log_freq_widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="logx_freq">
<property name="text">
<string>Log X</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="logy_freq">
<property name="text">
<string>Log Y</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="1">
<widget class="QWidget" name="logtime_widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
<number>1</number>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="logx_time">
<property name="text">
<string>Log X</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="logy_time">
<property name="text">
<string>Log Y</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>627</width>
<height>703</height>
<height>1245</height>
</rect>
</property>
<property name="windowTitle">
@ -301,9 +301,65 @@
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="dsdfsf">
<property name="text">
<string>Numerical value</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Filename</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton">
<property name="text">
<string>Regex</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QRadioButton" name="radioButton_2">
<property name="text">
<string>Custom value</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_2"/>
</item>
<item>
<widget class="QRadioButton" name="radioButton_3">
<property name="text">
<string>Position in filename</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox"/>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
@ -490,23 +546,6 @@
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
@ -587,5 +626,6 @@
</connections>
<buttongroups>
<buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_2"/>
</buttongroups>
</ui>