File: test_link.py

package info (click to toggle)
python-vispy 0.14.3-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 8,840 kB
  • sloc: python: 59,436; javascript: 6,800; makefile: 69; sh: 6
file content (53 lines) | stat: -rw-r--r-- 1,612 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) Vispy Development Team. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
# -----------------------------------------------------------------------------
from vispy.scene.widgets import ViewBox
from vispy.testing import run_tests_if_main


def test_turntable_camera_link():
    vbs = [ViewBox(camera='turntable') for _ in range(3)]
    cams = [vb.camera for vb in vbs]

    for cam in cams:
        cam.elevation = 45.0
        cam.azimuth = 120.0
        cam.scale_factor = 4.0

    cams[0].link(cams[1])
    cams[0].link(cams[2], props=['azimuth', 'elevation'])

    cams[1].elevation = 30.0
    cams[1].azimuth = 90.0
    cams[1].scale_factor = 2.0

    assert cams[0].elevation == 30.0
    assert cams[0].azimuth == 90.0
    assert cams[0].scale_factor == 2.0

    assert cams[2].elevation == 30.0
    assert cams[2].azimuth == 90.0
    assert cams[2].scale_factor == 4.0


def test_panzoom_link():
    vbs = [ViewBox(camera='panzoom') for _ in range(4)]
    cams = [vb.camera for vb in vbs]

    for cam in cams:
        cam.rect = (0, 0, 100, 100)

    cams[0].link(cams[1])
    cams[0].link(cams[2], axis='x')
    cams[0].link(cams[3], axis='y')

    cams[1].rect = (-20, -20, 130, 130)

    assert cams[0].rect.pos == (-20, -20) and cams[0].rect.size == (130, 130)
    assert cams[2].rect.pos == (-20, 0) and cams[2].rect.size == (130, 100)
    assert cams[3].rect.pos == (0, -20) and cams[3].rect.size == (100, 130)


run_tests_if_main()