可视化面板重构:目录/文件名双引擎汉化,Emoji图标智能分配
This commit is contained in:
@ -548,22 +548,24 @@ class ImageCategoryTree(QTreeWidget):
|
||||
|
||||
# 目录层级中文翻译
|
||||
DIR_MAPPING = {
|
||||
"14_visualization": "可视化产物",
|
||||
"glint_deglint_previews": "耀斑与去耀斑预览",
|
||||
"sampling_maps": "采样点地图",
|
||||
"scatter_plots": "模型评估散点图",
|
||||
"flight_maps": "飞行轨迹图",
|
||||
"11_12_13_predictions": "预测结果",
|
||||
"14_visualization": "统计与分析报表",
|
||||
"1_water_mask": "水域掩膜识别",
|
||||
"2_glint": "耀斑区域检测",
|
||||
"3_deglint": "去耀斑影像结果",
|
||||
"5_training_spectra": "训练光谱特征",
|
||||
"8_Regression_Modeling": "回归建模分析",
|
||||
"9_water_quality_prediction": "水质预测结果",
|
||||
"10_feature_construction": "特征构建散点",
|
||||
"11_12_13_predictions": "空间分布专题图",
|
||||
"glint_deglint_previews": "耀斑处理预览",
|
||||
"sampling_maps": "采样点空间分布",
|
||||
"flight_maps": "无人机飞行轨迹",
|
||||
"Machine_Learning_Prediction": "机器学习预测",
|
||||
"Non_Empirical_Prediction": "非经验模型预测",
|
||||
"Custom_Regression_Prediction": "自定义回归预测",
|
||||
"8_Regression_Modeling": "回归建模",
|
||||
"10_feature_construction": "特征构建",
|
||||
"5_training_spectra": "训练光谱",
|
||||
"2_glint": "耀斑分析",
|
||||
"3_deglint": "去耀斑处理",
|
||||
"1_water_mask": "水掩膜",
|
||||
"9_water_quality_prediction": "水质预测",
|
||||
"boxplot_dir": "水质参数箱线图",
|
||||
"boxplot": "水质参数箱线图",
|
||||
"output_dir": "输出目录",
|
||||
"8_spatial_inversion": "空间反演",
|
||||
"4_processed_data": "处理数据",
|
||||
}
|
||||
@ -610,59 +612,49 @@ class ImageCategoryTree(QTreeWidget):
|
||||
return self.DIR_MAPPING.get(dir_name, dir_name)
|
||||
|
||||
def _translate_filename(self, filename: str) -> str:
|
||||
"""翻译文件名为中文(动态替换后缀片段)"""
|
||||
# 依次替换常见后缀模式
|
||||
replacements = [
|
||||
("_spectrum_comparison", " 光谱曲线对比图"),
|
||||
("_scatter_true_vs_pred", " 真值-预测散点图"),
|
||||
("_true_vs_pred", " 真值-预测散点图"),
|
||||
("_histogram", " 分布直方图"),
|
||||
("_boxplot", " 箱线图"),
|
||||
("_distribution_map", " 分布图"),
|
||||
("_distribution_enhanced", " 增强分布图"),
|
||||
("_thematic_map", " 专题图"),
|
||||
("_water_quality_map", " 水质分布图"),
|
||||
("_prediction_map", " 预测结果图"),
|
||||
("_inversion_map", " 反演结果图"),
|
||||
("_glint_deglint", " 耀斑去耀斑对比"),
|
||||
("_glint_mask", " 耀斑掩膜"),
|
||||
("_deglint", " 去耀斑"),
|
||||
("_mask_overlay", " 掩膜叠加"),
|
||||
("_content", " 含量"),
|
||||
("_distribution", " 分布"),
|
||||
("_prediction", " 预测"),
|
||||
("_inversion", " 反演"),
|
||||
("_enhanced", " 增强"),
|
||||
("_scatter", " 散点图"),
|
||||
("_boxplot", " 箱线图"),
|
||||
("_correlation_heatmap", " 相关性热力图"),
|
||||
("_parameter_boxplot", " 箱线图"),
|
||||
("_sampling_point", " 采样点"),
|
||||
("_sampling_points", " 采样点"),
|
||||
("_flight_path", " 飞行轨迹"),
|
||||
("_trajectory", " 轨迹"),
|
||||
]
|
||||
result = filename
|
||||
for pattern, replacement in replacements:
|
||||
result = result.replace(pattern, replacement)
|
||||
|
||||
# 处理参数名(常见水质参数翻译)
|
||||
param_map = {
|
||||
"Chla": "叶绿素", "COD": "化学需氧量", "TN": "总氮", "TP": "总磷",
|
||||
"Turbidity": "浊度", "DO": "溶解氧", "pH": "pH值",
|
||||
"Conductivity": "电导率", "BOD": "生化需氧量", "NH3_N": "氨氮",
|
||||
# 1. 后缀替换 (图表类型)
|
||||
type_mapping = {
|
||||
'_scatter_true_vs_pred': ' 真值预测散点图',
|
||||
'_spectrum_comparison': ' 光谱曲线对比图',
|
||||
'_spectrum': ' 光谱特征图',
|
||||
'_histogram': ' 分布直方图',
|
||||
'_boxplot_seaborn': ' Seaborn箱线图',
|
||||
'_boxplot': ' 箱线图',
|
||||
'_distribution_enhanced': ' 增强空间分布图',
|
||||
'_distribution': ' 空间分布图',
|
||||
'_sampling_map': ' 采样点地图',
|
||||
'_flight_paths': ' 飞行轨迹图',
|
||||
'_preview': ' 效果预览图',
|
||||
'water_mask_overlay': '水域掩膜叠加图',
|
||||
'hsi_preview': '原始影像预览',
|
||||
'correlation_heatmap': '特征相关性热力图',
|
||||
'parameter_boxplot': '水质参数汇总箱线图',
|
||||
'all_parameters_boxplot': '全参数汇总箱线图',
|
||||
'content_map': '含量分布专题图',
|
||||
'_scatter_with_confidence': ' 置信区间散点图'
|
||||
}
|
||||
for eng, chn in param_map.items():
|
||||
# 在文件名中找到参数名并翻译
|
||||
if eng.lower() in result.lower():
|
||||
result = result.replace(eng, chn)
|
||||
if eng.lower() in result.lower():
|
||||
result = result.replace(eng.lower(), chn)
|
||||
|
||||
# 如果没有任何替换,返回原文件名(去掉扩展名)
|
||||
if result == filename:
|
||||
return filename.rsplit(".", 1)[0] if "." in filename else filename
|
||||
return result
|
||||
name = filename
|
||||
for eng, chn in type_mapping.items():
|
||||
if eng in name:
|
||||
name = name.replace(eng, chn)
|
||||
|
||||
# 2. 常见水质参数前缀替换
|
||||
param_mapping = {
|
||||
'Chlorophyll': '叶绿素', 'Chl_a': '叶绿素a', 'Chla': '叶绿素a',
|
||||
'Turbidity': '浊度', 'Temperature': '温度', 'spCond': '电导率',
|
||||
'COD': '化学需氧量', 'DO': '溶解氧', 'PH': 'pH值', 'TDS': '总溶解固体',
|
||||
'BGA': '蓝绿藻', 'TT': '透明度', 'NH3-N': '氨氮', 'NO3-N': '硝酸盐氮',
|
||||
'severe_glint_area': '重度耀斑区域', 'deglint_goodman': 'Goodman算法去耀斑'
|
||||
}
|
||||
|
||||
for eng, chn in param_mapping.items():
|
||||
if name.startswith(eng + ' ') or name.startswith(eng + '_'):
|
||||
name = name.replace(eng, chn, 1)
|
||||
elif eng in name:
|
||||
name = name.replace(eng, chn)
|
||||
|
||||
return name.strip('_')
|
||||
|
||||
def add_image_by_dir(self, file_path: Path, work_path: Path):
|
||||
"""按真实物理目录层级挂载图片节点
|
||||
@ -713,10 +705,19 @@ class ImageCategoryTree(QTreeWidget):
|
||||
else:
|
||||
parent_item = root_item
|
||||
|
||||
# 创建图片节点
|
||||
# 创建图片节点(根据翻译后的名称分配图标)
|
||||
display_name = self._translate_filename(file_path.stem) + file_path.suffix
|
||||
icon = "🖼️" # 默认
|
||||
if "散点" in display_name:
|
||||
icon = "📊"
|
||||
elif "光谱" in display_name or "曲线" in display_name:
|
||||
icon = "📈"
|
||||
elif "箱线" in display_name or "直方" in display_name:
|
||||
icon = "📉"
|
||||
elif "分布" in display_name or "地图" in display_name or "轨迹" in display_name:
|
||||
icon = "🗺️"
|
||||
image_item = QTreeWidgetItem(parent_item)
|
||||
image_item.setText(0, f" 🖼 {display_name}")
|
||||
image_item.setText(0, f" {icon} {display_name}")
|
||||
image_item.setData(0, Qt.UserRole, {"type": "image", "path": str(file_path), "display_name": display_name})
|
||||
image_item.setToolTip(0, str(file_path))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user