Files
orisys-app/apps/autocal/tests/test_sequence_to_capture.py
T
ykcheungab ff5f089dc1 autocal: 序列页阵列预览工具、2D 图点可见度,标签顺序与送到标定页
- 标签顺序:几何与安装 放到 测试序列 之前
- 序列点增加可选 uv_px(向后兼容),点表新增 U/V 列;加入所选点、删除所选、
  送到标定页(按 U/V 经同一套求解加入标定队列并切换页面)
- 已选点结果改显示在选点区状态行,不再写入全局顶部状态条
- 序列页左上区改紧凑:名称与备注同一行,分“阵列”“运动参数”两页;
  运动参数每行三组,输入框改用 compactField
- 新增阵列工具(array_plan.py、ui/array_tool.py):UV 规则网格(可蛇形遍历)与
  阶段预设,逐点检查是否在曲面内、是否留有边距,候选点实时预览在 2D 图上,
  只有可用点才能加入,已在序列里的点不重复加入
- 2D 平面图:标记改为缩放后再绘制并加深色描边,修复缩小后点不清;
  底图可选 原图/灰度/变暗/仅轮廓,点色可选 黄/白/青/橙/灰(默认灰度+黄,写入偏好);
  序列点带编号并连线显示遍历顺序,选中行高亮
- 新增测试 test_sequence_uv、test_sequence_to_capture、test_array_plan、test_array_tool
2026-10-19 11:39:09 +08:00

96 lines
3.6 KiB
Python

"""Sequence rows with U/V, the buttons that act on them, and the tab order."""
from __future__ import annotations
from orisys_app_shared.i18n import t
def test_the_geometry_tab_comes_before_the_sequence_tab(make_window):
window = make_window()
assert window.workspace.page_keys() == ["axes", "finger", "sequence", "sensor", "records"]
window.close()
def test_the_point_table_shows_u_and_v(make_window):
window = make_window()
panel = window.sequence_panel
keys = panel.column_keys()
assert keys.index("u") == keys.index("z") + 1 and keys.index("v") == keys.index("u") + 1
row = panel.append_point(1.0, 2.0, 3.0, uv=(-130.0, 470.0))
cells = panel.point_row(row)
assert (cells["u"], cells["v"]) == ("-130.0", "470.0")
# The placeholder rows have none, and say so.
assert panel.point_row(0)["u"] == "—"
assert panel.uv_of_row(0) is None
assert panel.uv_of_row(row) == (-130.0, 470.0)
window.close()
def test_send_is_off_until_a_row_with_uv_is_selected(make_window):
window = make_window()
panel = window.sequence_panel
row = panel.append_point(1.0, 2.0, 3.0, uv=(10.0, 20.0))
assert not panel.send_button.isEnabled()
panel.table.selectRow(0) # a placeholder without U/V
assert not panel.send_button.isEnabled()
panel.table.selectRow(row)
assert panel.send_button.isEnabled()
assert panel.send_button.text() == t("sequence.btn_send", count=1)
window.close()
def test_sending_emits_the_selected_uv_and_removing_renumbers(make_window):
window = make_window()
panel = window.sequence_panel
first = panel.append_point(1.0, 0.0, 0.0, uv=(10.0, 20.0))
second = panel.append_point(2.0, 0.0, 0.0, uv=(30.0, 40.0))
sent: list = []
panel.sendToCaptureRequested.connect(sent.append)
panel.table.selectRow(second)
panel.send_button.click()
assert sent == [[(30.0, 40.0)]]
panel.table.selectRow(first)
assert panel.remove_selected() == 1
assert panel.point_row(panel.point_row_count() - 1)["index"] == str(panel.point_row_count())
window.close()
def test_a_picked_point_is_added_once_with_its_uv(make_window):
window = make_window()
panel = window.sequence_panel
window.finger_panel._point = { # noqa: SLF001 - stands in for a click on a real surface
"X": 1.5, "Y": 2.5, "Z": 12.4, "u_px": -130.0, "v_px": 470.0,
}
before = panel.point_row_count()
window._on_add_picked_to_sequence() # noqa: SLF001
window._on_add_picked_to_sequence() # noqa: SLF001 - the same point again
assert panel.point_row_count() == before + 1
assert panel.uv_of_row(before) == (-130.0, 470.0)
window.close()
def test_sending_to_capture_queues_the_points_and_opens_that_page(make_window, monkeypatch):
window = make_window()
calls: list = []
monkeypatch.setattr(
window.calibration_panel, "add_uv_points", lambda uvs: calls.append(uvs) or (len(uvs), 0)
)
window.workspace.set_current_key("sequence")
window._on_send_sequence_to_capture([(1.0, 2.0)]) # noqa: SLF001
assert calls == [[(1.0, 2.0)]]
assert window.workspace.current_key() == "sensor"
window.close()
def test_a_pick_reports_in_the_picker_not_in_the_global_strip(make_window):
window = make_window()
strip_before = window.status_strip.last_action_text() if hasattr(
window.status_strip, "last_action_text"
) else None
window._on_pick_point(1, 1) # noqa: SLF001 - no bundle: the picker says why
assert window.finger_panel.status_label.text() == t("finger.no_bundle")
if strip_before is not None:
assert window.status_strip.last_action_text() == strip_before
window.close()