From 7c7a31ce0041d893a344a1fc98304a7514749359 Mon Sep 17 00:00:00 2001 From: DXC Date: Thu, 11 Jun 2026 14:56:33 +0800 Subject: [PATCH] Fix panel internal titles and step calls (Step3) --- ...aterindex_panel.py => step10_map_panel.py} | 4 +- ...alization_panel.py => step11_viz_panel.py} | 4 +- ...ration_panel.py => step12_report_panel.py} | 4 +- .../{step5_panel.py => step5_clean_panel.py} | 10 +-- ...{step6_panel.py => step6_feature_panel.py} | 4 +- .../{step7_panel.py => step7_index_panel.py} | 8 +- ...step9_panel.py => step8_ml_train_panel.py} | 89 ++----------------- ..._ml_panel.py => step9_ml_predict_panel.py} | 4 +- 8 files changed, 28 insertions(+), 99 deletions(-) rename src/gui/panels/{step8_waterindex_panel.py => step10_map_panel.py} (99%) rename src/gui/panels/{visualization_panel.py => step11_viz_panel.py} (99%) rename src/gui/panels/{report_generation_panel.py => step12_report_panel.py} (98%) rename src/gui/panels/{step5_panel.py => step5_clean_panel.py} (96%) rename src/gui/panels/{step6_panel.py => step6_feature_panel.py} (99%) rename src/gui/panels/{step7_panel.py => step7_index_panel.py} (99%) rename src/gui/panels/{step9_panel.py => step8_ml_train_panel.py} (78%) rename src/gui/panels/{step10_ml_panel.py => step9_ml_predict_panel.py} (99%) diff --git a/src/gui/panels/step8_waterindex_panel.py b/src/gui/panels/step10_map_panel.py similarity index 99% rename from src/gui/panels/step8_waterindex_panel.py rename to src/gui/panels/step10_map_panel.py index c3d8fc7..f2d9e45 100644 --- a/src/gui/panels/step8_waterindex_panel.py +++ b/src/gui/panels/step10_map_panel.py @@ -98,8 +98,8 @@ class WaterIndexWorker(QThread): self.progress.emit(msg, pct) -class Step9WaterColorPanel(QWidget): - """步骤9:水色指数反演(直接处理 BSQ 影像)""" +class Step10MapPanel(QWidget): + """步骤10:专题图生成""" def __init__(self, parent=None): super().__init__(parent) diff --git a/src/gui/panels/visualization_panel.py b/src/gui/panels/step11_viz_panel.py similarity index 99% rename from src/gui/panels/visualization_panel.py rename to src/gui/panels/step11_viz_panel.py index bf24411..f0ba0e9 100644 --- a/src/gui/panels/visualization_panel.py +++ b/src/gui/panels/step11_viz_panel.py @@ -1211,8 +1211,8 @@ class ChartBrowserDialog(QDialog): QMessageBox.critical(self, "错误", f"保存失败:\n{str(e)}") -class VisualizationPanel(QWidget): - """可视化分析面板 - 重构版:左侧目录树 + 右侧图像查看器""" +class Step11VizPanel(QWidget): + """步骤11:可视化展示""" def __init__(self, parent=None): super().__init__(parent) self.work_dir = None diff --git a/src/gui/panels/report_generation_panel.py b/src/gui/panels/step12_report_panel.py similarity index 98% rename from src/gui/panels/report_generation_panel.py rename to src/gui/panels/step12_report_panel.py index 5cffd07..d0842a3 100644 --- a/src/gui/panels/report_generation_panel.py +++ b/src/gui/panels/step12_report_panel.py @@ -79,8 +79,8 @@ class ReportGenerateThread(QThread): self.failed.emit(f"{e}\n{traceback.format_exc()}") -class ReportGenerationPanel(QWidget): - """Word 报告生成面板。AI 配置统一由 AISettingsDialog 管理,本面板不持有配置状态。""" +class Step12ReportPanel(QWidget): + """步骤12:分析报告生成。AI 配置统一由 AISettingsDialog 管理,本面板不持有配置状态。""" def __init__(self, main_window=None, parent=None): super().__init__(parent) diff --git a/src/gui/panels/step5_panel.py b/src/gui/panels/step5_clean_panel.py similarity index 96% rename from src/gui/panels/step5_panel.py rename to src/gui/panels/step5_clean_panel.py index 5c3fbf4..8d696db 100644 --- a/src/gui/panels/step5_panel.py +++ b/src/gui/panels/step5_clean_panel.py @@ -18,7 +18,7 @@ from src.gui.components.custom_widgets import FileSelectWidget from src.gui.styles import ModernStylesheet -class Step5Panel(QWidget): +class Step5CleanPanel(QWidget): """步骤5:数据清洗""" def __init__(self, parent=None): super().__init__(parent) @@ -135,18 +135,16 @@ class Step5Panel(QWidget): self.output_file.set_path("") def run_step(self): - """独立运行步骤4""" - # 验证输入 + """独立运行步骤5""" csv_path = self.csv_file.get_path() if not csv_path: QMessageBox.warning(self, "输入错误", "请选择水质参数文件!") return - # 获取主窗口并运行步骤 main_window = self.window() if hasattr(main_window, 'run_single_step'): - config = {'step4': self.get_config()} - main_window.run_single_step('step4', config) + config = {'step5': self.get_config()} + main_window.run_single_step('step5', config) def reset_preview(self, message="请选择CSV文件并点击刷新预览"): """重置预览表格""" diff --git a/src/gui/panels/step6_panel.py b/src/gui/panels/step6_feature_panel.py similarity index 99% rename from src/gui/panels/step6_panel.py rename to src/gui/panels/step6_feature_panel.py index 2c910fe..5f7e56a 100644 --- a/src/gui/panels/step6_panel.py +++ b/src/gui/panels/step6_feature_panel.py @@ -17,8 +17,8 @@ from src.gui.components.custom_widgets import FileSelectWidget from src.gui.styles import ModernStylesheet -class Step6Panel(QWidget): - """步骤6:光谱特征""" +class Step6FeaturePanel(QWidget): + """步骤6:光谱特征提取""" def __init__(self, parent=None): super().__init__(parent) self.init_ui() diff --git a/src/gui/panels/step7_panel.py b/src/gui/panels/step7_index_panel.py similarity index 99% rename from src/gui/panels/step7_panel.py rename to src/gui/panels/step7_index_panel.py index 30e3564..0bf8191 100644 --- a/src/gui/panels/step7_panel.py +++ b/src/gui/panels/step7_index_panel.py @@ -1,3 +1,9 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +Step7 面板 - 水质指数计算 +""" + import os import sys import pandas as pd @@ -35,7 +41,7 @@ def get_resource_path(relative_path: str) -> str: return str(base_dir / os.path.basename(relative_path)) -class Step7Panel(QWidget): +class Step7IndexPanel(QWidget): COLOR_RATIO = QColor(255, 255, 255) COLOR_CONCENTRATION = QColor(220, 240, 255) COLOR_HEADER = QColor(245, 245, 245) diff --git a/src/gui/panels/step9_panel.py b/src/gui/panels/step8_ml_train_panel.py similarity index 78% rename from src/gui/panels/step9_panel.py rename to src/gui/panels/step8_ml_train_panel.py index cc87fc8..1a7a977 100644 --- a/src/gui/panels/step9_panel.py +++ b/src/gui/panels/step8_ml_train_panel.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ -Step9 面板 - 机器学习建模 +Step8 面板 - 机器学习建模 """ import os @@ -41,8 +41,8 @@ def get_resource_path(relative_path: str) -> str: return str(base_dir / os.path.basename(relative_path)) -class Step9Panel(QWidget): - """步骤9:机器学习建模""" +class Step8MlTrainPanel(QWidget): + """步骤8:机器学习建模""" COLOR_RATIO = QColor(255, 255, 255) COLOR_CONCENTRATION = QColor(220, 240, 255) COLOR_HEADER = QColor(245, 245, 245) @@ -343,82 +343,7 @@ class Step9Panel(QWidget): QMessageBox.warning(self, "提示", "请先选择输入特征提取CSV文件") return - formula_names = config['formula_names'] - if not formula_names: - QMessageBox.warning(self, "提示", "请至少勾选一个公式") - return - - output_mode = config['output_mode'] - - try: - from src.core.steps.data_preparation_step import DataPreparationStep - - spec_df = pd.read_csv(training_path) - x_col, y_col = self._get_coord_cols(spec_df) - - formula_csv_path = self.builtin_formula_path - if not formula_csv_path or not os.path.exists(formula_csv_path): - possible_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'gui', 'model', 'waterindex.csv') - if os.path.exists(possible_path): - formula_csv_path = possible_path - - work_dir = self._get_work_dir() - - indices_csv_path = DataPreparationStep.calculate_water_quality_indices( - training_csv_path=training_path, - formula_csv_file=formula_csv_path, - formula_names=formula_names, - output_file=None, - enabled=True, - output_dir=work_dir if work_dir else os.getcwd(), - ) - - if indices_csv_path and os.path.exists(indices_csv_path): - output_df = pd.read_csv(indices_csv_path) - else: - output_df = spec_df - - track_a_path = None - track_b_dir = None - - if output_mode in (0, 1): - track_a_dir = os.path.join(work_dir, "9_supervised_modeling") if work_dir else "9_supervised_modeling" - os.makedirs(track_a_dir, exist_ok=True) - track_a_path = os.path.join(track_a_dir, "training_spectra_indices.csv") - - if output_mode in (0, 2): - track_b_dir = os.path.join(work_dir, "11_12_13_predictions", "Traditional_Indices") if work_dir else "11_12_13_predictions/Traditional_Indices" - os.makedirs(track_b_dir, exist_ok=True) - - saved = [] - if output_mode in (0, 1): - output_df.to_csv(track_a_path, index=False, float_format='%.6f') - saved.append(f"宽表: {track_a_path}") - - if output_mode in (0, 2): - coord_x = spec_df[x_col].values if x_col in spec_df.columns else np.arange(len(spec_df)) - coord_y = spec_df[y_col].values if y_col in spec_df.columns else np.zeros(len(spec_df)) - - for formula_name in formula_names: - if formula_name not in output_df.columns: - continue - single_df = pd.DataFrame({ - 'x_coord': coord_x, - 'y_coord': coord_y, - 'value': output_df[formula_name].values, - }) - safe_name = formula_name.replace('/', '_').replace(' ', '_') - out_path = os.path.join(track_b_dir, f"{safe_name}_prediction.csv") - single_df.to_csv(out_path, index=False, float_format='%.6f') - saved.append(f"单文件目录: {track_b_dir}") - - QMessageBox.information( - self, "计算完成", - f"已保存 {len(saved)} 个输出目标:\n" + "\n".join(saved) - ) - - except ImportError as e: - QMessageBox.critical(self, "依赖错误", f"无法导入模块:\n{e}") - except Exception as e: - import traceback - QMessageBox.critical(self, "计算失败", f"原因: {str(e)}\n{traceback.format_exc()}") \ No newline at end of file + main_window = self.window() + if hasattr(main_window, 'run_single_step'): + pipeline_config = {'step8': config} + main_window.run_single_step('step8', pipeline_config) \ No newline at end of file diff --git a/src/gui/panels/step10_ml_panel.py b/src/gui/panels/step9_ml_predict_panel.py similarity index 99% rename from src/gui/panels/step10_ml_panel.py rename to src/gui/panels/step9_ml_predict_panel.py index 3fdbd0d..bc22301 100644 --- a/src/gui/panels/step10_ml_panel.py +++ b/src/gui/panels/step9_ml_predict_panel.py @@ -19,8 +19,8 @@ from src.gui.components.custom_widgets import FileSelectWidget from src.gui.styles import ModernStylesheet -class Step10MlPanel(QWidget): - """步骤11:机器学习预测""" +class Step9MlPredictPanel(QWidget): + """步骤9:机器学习预测""" def __init__(self, parent=None): super().__init__(parent) self.external_models_dict = {} # {subdir_name: model_obj, ...}