dev #297
| @@ -33,9 +33,9 @@ class PointSelectWidget(QtWidgets.QWidget, Ui_Form): | |||||||
|         self.peaktable.itemDoubleClicked.connect(self.editing_started) |         self.peaktable.itemDoubleClicked.connect(self.editing_started) | ||||||
|  |  | ||||||
|     def keyPressEvent(self, e): |     def keyPressEvent(self, e): | ||||||
|         if e.key() == QtCore.Qt.Key_Delete: |         if e.key() == QtCore.Qt.Key.Key_Delete: | ||||||
|             self.remove_points() |             self.remove_points() | ||||||
|         elif e.key() == QtCore.Qt.Key_F2: |         elif e.key() == QtCore.Qt.Key.Key_F2: | ||||||
|             self.editing_started() |             self.editing_started() | ||||||
|         else: |         else: | ||||||
|             super().keyPressEvent(e) |             super().keyPressEvent(e) | ||||||
| @@ -102,13 +102,21 @@ class PointSelectWidget(QtWidgets.QWidget, Ui_Form): | |||||||
|  |  | ||||||
|     @QtCore.pyqtSlot() |     @QtCore.pyqtSlot() | ||||||
|     def apply(self) -> dict: |     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()], |             'avg_mode': {0: 'mean', 1: 'sum', 2: 'integral', 3: 'std'}[self.average_combobox.currentIndex()], | ||||||
|                    'special': None, 'idx': None, |             'special': None, | ||||||
|                    'xy': (self.xbutton.isChecked(), self.ybutton.isChecked())} |             'idx': None, | ||||||
|  |             'xy': (self.xbutton.isChecked(), self.ybutton.isChecked()), | ||||||
|  |         } | ||||||
|  |  | ||||||
|         if self.groupBox_2.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: |         if len(self.pts) != 0: | ||||||
|             ret_dic['idx'] = self.pts |             ret_dic['idx'] = self.pts | ||||||
|   | |||||||
| @@ -539,6 +539,10 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): | |||||||
|  |  | ||||||
|         if self.graphic.plotItem.sceneBoundingRect().contains(evt.scenePos()) and evt.button() == 1: |         if self.graphic.plotItem.sceneBoundingRect().contains(evt.scenePos()) and evt.button() == 1: | ||||||
|             pos = vb.mapSceneToView(evt.scenePos()) |             pos = vb.mapSceneToView(evt.scenePos()) | ||||||
|  |  | ||||||
|  |             if not _inside_range(pos.x(), pos.y(), vb.viewRange()): | ||||||
|  |                 return | ||||||
|  |  | ||||||
|             _x, _y = pos.x(), pos.y() |             _x, _y = pos.x(), pos.y() | ||||||
|  |  | ||||||
|             if self.log[0]: |             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.set_color(foreground=self._prev_colors[0], background=self._prev_colors[1]) | ||||||
|         self._prev_colors = temp |         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]) | ||||||
		Reference in New Issue
	
	Block a user