Step4 心跳刷新 + Step10 输出目录更名与智能寻址优化

This commit is contained in:
DXC
2026-06-12 10:27:47 +08:00
parent 4c9ca2aa03
commit be47b70594
3 changed files with 68 additions and 36 deletions

View File

@ -204,7 +204,7 @@ class Step10WatercolorPanel(QWidget):
"输出目录:",
"Directories"
)
self.output_dir.line_edit.setPlaceholderText("留空 → 工作目录/8_WaterIndex_Images")
self.output_dir.line_edit.setPlaceholderText("留空 → 工作目录/10_WaterIndex_Images")
self.output_dir.browse_btn.clicked.disconnect()
self.output_dir.browse_btn.clicked.connect(self._browse_output_dir)
output_layout.addRow("输出目录:", self.output_dir)
@ -437,22 +437,42 @@ class Step10WatercolorPanel(QWidget):
self.work_dir = None
main_window = self.window()
deglint_path = None
# 自动填入去耀斑影像
if main_window and hasattr(main_window, 'step3_panel'):
deglint_path = main_window.step3_panel.output_file.get_path()
if deglint_path and not self.bsq_file.get_path():
if not os.path.isabs(deglint_path):
deglint_path = os.path.join(self.work_dir or '', deglint_path).replace('\\', '/')
self.bsq_file.set_path(deglint_path)
hdr = Path(deglint_path).with_suffix('.hdr')
if hdr.exists():
self.hdr_file.set_path(str(hdr))
self._load_metadata(deglint_path, str(hdr))
# 1. 优先从 pipeline 的真实输出中获取
if pipeline and hasattr(pipeline, 'step_outputs'):
step3_out = pipeline.step_outputs.get('step3', {})
deglint_path = step3_out.get('deglint_image') or step3_out.get('output_path')
# 2. 回退:从 step3 面板实例获取
if not deglint_path and main_window and hasattr(main_window, 'step3_panel'):
if hasattr(main_window.step3_panel, 'output_file'):
deglint_path = main_window.step3_panel.output_file.get_path()
# 3. 终极回退:智能扫描 3_deglint 目录,取最新的 .bsq 或 .dat 文件
if not deglint_path and self.work_dir:
deglint_dir = os.path.join(self.work_dir, "3_deglint")
if os.path.isdir(deglint_dir):
import glob
candidates = glob.glob(os.path.join(deglint_dir, "*.bsq")) + glob.glob(os.path.join(deglint_dir, "*.dat"))
if candidates:
candidates.sort(key=os.path.getmtime, reverse=True)
deglint_path = candidates[0]
# 填入 UI 并自动寻找对应的 hdr 文件
if deglint_path:
if not os.path.isabs(deglint_path):
deglint_path = os.path.join(self.work_dir or '', deglint_path).replace('\\', '/')
self.bsq_file.set_path(deglint_path)
hdr_path = os.path.splitext(deglint_path)[0] + '.hdr'
if os.path.exists(hdr_path):
self.hdr_file.set_path(hdr_path)
self._load_metadata(deglint_path, hdr_path)
# 自动填入输出目录
if self.work_dir:
out_dir = os.path.join(self.work_dir, "8_WaterIndex_Images").replace('\\', '/')
out_dir = os.path.join(self.work_dir, "10_WaterIndex_Images").replace('\\', '/')
os.makedirs(out_dir, exist_ok=True)
if not self.output_dir.get_path():
self.output_dir.set_path(out_dir)
@ -483,7 +503,7 @@ class Step10WatercolorPanel(QWidget):
return
if not output_dir:
work_dir = self._get_default_work_dir()
output_dir = os.path.join(work_dir, "8_WaterIndex_Images").replace('\\', '/')
output_dir = os.path.join(work_dir, "10_WaterIndex_Images").replace('\\', '/')
os.makedirs(output_dir, exist_ok=True)
self.output_dir.set_path(output_dir)

View File

@ -6,6 +6,7 @@ Step4 面板 - 采样点布设
import os
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import (
QWidget, QVBoxLayout, QGroupBox, QFormLayout,
QPushButton, QCheckBox, QSpinBox, QMessageBox,
@ -94,6 +95,11 @@ class Step4SamplingPanel(QWidget):
layout.addStretch()
self.setLayout(layout)
# 添加心跳定时器每2秒自动检查一次输出文件状态刷新预览按钮
self._status_timer = QTimer(self)
self._status_timer.timeout.connect(self._check_csv_exists)
self._status_timer.start(2000)
# 监听输出路径变化,实时更新预览按钮状态
self.output_file.line_edit.textChanged.connect(self._on_output_changed)