From 26f93bd2332e610dd15a640530f01c82b5a380e0 Mon Sep 17 00:00:00 2001 From: DXC Date: Mon, 22 Jun 2026 16:14:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(step12=5Fviz):=20scatter=20=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E7=9B=AE=E5=BD=95=E6=94=B9=E8=AF=BB=20self.extra=20+?= =?UTF-8?q?=20=E4=B8=BB=E7=BA=BF=E7=A8=8B=20step8=20=E9=A2=84=E5=8F=96?= =?UTF-8?q?=E6=B3=A8=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit worker generate_all_selected.gen_scatter 块改读 self.extra['models_dir'], fallback 到 wp / 8_Supervised_Model_Training(替换旧版 7_Supervised_Model_Training)。 主线程 generate_all_visualizations 通过 panel_factory.get_panel('step8_ml_train') 预取 step8 panel.output_path,注入 extra 字典 models_dir 键。 Why: 子线程内 self.window() 无意义(VisualizationWorkerThread 是 QThread 子类 且无 parent 传参),必须主线程预取 + worker 读 extra 字典。与同文件既有 scatter 任务(line 208-209)和 step11 风格统一。 --- src/gui/panels/step12_viz_panel.py | 32 +++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/gui/panels/step12_viz_panel.py b/src/gui/panels/step12_viz_panel.py index 7266989..606eb85 100644 --- a/src/gui/panels/step12_viz_panel.py +++ b/src/gui/panels/step12_viz_panel.py @@ -223,11 +223,19 @@ class VisualizationWorkerThread(QThread): viz = WaterQualityVisualization(output_dir=str(resolve_subdir(self.work_dir, 'visualization'))) parts = [] - training_csv = wp / "5_training_spectra" / "training_spectra.csv" + training_csv_path = (self.extra.get("training_csv_path") or "").strip() + if training_csv_path: + training_csv = Path(training_csv_path) + else: + training_csv = wp / "5_training_spectra" / "training_spectra.csv" if self.extra.get("gen_scatter"): if training_csv.is_file(): - models_dir = wp / "7_Supervised_Model_Training" + models_dir_str = (self.extra.get("models_dir") or "").strip() + if models_dir_str: + models_dir = Path(models_dir_str) + else: + models_dir = wp / "8_Supervised_Model_Training" if models_dir.is_dir() and any(d.is_dir() for d in models_dir.iterdir()): from src.core.visualization.scatter_plot import generate_model_scatter_plots scatter_paths = generate_model_scatter_plots( @@ -1672,6 +1680,18 @@ class Step12VizPanel(QWidget): "gen_mask_glint": self.gen_mask_glint.isChecked(), "gen_sampling_map": self.gen_sampling_map.isChecked(), } + main_window = self.window() + factory = getattr(main_window, '_panel_factory', None) if main_window else None + step5_panel = factory.get_panel('step5_clean') if factory else None + if step5_panel and getattr(step5_panel, 'output_file', None): + _resolved_csv = step5_panel.output_file.get_path() + if _resolved_csv: + extra["training_csv_path"] = _resolved_csv + step8_panel = factory.get_panel('step8_ml_train') if factory else None + if step8_panel and getattr(step8_panel, 'output_path', None): + _resolved_models_dir = step8_panel.output_path.get_path() + if _resolved_models_dir: + extra["models_dir"] = _resolved_models_dir self._start_visualization_thread("generate_all_selected", extra) def generate_chart(self, chart_type): @@ -1684,7 +1704,13 @@ class Step12VizPanel(QWidget): QMessageBox.warning(self, "警告", "工作目录不存在!") return try: - training_spectra_csv = _viz_training_spectra_csv_path(work_path) + main_window = self.window() + factory = getattr(main_window, '_panel_factory', None) if main_window else None + step5_panel = factory.get_panel('step5_clean') if factory else None + if step5_panel and getattr(step5_panel, 'output_file', None) and step5_panel.output_file.get_path(): + training_spectra_csv = Path(step5_panel.output_file.get_path()) + else: + training_spectra_csv = _viz_training_spectra_csv_path(work_path) if chart_type == 'scatter': if not training_spectra_csv.is_file(): QMessageBox.warning(