feat: 完善 Edge 一级编辑与 CAD 建模语义

This commit is contained in:
2026-08-05 18:06:15 +08:00
parent ed1faf51d8
commit 57d75541c3
19 changed files with 2365 additions and 367 deletions
+64 -64
View File
@@ -375,8 +375,8 @@ class WindowActionMixin:
f"本次移动距离: {_format_value(distance)}\n"
f"当前法向位置: {_format_value(plan.get('current_plane_position'))}\n"
f"目标法向位置: {_format_value(plan.get('target_plane_position'))}\n"
f"编辑策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"影响范围: {_format_value(plan.get('edit_semantics'))}\n"
f"执行策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"执行影响: {_format_value(plan.get('edit_semantics'))}\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
f"{plan['message']}\n\n"
@@ -1153,7 +1153,7 @@ class WindowActionMixin:
face_id,
blocker,
resize_strategy="local-face-plane-offset-deform",
edit_strategy_label="偏移曲面(局部重建)",
edit_strategy_label="偏移变换(局部重建)",
edit_semantics="按当前面垂直方向移动 Face 边界顶点并重建一级相邻面;复杂内孔/多边界 Face 当前不放行。",
info=info,
extra={
@@ -1394,9 +1394,9 @@ class WindowActionMixin:
strategy_label = str(plan.get("edit_strategy_label") or "").strip()
edit_semantics = str(plan.get("edit_semantics") or "").strip()
if strategy_label:
semantic_lines.append(f"编辑策略: {strategy_label}")
semantic_lines.append(f"执行策略: {strategy_label}")
if edit_semantics:
semantic_lines.append(f"编辑方式: {edit_semantics}")
semantic_lines.append(f"建模意图: {edit_semantics}")
result = QMessageBox.question(
self,
@@ -1432,7 +1432,7 @@ class WindowActionMixin:
"V向尺寸(局部重建)",
"U向尺寸(缩放特征)",
"V向尺寸(缩放特征)",
"偏移曲面(局部重建)",
"偏移变换(局部重建)",
"中心(局部重建)",
"圆柱高度调整",
"高度(缩放特征)缩放所属对象",
@@ -1511,7 +1511,7 @@ class WindowActionMixin:
strategy = str(parameters.get("edit_strategy_label") or "").strip()
if strategy:
lines.append(f"编辑策略: {strategy}")
lines.append(f"执行策略: {strategy}")
surface = parameters.get("surface")
distance = parameters.get("semantic_distance")
@@ -2844,8 +2844,8 @@ class WindowActionMixin:
f"置信度: {plan['confidence']}\n"
f"材料投票: {plan['material_vote_summary']}\n"
f"工具策略: {plan['boss_tool_strategy']}\n"
f"编辑策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"编辑方式: {_format_value(plan.get('edit_semantics'))}\n"
f"执行策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"建模意图: {_format_value(plan.get('edit_semantics'))}\n"
f"工具高度: {_format_value(plan['boss_tool_height'])}\n"
f"轴向重叠余量: {_format_value(plan['boss_tool_axial_margin'])}\n"
f"风险: {plan['risk']}\n\n"
@@ -3034,8 +3034,8 @@ class WindowActionMixin:
f"端盖拉伸/切除距离: {_format_value(plan.get('push_pull_distance'))}\n"
f"候选判断: {plan.get('feature_guess')}\n"
f"置信度: {plan.get('confidence')}\n"
f"编辑策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"编辑方式: {_format_value(plan.get('edit_semantics'))}\n"
f"执行策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"建模意图: {_format_value(plan.get('edit_semantics'))}\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
f"{plan['message']}\n\n"
@@ -3737,8 +3737,8 @@ class WindowActionMixin:
f"支撑 Face: {_format_value(plan.get('feature_existing_fillet_support_face_ids', ''))}\n"
f"边界 Edge: {_format_value(plan.get('feature_boundary_edge_ids', ''))}\n"
f"策略: {plan['resize_strategy']}\n"
f"编辑策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"编辑方式: {_format_value(plan.get('edit_semantics'))}\n"
f"执行策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"建模意图: {_format_value(plan.get('edit_semantics'))}\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
f"{plan['message']}\n\n"
@@ -3828,8 +3828,8 @@ class WindowActionMixin:
f"半径/Edge长度比例: {_format_percent(plan['radius_to_length_ratio'])}\n"
f"相邻 Face: {_format_value(plan.get('adjacent_face_ids', ''))}\n"
f"相邻 Face 数: {_format_value(plan.get('adjacent_face_count', ''))}\n"
f"编辑策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"编辑方式: {_format_value(plan.get('edit_semantics'))}\n"
f"执行策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"建模意图: {_format_value(plan.get('edit_semantics'))}\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
f"{plan['message']}\n\n"
@@ -3910,8 +3910,8 @@ class WindowActionMixin:
f"倒角距离/Edge长度比例: {_format_percent(plan['distance_to_length_ratio'])}\n"
f"相邻 Face: {_format_value(plan.get('adjacent_face_ids', ''))}\n"
f"相邻 Face 数: {_format_value(plan.get('adjacent_face_count', ''))}\n"
f"编辑策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"编辑方式: {_format_value(plan.get('edit_semantics'))}\n"
f"执行策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"建模意图: {_format_value(plan.get('edit_semantics'))}\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
f"{plan['message']}\n\n"
@@ -4175,9 +4175,9 @@ class WindowActionMixin:
f"目标Edge长度: {_format_value(plan['target_length'])}\n"
f"变化量: {_format_value(plan['delta_length'])}\n"
f"Edge长度基准: {_format_value(plan.get('edge_length_anchor_label', ''))}\n"
f"Edge修改策略: {_format_value(plan.get('edge_length_strategy_label', ''))}\n"
f"建模意图: {_format_value(plan.get('edge_length_strategy_label', ''))}\n"
f"固定约束: {_format_value(plan.get('edge_length_constraint_summary', ''))}\n"
f"影响范围: {_format_value(plan.get('edge_length_impact_summary', ''))}\n"
f"执行影响: {_format_value(plan.get('edge_length_impact_summary', ''))}\n"
f"策略: {_format_value(plan.get('resize_strategy', ''))}\n"
f"局部形变目标: {_format_value(plan.get('local_edge_deform_target_kind', ''))}\n"
f"局部形变: {_format_value(plan.get('local_edge_deform_anchor', ''))}\n"
@@ -4343,9 +4343,9 @@ class WindowActionMixin:
f"目标Edge长度: {_format_value(plan['target_length'])}\n"
f"变化量: {_format_value(plan['delta_length'])}\n"
f"Edge长度基准: {_format_value(plan.get('edge_length_anchor_label', ''))}\n"
f"Edge修改策略: {_format_value(plan.get('edge_length_strategy_label', ''))}\n"
f"建模意图: {_format_value(plan.get('edge_length_strategy_label', ''))}\n"
f"固定约束: {_format_value(plan.get('edge_length_constraint_summary', ''))}\n"
f"影响范围: {_format_value(plan.get('edge_length_impact_summary', ''))}\n"
f"执行影响: {_format_value(plan.get('edge_length_impact_summary', ''))}\n"
f"策略: {_format_value(strategy)}\n"
f"局部形变目标: {_format_value(plan.get('local_edge_deform_target_kind', ''))}\n"
f"局部形变: {_format_value(plan.get('local_edge_deform_anchor', ''))}\n"
@@ -4516,7 +4516,7 @@ class WindowActionMixin:
f"目标小半径: {_format_value(plan.get('ellipse_target_minor_radius'))}\n"
f"缩放方向: {_format_value(plan.get('ellipse_axis_direction_label'))}\n"
f"缩放比例: {_format_value(plan.get('affine_scale'))}\n"
f"影响范围: {_format_value(plan.get('edit_semantics'))}\n"
f"执行影响: {_format_value(plan.get('edit_semantics'))}\n"
f"缩放目标: {_format_value(plan.get('affine_target_kind'))}\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
@@ -4883,8 +4883,8 @@ class WindowActionMixin:
f"缩放目标: {_format_value(plan.get('affine_target_kind'))}\n"
f"缩放比例: {_format_value(plan.get('affine_scale'))}\n"
f"策略: {_format_value(plan.get('resize_strategy'))}\n"
f"编辑策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"编辑方式: {_format_value(plan.get('edit_semantics'))}\n"
f"执行策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"建模意图: {_format_value(plan.get('edit_semantics'))}\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
f"{plan['message']}\n\n"
@@ -4980,8 +4980,8 @@ class WindowActionMixin:
f"目标半角: {_format_value(plan.get('target_semi_angle_degrees'))}\n"
f"目标参考半径: {_format_value(plan.get('target_reference_radius'))}\n"
f"变化比例: {_format_percent(plan.get('reference_radius_delta_ratio'))}\n"
f"编辑策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"影响范围: {_format_value(plan.get('edit_semantics'))}\n"
f"执行策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"执行影响: {_format_value(plan.get('edit_semantics'))}\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
f"{plan['message']}\n\n"
@@ -5079,8 +5079,8 @@ class WindowActionMixin:
f"缩放目标: {_format_value(plan.get('affine_target_kind'))}\n"
f"缩放比例: {_format_value(plan.get('affine_scale'))}\n"
f"策略: {_format_value(plan.get('resize_strategy'))}\n"
f"编辑策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"编辑方式: {_format_value(plan.get('edit_semantics'))}\n"
f"执行策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"建模意图: {_format_value(plan.get('edit_semantics'))}\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
f"{plan['message']}\n\n"
@@ -5184,8 +5184,8 @@ class WindowActionMixin:
f"缩放目标: {_format_value(plan.get('affine_target_kind'))}\n"
f"缩放比例: {_format_value(plan.get('affine_scale'))}\n"
f"策略: {_format_value(plan.get('resize_strategy'))}\n"
f"编辑策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"编辑方式: {_format_value(plan.get('edit_semantics'))}\n"
f"执行策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"建模意图: {_format_value(plan.get('edit_semantics'))}\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
f"{plan['message']}\n\n"
@@ -5277,8 +5277,8 @@ class WindowActionMixin:
f"缩放目标: {_format_value(plan.get('affine_target_kind'))}\n"
f"缩放比例: {_format_value(plan.get('affine_scale'))}\n"
f"策略: {_format_value(plan.get('resize_strategy'))}\n"
f"编辑策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"编辑方式: {_format_value(plan.get('edit_semantics'))}\n"
f"执行策略: {_format_value(plan.get('edit_strategy_label'))}\n"
f"建模意图: {_format_value(plan.get('edit_semantics'))}\n"
f"影响说明: {_format_value(plan.get('affine_transform_note'))}\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
@@ -5625,7 +5625,7 @@ class WindowActionMixin:
def move_selected_face_plane_position_by_translation(self) -> None:
if self.model is None:
return
if self._edit_busy("请等待当前编辑完成后再按偏移曲面平移所属对象。"):
if self._edit_busy("请等待当前编辑完成后再按偏移变换平移所属对象。"):
return
if self.selected_face_id is None:
QMessageBox.information(self, "未选择Face", "请先选择一个平面 Face。")
@@ -5633,14 +5633,14 @@ class WindowActionMixin:
try:
distance = float(self.offset_input.text())
except (AttributeError, ValueError):
QMessageBox.critical(self, "偏移曲面无效", "请输入数字形式的目标偏移曲面")
QMessageBox.critical(self, "偏移变换无效", "请输入数字形式的目标偏移变换位置")
return
face_id = self.selected_face_id
plan = self.model.face_plane_offset_owning_translation_plan(face_id, distance)
if plan["status"] == "blocked":
QMessageBox.information(self, "不能按偏移曲面平移", str(plan["message"]))
self.statusBar().showMessage("偏移曲面整体平移已阻止")
QMessageBox.information(self, "不能按偏移变换平移", str(plan["message"]))
self.statusBar().showMessage("偏移变换整体平移已阻止")
return
current_position = float(plan.get("current_plane_position", 0.0) or 0.0)
target_position = float(plan.get("target_plane_position", current_position) or current_position)
@@ -5652,7 +5652,7 @@ class WindowActionMixin:
target_position,
plane_direction,
):
self.statusBar().showMessage("已取消偏移曲面整体平移")
self.statusBar().showMessage("已取消偏移变换整体平移")
return
self.clear_edit_preview(render=False)
@@ -5663,7 +5663,7 @@ class WindowActionMixin:
moved_id = plan.get("solid_id") if moved_kind == "solid" else plan.get("part_id")
self._run_edit_action(
action,
operation_name="偏移曲面(移动特征)",
operation_name="偏移变换(移动特征)",
target=f"Face {face_id}",
parameters={
"face_id": face_id,
@@ -5684,8 +5684,8 @@ class WindowActionMixin:
"translate_warnings": plan.get("warnings"),
"translate_blockers": plan.get("blockers"),
"resize_strategy": "translate-owning-shape-from-plane-offset",
"edit_strategy_label": "按偏移曲面平移所属对象",
"edit_semantics": "把目标偏移曲面换算成沿当前面垂直方向的平移量,并平移所属特征或 Solid;不拉伸/切除,不切削,也不补料。",
"edit_strategy_label": "按偏移变换平移所属对象",
"edit_semantics": "把目标偏移变换位置换算成沿当前面垂直方向的平移量,并平移所属特征或 Solid;不拉伸/切除,不切削,也不补料。",
},
target_kind="face",
target_id=face_id,
@@ -5694,7 +5694,7 @@ class WindowActionMixin:
def move_selected_face_plane_position_local(self) -> None:
if self.model is None:
return
if self._edit_busy("请等待当前编辑完成后再执行偏移曲面(局部重建)。"):
if self._edit_busy("请等待当前编辑完成后再执行偏移变换(局部重建)。"):
return
if self.selected_face_id is None:
QMessageBox.information(self, "未选择Face", "请先选择一个平面 Face。")
@@ -5702,7 +5702,7 @@ class WindowActionMixin:
try:
distance = float(self.offset_input.text())
except (AttributeError, ValueError):
QMessageBox.critical(self, "偏移曲面无效", "请输入数字形式的目标偏移曲面")
QMessageBox.critical(self, "偏移变换无效", "请输入数字形式的目标偏移变换位置")
return
face_id = self.selected_face_id
@@ -5711,8 +5711,8 @@ class WindowActionMixin:
plan = self.model.face_plane_offset_local_plan(face_id, distance)
lines = [
f"Face: {face_id}",
f"当前偏移曲面: {_format_value(plan.get('current_plane_position'))}",
f"目标偏移曲面: {_format_value(plan.get('target_plane_position'))}",
f"当前偏移变换位置: {_format_value(plan.get('current_plane_position'))}",
f"目标偏移变换位置: {_format_value(plan.get('target_plane_position'))}",
f"平面方向: {_format_value(plan.get('plane_direction'))}",
f"移动向量: {_format_value(plan.get('face_center_move_vector'))}",
f"移动距离: {_format_value(plan.get('face_center_move_distance'))}",
@@ -5722,11 +5722,11 @@ class WindowActionMixin:
f"影响目标: {_format_value(plan.get('local_face_deform_target_kind'))}",
]
if not self._confirm_quick_edit_plan(
"偏移曲面(局部重建)",
"偏移变换(局部重建)",
plan,
lines,
"偏移曲面(局部重建)已阻止",
"已取消偏移曲面(局部重建)",
"偏移变换(局部重建)已阻止",
"已取消偏移变换(局部重建)",
):
return
self.clear_edit_preview(render=False)
@@ -5736,7 +5736,7 @@ class WindowActionMixin:
self._run_edit_action(
action,
operation_name="偏移曲面(局部重建)",
operation_name="偏移变换(局部重建)",
target=f"Face {face_id}",
parameters={
"face_id": face_id,
@@ -5758,9 +5758,9 @@ class WindowActionMixin:
"local_face_deform_face_count": plan.get("local_face_deform_face_count"),
"local_face_deform_moved_point_count": plan.get("local_face_deform_moved_point_count"),
"resize_strategy": "local-face-plane-offset-deform",
"edit_strategy_label": "偏移曲面(局部重建)",
"edit_strategy_label": "偏移变换(局部重建)",
"edit_semantics": (
"把目标偏移曲面换算成沿当前面垂直方向的移动量,移动当前 Face 的顶点并重建相邻平面;"
"把目标偏移变换位置换算成沿当前面垂直方向的移动量,移动当前 Face 的顶点并重建相邻平面;"
"不拉伸/切除加料/切削,也不平移所属对象。"
),
"resize_status": plan.get("status"),
@@ -6067,8 +6067,8 @@ class WindowActionMixin:
f"目标轴心: {_format_value(target_center)}\n"
f"平移向量: {_format_value(plan['translation_vector'])}\n"
f"平移距离: {_format_value(plan['translation_distance'])}\n"
f"编辑策略: 按轴心平移所属对象\n"
f"编辑方式: 平移所属特征或 Solid;不填旧孔、不切新孔、不重建局部凸台。\n"
f"执行策略: 按轴心平移所属对象\n"
f"建模意图: 平移所属特征或 Solid;不填旧孔、不切新孔、不重建局部凸台。\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
f"{plan['message']}\n\n"
@@ -6157,8 +6157,8 @@ class WindowActionMixin:
f"目标Face中心: {_format_value(target_center)}\n"
f"平移向量: {_format_value(plan['translation_vector'])}\n"
f"平移距离: {_format_value(plan['translation_distance'])}\n"
f"编辑策略: 平移Face所属对象\n"
f"编辑方式: 把目标 Face 的中心坐标换算成平移量,并平移所属特征或 Solid;不做单面局部扭曲。\n"
f"执行策略: 平移Face所属对象\n"
f"建模意图: 把目标 Face 的中心坐标换算成平移量,并平移所属特征或 Solid;不做单面局部扭曲。\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
f"{plan['message']}\n\n"
@@ -6184,23 +6184,23 @@ class WindowActionMixin:
warnings_line = f"警告: {warnings}\n\n" if warnings else ""
result = QMessageBox.question(
self,
"确认偏移曲面整体平移",
"确认偏移变换整体平移",
(
f"Face: {face_id}\n"
f"移动对象: {_format_value(plan.get('target_kind', ''))}\n"
f"零件: {_format_value(plan.get('part_id', ''))}\n"
f"Solid: {_format_value(plan.get('solid_id', ''))}\n"
f"当前偏移曲面: {_format_value(current_position)}\n"
f"目标偏移曲面: {_format_value(target_position)}\n"
f"当前偏移变换位置: {_format_value(current_position)}\n"
f"目标偏移变换位置: {_format_value(target_position)}\n"
f"平面方向: {_format_value(plane_direction)}\n"
f"平移向量: {_format_value(plan['translation_vector'])}\n"
f"平移距离: {_format_value(plan['translation_distance'])}\n"
f"编辑策略: 按偏移曲面平移所属对象\n"
f"编辑方式: 沿当前面垂直方向平移所属特征或 Solid;不拉伸/切除,不切削,也不补料。\n"
f"执行策略: 按偏移变换平移所属对象\n"
f"建模意图: 沿当前面垂直方向平移所属特征或 Solid;不拉伸/切除,不切削,也不补料。\n"
f"风险: {plan['risk']}\n\n"
f"{warnings_line}"
f"{plan['message']}\n\n"
"如果你想改变厚度或把这个面推出/切入,请在“偏移曲面”这一行把影响范围选为“拉伸/切除”。确定继续吗?"
"如果你想改变厚度或把这个面推出/切入,请在“偏移变换”这一行把建模意图选为“拉伸/切除”。确定继续吗?"
),
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No,
@@ -7577,7 +7577,7 @@ class WindowActionMixin:
if target_position is not None and plane_direction is not None:
checks.append(
(
"偏移曲面",
"偏移变换",
self._face_target_plane_position_matches(
model,
face_ids,
@@ -8007,7 +8007,7 @@ class WindowActionMixin:
"中心",
"U向尺寸",
"V向尺寸",
"偏移曲面",
"偏移变换",
"壳体",
"拉伸/切除",
"圆锥",
@@ -8062,9 +8062,9 @@ class WindowActionMixin:
progress_text = f"{operation_name} 正在后台计算;当前会沿选中 Face 的平面内方向缩放所属特征或 Solid,其它几何会跟随变化。"
elif "U向尺寸(局部重建)" in operation_name or "V向尺寸(局部重建)" in operation_name:
progress_text = f"{operation_name} 正在后台计算;当前会只沿选中 Face 的一个平面内方向缩放顶点并重建相邻平面。"
elif "偏移曲面(局部重建)" in operation_name:
elif "偏移变换(局部重建)" in operation_name:
progress_text = f"{operation_name} 正在后台计算;当前会沿当前面垂直方向移动所选 Face 顶点并重建相邻平面。"
elif "偏移曲面(移动特征)" in operation_name:
elif "偏移变换(移动特征)" in operation_name:
progress_text = f"{operation_name} 正在后台计算;当前会沿当前面垂直方向平移所属特征或 Solid,不拉伸/切除。"
elif "Face中心" in operation_name:
progress_text = f"{operation_name} 正在后台计算;当前会平移所属特征或 Solid,不做单面局部扭曲。"