feat(Step2Panel): 优化耀斑检测步骤交互体验
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
水质参数反演分析系统 - 图形用户界面
|
水质参数反演分析系统 - 图形用户界面
|
||||||
@ -1212,6 +1212,7 @@ class Step2Panel(QWidget):
|
|||||||
"""2. 耀斑区域识别"""
|
"""2. 耀斑区域识别"""
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
self.work_dir = None
|
||||||
self.init_ui()
|
self.init_ui()
|
||||||
|
|
||||||
def init_ui(self):
|
def init_ui(self):
|
||||||
@ -1232,7 +1233,7 @@ class Step2Panel(QWidget):
|
|||||||
"水域掩膜:",
|
"水域掩膜:",
|
||||||
"Mask Files (*.dat *.tif);;All Files (*.*)"
|
"Mask Files (*.dat *.tif);;All Files (*.*)"
|
||||||
)
|
)
|
||||||
self.water_mask_file.label.setText("水域掩膜(可选):")
|
self.water_mask_file.label.setText("水域掩膜:")
|
||||||
layout.addWidget(self.water_mask_file)
|
layout.addWidget(self.water_mask_file)
|
||||||
|
|
||||||
# 参数设置
|
# 参数设置
|
||||||
@ -1273,7 +1274,7 @@ class Step2Panel(QWidget):
|
|||||||
"输出耀斑掩膜:",
|
"输出耀斑掩膜:",
|
||||||
"Mask Files (*.dat *.tif);;All Files (*.*)"
|
"Mask Files (*.dat *.tif);;All Files (*.*)"
|
||||||
)
|
)
|
||||||
self.output_file.line_edit.setPlaceholderText("glint_mask.dat")
|
self.output_file.line_edit.setPlaceholderText("")
|
||||||
layout.addWidget(self.output_file)
|
layout.addWidget(self.output_file)
|
||||||
|
|
||||||
# 启用步骤
|
# 启用步骤
|
||||||
@ -1330,6 +1331,37 @@ class Step2Panel(QWidget):
|
|||||||
if 'output_path' in config:
|
if 'output_path' in config:
|
||||||
self.output_file.set_path(config['output_path'])
|
self.output_file.set_path(config['output_path'])
|
||||||
|
|
||||||
|
def update_from_config(self, work_dir=None, pipeline=None):
|
||||||
|
"""
|
||||||
|
从全局配置/Pipeline 自动填充路径,实现上下游数据流转
|
||||||
|
|
||||||
|
Args:
|
||||||
|
work_dir: 工作目录路径
|
||||||
|
pipeline: Pipeline 实例,用于获取步骤1生成的水域掩膜路径
|
||||||
|
"""
|
||||||
|
# 保存工作目录引用
|
||||||
|
if work_dir:
|
||||||
|
self.work_dir = work_dir
|
||||||
|
elif hasattr(self, 'work_dir') and self.work_dir:
|
||||||
|
pass # 保持现有工作目录
|
||||||
|
else:
|
||||||
|
self.work_dir = None
|
||||||
|
|
||||||
|
# 1. 自动填充水域掩膜路径(从步骤1的输出获取)
|
||||||
|
if pipeline and hasattr(pipeline, 'water_mask_path') and pipeline.water_mask_path:
|
||||||
|
self.water_mask_file.set_path(pipeline.water_mask_path)
|
||||||
|
|
||||||
|
# 2. 自动填充输出路径(基于工作目录)
|
||||||
|
if self.work_dir:
|
||||||
|
# 生成输出耀斑掩膜的标准路径:workspace/2_glint_mask/glint_mask_out.dat
|
||||||
|
output_dir = os.path.join(self.work_dir, "2_glint_mask")
|
||||||
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
|
default_output_path = os.path.join(output_dir, "glint_mask_out.dat").replace('\\', '/')
|
||||||
|
self.output_file.set_path(default_output_path)
|
||||||
|
else:
|
||||||
|
# 没有工作目录时,清空输出路径
|
||||||
|
self.output_file.set_path("")
|
||||||
|
|
||||||
def run_step(self):
|
def run_step(self):
|
||||||
"""独立运行步骤2"""
|
"""独立运行步骤2"""
|
||||||
# 验证输入
|
# 验证输入
|
||||||
@ -2598,7 +2630,7 @@ class Step7Panel(QWidget):
|
|||||||
"水域掩膜:",
|
"水域掩膜:",
|
||||||
"Mask Files (*.dat *.tif);;All Files (*.*)"
|
"Mask Files (*.dat *.tif);;All Files (*.*)"
|
||||||
)
|
)
|
||||||
self.water_mask_file.label.setText("水域掩膜(可选):")
|
self.water_mask_file.label.setText("水域掩膜:")
|
||||||
layout.addWidget(self.water_mask_file)
|
layout.addWidget(self.water_mask_file)
|
||||||
|
|
||||||
# 参数设置
|
# 参数设置
|
||||||
@ -6342,10 +6374,13 @@ class WaterQualityGUI(QMainWindow):
|
|||||||
|
|
||||||
item_data = item.data(Qt.UserRole)
|
item_data = item.data(Qt.UserRole)
|
||||||
if item_data == target_step_id:
|
if item_data == target_step_id:
|
||||||
# 找到对应的步骤项,设置为当前选中
|
|
||||||
self.step_list.setCurrentRow(row)
|
self.step_list.setCurrentRow(row)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Step2 切换时自动填充数据流转路径
|
||||||
|
if index == 1:
|
||||||
|
self.step2_panel.update_from_config(work_dir=self.work_dir, pipeline=self.pipeline)
|
||||||
|
|
||||||
def apply_stylesheet(self):
|
def apply_stylesheet(self):
|
||||||
"""应用样式表 - 应用现代化设计风格"""
|
"""应用样式表 - 应用现代化设计风格"""
|
||||||
# 应用主样式表
|
# 应用主样式表
|
||||||
|
|||||||
Reference in New Issue
Block a user