コード例 #1
0
def test_plane_drag_callback():
    """Plane drag callback should only be active when depicting as plane."""
    np.random.seed(0)
    data = np.random.random((10, 15, 20))
    layer = Image(data, depiction='volume')

    assert move_plane_along_normal not in layer.mouse_drag_callbacks
    layer.depiction = 'plane'
    assert move_plane_along_normal in layer.mouse_drag_callbacks
    layer.depiction = 'volume'
    assert move_plane_along_normal not in layer.mouse_drag_callbacks
コード例 #2
0
def test_plane_controls_show_hide_on_depiction_change(qtbot):
    """Changing depiction mode should show/hide plane controls in 3D."""
    layer = Image(np.random.rand(10, 15, 20))
    layer._slice_dims(ndisplay=3)
    qtctrl = QtImageControls(layer)
    qtbot.addWidget(qtctrl)

    layer.depiction = 'volume'
    assert qtctrl.planeControls.isHidden()

    layer.depiction = 'plane'
    assert not qtctrl.planeControls.isHidden()  # isVisible() != not isHidden()
コード例 #3
0
def test_depiction_combobox_changes(qtbot):
    """Changing the model attribute should update the view."""
    layer = Image(np.random.rand(10, 15, 20))
    layer._slice_dims(ndisplay=3)
    qtctrl = QtImageControls(layer)
    qtbot.addWidget(qtctrl)
    combo_box = qtctrl.depictionComboBox
    opts = {combo_box.itemText(i) for i in range(combo_box.count())}
    depiction_options = {
        'volume',
        'plane',
    }
    assert opts == depiction_options
    layer.depiction = 'plane'
    assert combo_box.findText('plane') == combo_box.currentIndex()
    layer.depiction = 'volume'
    assert combo_box.findText('volume') == combo_box.currentIndex()
コード例 #4
0
def test_plane_controls_show_hide_on_depiction_change(qtbot):
    """Changing depiction mode should show/hide plane controls in 3D."""
    layer = Image(np.random.rand(10, 15, 20))
    layer._slice_dims(ndisplay=3)
    qtctrl = QtImageControls(layer)
    qtbot.addWidget(qtctrl)

    layer.depiction = 'volume'
    assert qtctrl.planeThicknessSlider.isHidden()
    assert qtctrl.planeThicknessLabel.isHidden()
    assert qtctrl.planeNormalButtons.isHidden()
    assert qtctrl.planeNormalLabel.isHidden()

    layer.depiction = 'plane'
    assert not qtctrl.planeThicknessSlider.isHidden()
    assert not qtctrl.planeThicknessLabel.isHidden()
    assert not qtctrl.planeNormalButtons.isHidden()
    assert not qtctrl.planeNormalLabel.isHidden()