结构修改,后端文件跟前端内容进行适配

This commit is contained in:
DXC
2026-06-11 17:44:24 +08:00
parent 3584c07b67
commit e59703f163
12 changed files with 1311 additions and 495 deletions

View File

@ -117,17 +117,17 @@ from src.gui.components.custom_widgets import FileSelectWidget
from src.gui.panels.step1_panel import Step1Panel
from src.gui.panels.step2_panel import Step2Panel
from src.gui.panels.step3_panel import Step3Panel
from src.gui.panels.step4_sampling_panel import Step4SamplingPanel # 采样点布设原step10→新step4
from src.gui.panels.step4_sampling_panel import Step4SamplingPanel # 采样点布设
from src.gui.panels.step5_clean_panel import Step5CleanPanel # 数据清洗
from src.gui.panels.step6_feature_panel import Step6FeaturePanel # 光谱特征
from src.gui.panels.step7_index_panel import Step7IndexPanel # 水质光谱指数
from src.gui.panels.step10_map_panel import Step10MapPanel # 水色指数反演
from src.gui.panels.step10_watercolor_panel import Step10WatercolorPanel # 水色指数反演
from src.gui.panels.step8_ml_train_panel import Step8MlTrainPanel # 机器学习建模
from src.gui.panels.step9_ml_predict_panel import Step9MlPredictPanel # 机器学习预测
from src.gui.panels.step14_panel import Step14Panel
from src.gui.dialogs import BandConfirmDialog, AISettingsDialog
from src.gui.panels.step11_viz_panel import Step11VizPanel # 可视化(覆盖旧 step11_viz_panel.py
from src.gui.panels.step12_report_panel import Step12ReportPanel # 报告生成
from src.gui.panels.step11_map_panel import Step11MapPanel # 专题图生成
from src.gui.panels.step12_viz_panel import Step12VizPanel # 可视化
from src.gui.panels.step13_report_panel import Step13ReportPanel # 报告生成
# Pipeline 核心异常(用于预检弹窗)
from src.core.pipeline.runner import PipelineHalt
@ -1399,7 +1399,7 @@ class WaterQualityGUI(QMainWindow):
'step9_ml_predict': {
'predictions': '11_12_13_predictions/Machine_Learning_Prediction/'
},
'step10_map': {
'step11_map': {
'distribution_maps': '14_visualization/'
}
}
@ -1435,7 +1435,7 @@ class WaterQualityGUI(QMainWindow):
'sampling_csv_path': ('step4_sampling', 'sampling_points', 'sampling_csv_file'),
'models_dir': ('step8_ml_train', 'models', 'models_dir_file')
},
'step10_map': {
'step11_map': {
'prediction_csv_path': ('step9_ml_predict', 'predictions', 'prediction_csv_file')
}
}
@ -1826,9 +1826,10 @@ class WaterQualityGUI(QMainWindow):
],
"阶段四:预测与成果输出": [
("step9_ml_predict", "9. 机器学习预测"),
("step10_map", "10. 专题图生成"),
("step11_viz", "11. 可视化展示"),
("step12_report", "12. 分析报告生成")
("step10_watercolor", "10. 水色指数反演"),
("step11_map", "11. 专题图生成"),
("step12_viz", "12. 可视化展示"),
("step13_report", "13. 分析报告生成")
]
}
@ -1936,17 +1937,17 @@ class WaterQualityGUI(QMainWindow):
self.step9_ml_predict_panel = Step9MlPredictPanel()
self.step_stack.addTab(self.create_scroll_area(self.step9_ml_predict_panel), QIcon(self.get_icon_path("10.png")), "机器学习预测")
self.step10_map_panel = Step10MapPanel()
self.step_stack.addTab(self.create_scroll_area(self.step10_map_panel), QIcon(self.get_icon_path("10.png")), "专题图生成")
self.step10_watercolor_panel = Step10WatercolorPanel()
self.step_stack.addTab(self.create_scroll_area(self.step10_watercolor_panel), QIcon(self.get_icon_path("10.png")), "水色指数反演")
self.step14_panel = Step14Panel()
self.step_stack.addTab(self.create_scroll_area(self.step14_panel), QIcon(self.get_icon_path("11.png")), "专题图生成")
self.step11_map_panel = Step11MapPanel()
self.step_stack.addTab(self.create_scroll_area(self.step11_map_panel), QIcon(self.get_icon_path("10.png")), "专题图生成")
self.step11_viz_panel = Step11VizPanel()
self.step_stack.addTab(self.create_scroll_area(self.step11_viz_panel), QIcon(self.get_icon_path("9.png")), "可视化")
self.step12_viz_panel = Step12VizPanel()
self.step_stack.addTab(self.create_scroll_area(self.step12_viz_panel), QIcon(self.get_icon_path("9.png")), "可视化")
self.step12_report_panel = Step12ReportPanel(main_window=self)
self.step_stack.addTab(self.create_scroll_area(self.step12_report_panel), QIcon(self.get_icon_path("10.png")), "报告生成")
self.step13_report_panel = Step13ReportPanel(main_window=self)
self.step_stack.addTab(self.create_scroll_area(self.step13_report_panel), QIcon(self.get_icon_path("10.png")), "报告生成")
# 连接Tab切换信号实现双向同步必须在step_stack创建后
self.step_stack.currentChanged.connect(self.on_tab_changed)
@ -2085,18 +2086,11 @@ class WaterQualityGUI(QMainWindow):
# 根据步骤ID查找对应的tab索引
step_id_to_tab = {
'step1': 0,
'step2': 1,
'step3': 2,
'step4_sampling': 3,
'step5_clean': 4,
'step6_feature': 5,
'step7_index': 6,
'step8_ml_train': 7,
'step9_ml_predict': 8,
'step10_map': 9,
'step11_viz': 11,
'step12_report': 12,
'step1': 0, 'step2': 1, 'step3': 2, 'step4_sampling': 3,
'step5_clean': 4, 'step6_feature': 5, 'step7_index': 6,
'step8_ml_train': 7, 'step9_ml_predict': 8,
'step10_watercolor': 9, 'step11_map': 10,
'step12_viz': 11, 'step13_report': 12,
}
if item_data in step_id_to_tab:
@ -2110,21 +2104,13 @@ class WaterQualityGUI(QMainWindow):
if index < 0:
return
# Tab索引到步骤ID的反向映射
# Tab索引到步骤ID的反向映射13个Tabindex 0-12
tab_to_step_id = {
0: 'step1',
1: 'step2',
2: 'step3',
3: 'step4_sampling',
4: 'step5_clean',
5: 'step6_feature',
6: 'step7_index',
7: 'step8_ml_train',
8: 'step9_ml_predict',
9: 'step10_map',
10: None, # 遗留 step14_panel保留 tab 但不加入 process_stages
11: 'step11_viz',
12: 'step12_report',
0: 'step1', 1: 'step2', 2: 'step3', 3: 'step4_sampling',
4: 'step5_clean', 5: 'step6_feature', 6: 'step7_index',
7: 'step8_ml_train', 8: 'step9_ml_predict',
9: 'step10_watercolor', 10: 'step11_map',
11: 'step12_viz', 12: 'step13_report',
}
if index not in tab_to_step_id:
@ -2143,49 +2129,27 @@ class WaterQualityGUI(QMainWindow):
self.step_list.setCurrentRow(row)
break
# Step2 切换时自动填充数据流转路径
if index == 1:
self.step2_panel.update_from_config(work_dir=self.work_dir, pipeline=self.pipeline)
# 面板自动填充:统一 mapping 覆盖 index 0-12
mapping = {
0: (self.step1_panel, "Step1"),
1: (self.step2_panel, "Step2"),
2: (self.step3_panel, "Step3"),
3: (self.step4_sampling_panel, "Step4"),
4: (self.step5_clean_panel, "Step5"),
5: (self.step6_feature_panel, "Step6"),
6: (self.step7_index_panel, "Step7"),
7: (self.step8_ml_train_panel, "Step8"),
8: (self.step9_ml_predict_panel, "Step9"),
9: (self.step10_watercolor_panel, "Step10"), # 水色指数反演
10: (self.step11_map_panel, "Step11"), # 专题图生成
11: (self.step12_viz_panel, "Step12"),
12: (self.step13_report_panel, "Step13")
}
# Step3 切换时自动填充数据流转路径
elif index == 2:
self.step3_panel.update_from_config(work_dir=self.work_dir)
# Step4采样点布设切换时自动填充输出路径
elif index == 3:
self.step4_sampling_panel.update_from_config(work_dir=self.work_dir)
# Step5数据清洗切换时自动填充数据流转路径
elif index == 4:
self.step5_clean_panel.update_from_config(work_dir=self.work_dir, pipeline=self.pipeline)
# Step6光谱特征切换时自动填充输出路径
elif index == 5:
self.step6_feature_panel.update_from_config(work_dir=self.work_dir, pipeline=self.pipeline)
# Step7水质光谱指数计算切换时自动填充水质参数 CSV
elif index == 6:
self.step7_index_panel.update_from_config(work_dir=self.work_dir, pipeline=self.pipeline)
# Step8机器学习建模切换时自动填充训练数据和输出路径
elif index == 7:
self.step8_ml_train_panel.update_from_config(work_dir=self.work_dir, pipeline=self.pipeline)
# Step9机器学习预测切换时自动填充采样光谱和模型目录
elif index == 8:
self.step9_ml_predict_panel.update_from_config(work_dir=self.work_dir, pipeline=self.pipeline)
# Step10水色指数反演切换时自动填充光谱数据和输出路径
elif index == 9:
self.step10_map_panel.update_from_config(work_dir=self.work_dir, pipeline=self.pipeline)
# Step12专题图生成切换时自动填充预测结果目录
elif index == 10:
self.step14_panel.update_from_config(work_dir=self.work_dir, pipeline=self.pipeline)
# Step13可视化分析切换时自动推断图像目录并加载目录树
elif index == 11:
self.step11_viz_panel.update_from_config(work_dir=self.work_dir, pipeline=self.pipeline)
if index in mapping:
panel, _ = mapping[index]
if hasattr(panel, 'update_from_config'):
panel.update_from_config(work_dir=self.work_dir, pipeline=self.pipeline)
def apply_stylesheet(self):
"""应用样式表 - 应用现代化设计风格"""
@ -2234,12 +2198,12 @@ class WaterQualityGUI(QMainWindow):
self.step7_index_panel.set_config(config['step7_index'])
if 'step9_ml_predict' in config:
self.step9_ml_predict_panel.set_config(config['step9_ml_predict'])
if 'step14' in config:
self.step14_panel.set_config(config['step14'])
if 'step11_viz' in config:
self.step11_viz_panel.set_config(config['step11_viz'])
if 'step12_report' in config:
self.step12_report_panel.set_config(config['step12_report'])
if 'step11_map' in config:
self.step11_map_panel.set_config(config['step11_map'])
if 'step12_viz' in config:
self.step12_viz_panel.set_config(config['step12_viz'])
if 'step13_report' in config:
self.step13_report_panel.set_config(config['step13_report'])
self.config_file = file_path
self.log_message(f"已加载配置: {file_path}", "info")
@ -2282,10 +2246,9 @@ class WaterQualityGUI(QMainWindow):
'step7_index': self.step7_index_panel.get_config(),
'step8_ml_train': self.step8_ml_train_panel.get_config(),
'step9_ml_predict': self.step9_ml_predict_panel.get_config(),
'step10_map': self.step10_map_panel.get_config(),
'step11_viz': self.step11_viz_panel.get_config(),
'step12_report': self.step12_report_panel.get_config(),
'step14': self.step14_panel.get_config(),
'step11_map': self.step11_map_panel.get_config(),
'step12_viz': self.step12_viz_panel.get_config(),
'step13_report': self.step13_report_panel.get_config(),
}
return config
@ -2338,10 +2301,9 @@ class WaterQualityGUI(QMainWindow):
'step7_index': self.step7_index_panel,
'step8_ml_train': self.step8_ml_train_panel,
'step9_ml_predict': self.step9_ml_predict_panel,
'step10_map': self.step10_map_panel,
'step11_viz': self.step11_viz_panel,
'step12_report': self.step12_report_panel,
'step14': self.step14_panel,
'step11_map': self.step11_map_panel,
'step12_viz': self.step12_viz_panel,
'step13_report': self.step13_report_panel,
}
return panel_map.get(step_id)
@ -2440,10 +2402,10 @@ class WaterQualityGUI(QMainWindow):
'8_Regression_Modeling': 'step8_ml_train',
'9_Custom_Regression_Modeling': 'step9_ml_predict',
'11_12_13_predictions/Machine_Learning_Prediction': 'step9_ml_predict',
'11_12_13_predictions/Non_Empirical_Prediction': 'step10_map',
'11_12_13_predictions/Custom_Regression_Prediction': 'step11_viz',
'14_visualization': 'step12_report',
'14_geotiff_batch_rendering': 'step14'
'11_12_13_predictions/Non_Empirical_Prediction': 'step11_map',
'11_12_13_predictions/Custom_Regression_Prediction': 'step12_viz',
'14_visualization': 'step13_report',
'10_geotiff_batch_rendering': 'step11_map'
}
for subdir, step_ids in subdirs.items():
@ -2493,7 +2455,7 @@ class WaterQualityGUI(QMainWindow):
discovered_outputs[step_id]['water_indices'] = str(file_path)
elif 'sampling_spectra' in file_name and step_id == 'step4_sampling':
discovered_outputs[step_id]['sampling_points'] = str(file_path)
elif file_name.endswith('.csv') and step_id in ['step9_ml_predict', 'step10_map', 'step11_viz']:
elif file_name.endswith('.csv') and step_id in ['step9_ml_predict', 'step11_map', 'step12_viz']:
discovered_outputs[step_id]['predictions'] = str(file_path)
# 更新内部记录
@ -2517,7 +2479,7 @@ class WaterQualityGUI(QMainWindow):
self.scan_work_directory_for_files(work_path)
step_order = ['step2', 'step3', 'step4_sampling', 'step5_clean', 'step6_feature', 'step7_index',
'step8_ml_train', 'step9_ml_predict', 'step10_map', 'step11_viz', 'step12_report', 'step14']
'step8_ml_train', 'step9_ml_predict', 'step11_map', 'step12_viz', 'step13_report']
filled_count = 0
for step_id in step_order:
@ -2544,10 +2506,9 @@ class WaterQualityGUI(QMainWindow):
('step7_index', self.step7_index_panel),
('step8_ml_train', self.step8_ml_train_panel),
('step9_ml_predict', self.step9_ml_predict_panel),
('step10_map', self.step10_map_panel),
('step11_viz', self.step11_viz_panel),
('step12_report', self.step12_report_panel),
('step14', self.step14_panel)
('step11_map', self.step11_map_panel),
('step12_viz', self.step12_viz_panel),
('step13_report', self.step13_report_panel),
]
for step_id, panel in panels_with_dependencies:
@ -2617,10 +2578,10 @@ class WaterQualityGUI(QMainWindow):
self.statusBar().showMessage(f"工作目录: {dir_path}")
# 同步到可视化面板
if hasattr(self, 'step11_viz_panel'):
self.step11_viz_panel.set_work_dir(dir_path)
if hasattr(self, 'step12_report_panel'):
self.step12_report_panel.set_work_dir(dir_path)
if hasattr(self, 'step12_viz_panel'):
self.step12_viz_panel.set_work_dir(dir_path)
if hasattr(self, 'step13_report_panel'):
self.step13_report_panel.set_work_dir(dir_path)
def open_work_directory(self):
"""打开工作目录"""
@ -3179,7 +3140,7 @@ class WaterQualityGUI(QMainWindow):
step_id_to_tab_training = {
'step1': 0, 'step2': 1, 'step3': 2, 'step4_sampling': 3,
'step5_clean': 4, 'step6_feature': 5, 'step7_index': 6, 'step9_ml_predict': 7,
'step10_map': 8, 'step14': 10, 'step11_viz': 11, 'step12_report': 12
'step10_watercolor': 9, 'step11_map': 10, 'step12_viz': 11, 'step13_report': 12
}
for step_id in disabled_step_ids: