clicking outside axes no longer emits signal

This commit is contained in:
Dominik Demuth 2024-10-13 18:29:04 +02:00
parent d90959c6b6
commit b6b98d292a
2 changed files with 23 additions and 7 deletions

View File

@ -33,9 +33,9 @@ class PointSelectWidget(QtWidgets.QWidget, Ui_Form):
self.peaktable.itemDoubleClicked.connect(self.editing_started)
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,13 +102,21 @@ class PointSelectWidget(QtWidgets.QWidget, Ui_Form):
@QtCore.pyqtSlot()
def apply(self) -> dict:
ret_dic = {'avg_range': [self.left_pt.value(), self.right_pt.value()],
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())}
'special': None,
'idx': None,
'xy': (self.xbutton.isChecked(), self.ybutton.isChecked()),
}
if self.groupBox_2.isChecked():
ret_dic['special'] = {0: 'max', 1: 'absmax', 2: 'min', 3: 'absmin'}[self.special_comboBox.currentIndex()]
ret_dic['special'] = {
0: 'max',
1: 'absmax',
2: 'min',
3: 'absmin'
}[self.special_comboBox.currentIndex()]
if len(self.pts) != 0:
ret_dic['idx'] = self.pts

View File

@ -539,6 +539,10 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
if self.graphic.plotItem.sceneBoundingRect().contains(evt.scenePos()) and evt.button() == 1:
pos = vb.mapSceneToView(evt.scenePos())
if not _inside_range(pos.x(), pos.y(), vb.viewRange()):
return
_x, _y = pos.x(), pos.y()
if self.log[0]:
@ -854,3 +858,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
self.set_color(foreground=self._prev_colors[0], background=self._prev_colors[1])
self._prev_colors = temp
def _inside_range(x: float, y: float, ranges: list[list[float]]) -> bool:
x_range, y_range = ranges
return (x_range[0] <= x <= x_range[1]) and (y_range[0] <= y <= y_range[1])