Panel交互增强:Step6.75/8/8.5/8.75/9 面板UI联动优化与稳定性修复
This commit is contained in:
@ -287,32 +287,45 @@ class Step6_75Panel(QWidget):
|
|||||||
work_dir: 工作目录路径
|
work_dir: 工作目录路径
|
||||||
pipeline: Pipeline 实例(未使用,保留接口兼容性)
|
pipeline: Pipeline 实例(未使用,保留接口兼容性)
|
||||||
"""
|
"""
|
||||||
if work_dir:
|
try:
|
||||||
self.work_dir = work_dir
|
import traceback
|
||||||
elif hasattr(self, 'work_dir') and self.work_dir:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
self.work_dir = None
|
|
||||||
|
|
||||||
# 1. 尝试从 Step5 界面读取训练光谱 CSV 路径
|
if work_dir:
|
||||||
main_window = self.window()
|
self.work_dir = work_dir
|
||||||
if main_window and hasattr(main_window, 'step5_panel'):
|
elif hasattr(self, 'work_dir') and self.work_dir:
|
||||||
step5_output_path = main_window.step5_panel.output_file.get_path()
|
pass
|
||||||
if step5_output_path:
|
else:
|
||||||
# 若为相对路径,使用 work_dir 合成为绝对路径
|
self.work_dir = None
|
||||||
if not os.path.isabs(step5_output_path):
|
|
||||||
step5_output_path = os.path.join(self.work_dir or '', step5_output_path).replace('\\', '/')
|
|
||||||
existing = self.csv_file.get_path()
|
|
||||||
if not existing or not existing.strip():
|
|
||||||
self.csv_file.set_path(step5_output_path)
|
|
||||||
|
|
||||||
# 2. 自动填充输出目录(9_Custom_Regression_Modeling)
|
# 1. 尝试从 Step5 界面读取训练光谱 CSV 路径
|
||||||
if self.work_dir:
|
main_window = self.window()
|
||||||
output_dir = os.path.join(self.work_dir, "9_Custom_Regression_Modeling")
|
if main_window and hasattr(main_window, 'step5_panel'):
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
step5_widget = getattr(main_window.step5_panel, 'output_file', None)
|
||||||
existing_out = self.output_dir.text().strip()
|
step5_output_path = ""
|
||||||
if not existing_out:
|
if hasattr(step5_widget, 'get_path'):
|
||||||
self.output_dir.setText(output_dir)
|
step5_output_path = step5_widget.get_path() or ""
|
||||||
|
elif hasattr(step5_widget, 'text'):
|
||||||
|
step5_output_path = step5_widget.text() or ""
|
||||||
|
|
||||||
|
if step5_output_path:
|
||||||
|
# 若为相对路径,使用 work_dir 合成为绝对路径
|
||||||
|
if not os.path.isabs(step5_output_path):
|
||||||
|
step5_output_path = os.path.join(self.work_dir or '', step5_output_path).replace('\\', '/')
|
||||||
|
existing = self.csv_file.get_path()
|
||||||
|
if not existing or not existing.strip():
|
||||||
|
self.csv_file.set_path(step5_output_path)
|
||||||
|
|
||||||
|
# 2. 自动填充输出目录(9_Custom_Regression_Modeling)
|
||||||
|
if self.work_dir:
|
||||||
|
output_dir = os.path.join(self.work_dir, "9_Custom_Regression_Modeling")
|
||||||
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
|
existing_out = self.output_dir.text().strip()
|
||||||
|
if not existing_out:
|
||||||
|
self.output_dir.setText(output_dir)
|
||||||
|
except Exception as e:
|
||||||
|
import traceback
|
||||||
|
print(f"【{self.__class__.__name__}】自动填充失败,跳过: {e}")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
def run_step(self):
|
def run_step(self):
|
||||||
"""独立运行步骤6.75"""
|
"""独立运行步骤6.75"""
|
||||||
|
|||||||
@ -89,44 +89,63 @@ class Step8_5Panel(QWidget):
|
|||||||
work_dir: 工作目录路径
|
work_dir: 工作目录路径
|
||||||
pipeline: Pipeline 实例(未使用,保留接口兼容性)
|
pipeline: Pipeline 实例(未使用,保留接口兼容性)
|
||||||
"""
|
"""
|
||||||
if work_dir:
|
try:
|
||||||
self.work_dir = work_dir
|
import traceback
|
||||||
elif hasattr(self, 'work_dir') and self.work_dir:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
self.work_dir = None
|
|
||||||
|
|
||||||
main_window = self.window()
|
if work_dir:
|
||||||
|
self.work_dir = work_dir
|
||||||
|
elif hasattr(self, 'work_dir') and self.work_dir:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.work_dir = None
|
||||||
|
|
||||||
# 1. 尝试从 Step7 界面读取全湖采样点 CSV 路径
|
main_window = self.window()
|
||||||
if main_window and hasattr(main_window, 'step7_panel'):
|
|
||||||
step7_output_path = main_window.step7_panel.output_file.get_path()
|
|
||||||
if step7_output_path:
|
|
||||||
# 若为相对路径,使用 work_dir 合成为绝对路径
|
|
||||||
if not os.path.isabs(step7_output_path):
|
|
||||||
step7_output_path = os.path.join(self.work_dir or '', step7_output_path).replace('\\', '/')
|
|
||||||
existing = self.sampling_csv_file.get_path()
|
|
||||||
if not existing or not existing.strip():
|
|
||||||
self.sampling_csv_file.set_path(step7_output_path)
|
|
||||||
|
|
||||||
# 2. 尝试从 Step6.5 界面读取回归模型目录
|
# 1. 尝试从 Step7 界面读取全湖采样点 CSV 路径
|
||||||
if main_window and hasattr(main_window, 'step6_5_panel'):
|
if main_window and hasattr(main_window, 'step7_panel'):
|
||||||
step6_5_models_dir = main_window.step6_5_panel.output_dir.get_path()
|
step7_widget = getattr(main_window.step7_panel, 'output_file', None)
|
||||||
if step6_5_models_dir:
|
step7_output_path = ""
|
||||||
# 若为相对路径,使用 work_dir 合成为绝对路径
|
if hasattr(step7_widget, 'get_path'):
|
||||||
if not os.path.isabs(step6_5_models_dir):
|
step7_output_path = step7_widget.get_path() or ""
|
||||||
step6_5_models_dir = os.path.join(self.work_dir or '', step6_5_models_dir).replace('\\', '/')
|
elif hasattr(step7_widget, 'text'):
|
||||||
existing_models = self.models_dir_file.get_path()
|
step7_output_path = step7_widget.text() or ""
|
||||||
if not existing_models or not existing_models.strip():
|
|
||||||
self.models_dir_file.set_path(step6_5_models_dir)
|
|
||||||
|
|
||||||
# 3. 自动填充输出路径(非经验模型预测目录)
|
if step7_output_path:
|
||||||
if self.work_dir:
|
# 若为相对路径,使用 work_dir 合成为绝对路径
|
||||||
output_dir = os.path.join(self.work_dir, "11_12_13_predictions/Non_Empirical_Prediction")
|
if not os.path.isabs(step7_output_path):
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
step7_output_path = os.path.join(self.work_dir or '', step7_output_path).replace('\\', '/')
|
||||||
existing_out = self.output_file.get_path()
|
existing = self.sampling_csv_file.get_path()
|
||||||
if not existing_out or not existing_out.strip():
|
if not existing or not existing.strip():
|
||||||
self.output_file.set_path(output_dir)
|
self.sampling_csv_file.set_path(step7_output_path)
|
||||||
|
|
||||||
|
# 2. 尝试从 Step6.5 界面读取回归模型目录
|
||||||
|
if main_window and hasattr(main_window, 'step6_5_panel'):
|
||||||
|
step6_5_widget = getattr(main_window.step6_5_panel, 'output_dir', None)
|
||||||
|
step6_5_models_dir = ""
|
||||||
|
if hasattr(step6_5_widget, 'get_path'):
|
||||||
|
step6_5_models_dir = step6_5_widget.get_path() or ""
|
||||||
|
elif hasattr(step6_5_widget, 'text'):
|
||||||
|
step6_5_models_dir = step6_5_widget.text() or ""
|
||||||
|
|
||||||
|
if step6_5_models_dir:
|
||||||
|
# 若为相对路径,使用 work_dir 合成为绝对路径
|
||||||
|
if not os.path.isabs(step6_5_models_dir):
|
||||||
|
step6_5_models_dir = os.path.join(self.work_dir or '', step6_5_models_dir).replace('\\', '/')
|
||||||
|
existing_models = self.models_dir_file.get_path()
|
||||||
|
if not existing_models or not existing_models.strip():
|
||||||
|
self.models_dir_file.set_path(step6_5_models_dir)
|
||||||
|
|
||||||
|
# 3. 自动填充输出路径(非经验模型预测目录)
|
||||||
|
if self.work_dir:
|
||||||
|
output_dir = os.path.join(self.work_dir, "11_12_13_predictions/Non_Empirical_Prediction")
|
||||||
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
|
existing_out = self.output_file.get_path()
|
||||||
|
if not existing_out or not existing_out.strip():
|
||||||
|
self.output_file.set_path(output_dir)
|
||||||
|
except Exception as e:
|
||||||
|
import traceback
|
||||||
|
print(f"【{self.__class__.__name__}】自动填充失败,跳过: {e}")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
def _get_default_work_dir(self):
|
def _get_default_work_dir(self):
|
||||||
"""获取 work_dir,优先用 panel 自身缓存的,否则尝试从主窗口取"""
|
"""获取 work_dir,优先用 panel 自身缓存的,否则尝试从主窗口取"""
|
||||||
|
|||||||
@ -82,51 +82,71 @@ class Step8_75Panel(QWidget):
|
|||||||
work_dir: 工作目录路径
|
work_dir: 工作目录路径
|
||||||
pipeline: Pipeline 实例(未使用,保留接口兼容性)
|
pipeline: Pipeline 实例(未使用,保留接口兼容性)
|
||||||
"""
|
"""
|
||||||
if work_dir:
|
try:
|
||||||
self.work_dir = work_dir
|
import traceback
|
||||||
elif hasattr(self, 'work_dir') and self.work_dir:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
self.work_dir = None
|
|
||||||
|
|
||||||
main_window = self.window()
|
if work_dir:
|
||||||
|
self.work_dir = work_dir
|
||||||
|
elif hasattr(self, 'work_dir') and self.work_dir:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.work_dir = None
|
||||||
|
|
||||||
# 1. 尝试从 Step7 界面读取全湖采样点 CSV 路径
|
main_window = self.window()
|
||||||
if main_window and hasattr(main_window, 'step7_panel'):
|
|
||||||
step7_output_path = main_window.step7_panel.output_file.get_path()
|
|
||||||
if step7_output_path:
|
|
||||||
# 若为相对路径,使用 work_dir 合成为绝对路径
|
|
||||||
if not os.path.isabs(step7_output_path):
|
|
||||||
step7_output_path = os.path.join(self.work_dir or '', step7_output_path).replace('\\', '/')
|
|
||||||
existing = self.sampling_csv_file.get_path()
|
|
||||||
if not existing or not existing.strip():
|
|
||||||
self.sampling_csv_file.set_path(step7_output_path)
|
|
||||||
|
|
||||||
# 2. 尝试从 Step6.75 界面读取自定义回归模型目录
|
# 1. 尝试从 Step7 界面读取全湖采样点 CSV 路径
|
||||||
if main_window and hasattr(main_window, 'step6_75_panel'):
|
if main_window and hasattr(main_window, 'step7_panel'):
|
||||||
step6_75_models_dir = main_window.step6_75_panel.output_dir.text().strip()
|
step7_widget = getattr(main_window.step7_panel, 'output_file', None)
|
||||||
if step6_75_models_dir:
|
step7_output_path = ""
|
||||||
# 若为相对路径,使用 work_dir 合成为绝对路径
|
if hasattr(step7_widget, 'get_path'):
|
||||||
if not os.path.isabs(step6_75_models_dir):
|
step7_output_path = step7_widget.get_path() or ""
|
||||||
step6_75_models_dir = os.path.join(self.work_dir or '', step6_75_models_dir).replace('\\', '/')
|
elif hasattr(step7_widget, 'text'):
|
||||||
existing_models = self.regression_models_dir.get_path()
|
step7_output_path = step7_widget.text() or ""
|
||||||
if not existing_models or not existing_models.strip():
|
|
||||||
self.regression_models_dir.set_path(step6_75_models_dir)
|
|
||||||
|
|
||||||
# 3. 自动填充回归模型目录(如果 step6_75 未提供)
|
if step7_output_path:
|
||||||
if self.work_dir:
|
# 若为相对路径,使用 work_dir 合成为绝对路径
|
||||||
models_dir = self.regression_models_dir.get_path().strip()
|
if not os.path.isabs(step7_output_path):
|
||||||
if not models_dir:
|
step7_output_path = os.path.join(self.work_dir or '', step7_output_path).replace('\\', '/')
|
||||||
default_models_dir = os.path.join(self.work_dir, "9_Custom_Regression_Modeling").replace('\\', '/')
|
existing = self.sampling_csv_file.get_path()
|
||||||
self.regression_models_dir.set_path(default_models_dir)
|
if not existing or not existing.strip():
|
||||||
|
self.sampling_csv_file.set_path(step7_output_path)
|
||||||
|
|
||||||
# 4. 自动填充输出目录(自定义回归预测目录)
|
# 2. 尝试从 Step6.75 界面读取自定义回归模型目录
|
||||||
if self.work_dir:
|
if main_window and hasattr(main_window, 'step6_75_panel'):
|
||||||
output_dir = os.path.join(self.work_dir, "11_12_13_predictions/Custom_Regression_Prediction")
|
step6_75_widget = getattr(main_window.step6_75_panel, 'output_dir', None)
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
step6_75_models_dir = ""
|
||||||
existing_out = self.output_dir_widget.get_path()
|
if hasattr(step6_75_widget, 'get_path'):
|
||||||
if not existing_out or not existing_out.strip():
|
step6_75_models_dir = step6_75_widget.get_path() or ""
|
||||||
self.output_dir_widget.set_path(output_dir)
|
elif hasattr(step6_75_widget, 'text'):
|
||||||
|
step6_75_models_dir = step6_75_widget.text() or ""
|
||||||
|
step6_75_models_dir = step6_75_models_dir.strip()
|
||||||
|
|
||||||
|
if step6_75_models_dir:
|
||||||
|
# 若为相对路径,使用 work_dir 合成为绝对路径
|
||||||
|
if not os.path.isabs(step6_75_models_dir):
|
||||||
|
step6_75_models_dir = os.path.join(self.work_dir or '', step6_75_models_dir).replace('\\', '/')
|
||||||
|
existing_models = self.regression_models_dir.get_path()
|
||||||
|
if not existing_models or not existing_models.strip():
|
||||||
|
self.regression_models_dir.set_path(step6_75_models_dir)
|
||||||
|
|
||||||
|
# 3. 自动填充回归模型目录(如果 step6_75 未提供)
|
||||||
|
if self.work_dir:
|
||||||
|
models_dir = self.regression_models_dir.get_path().strip()
|
||||||
|
if not models_dir:
|
||||||
|
default_models_dir = os.path.join(self.work_dir, "9_Custom_Regression_Modeling").replace('\\', '/')
|
||||||
|
self.regression_models_dir.set_path(default_models_dir)
|
||||||
|
|
||||||
|
# 4. 自动填充输出目录(自定义回归预测目录)
|
||||||
|
if self.work_dir:
|
||||||
|
output_dir = os.path.join(self.work_dir, "11_12_13_predictions/Custom_Regression_Prediction")
|
||||||
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
|
existing_out = self.output_dir_widget.get_path()
|
||||||
|
if not existing_out or not existing_out.strip():
|
||||||
|
self.output_dir_widget.set_path(output_dir)
|
||||||
|
except Exception as e:
|
||||||
|
import traceback
|
||||||
|
print(f"【{self.__class__.__name__}】自动填充失败,跳过: {e}")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
def _get_default_work_dir(self):
|
def _get_default_work_dir(self):
|
||||||
"""获取 work_dir,优先用 panel 自身缓存的,否则尝试从主窗口取"""
|
"""获取 work_dir,优先用 panel 自身缓存的,否则尝试从主窗口取"""
|
||||||
|
|||||||
@ -86,44 +86,63 @@ class Step8Panel(QWidget):
|
|||||||
work_dir: 工作目录路径
|
work_dir: 工作目录路径
|
||||||
pipeline: Pipeline 实例(未使用,保留接口兼容性)
|
pipeline: Pipeline 实例(未使用,保留接口兼容性)
|
||||||
"""
|
"""
|
||||||
if work_dir:
|
try:
|
||||||
self.work_dir = work_dir
|
import traceback
|
||||||
elif hasattr(self, 'work_dir') and self.work_dir:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
self.work_dir = None
|
|
||||||
|
|
||||||
main_window = self.window()
|
if work_dir:
|
||||||
|
self.work_dir = work_dir
|
||||||
|
elif hasattr(self, 'work_dir') and self.work_dir:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.work_dir = None
|
||||||
|
|
||||||
# 1. 尝试从 Step7 界面读取全湖采样点 CSV 路径
|
main_window = self.window()
|
||||||
if main_window and hasattr(main_window, 'step7_panel'):
|
|
||||||
step7_output_path = main_window.step7_panel.output_file.get_path()
|
|
||||||
if step7_output_path:
|
|
||||||
# 若为相对路径,使用 work_dir 合成为绝对路径
|
|
||||||
if not os.path.isabs(step7_output_path):
|
|
||||||
step7_output_path = os.path.join(self.work_dir or '', step7_output_path).replace('\\', '/')
|
|
||||||
existing = self.sampling_csv_file.get_path()
|
|
||||||
if not existing or not existing.strip():
|
|
||||||
self.sampling_csv_file.set_path(step7_output_path)
|
|
||||||
|
|
||||||
# 2. 尝试从 Step6 界面读取监督模型目录
|
# 1. 尝试从 Step7 界面读取全湖采样点 CSV 路径
|
||||||
if main_window and hasattr(main_window, 'step6_panel'):
|
if main_window and hasattr(main_window, 'step7_panel'):
|
||||||
step6_models_dir = main_window.step6_panel.output_dir.get_path()
|
step7_widget = getattr(main_window.step7_panel, 'output_file', None)
|
||||||
if step6_models_dir:
|
step7_output_path = ""
|
||||||
# 若为相对路径,使用 work_dir 合成为绝对路径
|
if hasattr(step7_widget, 'get_path'):
|
||||||
if not os.path.isabs(step6_models_dir):
|
step7_output_path = step7_widget.get_path() or ""
|
||||||
step6_models_dir = os.path.join(self.work_dir or '', step6_models_dir).replace('\\', '/')
|
elif hasattr(step7_widget, 'text'):
|
||||||
existing_models = self.models_dir_file.get_path()
|
step7_output_path = step7_widget.text() or ""
|
||||||
if not existing_models or not existing_models.strip():
|
|
||||||
self.models_dir_file.set_path(step6_models_dir)
|
|
||||||
|
|
||||||
# 3. 自动填充输出路径(机器学习预测目录)
|
if step7_output_path:
|
||||||
if self.work_dir:
|
# 若为相对路径,使用 work_dir 合成为绝对路径
|
||||||
output_dir = os.path.join(self.work_dir, "11_12_13_predictions/Machine_Learning_Prediction")
|
if not os.path.isabs(step7_output_path):
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
step7_output_path = os.path.join(self.work_dir or '', step7_output_path).replace('\\', '/')
|
||||||
existing_out = self.output_file.get_path()
|
existing = self.sampling_csv_file.get_path()
|
||||||
if not existing_out or not existing_out.strip():
|
if not existing or not existing.strip():
|
||||||
self.output_file.set_path(output_dir)
|
self.sampling_csv_file.set_path(step7_output_path)
|
||||||
|
|
||||||
|
# 2. 尝试从 Step6 界面读取监督模型目录
|
||||||
|
if main_window and hasattr(main_window, 'step6_panel'):
|
||||||
|
step6_widget = getattr(main_window.step6_panel, 'output_dir', None)
|
||||||
|
step6_models_dir = ""
|
||||||
|
if hasattr(step6_widget, 'get_path'):
|
||||||
|
step6_models_dir = step6_widget.get_path() or ""
|
||||||
|
elif hasattr(step6_widget, 'text'):
|
||||||
|
step6_models_dir = step6_widget.text() or ""
|
||||||
|
|
||||||
|
if step6_models_dir:
|
||||||
|
# 若为相对路径,使用 work_dir 合成为绝对路径
|
||||||
|
if not os.path.isabs(step6_models_dir):
|
||||||
|
step6_models_dir = os.path.join(self.work_dir or '', step6_models_dir).replace('\\', '/')
|
||||||
|
existing_models = self.models_dir_file.get_path()
|
||||||
|
if not existing_models or not existing_models.strip():
|
||||||
|
self.models_dir_file.set_path(step6_models_dir)
|
||||||
|
|
||||||
|
# 3. 自动填充输出路径(机器学习预测目录)
|
||||||
|
if self.work_dir:
|
||||||
|
output_dir = os.path.join(self.work_dir, "11_12_13_predictions/Machine_Learning_Prediction")
|
||||||
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
|
existing_out = self.output_file.get_path()
|
||||||
|
if not existing_out or not existing_out.strip():
|
||||||
|
self.output_file.set_path(output_dir)
|
||||||
|
except Exception as e:
|
||||||
|
import traceback
|
||||||
|
print(f"【{self.__class__.__name__}】自动填充失败,跳过: {e}")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
def _get_default_work_dir(self):
|
def _get_default_work_dir(self):
|
||||||
"""获取 work_dir,优先用 panel 自身缓存的,否则尝试从主窗口取"""
|
"""获取 work_dir,优先用 panel 自身缓存的,否则尝试从主窗口取"""
|
||||||
|
|||||||
@ -308,57 +308,82 @@ class Step9Panel(QWidget):
|
|||||||
work_dir: 工作目录路径
|
work_dir: 工作目录路径
|
||||||
pipeline: Pipeline 实例(未使用,保留接口兼容性)
|
pipeline: Pipeline 实例(未使用,保留接口兼容性)
|
||||||
"""
|
"""
|
||||||
if work_dir:
|
try:
|
||||||
self.work_dir = work_dir
|
import traceback
|
||||||
elif hasattr(self, 'work_dir') and self.work_dir:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
self.work_dir = None
|
|
||||||
|
|
||||||
main_window = self.window()
|
if work_dir:
|
||||||
if not main_window:
|
self.work_dir = work_dir
|
||||||
return
|
elif hasattr(self, 'work_dir') and self.work_dir:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.work_dir = None
|
||||||
|
|
||||||
# 1. 尝试从 Step8 界面读取机器学习预测输出目录(优先)
|
main_window = self.window()
|
||||||
pred_dir = None
|
if not main_window:
|
||||||
if hasattr(main_window, 'step8_panel'):
|
return
|
||||||
step8_output = main_window.step8_panel.output_file.get_path()
|
|
||||||
if step8_output:
|
|
||||||
# 若为相对路径,使用 work_dir 合成为绝对路径
|
|
||||||
if not os.path.isabs(step8_output):
|
|
||||||
step8_output = os.path.join(self.work_dir or '', step8_output).replace('\\', '/')
|
|
||||||
pred_dir = str(Path(step8_output).parent)
|
|
||||||
|
|
||||||
# 2. 备选:从 Step8.5 界面读取非经验预测输出目录
|
# 1. 尝试从 Step8 界面读取机器学习预测输出目录(优先)
|
||||||
if not pred_dir and hasattr(main_window, 'step8_5_panel'):
|
pred_dir = None
|
||||||
step8_5_output = main_window.step8_5_panel.output_file.get_path()
|
if hasattr(main_window, 'step8_panel'):
|
||||||
if step8_5_output:
|
step8_widget = getattr(main_window.step8_panel, 'output_file', None)
|
||||||
# 若为相对路径,使用 work_dir 合成为绝对路径
|
step8_output = ""
|
||||||
if not os.path.isabs(step8_5_output):
|
if hasattr(step8_widget, 'get_path'):
|
||||||
step8_5_output = os.path.join(self.work_dir or '', step8_5_output).replace('\\', '/')
|
step8_output = step8_widget.get_path() or ""
|
||||||
pred_dir = str(Path(step8_5_output).parent)
|
elif hasattr(step8_widget, 'text'):
|
||||||
|
step8_output = step8_widget.text() or ""
|
||||||
|
|
||||||
# 3. 备选:从 Step8.75 界面读取自定义回归预测输出目录
|
if step8_output:
|
||||||
if not pred_dir and hasattr(main_window, 'step8_75_panel'):
|
# 若为相对路径,使用 work_dir 合成为绝对路径
|
||||||
step8_75_output = main_window.step8_75_panel.output_dir_widget.get_path()
|
if not os.path.isabs(step8_output):
|
||||||
if step8_75_output:
|
step8_output = os.path.join(self.work_dir or '', step8_output).replace('\\', '/')
|
||||||
pred_dir = step8_75_output
|
pred_dir = str(Path(step8_output).parent)
|
||||||
|
|
||||||
# 自动填入"预测CSV目录"(文件夹批量模式)
|
# 2. 备选:从 Step8.5 界面读取非经验预测输出目录
|
||||||
if pred_dir:
|
if not pred_dir and hasattr(main_window, 'step8_5_panel'):
|
||||||
existing_dir = (self.prediction_csv_dir_edit.text() or "").strip()
|
step8_5_widget = getattr(main_window.step8_5_panel, 'output_file', None)
|
||||||
if not existing_dir:
|
step8_5_output = ""
|
||||||
self.prediction_csv_dir_edit.setText(pred_dir)
|
if hasattr(step8_5_widget, 'get_path'):
|
||||||
# 切换到文件夹批量模式
|
step8_5_output = step8_5_widget.get_path() or ""
|
||||||
self.mode_folder_rb.setChecked(True)
|
elif hasattr(step8_5_widget, 'text'):
|
||||||
|
step8_5_output = step8_5_widget.text() or ""
|
||||||
|
|
||||||
# 4. 自动填充输出目录(14_visualization)
|
if step8_5_output:
|
||||||
if self.work_dir:
|
# 若为相对路径,使用 work_dir 合成为绝对路径
|
||||||
output_dir = os.path.join(self.work_dir, "14_visualization")
|
if not os.path.isabs(step8_5_output):
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
step8_5_output = os.path.join(self.work_dir or '', step8_5_output).replace('\\', '/')
|
||||||
existing_out = self.output_dir.get_path()
|
pred_dir = str(Path(step8_5_output).parent)
|
||||||
if not existing_out or not existing_out.strip():
|
|
||||||
self.output_dir.set_path(output_dir)
|
# 3. 备选:从 Step8.75 界面读取自定义回归预测输出目录
|
||||||
|
if not pred_dir and hasattr(main_window, 'step8_75_panel'):
|
||||||
|
step8_75_widget = getattr(main_window.step8_75_panel, 'output_dir_widget', None)
|
||||||
|
step8_75_output = ""
|
||||||
|
if hasattr(step8_75_widget, 'get_path'):
|
||||||
|
step8_75_output = step8_75_widget.get_path() or ""
|
||||||
|
elif hasattr(step8_75_widget, 'text'):
|
||||||
|
step8_75_output = step8_75_widget.text() or ""
|
||||||
|
|
||||||
|
if step8_75_output:
|
||||||
|
pred_dir = step8_75_output
|
||||||
|
|
||||||
|
# 自动填入"预测CSV目录"(文件夹批量模式)
|
||||||
|
if pred_dir:
|
||||||
|
existing_dir = (self.prediction_csv_dir_edit.text() or "").strip()
|
||||||
|
if not existing_dir:
|
||||||
|
self.prediction_csv_dir_edit.setText(pred_dir)
|
||||||
|
# 切换到文件夹批量模式
|
||||||
|
self.mode_folder_rb.setChecked(True)
|
||||||
|
|
||||||
|
# 4. 自动填充输出目录(14_visualization)
|
||||||
|
if self.work_dir:
|
||||||
|
output_dir = os.path.join(self.work_dir, "14_visualization")
|
||||||
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
|
existing_out = self.output_dir.get_path()
|
||||||
|
if not existing_out or not existing_out.strip():
|
||||||
|
self.output_dir.set_path(output_dir)
|
||||||
|
except Exception as e:
|
||||||
|
import traceback
|
||||||
|
print(f"【{self.__class__.__name__}】自动填充失败,跳过: {e}")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
def browse_output_dir(self):
|
def browse_output_dir(self):
|
||||||
"""浏览输出目录"""
|
"""浏览输出目录"""
|
||||||
|
|||||||
Reference in New Issue
Block a user