From 9e9751cd9d3770328d94f68ebc7f6d302089d375 Mon Sep 17 00:00:00 2001
From: Dominik Demuth
Date: Sun, 5 Nov 2023 15:20:40 +0100
Subject: [PATCH] add log to edit signal
---
src/gui_qt/_py/apod_dialog.py | 47 +++++++++--
src/gui_qt/_py/asciidialog.py | 48 +++++++++--
src/gui_qt/data/signaledit/phase_dialog.py | 24 ++++++
src/gui_qt/io/asciireader.py | 12 +++
src/resources/_ui/apod_dialog.ui | 95 +++++++++++++++++++---
src/resources/_ui/asciidialog.ui | 76 +++++++++++++----
6 files changed, 255 insertions(+), 47 deletions(-)
diff --git a/src/gui_qt/_py/apod_dialog.py b/src/gui_qt/_py/apod_dialog.py
index 1f64573..b739769 100644
--- a/src/gui_qt/_py/apod_dialog.py
+++ b/src/gui_qt/_py/apod_dialog.py
@@ -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
diff --git a/src/gui_qt/_py/asciidialog.py b/src/gui_qt/_py/asciidialog.py
index f3c89db..8fee8ed 100644
--- a/src/gui_qt/_py/asciidialog.py
+++ b/src/gui_qt/_py/asciidialog.py
@@ -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", "
Specify which column is used as x-value.
"))
self.label_5.setText(_translate("ascii_reader", "Δy
"))
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"))
diff --git a/src/gui_qt/data/signaledit/phase_dialog.py b/src/gui_qt/data/signaledit/phase_dialog.py
index 3494a45..06f7d0d 100644
--- a/src/gui_qt/data/signaledit/phase_dialog.py
+++ b/src/gui_qt/data/signaledit/phase_dialog.py
@@ -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
diff --git a/src/gui_qt/io/asciireader.py b/src/gui_qt/io/asciireader.py
index 66f5d45..f4b71a3 100644
--- a/src/gui_qt/io/asciireader.py
+++ b/src/gui_qt/io/asciireader.py
@@ -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)
diff --git a/src/resources/_ui/apod_dialog.ui b/src/resources/_ui/apod_dialog.ui
index e5ee569..d32af4e 100644
--- a/src/resources/_ui/apod_dialog.ui
+++ b/src/resources/_ui/apod_dialog.ui
@@ -35,6 +35,9 @@
3
+ -
+
+
-
@@ -45,19 +48,6 @@
- -
-
-
- -
-
-
- Qt::Horizontal
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
-
-
@@ -415,6 +405,85 @@
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+ -
+
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Log X
+
+
+
+ -
+
+
+ Log Y
+
+
+
+
+
+
+ -
+
+
+
+ 1
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Log X
+
+
+
+ -
+
+
+ Log Y
+
+
+
+
+
+
diff --git a/src/resources/_ui/asciidialog.ui b/src/resources/_ui/asciidialog.ui
index 7218f42..1c91059 100644
--- a/src/resources/_ui/asciidialog.ui
+++ b/src/resources/_ui/asciidialog.ui
@@ -7,7 +7,7 @@
0
0
627
- 703
+ 1245
@@ -301,9 +301,65 @@
+ -
+
+
+ -
+
+
+ Numerical value
+
+
+
+ -
+
+
+ Filename
+
+
+
+ -
+
+
+ Regex
+
+
+ buttonGroup_2
+
+
+
+ -
+
+
+ -
+
+
+ Custom value
+
+
+ buttonGroup_2
+
+
+
+ -
+
+
+ -
+
+
+ Position in filename
+
+
+ buttonGroup_2
+
+
+
+ -
+
+
-
@@ -490,23 +546,6 @@
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
@@ -587,5 +626,6 @@
+