1、完成了<数据精对齐>的所有代码

This commit is contained in:
2025-05-08 15:51:32 +08:00
parent b4c4e124f8
commit 6a250a64a0
12 changed files with 2662 additions and 480 deletions

View File

@ -213,8 +213,6 @@ class MainWindow_label_check(QMainWindow):
self.is_left_button_pressed = None
self.is_right_button_pressed = None
self.line_processed_data_1 = None
self.line_processed_data_2 = None
self.point_peak_original = None
self.point_peak_corrected = None
self.annotation_tableWidget = None
@ -250,6 +248,7 @@ class MainWindow_label_check(QMainWindow):
self.fig = plt.figure(figsize=(12, 9), dpi=100)
self.canvas = FigureCanvasQTAgg(self.fig)
self.figToolbar = CustomNavigationToolbar(self.canvas, self)
self.figToolbar.action_Label_Multiple.setEnabled(False)
for action in self.figToolbar._actions.values():
action.setEnabled(False)
for action in self.figToolbar.actions():
@ -300,7 +299,6 @@ class MainWindow_label_check(QMainWindow):
self.ui.tableWidget_peak_corrected.cellDoubleClicked.connect(
self.__slot_tableWidget_on_cell_double_clicked__)
self.ui.doubleSpinBox_findpeaks_min_interval.editingFinished.connect(self.__update_config__)
self.ui.doubleSpinBox_findpeaks_min_height.editingFinished.connect(self.__update_config__)
self.ui.spinBox_moveLength.editingFinished.connect(self.__update_config__)
@ -316,12 +314,11 @@ class MainWindow_label_check(QMainWindow):
QApplication.processEvents()
# 清空画框
if self.line_processed_data_1 and self.line_processed_data_2 and self.point_peak_original and self.point_peak_corrected:
del self.line_processed_data_1
del self.line_processed_data_2
del self.point_peak_original
del self.point_peak_corrected
self.canvas.draw()
del self.point_peak_original
del self.point_peak_corrected
del self.annotation_tableWidget
self.ax0.clear()
self.ax1.clear()
# 释放资源
del self.data
@ -340,25 +337,28 @@ class MainWindow_label_check(QMainWindow):
def __plot__(self):
# 清空画框
if self.line_processed_data_1 and self.line_processed_data_2 and self.point_peak_original and self.point_peak_corrected:
try:
self.line_processed_data_1.remove()
self.line_processed_data_2.remove()
self.point_peak_original.remove()
self.point_peak_corrected.remove()
except ValueError:
pass
if self.point_peak_original is not None:
self.point_peak_original.remove()
self.point_peak_original = None
if self.point_peak_corrected is not None:
self.point_peak_corrected.remove()
self.point_peak_corrected = None
if self.annotation_tableWidget is not None:
self.annotation_tableWidget.remove()
self.annotation_tableWidget = None
self.reset_axes()
sender = self.sender()
if sender == self.ui.pushButton_input:
self.ui.spinBox_data_length.setValue(len(self.data.processed_data))
self.line_processed_data_1, = self.ax0.plot(self.data.processed_data,
label=Constants.LABEL_CHECK_PLOT_LABEL_SIGNAL,
color=Constants.PLOT_COLOR_BLUE)
self.line_processed_data_2, = self.ax1.plot(self.data.processed_data,
label=Constants.LABEL_CHECK_PLOT_LABEL_SIGNAL,
color=Constants.PLOT_COLOR_BLUE)
self.ax0.plot(self.data.processed_data,
label=Constants.LABEL_CHECK_PLOT_LABEL_SIGNAL,
color=Constants.PLOT_COLOR_BLUE)
self.ax1.plot(self.data.processed_data,
label=Constants.LABEL_CHECK_PLOT_LABEL_SIGNAL,
color=Constants.PLOT_COLOR_BLUE)
self.ax0.legend(loc=Constants.PLOT_UPPER_RIGHT)
self.ax1.legend(loc=Constants.PLOT_UPPER_RIGHT)
status = True
@ -382,7 +382,7 @@ class MainWindow_label_check(QMainWindow):
self.ax1.callbacks.connect('xlim_changed', lambda ax: self.on_xlim_change(ax))
self.ax0.legend(loc=Constants.PLOT_UPPER_RIGHT)
self.ax1.legend(loc=Constants.PLOT_UPPER_RIGHT)
except Exception as e:
except Exception:
return False, Constants.DRAWING_FAILURE
self.canvas.draw()
@ -431,14 +431,17 @@ class MainWindow_label_check(QMainWindow):
PublicFunc.__disableAllButton__(self, ButtonState)
# 清空画框
if self.line_processed_data_1 and self.line_processed_data_2 and self.point_peak_original and self.point_peak_corrected:
try:
self.line_processed_data_1.remove()
self.line_processed_data_2.remove()
self.point_peak_original.remove()
self.point_peak_corrected.remove()
except ValueError:
pass
if self.point_peak_original is not None:
self.point_peak_original.remove()
self.point_peak_original = None
if self.point_peak_corrected is not None:
self.point_peak_corrected.remove()
self.point_peak_corrected = None
if self.annotation_tableWidget is not None:
self.annotation_tableWidget.remove()
self.annotation_tableWidget = None
self.reset_axes()
self.canvas.draw()
self.data = Data()
@ -653,14 +656,24 @@ class MainWindow_label_check(QMainWindow):
self.canvas.draw()
PublicFunc.text_output(self.ui, f"{Constants.LABEL_CHECK_JUMP_X_INDEX}{str(int(x))}", Constants.TIPS_TYPE_INFO)
def reset_axes(self):
self.ax0.clear()
self.ax1.clear()
self.ax0.grid(True)
self.ax0.xaxis.set_major_formatter(ConfigParams.FORMATTER)
self.ax0.tick_params(axis='x', colors=Constants.PLOT_COLOR_WHITE)
self.ax1.grid(True)
self.ax1.xaxis.set_major_formatter(ConfigParams.FORMATTER)
def on_xlim_change(self, event_ax):
try:
if self.annotation_tableWidget:
if self.annotation_tableWidget is not None:
self.annotation_tableWidget.remove()
self.annotation_tableWidget = None
except AttributeError:
pass
self.annotation_tableWidget = None
def autoplay_move_xlim(self):
@ -967,7 +980,6 @@ class Data:
class CustomNavigationToolbar(NavigationToolbar2QT):
def __init__(self, canvas, parent):
super().__init__(canvas, parent)
# 初始化画框工具栏
@ -997,24 +1009,20 @@ class CustomNavigationToolbar(NavigationToolbar2QT):
self.rect_patch_ax0 = None # 用于绘制矩形的patch
self.rect_patch_ax1 = None # 用于绘制矩形的patch
def home(self, *args):
pass
def zoom(self, *args):
super().zoom(*args)
self.deactivate_figToorbar_changeLabel_mode()
def pan(self, *args):
super().pan(*args)
self.deactivate_figToorbar_changeLabel_mode()
def deactivate_figToorbar_changeLabel_mode(self):
if self.action_Label_Multiple.isChecked():