示例#1
0
def test_line_tool():
    img = data.camera()
    viewer = ImageViewer(img)

    tool = LineTool(viewer.ax, maxdist=10)
    tool.end_points = get_end_points(img)
    assert_equal(tool.end_points, np.array([[170, 256], [341, 256]]))

    # grab a handle and move it
    grab = create_mouse_event(viewer.ax, xdata=170, ydata=256)
    tool.on_mouse_press(grab)
    move = create_mouse_event(viewer.ax, xdata=180, ydata=260)
    tool.on_move(move)
    tool.on_mouse_release(move)
    assert_equal(tool.geometry, np.array([[180, 260], [341, 256]]))

    # create a new line
    new = create_mouse_event(viewer.ax, xdata=10, ydata=10)
    tool.on_mouse_press(new)
    move = create_mouse_event(viewer.ax, xdata=100, ydata=100)
    tool.on_move(move)
    tool.on_mouse_release(move)
    assert_equal(tool.geometry, np.array([[100, 100], [10, 10]]))
示例#2
0
def test_line_tool():
    img = data.camera()
    viewer = ImageViewer(img)

    tool = LineTool(viewer.ax, maxdist=10)
    tool.end_points = get_end_points(img)
    assert_equal(tool.end_points, np.array([[170, 256], [341, 256]]))

    # grab a handle and move it
    grab = create_mouse_event(viewer.ax, xdata=170, ydata=256)
    tool.on_mouse_press(grab)
    move = create_mouse_event(viewer.ax, xdata=180, ydata=260)
    tool.on_move(move)
    tool.on_mouse_release(move)
    assert_equal(tool.geometry, np.array([[180, 260], [341, 256]]))

    # create a new line
    new = create_mouse_event(viewer.ax, xdata=10, ydata=10)
    tool.on_mouse_press(new)
    move = create_mouse_event(viewer.ax, xdata=100, ydata=100)
    tool.on_move(move)
    tool.on_mouse_release(move)
    assert_equal(tool.geometry, np.array([[100, 100], [10, 10]]))