feat: 扩展Face保持关系编辑语义

This commit is contained in:
2026-08-10 17:50:50 +08:00
parent 61f0b76e59
commit 3a851d0967
8 changed files with 382 additions and 41 deletions
+114
View File
@@ -3427,6 +3427,43 @@ class WindowStateMixin:
_triple_or_none(action_info.get("area_center"))
or _triple_or_none(action_info.get("bbox_center"))
)
keep_relation_fields_present = any(
key in action_info
for key in (
"first_level_planar_relation_status",
"first_level_planar_relation_count",
"first_level_planar_relation_angled_count",
"first_level_planar_relation_non_planar_face_ids",
"first_level_adjacent_surface_types",
)
)
face_keep_relation_enabled = bool(is_plane)
face_keep_relation_disabled_tip = "当前对象不是平面 Face,不能保持一级平面关系。"
if face_keep_relation_enabled and keep_relation_fields_present:
relation_status = str(action_info.get("first_level_planar_relation_status") or "")
relation_count = _int_or_none(action_info.get("first_level_planar_relation_count")) or 0
angled_count = _int_or_none(action_info.get("first_level_planar_relation_angled_count")) or 0
non_planar_face_ids = _int_values(action_info.get("first_level_planar_relation_non_planar_face_ids"))
adjacent_surfaces = tuple(action_info.get("first_level_adjacent_surface_types") or ())
non_plane_adjacent_surfaces = tuple(
item
for item in adjacent_surfaces
if isinstance(item, (tuple, list))
and len(item) >= 2
and str(item[1]) != "plane"
)
if non_planar_face_ids or non_plane_adjacent_surfaces:
face_keep_relation_enabled = False
face_keep_relation_disabled_tip = "一级相邻 Face 中包含非平面/曲面,当前“保持关系”只支持平面邻域。"
elif angled_count > 0:
face_keep_relation_enabled = False
face_keep_relation_disabled_tip = "一级相邻平面中存在斜交关系,当前“保持关系”只支持平行/垂直。"
elif relation_status != "ready":
face_keep_relation_enabled = False
face_keep_relation_disabled_tip = "当前一级平面关系还不可验证,不能使用“保持关系”。"
elif relation_count <= 0:
face_keep_relation_enabled = False
face_keep_relation_disabled_tip = "当前一级邻域没有识别到可保持的平行/垂直平面关系。"
if is_plane:
current_face_width = _float_or_none(action_info.get("local_face_width"))
current_face_height = _float_or_none(action_info.get("local_face_height"))
@@ -3461,6 +3498,31 @@ class WindowStateMixin:
),
"range_hint": f"{face_size_tip} {relative_range_hint(current_face_width, 0.25, 0.8, face_linear_hard_limit)}",
},
"keep_relations": {
"label": "保持关系",
"action": "resize_face_width_keep_relations",
"target_attr": "face_width_input",
"enabled": bool(
current_face_width is not None
and current_face_width > 0
and current_face_center is not None
and (self.selected_part_id is not None or self.selected_solid_id is not None)
and face_keep_relation_enabled
),
"enabled_tip": (
"输入目标面内长度;程序会沿该方向缩放所属特征或 Solid,"
"并要求一级相邻平面的平行/垂直关系在执行前可验证、执行后可反查。"
),
"disabled_tip": (
face_keep_relation_disabled_tip
if not face_keep_relation_enabled
else "当前 Face 缺少稳定面内长度、中心坐标或所属对象,不能保持关系地修改面内长度。"
),
"range_hint": (
"保持关系会把面内长度修改转换为所属对象单向缩放,并在结果上反查一级平面关系;"
f"{relative_range_hint(current_face_width, 0.25, 0.8, face_linear_hard_limit)}"
),
},
"owning": {
"label": "缩放特征",
"action": "resize_face_width_owning_scale",
@@ -3503,6 +3565,31 @@ class WindowStateMixin:
),
"range_hint": f"{face_size_tip} {relative_range_hint(current_face_height, 0.25, 0.8, face_linear_hard_limit)}",
},
"keep_relations": {
"label": "保持关系",
"action": "resize_face_height_keep_relations",
"target_attr": "face_height_input",
"enabled": bool(
current_face_height is not None
and current_face_height > 0
and current_face_center is not None
and (self.selected_part_id is not None or self.selected_solid_id is not None)
and face_keep_relation_enabled
),
"enabled_tip": (
"输入目标面内宽度;程序会沿该方向缩放所属特征或 Solid,"
"并要求一级相邻平面的平行/垂直关系在执行前可验证、执行后可反查。"
),
"disabled_tip": (
face_keep_relation_disabled_tip
if not face_keep_relation_enabled
else "当前 Face 缺少稳定面内宽度、中心坐标或所属对象,不能保持关系地修改面内宽度。"
),
"range_hint": (
"保持关系会把面内宽度修改转换为所属对象单向缩放,并在结果上反查一级平面关系;"
f"{relative_range_hint(current_face_height, 0.25, 0.8, face_linear_hard_limit)}"
),
},
"owning": {
"label": "缩放特征",
"action": "resize_face_height_owning_scale",
@@ -3549,6 +3636,33 @@ class WindowStateMixin:
"transform_context": {"current_center": current_face_center},
**face_vector_move_limit(current_face_center),
},
"keep_relations": {
"label": "保持关系",
"action": "move_selected_face_center_keep_relations",
"target_attrs": ("translate_x_input", "translate_y_input", "translate_z_input"),
"enabled": bool(
is_plane
and current_face_center is not None
and (self.selected_part_id is not None or self.selected_solid_id is not None)
and face_keep_relation_enabled
),
"enabled_tip": (
"输入这个 Face 中心要移动到的目标 X, Y, Z 坐标;程序会平移所属特征或 Solid,"
"并要求一级相邻平面的平行/垂直关系在执行前可验证、执行后可反查。"
),
"disabled_tip": (
face_keep_relation_disabled_tip
if not face_keep_relation_enabled
else "当前 Face 缺少稳定中心坐标或所属对象,不能保持关系地修改中心位置。"
),
"range_hint": (
"保持关系会把中心修改转换为所属对象平移,并在结果上反查一级平面关系;"
f"{translation_hint()} {face_center_hard_limit}"
),
"target_transform": "target_center_to_translation",
"transform_context": {"current_center": current_face_center},
**face_vector_move_limit(current_face_center),
},
"owning": {
"label": "移动特征",
"action": "move_selected_face_center",