|
|
|
@ -409,7 +409,12 @@ def _selected_contact_face_refs():
|
|
|
|
shape_type = (getattr(sub_object, "ShapeType", "") or "").strip().lower()
|
|
|
|
shape_type = (getattr(sub_object, "ShapeType", "") or "").strip().lower()
|
|
|
|
if shape_type != "face":
|
|
|
|
if shape_type != "face":
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
point = _face_anchor_point(picked, sub_object)
|
|
|
|
point = None
|
|
|
|
|
|
|
|
picked_points = list(getattr(picked, "PickedPoints", []) or [])
|
|
|
|
|
|
|
|
if index < len(picked_points):
|
|
|
|
|
|
|
|
point = picked_points[index]
|
|
|
|
|
|
|
|
if point is None:
|
|
|
|
|
|
|
|
point = _face_anchor_point(picked if not picked_points else None, sub_object)
|
|
|
|
normal = _face_normal(sub_object)
|
|
|
|
normal = _face_normal(sub_object)
|
|
|
|
if point is None or normal is None:
|
|
|
|
if point is None or normal is None:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
@ -422,7 +427,6 @@ def _selected_contact_face_refs():
|
|
|
|
"subelement_name": subelement_names[index] if index < len(subelement_names) else "",
|
|
|
|
"subelement_name": subelement_names[index] if index < len(subelement_names) else "",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
break
|
|
|
|
|
|
|
|
if refs:
|
|
|
|
if refs:
|
|
|
|
return refs
|
|
|
|
return refs
|
|
|
|
|
|
|
|
|
|
|
|
@ -464,6 +468,13 @@ def _has_placement(obj):
|
|
|
|
return getattr(obj, "Placement", None) is not None
|
|
|
|
return getattr(obj, "Placement", None) is not None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _is_app_part_object(obj):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
return bool(obj is not None and obj.isDerivedFrom("App::Part"))
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
return (getattr(obj, "TypeId", "") or "") == "App::Part"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _contact_transform_object(obj):
|
|
|
|
def _contact_transform_object(obj):
|
|
|
|
carrier = _carrier_object_from_object(obj)
|
|
|
|
carrier = _carrier_object_from_object(obj)
|
|
|
|
if carrier is not None and _has_placement(carrier):
|
|
|
|
if carrier is not None and _has_placement(carrier):
|
|
|
|
@ -484,6 +495,7 @@ def _contact_transform_object(obj):
|
|
|
|
name.startswith("QETDevice_")
|
|
|
|
name.startswith("QETDevice_")
|
|
|
|
or (getattr(parent, "QetInstanceId", "") or "").strip()
|
|
|
|
or (getattr(parent, "QetInstanceId", "") or "").strip()
|
|
|
|
or (getattr(parent, "QetCarrierKind", "") or "").strip()
|
|
|
|
or (getattr(parent, "QetCarrierKind", "") or "").strip()
|
|
|
|
|
|
|
|
or _is_app_part_object(parent)
|
|
|
|
):
|
|
|
|
):
|
|
|
|
best = parent
|
|
|
|
best = parent
|
|
|
|
current = parent
|
|
|
|
current = parent
|
|
|
|
@ -502,12 +514,12 @@ def _rotation_for_face_contact(moving_normal, target_normal):
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _normal_contact_translation(target_point, target_normal, moving_point):
|
|
|
|
def _normal_contact_translation(target_point, target_normal, moving_point, offset_mm=0.0):
|
|
|
|
normal = _normalize_vector(target_normal)
|
|
|
|
normal = _normalize_vector(target_normal)
|
|
|
|
if normal is None:
|
|
|
|
if normal is None:
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
signed_distance = _vector_dot(_vector_sub(moving_point, target_point), normal)
|
|
|
|
signed_distance = _vector_dot(_vector_sub(moving_point, target_point), normal)
|
|
|
|
return _vector_scale(normal, -signed_distance)
|
|
|
|
return _vector_scale(normal, float(offset_mm or 0.0) - signed_distance)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _rotate_object_about_point(obj, rotation, pivot):
|
|
|
|
def _rotate_object_about_point(obj, rotation, pivot):
|
|
|
|
@ -645,7 +657,7 @@ def _mount_kind(obj):
|
|
|
|
return "object"
|
|
|
|
return "object"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _set_face_contact_mount_metadata(moving_obj, target_ref, moving_ref):
|
|
|
|
def _set_face_contact_mount_metadata(moving_obj, target_ref, moving_ref, offset_mm=0.0):
|
|
|
|
if moving_obj is None or not isinstance(target_ref, dict) or not isinstance(moving_ref, dict):
|
|
|
|
if moving_obj is None or not isinstance(target_ref, dict) or not isinstance(moving_ref, dict):
|
|
|
|
return
|
|
|
|
return
|
|
|
|
target_obj = target_ref.get("object")
|
|
|
|
target_obj = target_ref.get("object")
|
|
|
|
@ -672,6 +684,12 @@ def _set_face_contact_mount_metadata(moving_obj, target_ref, moving_ref):
|
|
|
|
"QET cabinet assembly mount metadata",
|
|
|
|
"QET cabinet assembly mount metadata",
|
|
|
|
value,
|
|
|
|
value,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
_ensure_float_property(
|
|
|
|
|
|
|
|
moving_obj,
|
|
|
|
|
|
|
|
"QetMountOffsetMm",
|
|
|
|
|
|
|
|
float(offset_mm or 0.0),
|
|
|
|
|
|
|
|
"QET cabinet assembly contact offset in target normal direction",
|
|
|
|
|
|
|
|
)
|
|
|
|
if target_base is not None:
|
|
|
|
if target_base is not None:
|
|
|
|
_set_vector_json_property(
|
|
|
|
_set_vector_json_property(
|
|
|
|
moving_obj,
|
|
|
|
moving_obj,
|
|
|
|
@ -679,6 +697,14 @@ def _set_face_contact_mount_metadata(moving_obj, target_ref, moving_ref):
|
|
|
|
target_base,
|
|
|
|
target_base,
|
|
|
|
"QET cabinet assembly host base at bind time",
|
|
|
|
"QET cabinet assembly host base at bind time",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
host_normal = _normalize_vector(target_ref.get("normal"))
|
|
|
|
|
|
|
|
if host_normal is not None:
|
|
|
|
|
|
|
|
_set_vector_json_property(
|
|
|
|
|
|
|
|
moving_obj,
|
|
|
|
|
|
|
|
"QetMountHostNormalJson",
|
|
|
|
|
|
|
|
host_normal,
|
|
|
|
|
|
|
|
"QET cabinet assembly host face normal at bind time",
|
|
|
|
|
|
|
|
)
|
|
|
|
if target_base is not None and moving_base is not None:
|
|
|
|
if target_base is not None and moving_base is not None:
|
|
|
|
_set_vector_json_property(
|
|
|
|
_set_vector_json_property(
|
|
|
|
moving_obj,
|
|
|
|
moving_obj,
|
|
|
|
@ -1381,8 +1407,9 @@ def _abort_transaction(doc, opened):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ManualWiringController:
|
|
|
|
class ManualWiringController:
|
|
|
|
def __init__(self, terminal_exit_length=DEFAULT_TERMINAL_EXIT_LENGTH):
|
|
|
|
def __init__(self, terminal_exit_length=DEFAULT_TERMINAL_EXIT_LENGTH, contact_offset_mm=0.0):
|
|
|
|
self.terminal_exit_length = float(terminal_exit_length or 0.0)
|
|
|
|
self.terminal_exit_length = float(terminal_exit_length or 0.0)
|
|
|
|
|
|
|
|
self.contact_offset_mm = float(contact_offset_mm or 0.0)
|
|
|
|
self.current_task = None
|
|
|
|
self.current_task = None
|
|
|
|
self.contact_target_ref = None
|
|
|
|
self.contact_target_ref = None
|
|
|
|
self.start_terminal = None
|
|
|
|
self.start_terminal = None
|
|
|
|
@ -1395,6 +1422,10 @@ class ManualWiringController:
|
|
|
|
self.terminal_exit_length = max(float(value or 0.0), 0.0)
|
|
|
|
self.terminal_exit_length = max(float(value or 0.0), 0.0)
|
|
|
|
return self.terminal_exit_length
|
|
|
|
return self.terminal_exit_length
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_contact_offset(self, value):
|
|
|
|
|
|
|
|
self.contact_offset_mm = float(value or 0.0)
|
|
|
|
|
|
|
|
return self.contact_offset_mm
|
|
|
|
|
|
|
|
|
|
|
|
def mark_selected_carriers(self, carrier_kind):
|
|
|
|
def mark_selected_carriers(self, carrier_kind):
|
|
|
|
carrier_kind = (carrier_kind or "").strip()
|
|
|
|
carrier_kind = (carrier_kind or "").strip()
|
|
|
|
if carrier_kind not in CARRIER_ROLE_LABELS:
|
|
|
|
if carrier_kind not in CARRIER_ROLE_LABELS:
|
|
|
|
@ -1475,6 +1506,7 @@ class ManualWiringController:
|
|
|
|
_activate_document(doc)
|
|
|
|
_activate_document(doc)
|
|
|
|
|
|
|
|
|
|
|
|
def apply_length_to_selected_carriers(self, length_mm):
|
|
|
|
def apply_length_to_selected_carriers(self, length_mm):
|
|
|
|
|
|
|
|
doc = _active_document()
|
|
|
|
selected = _selected_carrier_objects()
|
|
|
|
selected = _selected_carrier_objects()
|
|
|
|
if not selected:
|
|
|
|
if not selected:
|
|
|
|
raise ManualWiringPanelError("请先选择线槽或导轨对象。")
|
|
|
|
raise ManualWiringPanelError("请先选择线槽或导轨对象。")
|
|
|
|
@ -1485,8 +1517,83 @@ class ManualWiringController:
|
|
|
|
updated.append(_apply_carrier_length(carrier, length_mm))
|
|
|
|
updated.append(_apply_carrier_length(carrier, length_mm))
|
|
|
|
if not updated:
|
|
|
|
if not updated:
|
|
|
|
raise ManualWiringPanelError("所选对象不是已标记的线槽或导轨。")
|
|
|
|
raise ManualWiringPanelError("所选对象不是已标记的线槽或导轨。")
|
|
|
|
|
|
|
|
refresh_mount_hosted_objects(doc)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
_active_document().recompute()
|
|
|
|
doc.recompute()
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
return updated
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def apply_contact_offset_to_selected_mounts(self, offset_mm):
|
|
|
|
|
|
|
|
doc = _active_document()
|
|
|
|
|
|
|
|
selected = _selection()
|
|
|
|
|
|
|
|
if not selected:
|
|
|
|
|
|
|
|
raise ManualWiringPanelError("请先选择已贴合的对象。")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new_offset = float(offset_mm or 0.0)
|
|
|
|
|
|
|
|
updated = []
|
|
|
|
|
|
|
|
for selected_obj in selected:
|
|
|
|
|
|
|
|
obj = _contact_transform_object(selected_obj)
|
|
|
|
|
|
|
|
if obj is None or (getattr(obj, "QetMountMode", "") or "").strip() != "face_contact":
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
host_normal = _normalize_vector(_vector_from_json_property(obj, "QetMountHostNormalJson"))
|
|
|
|
|
|
|
|
if host_normal is None:
|
|
|
|
|
|
|
|
raise ManualWiringPanelError("所选对象没有保存贴合法向,请重新执行一次贴合后再调节间距。")
|
|
|
|
|
|
|
|
old_offset = float(getattr(obj, "QetMountOffsetMm", 0.0) or 0.0)
|
|
|
|
|
|
|
|
delta = _vector_scale(host_normal, new_offset - old_offset)
|
|
|
|
|
|
|
|
_translate_object(obj, delta)
|
|
|
|
|
|
|
|
_ensure_float_property(
|
|
|
|
|
|
|
|
obj,
|
|
|
|
|
|
|
|
"QetMountOffsetMm",
|
|
|
|
|
|
|
|
new_offset,
|
|
|
|
|
|
|
|
"QET cabinet assembly contact offset in target normal direction",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
host_name = (getattr(obj, "QetMountHostName", "") or "").strip()
|
|
|
|
|
|
|
|
host = doc.getObject(host_name) if host_name and hasattr(doc, "getObject") else None
|
|
|
|
|
|
|
|
host_base = _placement_base(host)
|
|
|
|
|
|
|
|
obj_base = _placement_base(obj)
|
|
|
|
|
|
|
|
if host_base is not None and obj_base is not None:
|
|
|
|
|
|
|
|
_set_vector_json_property(
|
|
|
|
|
|
|
|
obj,
|
|
|
|
|
|
|
|
"QetMountLocalBaseJson",
|
|
|
|
|
|
|
|
_vector_sub(obj_base, host_base),
|
|
|
|
|
|
|
|
"QET cabinet assembly local base offset from host",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
updated.append(obj)
|
|
|
|
|
|
|
|
if not updated:
|
|
|
|
|
|
|
|
raise ManualWiringPanelError("所选对象不是已贴合的装配对象。")
|
|
|
|
|
|
|
|
self.contact_offset_mm = new_offset
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
doc.recompute()
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
return updated
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reverse_contact_normal_for_selected_mounts(self):
|
|
|
|
|
|
|
|
doc = _active_document()
|
|
|
|
|
|
|
|
selected = _selection()
|
|
|
|
|
|
|
|
if not selected:
|
|
|
|
|
|
|
|
raise ManualWiringPanelError("请先选择已贴合的对象。")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updated = []
|
|
|
|
|
|
|
|
for selected_obj in selected:
|
|
|
|
|
|
|
|
obj = _contact_transform_object(selected_obj)
|
|
|
|
|
|
|
|
if obj is None or (getattr(obj, "QetMountMode", "") or "").strip() != "face_contact":
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
host_normal = _normalize_vector(_vector_from_json_property(obj, "QetMountHostNormalJson"))
|
|
|
|
|
|
|
|
if host_normal is None:
|
|
|
|
|
|
|
|
raise ManualWiringPanelError("所选对象没有保存贴合法向,请重新执行一次贴合后再反转方向。")
|
|
|
|
|
|
|
|
_set_vector_json_property(
|
|
|
|
|
|
|
|
obj,
|
|
|
|
|
|
|
|
"QetMountHostNormalJson",
|
|
|
|
|
|
|
|
_vector_scale(host_normal, -1.0),
|
|
|
|
|
|
|
|
"QET cabinet assembly host face normal at bind time",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
updated.append(obj)
|
|
|
|
|
|
|
|
if not updated:
|
|
|
|
|
|
|
|
raise ManualWiringPanelError("所选对象不是已贴合的装配对象。")
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
doc.recompute()
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
return updated
|
|
|
|
return updated
|
|
|
|
@ -1523,11 +1630,12 @@ class ManualWiringController:
|
|
|
|
target["point"],
|
|
|
|
target["point"],
|
|
|
|
target["normal"],
|
|
|
|
target["normal"],
|
|
|
|
moving["point"],
|
|
|
|
moving["point"],
|
|
|
|
|
|
|
|
self.contact_offset_mm,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if translation is None:
|
|
|
|
if translation is None:
|
|
|
|
raise ManualWiringPanelError("无法读取目标面的法向,不能执行贴合。")
|
|
|
|
raise ManualWiringPanelError("无法读取目标面的法向,不能执行贴合。")
|
|
|
|
_translate_object(moving_object, translation)
|
|
|
|
_translate_object(moving_object, translation)
|
|
|
|
_set_face_contact_mount_metadata(moving_object, target, moving)
|
|
|
|
_set_face_contact_mount_metadata(moving_object, target, moving, self.contact_offset_mm)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
_active_document().recompute()
|
|
|
|
_active_document().recompute()
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
@ -1541,6 +1649,7 @@ class ManualWiringController:
|
|
|
|
"moving_point": moving["point"],
|
|
|
|
"moving_point": moving["point"],
|
|
|
|
"translation": translation,
|
|
|
|
"translation": translation,
|
|
|
|
"translation_mode": "normal",
|
|
|
|
"translation_mode": "normal",
|
|
|
|
|
|
|
|
"contact_offset_mm": self.contact_offset_mm,
|
|
|
|
"rotated": rotated,
|
|
|
|
"rotated": rotated,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1770,6 +1879,23 @@ class ManualWiringController:
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
raise ManualWiringPanelError("当前 FreeCAD 文档不支持撤销。")
|
|
|
|
raise ManualWiringPanelError("当前 FreeCAD 文档不支持撤销。")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def launch_native_transform_for_selection(self):
|
|
|
|
|
|
|
|
_active_document()
|
|
|
|
|
|
|
|
if not _selection():
|
|
|
|
|
|
|
|
raise ManualWiringPanelError("请选择要变换的对象。")
|
|
|
|
|
|
|
|
if Gui is None or not hasattr(Gui, "runCommand"):
|
|
|
|
|
|
|
|
raise ManualWiringPanelError("当前 FreeCAD 界面不支持原生变换命令。")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# FreeCAD 原生变换也是任务面板;先关闭本面板,避免 TaskDialog 互相占用。
|
|
|
|
|
|
|
|
control = getattr(Gui, "Control", None)
|
|
|
|
|
|
|
|
if control is not None and hasattr(control, "closeDialog"):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
control.closeDialog()
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
Gui.runCommand("Std_TransformManip")
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def set_end_from_selection_and_generate(self):
|
|
|
|
def set_end_from_selection_and_generate(self):
|
|
|
|
doc = _active_document()
|
|
|
|
doc = _active_document()
|
|
|
|
if self.start_terminal is None:
|
|
|
|
if self.start_terminal is None:
|
|
|
|
@ -1859,10 +1985,11 @@ class ManualWiringController:
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if len(self.waypoints) > 3:
|
|
|
|
if len(self.waypoints) > 3:
|
|
|
|
waypoint_text += ";..."
|
|
|
|
waypoint_text += ";..."
|
|
|
|
return "任务:{0};起点:{1};出线:{2:.1f} mm;折点:{3} 个;最近导线:{4};折点明细:{5}".format(
|
|
|
|
return "任务:{0};起点:{1};出线:{2:.1f} mm;贴合间距:{3:.1f} mm;折点:{4} 个;最近导线:{5};折点明细:{6}".format(
|
|
|
|
task_text,
|
|
|
|
task_text,
|
|
|
|
start_text,
|
|
|
|
start_text,
|
|
|
|
self.terminal_exit_length,
|
|
|
|
self.terminal_exit_length,
|
|
|
|
|
|
|
|
self.contact_offset_mm,
|
|
|
|
len(self.waypoints),
|
|
|
|
len(self.waypoints),
|
|
|
|
wire_text,
|
|
|
|
wire_text,
|
|
|
|
waypoint_text,
|
|
|
|
waypoint_text,
|
|
|
|
@ -1889,6 +2016,12 @@ class ManualWiringTaskPanel:
|
|
|
|
self.exit_length_input.setSingleStep(5.0)
|
|
|
|
self.exit_length_input.setSingleStep(5.0)
|
|
|
|
self.exit_length_input.setSuffix(" mm")
|
|
|
|
self.exit_length_input.setSuffix(" mm")
|
|
|
|
self.exit_length_input.setValue(self.controller.terminal_exit_length)
|
|
|
|
self.exit_length_input.setValue(self.controller.terminal_exit_length)
|
|
|
|
|
|
|
|
self.contact_offset_input = QtWidgets.QDoubleSpinBox()
|
|
|
|
|
|
|
|
self.contact_offset_input.setRange(-1000.0, 1000.0)
|
|
|
|
|
|
|
|
self.contact_offset_input.setDecimals(1)
|
|
|
|
|
|
|
|
self.contact_offset_input.setSingleStep(1.0)
|
|
|
|
|
|
|
|
self.contact_offset_input.setSuffix(" mm")
|
|
|
|
|
|
|
|
self.contact_offset_input.setValue(self.controller.contact_offset_mm)
|
|
|
|
self.carrier_length_input = QtWidgets.QDoubleSpinBox()
|
|
|
|
self.carrier_length_input = QtWidgets.QDoubleSpinBox()
|
|
|
|
self.carrier_length_input.setRange(1.0, 10000.0)
|
|
|
|
self.carrier_length_input.setRange(1.0, 10000.0)
|
|
|
|
self.carrier_length_input.setDecimals(1)
|
|
|
|
self.carrier_length_input.setDecimals(1)
|
|
|
|
@ -1906,7 +2039,10 @@ class ManualWiringTaskPanel:
|
|
|
|
self.batch_breaker_button = QtWidgets.QPushButton("批量断路器")
|
|
|
|
self.batch_breaker_button = QtWidgets.QPushButton("批量断路器")
|
|
|
|
self.set_contact_target_button = QtWidgets.QPushButton("设为贴合目标面")
|
|
|
|
self.set_contact_target_button = QtWidgets.QPushButton("设为贴合目标面")
|
|
|
|
self.align_faces_button = QtWidgets.QPushButton("贴合到选中面")
|
|
|
|
self.align_faces_button = QtWidgets.QPushButton("贴合到选中面")
|
|
|
|
|
|
|
|
self.apply_contact_offset_button = QtWidgets.QPushButton("应用贴合间距")
|
|
|
|
|
|
|
|
self.reverse_contact_normal_button = QtWidgets.QPushButton("反转贴合方向")
|
|
|
|
self.refresh_mount_hosts_button = QtWidgets.QPushButton("刷新宿主装配")
|
|
|
|
self.refresh_mount_hosts_button = QtWidgets.QPushButton("刷新宿主装配")
|
|
|
|
|
|
|
|
self.native_transform_button = QtWidgets.QPushButton("关闭面板并变换")
|
|
|
|
self.waypoint_button = QtWidgets.QPushButton("添加折点")
|
|
|
|
self.waypoint_button = QtWidgets.QPushButton("添加折点")
|
|
|
|
self.delete_waypoint_button = QtWidgets.QPushButton("删除最后折点")
|
|
|
|
self.delete_waypoint_button = QtWidgets.QPushButton("删除最后折点")
|
|
|
|
self.end_button = QtWidgets.QPushButton("设为终点并生成")
|
|
|
|
self.end_button = QtWidgets.QPushButton("设为终点并生成")
|
|
|
|
@ -1925,6 +2061,10 @@ class ManualWiringTaskPanel:
|
|
|
|
exit_layout.addWidget(QtWidgets.QLabel("手动端子出线长度"))
|
|
|
|
exit_layout.addWidget(QtWidgets.QLabel("手动端子出线长度"))
|
|
|
|
exit_layout.addWidget(self.exit_length_input)
|
|
|
|
exit_layout.addWidget(self.exit_length_input)
|
|
|
|
layout.addLayout(exit_layout)
|
|
|
|
layout.addLayout(exit_layout)
|
|
|
|
|
|
|
|
contact_offset_layout = QtWidgets.QHBoxLayout()
|
|
|
|
|
|
|
|
contact_offset_layout.addWidget(QtWidgets.QLabel("贴合间距"))
|
|
|
|
|
|
|
|
contact_offset_layout.addWidget(self.contact_offset_input)
|
|
|
|
|
|
|
|
layout.addLayout(contact_offset_layout)
|
|
|
|
carrier_length_layout = QtWidgets.QHBoxLayout()
|
|
|
|
carrier_length_layout = QtWidgets.QHBoxLayout()
|
|
|
|
carrier_length_layout.addWidget(QtWidgets.QLabel("载体长度"))
|
|
|
|
carrier_length_layout.addWidget(QtWidgets.QLabel("载体长度"))
|
|
|
|
carrier_length_layout.addWidget(self.carrier_length_input)
|
|
|
|
carrier_length_layout.addWidget(self.carrier_length_input)
|
|
|
|
@ -1945,7 +2085,10 @@ class ManualWiringTaskPanel:
|
|
|
|
layout.addLayout(batch_layout)
|
|
|
|
layout.addLayout(batch_layout)
|
|
|
|
layout.addWidget(self.set_contact_target_button)
|
|
|
|
layout.addWidget(self.set_contact_target_button)
|
|
|
|
layout.addWidget(self.align_faces_button)
|
|
|
|
layout.addWidget(self.align_faces_button)
|
|
|
|
|
|
|
|
layout.addWidget(self.apply_contact_offset_button)
|
|
|
|
|
|
|
|
layout.addWidget(self.reverse_contact_normal_button)
|
|
|
|
layout.addWidget(self.refresh_mount_hosts_button)
|
|
|
|
layout.addWidget(self.refresh_mount_hosts_button)
|
|
|
|
|
|
|
|
layout.addWidget(self.native_transform_button)
|
|
|
|
layout.addWidget(self.start_button)
|
|
|
|
layout.addWidget(self.start_button)
|
|
|
|
layout.addWidget(self.waypoint_button)
|
|
|
|
layout.addWidget(self.waypoint_button)
|
|
|
|
layout.addWidget(self.delete_waypoint_button)
|
|
|
|
layout.addWidget(self.delete_waypoint_button)
|
|
|
|
@ -1971,6 +2114,7 @@ class ManualWiringTaskPanel:
|
|
|
|
self.use_task_button.clicked.connect(self.use_selected_task)
|
|
|
|
self.use_task_button.clicked.connect(self.use_selected_task)
|
|
|
|
self.reload_tasks_button.clicked.connect(self._refresh_task_list)
|
|
|
|
self.reload_tasks_button.clicked.connect(self._refresh_task_list)
|
|
|
|
self.exit_length_input.valueChanged.connect(self.set_exit_length)
|
|
|
|
self.exit_length_input.valueChanged.connect(self.set_exit_length)
|
|
|
|
|
|
|
|
self.contact_offset_input.valueChanged.connect(self.set_contact_offset)
|
|
|
|
self.import_duct_button.clicked.connect(self.import_wire_duct)
|
|
|
|
self.import_duct_button.clicked.connect(self.import_wire_duct)
|
|
|
|
self.import_rail_button.clicked.connect(self.import_din_rail)
|
|
|
|
self.import_rail_button.clicked.connect(self.import_din_rail)
|
|
|
|
self.apply_carrier_length_button.clicked.connect(self.apply_carrier_length)
|
|
|
|
self.apply_carrier_length_button.clicked.connect(self.apply_carrier_length)
|
|
|
|
@ -1981,7 +2125,10 @@ class ManualWiringTaskPanel:
|
|
|
|
self.batch_breaker_button.clicked.connect(self.create_breakers)
|
|
|
|
self.batch_breaker_button.clicked.connect(self.create_breakers)
|
|
|
|
self.set_contact_target_button.clicked.connect(self.set_contact_target_face)
|
|
|
|
self.set_contact_target_button.clicked.connect(self.set_contact_target_face)
|
|
|
|
self.align_faces_button.clicked.connect(self.align_selected_contact_faces)
|
|
|
|
self.align_faces_button.clicked.connect(self.align_selected_contact_faces)
|
|
|
|
|
|
|
|
self.apply_contact_offset_button.clicked.connect(self.apply_contact_offset)
|
|
|
|
|
|
|
|
self.reverse_contact_normal_button.clicked.connect(self.reverse_contact_normal)
|
|
|
|
self.refresh_mount_hosts_button.clicked.connect(self.refresh_mount_hosts)
|
|
|
|
self.refresh_mount_hosts_button.clicked.connect(self.refresh_mount_hosts)
|
|
|
|
|
|
|
|
self.native_transform_button.clicked.connect(self.launch_native_transform)
|
|
|
|
self.start_button.clicked.connect(self.set_start)
|
|
|
|
self.start_button.clicked.connect(self.set_start)
|
|
|
|
self.waypoint_button.clicked.connect(self.add_waypoint)
|
|
|
|
self.waypoint_button.clicked.connect(self.add_waypoint)
|
|
|
|
self.delete_waypoint_button.clicked.connect(self.delete_last_waypoint)
|
|
|
|
self.delete_waypoint_button.clicked.connect(self.delete_last_waypoint)
|
|
|
|
@ -2057,6 +2204,13 @@ class ManualWiringTaskPanel:
|
|
|
|
except Exception as exc:
|
|
|
|
except Exception as exc:
|
|
|
|
self._set_error(str(exc))
|
|
|
|
self._set_error(str(exc))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_contact_offset(self, value):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
self.controller.set_contact_offset(value)
|
|
|
|
|
|
|
|
self._set_status(self.controller.state_text())
|
|
|
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
|
|
|
self._set_error(str(exc))
|
|
|
|
|
|
|
|
|
|
|
|
def _select_carrier_asset_path(self, carrier_kind):
|
|
|
|
def _select_carrier_asset_path(self, carrier_kind):
|
|
|
|
default_path = _builtin_carrier_asset_path(carrier_kind)
|
|
|
|
default_path = _builtin_carrier_asset_path(carrier_kind)
|
|
|
|
default_dir = str(Path(default_path).parent) if default_path else ""
|
|
|
|
default_dir = str(Path(default_path).parent) if default_path else ""
|
|
|
|
@ -2188,6 +2342,27 @@ class ManualWiringTaskPanel:
|
|
|
|
except Exception as exc:
|
|
|
|
except Exception as exc:
|
|
|
|
self._set_error(str(exc))
|
|
|
|
self._set_error(str(exc))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def apply_contact_offset(self):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
updated = self.controller.apply_contact_offset_to_selected_mounts(
|
|
|
|
|
|
|
|
self.contact_offset_input.value()
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
self._set_status(
|
|
|
|
|
|
|
|
"已对 {0} 个贴合对象应用间距 {1:.1f} mm。".format(
|
|
|
|
|
|
|
|
len(updated),
|
|
|
|
|
|
|
|
self.contact_offset_input.value(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
|
|
|
self._set_error(str(exc))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reverse_contact_normal(self):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
updated = self.controller.reverse_contact_normal_for_selected_mounts()
|
|
|
|
|
|
|
|
self._set_status("已反转 {0} 个贴合对象的间距方向。".format(len(updated)))
|
|
|
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
|
|
|
self._set_error(str(exc))
|
|
|
|
|
|
|
|
|
|
|
|
def set_contact_target_face(self):
|
|
|
|
def set_contact_target_face(self):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
target = self.controller.set_contact_target_from_selection()
|
|
|
|
target = self.controller.set_contact_target_from_selection()
|
|
|
|
@ -2203,6 +2378,12 @@ class ManualWiringTaskPanel:
|
|
|
|
except Exception as exc:
|
|
|
|
except Exception as exc:
|
|
|
|
self._set_error(str(exc))
|
|
|
|
self._set_error(str(exc))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def launch_native_transform(self):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
self.controller.launch_native_transform_for_selection()
|
|
|
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
|
|
|
self._set_error(str(exc))
|
|
|
|
|
|
|
|
|
|
|
|
def set_start(self):
|
|
|
|
def set_start(self):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
terminal = self.controller.set_start_from_selection()
|
|
|
|
terminal = self.controller.set_start_from_selection()
|
|
|
|
|