dev (#295)
All checks were successful
Build AppImage / Explore-Gitea-Actions (push) Successful in 2m58s
All checks were successful
Build AppImage / Explore-Gitea-Actions (push) Successful in 2m58s
Co-authored-by: Dominik Demuth <dominik.demuth@physik.tu-darmstadt.de> Reviewed-on: #295
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import re
|
||||
|
||||
from ..Qt import QtCore, QtWidgets
|
||||
from ..Qt import QtCore, QtWidgets, QtGui
|
||||
from .._py.ptstab import Ui_Form
|
||||
from ..lib.pg_objects import LogInfiniteLine, RegionItem
|
||||
|
||||
@ -27,15 +27,23 @@ class PointSelectWidget(QtWidgets.QWidget, Ui_Form):
|
||||
self._last_item = None
|
||||
self.connected_figure = ''
|
||||
|
||||
self._avg_modes = ['mean', 'sum', 'integral', 'std']
|
||||
self._special_values = ['max', 'absmax', 'min', 'absmin']
|
||||
self._group_modes = ['group', 'x']
|
||||
|
||||
self.okButton.clicked.connect(self.apply)
|
||||
self.deleteButton.clicked.connect(self.remove_points)
|
||||
|
||||
self.peaktable.itemChanged.connect(self.editing_finished)
|
||||
self.peaktable.itemDoubleClicked.connect(self.editing_started)
|
||||
|
||||
self.left_limit.setValidator(QtGui.QDoubleValidator())
|
||||
self.right_limit.setValidator(QtGui.QDoubleValidator())
|
||||
|
||||
def keyPressEvent(self, e):
|
||||
if e.key() == QtCore.Qt.Key_Delete:
|
||||
if e.key() == QtCore.Qt.Key.Key_Delete:
|
||||
self.remove_points()
|
||||
elif e.key() == QtCore.Qt.Key_F2:
|
||||
elif e.key() == QtCore.Qt.Key.Key_F2:
|
||||
self.editing_started()
|
||||
else:
|
||||
super().keyPressEvent(e)
|
||||
@ -102,21 +110,22 @@ class PointSelectWidget(QtWidgets.QWidget, Ui_Form):
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def apply(self) -> dict:
|
||||
ret_dic = {'avg_range': [self.left_pt.value(), self.right_pt.value()],
|
||||
'avg_mode': {0: 'mean', 1: 'sum', 2: 'integral', 3: 'std'}[self.average_combobox.currentIndex()],
|
||||
'special': None, 'idx': None,
|
||||
'xy': (self.xbutton.isChecked(), self.ybutton.isChecked())}
|
||||
ret_dic = {
|
||||
'avg_range': self.get_limits(),
|
||||
'avg_mode': self._avg_modes[self.average_combobox.currentIndex()],
|
||||
'special': None,
|
||||
'idx': None,
|
||||
'xy': (self.xbutton.isChecked(), self.ybutton.isChecked()),
|
||||
'groupby': self._group_modes[self.group_box.currentIndex()],
|
||||
}
|
||||
|
||||
if self.groupBox_2.isChecked():
|
||||
ret_dic['special'] = {0: 'max', 1: 'absmax', 2: 'min', 3: 'absmin'}[self.special_comboBox.currentIndex()]
|
||||
if self.special_checkbox.isChecked():
|
||||
ret_dic['special'] = self._special_values[self.special_comboBox.currentIndex()]
|
||||
|
||||
if len(self.pts) != 0:
|
||||
ret_dic['idx'] = self.pts
|
||||
|
||||
if self.graph_checkbox.isChecked():
|
||||
gid = ''
|
||||
else:
|
||||
gid = self.graph_combobox.currentData()
|
||||
gid = self.graph_combobox.currentData() if not self.graph_checkbox.isChecked() else ''
|
||||
|
||||
self.points_selected.emit(ret_dic, gid)
|
||||
|
||||
@ -200,3 +209,21 @@ class PointSelectWidget(QtWidgets.QWidget, Ui_Form):
|
||||
@QtCore.pyqtSlot(int, name='on_graph_checkbox_stateChanged')
|
||||
def changed_state(self, checked):
|
||||
self.graph_combobox.setEnabled(checked != QtCore.Qt.CheckState.Checked)
|
||||
|
||||
@QtCore.pyqtSlot(int, name='on_special_checkbox_stateChanged')
|
||||
def changed_special(self, checked: int):
|
||||
self.graph_combobox.setEnabled(checked != QtCore.Qt.CheckState.Checked)
|
||||
|
||||
def get_limits(self) -> tuple[float, float, str]:
|
||||
try:
|
||||
left = float(self.left_limit.text())
|
||||
except ValueError:
|
||||
left = 0.
|
||||
|
||||
try:
|
||||
right = float(self.right_limit.text())
|
||||
except ValueError:
|
||||
right = 0.
|
||||
|
||||
return left, right, self.limit_combobox.currentText()
|
||||
|
||||
|
Reference in New Issue
Block a user