示例#1
0
def test_panzoom_zoom_mouse(qtbot, canvas_pz, panzoom):
    c = canvas_pz
    pz = panzoom

    # Zoom with mouse.
    press = MouseEvent(type='mouse_press', pos=(50., 50.))
    c.events.mouse_move(pos=(0., 0.),
                        button=2,
                        last_event=press,
                        press_event=press)
    assert pz.pan[0] < 0
    assert pz.pan[1] < 0
    assert pz.zoom[0] < 1
    assert pz.zoom[1] > 1
    pz.reset()

    # Zoom with mouse.
    size = np.asarray(c.size)
    c.events.mouse_wheel(pos=size / 2., delta=(0., 1.))
    assert pz.pan == [0, 0]
    assert pz.zoom[0] > 1
    assert pz.zoom[1] > 1
    pz.reset()

    # Using modifiers with the wheel should not zoom.
    c.events.mouse_wheel(pos=(0., 0.),
                         delta=(0., 1.),
                         modifiers=(keys.CONTROL, ))
    assert pz.pan == [0, 0]
    assert pz.zoom == [1, 1]
    pz.reset()
示例#2
0
def test_mouse_key_events():
    me = MouseEvent('mouse_press')
    for fun in (me.pos, me.button, me.buttons, me.modifiers, me.delta,
                me.press_event, me.last_event, me.is_dragging):
        fun
    me.drag_events()
    me._forget_last_event()
    me.trail()
    ke = KeyEvent('key_release')
    ke.key
    ke.text
    ke.modifiers
示例#3
0
文件: test_app.py 项目: kif/vispy
def test_mouse_key_events():
    me = MouseEvent("mouse_press")
    for fun in (me.pos, me.button, me.buttons, me.modifiers, me.delta, me.press_event, me.last_event, me.is_dragging):
        fun
    me.drag_events()
    me._forget_last_event()
    me.trail()
    ke = KeyEvent("key_release")
    ke.key
    ke.text
    ke.modifiers
示例#4
0
def test_panzoom_pan_mouse(qtbot, canvas_pz, panzoom):
    c = canvas_pz
    pz = panzoom

    # Pan with mouse.
    press = MouseEvent(type='mouse_press', pos=(0, 0))
    c.events.mouse_move(pos=(10., 0.),
                        button=1,
                        last_event=press,
                        press_event=press)
    assert pz.pan[0] > 0
    assert pz.pan[1] == 0
    pz.pan = (0, 0)

    # Panning with a modifier should not pan.
    press = MouseEvent(type='mouse_press', pos=(0, 0))
    c.events.mouse_move(pos=(10., 0.),
                        button=1,
                        last_event=press,
                        press_event=press,
                        modifiers=(keys.CONTROL, ))
    assert pz.pan == [0, 0]
示例#5
0
文件: test_app.py 项目: Zulko/vispy
def test_mouse_key_events():
    """Test mouse and key events"""
    me = MouseEvent('mouse_press')
    for fun in (me.pos, me.button, me.buttons, me.modifiers, me.delta,
                me.press_event, me.last_event, me.is_dragging):
        fun
    me.drag_events()
    me._forget_last_event()
    me.trail()
    ke = KeyEvent('key_release')
    ke.key
    ke.text
    ke.modifiers
示例#6
0
def test_volumeviewer_toolbar():
    session = simple_session()
    v = VispyVolumeViewer(session)
    data = make_test_data()
    session.data_collection.append(data)
    v.add_data(data)
    assert v.toolbar is not None

    toolbar = v.toolbar

    # test rotate tool
    toolbar.actions['vispy:rotate'].toggle()
    assert toolbar.active_tool.tool_id == 'vispy:rotate'
    # TODO: assert a mode here
    toolbar.actions['vispy:rotate'].toggle()
    assert toolbar.active_tool is None

    # test lasso selection tool
    toolbar.actions['vispy:lasso'].toggle()
    assert 'vispy:lasso' in toolbar.active_tool.tool_id
    lasso = toolbar.active_tool
    # event = QTest.mouseMove(viewer._vispy_widget)

    # TODO: add a real mouse move event so content in lasso.move() is called
    lasso.press(MouseEvent('mouse_press'))
    lasso.move(MouseEvent('mouse_move'))
    lasso.release(MouseEvent('mouse_release'))
    assert toolbar.tools['vispy:lasso'] == lasso

    # add point selection test
    # set to perspective mode
    toolbar.actions['volume3d:floodfill'].toggle()
    assert 'volume3d:floodfill' in toolbar.active_tool.tool_id
    point = toolbar.active_tool
    # event = QTest.mouseMove(viewer._vispy_widget)

    # TODO: add a real mouse move event so content in lasso.move() is called
    point.press(MouseEvent('mouse_press'))
    point.move(MouseEvent('mouse_move'))
    point.release(MouseEvent('mouse_release'))
    assert toolbar.tools['volume3d:floodfill'] == point

    v.close()