优化界面布局,新增偏移量调整功能,支持x轴解绑,手动获取偏移位置,调整控件大小和字体,增强X轴同步处理逻辑
This commit is contained in:
@ -39,7 +39,10 @@ ButtonState = {
|
||||
"pushButton_calculate_correlation": False,
|
||||
"pushButton_correlation_align": False,
|
||||
"pushButton_view_align": False,
|
||||
"pushButton_save": False
|
||||
"pushButton_save": False,
|
||||
"checkBox_sync_xlim": False,
|
||||
"pushButton_getPos": False,
|
||||
"pushButton_resetPos": False
|
||||
},
|
||||
"Current": {
|
||||
"pushButton_input_setting": True,
|
||||
@ -47,7 +50,10 @@ ButtonState = {
|
||||
"pushButton_calculate_correlation": False,
|
||||
"pushButton_correlation_align": False,
|
||||
"pushButton_view_align": False,
|
||||
"pushButton_save": False
|
||||
"pushButton_save": False,
|
||||
"checkBox_sync_xlim": False,
|
||||
"pushButton_getPos": False,
|
||||
"pushButton_resetPos": False
|
||||
},
|
||||
"Statue_1": {
|
||||
"pushButton_input_setting": False,
|
||||
@ -55,7 +61,10 @@ ButtonState = {
|
||||
"pushButton_calculate_correlation": True,
|
||||
"pushButton_correlation_align": False,
|
||||
"pushButton_view_align": False,
|
||||
"pushButton_save": False
|
||||
"pushButton_save": False,
|
||||
"checkBox_sync_xlim": True,
|
||||
"pushButton_getPos": False,
|
||||
"pushButton_resetPos": False
|
||||
},
|
||||
"Statue_2": {
|
||||
"pushButton_input_setting": False,
|
||||
@ -63,7 +72,10 @@ ButtonState = {
|
||||
"pushButton_calculate_correlation": True,
|
||||
"pushButton_correlation_align": True,
|
||||
"pushButton_view_align": False,
|
||||
"pushButton_save": False
|
||||
"pushButton_save": False,
|
||||
"checkBox_sync_xlim": False,
|
||||
"pushButton_getPos": False,
|
||||
"pushButton_resetPos": False
|
||||
},
|
||||
"Statue_3": {
|
||||
"pushButton_input_setting": False,
|
||||
@ -71,7 +83,10 @@ ButtonState = {
|
||||
"pushButton_calculate_correlation": False,
|
||||
"pushButton_correlation_align": False,
|
||||
"pushButton_view_align": True,
|
||||
"pushButton_save": False
|
||||
"pushButton_save": False,
|
||||
"checkBox_sync_xlim": False,
|
||||
"pushButton_getPos": False,
|
||||
"pushButton_resetPos": False
|
||||
},
|
||||
"Statue_4": {
|
||||
"pushButton_input_setting": False,
|
||||
@ -79,7 +94,10 @@ ButtonState = {
|
||||
"pushButton_calculate_correlation": False,
|
||||
"pushButton_correlation_align": False,
|
||||
"pushButton_view_align": False,
|
||||
"pushButton_save": True
|
||||
"pushButton_save": True,
|
||||
"checkBox_sync_xlim": False,
|
||||
"pushButton_getPos": False,
|
||||
"pushButton_resetPos": False
|
||||
},
|
||||
}
|
||||
|
||||
@ -394,8 +412,12 @@ class MainWindow_precisely_align(QMainWindow):
|
||||
self.ui.pushButton_correlation_align.clicked.connect(self.__slot_btn_correlation_align__)
|
||||
self.ui.pushButton_view_align.clicked.connect(self.__slot_btn_view_align__)
|
||||
self.ui.pushButton_save.clicked.connect(self.__slot_btn_save__)
|
||||
self.ui.pushButton_getPos.clicked.connect(self.__get_current_pos__)
|
||||
self.ui.pushButton_resetPos.clicked.connect(self.__reset_pos__)
|
||||
self.canvas.mpl_connect('pick_event', self.on_pick)
|
||||
|
||||
self.ui.checkBox_sync_xlim.checkStateChanged.connect(self.__checkBox_sync_xlim_changed__)
|
||||
|
||||
self.ui.spinBox_BCG_front_JJIV_1.editingFinished.connect(self.__update_coordinate__)
|
||||
self.ui.spinBox_BCG_front_JJIV_2.editingFinished.connect(self.__update_coordinate__)
|
||||
self.ui.spinBox_BCG_back_JJIV_1.editingFinished.connect(self.__update_coordinate__)
|
||||
@ -405,6 +427,8 @@ class MainWindow_precisely_align(QMainWindow):
|
||||
self.ui.spinBox_ECG_back_RRIV_1.editingFinished.connect(self.__update_coordinate__)
|
||||
self.ui.spinBox_ECG_back_RRIV_2.editingFinished.connect(self.__update_coordinate__)
|
||||
|
||||
self.ui.label_sampno.setText(str(self.sampID))
|
||||
|
||||
@overrides
|
||||
def closeEvent(self, event):
|
||||
reply = QMessageBox.question(self, '确认', '确认退出吗?', QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
|
||||
@ -497,6 +521,8 @@ class MainWindow_precisely_align(QMainWindow):
|
||||
self._syncing_xlim_change = False
|
||||
|
||||
def on_ax0_xlim_changed(ax):
|
||||
if self.ui.checkBox_sync_xlim.isChecked() is False:
|
||||
return
|
||||
if self._syncing_xlim_change:
|
||||
return
|
||||
if ax is self.ax0:
|
||||
@ -506,6 +532,8 @@ class MainWindow_precisely_align(QMainWindow):
|
||||
self._syncing_xlim_change = False
|
||||
|
||||
def on_ax1_xlim_changed(ax):
|
||||
if self.ui.checkBox_sync_xlim.isChecked() is False:
|
||||
return
|
||||
if self._syncing_xlim_change:
|
||||
return
|
||||
if ax is self.ax1:
|
||||
@ -695,6 +723,55 @@ class MainWindow_precisely_align(QMainWindow):
|
||||
self.canvas.draw()
|
||||
return Result().failure(info=Constants.DRAW_FAILURE)
|
||||
|
||||
def __checkBox_sync_xlim_changed__(self):
|
||||
if not self.ui.checkBox_sync_xlim.isChecked():
|
||||
self.ui.pushButton_getPos.setEnabled(True)
|
||||
self.ui.pushButton_resetPos.setEnabled(True)
|
||||
else:
|
||||
self.ui.pushButton_getPos.setEnabled(False)
|
||||
self.ui.pushButton_resetPos.setEnabled(False)
|
||||
|
||||
def __get_current_pos__(self):
|
||||
if self.ui.checkBox_sync_xlim.isChecked():
|
||||
return
|
||||
# 获取当前两子图的x轴起始点
|
||||
ax0_x0, _ = self.ax0.get_xlim()
|
||||
ax1_x0, _ = self.ax1.get_xlim()
|
||||
# 获取ax0的trick位置
|
||||
# if self.data.BCG_early:
|
||||
# ax1_x0 += self.data.approximately_align_pos
|
||||
# else:
|
||||
# ax0_x0 -= self.data.approximately_align_pos
|
||||
|
||||
print(ax0_x0, ax1_x0)
|
||||
|
||||
actual_pos = -1 * self.data.approximately_align_pos if self.data.BCG_early else self.data.approximately_align_pos
|
||||
actual_ax0_x0 = ax0_x0 - actual_pos
|
||||
new_pos = actual_ax0_x0 - ax1_x0
|
||||
print(actual_ax0_x0, ax1_x0)
|
||||
if new_pos > 0:
|
||||
self.data.BCG_early = True
|
||||
else:
|
||||
self.data.BCG_early = False
|
||||
|
||||
self.data.approximately_align_pos = abs(new_pos)
|
||||
print(self.data.BCG_early, self.data.approximately_align_pos)
|
||||
|
||||
self.ui.label_pos.setText(str(int(self.data.approximately_align_pos) * (-1 if self.data.BCG_early else 1)))
|
||||
|
||||
self.ui.pushButton_input.click()
|
||||
|
||||
|
||||
def __reset_pos__(self):
|
||||
if self.data.TimeBiasSecond > 0:
|
||||
self.data.BCG_early = True
|
||||
else:
|
||||
self.data.BCG_early = False
|
||||
self.data.approximately_align_pos = abs(self.data.TimeBiasSecond)
|
||||
self.ui.label_pos.setText(str(int(self.data.approximately_align_pos) * (-1 if self.data.BCG_early else 1)))
|
||||
|
||||
|
||||
|
||||
def __update_info__(self):
|
||||
self.ui.spinBox_BCG_front_JJIV_1.setValue(Config["IV_Coordinate"]["BCG_front_1"])
|
||||
self.ui.spinBox_BCG_front_JJIV_2.setValue(Config["IV_Coordinate"]["BCG_front_2"])
|
||||
@ -774,6 +851,9 @@ class MainWindow_precisely_align(QMainWindow):
|
||||
action.setEnabled(True)
|
||||
ButtonState["Current"].update(ButtonState["Statue_1"].copy())
|
||||
PublicFunc.finish_operation(self, ButtonState)
|
||||
|
||||
self.ui.label_pos.setText(str(int(self.data.approximately_align_pos) * (-1 if self.data.BCG_early else 1)))
|
||||
|
||||
self.ui.pushButton_input.clicked.disconnect()
|
||||
self.ui.pushButton_input.clicked.connect(self.__slot_btn_repick__)
|
||||
self.ui.pushButton_input.setText("重新选取")
|
||||
@ -1693,6 +1773,7 @@ class Data:
|
||||
self.approximately_align_slope = None
|
||||
self.approximately_align_intercept = None
|
||||
self.BCG_early = None
|
||||
self.TimeBiasSecond = None
|
||||
|
||||
self.res_orgBcg = None
|
||||
self.res_BCG = None
|
||||
@ -1731,6 +1812,13 @@ class Data:
|
||||
if Path(Config["Path"]["Input_Approximately_Align"]).is_file():
|
||||
Config["Path"]["Input_Approximately_Align"] = str(Path(Config["Path"]["Input_Approximately_Align"]).parent)
|
||||
|
||||
result = PublicFunc.get_machine_start_time_bias(Config["Path"]["Input_ECG"], Config["Path"]["Input_OrgBCG"])
|
||||
if result.status:
|
||||
self.TimeBiasSecond = result.data["time_bias"] * Config["InputConfig"]["UseFreq"]
|
||||
else:
|
||||
self.TimeBiasSecond = 0
|
||||
|
||||
|
||||
result = PublicFunc.examine_file(Config["Path"]["Input_OrgBCG"], Filename.ORGBCG_RAW, Params.ENDSWITH_TXT)
|
||||
if result.status:
|
||||
Config["Path"]["Input_OrgBCG"] = result.data["path"]
|
||||
@ -1787,11 +1875,11 @@ class Data:
|
||||
Filename.RPEAK_FINAL_CORRECTED + ":" +
|
||||
Config["Path"]["Input_Rpeak"] +
|
||||
Constants.FAILURE_REASON["Path_Not_Exist"])
|
||||
if not Path(Config["Path"]["Input_Approximately_Align"]).exists():
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + "\n" +
|
||||
Filename.APPROXIMATELY_ALIGN_INFO + ":" +
|
||||
Config["Path"]["Input_Approximately_Align"] +
|
||||
Constants.FAILURE_REASON["Path_Not_Exist"])
|
||||
# if not Path(Config["Path"]["Input_Approximately_Align"]).exists():
|
||||
# return Result().failure(info=Constants.INPUT_FAILURE + "\n" +
|
||||
# Filename.APPROXIMATELY_ALIGN_INFO + ":" +
|
||||
# Config["Path"]["Input_Approximately_Align"] +
|
||||
# Constants.FAILURE_REASON["Path_Not_Exist"])
|
||||
|
||||
try:
|
||||
self.raw_orgBcg = read_csv(Config["Path"]["Input_OrgBCG"],
|
||||
@ -1831,9 +1919,21 @@ class Data:
|
||||
self.approximately_align_slope = df["estimate_slope"].values[-1] / \
|
||||
Params.APPROXIMATELY_ALIGN_CONFIG_NEW_CONTENT["Second_PerEpoch"]
|
||||
self.approximately_align_intercept = df["estimate_intercept"].values[-1] * Config["InputConfig"]["UseFreq"]
|
||||
self.TimeBiasSecond = self.approximately_align_pos
|
||||
|
||||
except Exception:
|
||||
self.approximately_align_pos = 0
|
||||
self.approximately_align_pos = abs(self.TimeBiasSecond)
|
||||
if self.approximately_align_pos > 0:
|
||||
if self.TimeBiasSecond > 0:
|
||||
self.BCG_early = True
|
||||
else:
|
||||
self.BCG_early = False
|
||||
else:
|
||||
self.BCG_early = None
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return Result().success(info=Constants.INPUT_FINISHED)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user