示例#1
0
def _create_presenter(model, view, mock_sliceinfo_cls, enable_nonortho_axes,
                      supports_nonortho):
    model.get_ws_type = mock.Mock(return_value=WS_TYPE.MDH)
    model.is_ragged_matrix_plotted.return_value = False
    model.get_dim_limits.return_value = ((-1, 1), (-2, 2))
    data_view_mock = view.data_view
    data_view_mock.plot_MDH = mock.Mock()
    presenter = SliceViewer(None, model=model, view=view)
    if enable_nonortho_axes:
        data_view_mock.nonorthogonal_mode = True
        data_view_mock.nonortho_transform = mock.MagicMock(
            NonOrthogonalTransform)
        data_view_mock.nonortho_transform.tr.return_value = (0, 1)
        presenter.nonorthogonal_axes(True)
    else:
        data_view_mock.nonorthogonal_mode = False
        data_view_mock.nonortho_transform = None

    data_view_mock.disable_tool_button.reset_mock()
    data_view_mock.create_axes_orthogonal.reset_mock()
    data_view_mock.create_axes_nonorthogonal.reset_mock()
    mock_sliceinfo_instance = mock_sliceinfo_cls.return_value
    mock_sliceinfo_instance.can_support_nonorthogonal_axes.return_value = supports_nonortho

    return presenter, data_view_mock
    def test_axes_limits_respect_nonorthog_transfrom(self):
        limits = (-10.0, 10.0, -9.0, 9.0)
        ws_nonrotho = CreateMDWorkspace(
            Dimensions=3,
            Extents=','.join([str(lim) for lim in limits]) + ',-8,8',
            Names='A,B,C',
            Units='r.l.u.,r.l.u.,r.l.u.',
            Frames='HKL,HKL,HKL')
        expt_info_nonortho = CreateSampleWorkspace()
        ws_nonrotho.addExperimentInfo(expt_info_nonortho)
        SetUB(ws_nonrotho, 1, 1, 2, 90, 90, 120)
        pres = SliceViewer(ws_nonrotho)

        # assert limits of orthog
        limits_orthog = pres.view.data_view.get_axes_limits()
        self.assertEqual(limits_orthog[0], limits[0:2])
        self.assertEqual(limits_orthog[1], limits[2:])

        # set nonorthog view and retrieve new limits
        pres.nonorthogonal_axes(True)
        limits_nonorthog = pres.view.data_view.get_axes_limits()
        self.assertAlmostEqual(limits_nonorthog[0][0], -19, delta=1e-5)
        self.assertAlmostEqual(limits_nonorthog[0][1], 19, delta=1e-5)
        self.assertEqual(limits_nonorthog[1], limits[2:])

        pres.view.close()
示例#3
0
    def test_non_orthogonal_axes_toggled_on(self):
        self.model.get_ws_type = mock.Mock(return_value=WS_TYPE.MATRIX)
        data_view_mock = self.view.data_view
        data_view_mock.plot_matrix = mock.Mock()

        presenter = SliceViewer(None, model=self.model, view=self.view)
        data_view_mock.plot_matrix.reset_mock()  # clear initial plot call
        data_view_mock.create_axes_orthogonal.reset_mock()
        presenter.nonorthogonal_axes(True)

        data_view_mock.remove_line_plots.assert_called_once()
        data_view_mock.create_axes_nonorthogonal.assert_called_once()
        data_view_mock.create_axes_orthogonal.assert_not_called()
        data_view_mock.plot_matrix.assert_called_once()
        data_view_mock.disable_lineplots_button.assert_called_once()
        data_view_mock.disable_peaks_button.assert_called_once()
示例#4
0
def _create_presenter(model, view, mock_sliceinfo_cls, enable_nonortho_axes,
                      supports_nonortho):
    model.get_ws_type = mock.Mock(return_value=WS_TYPE.MDH)
    data_view_mock = view.data_view
    data_view_mock.plot_MDH = mock.Mock()
    presenter = SliceViewer(None, model=model, view=view)
    if enable_nonortho_axes:
        presenter.nonorthogonal_axes(True)
    else:
        data_view_mock.nonorthogonal_mode = False
    data_view_mock.create_axes_orthogonal.reset_mock()
    data_view_mock.create_axes_nonorthogonal.reset_mock()
    mock_sliceinfo_instance = mock_sliceinfo_cls.return_value
    mock_sliceinfo_instance.can_support_nonorthogonal_axes.return_value = supports_nonortho

    return presenter, data_view_mock
    def test_non_orthogonal_axes_toggled_on(self):
        self.model.get_ws_type = mock.Mock(return_value=WS_TYPE.MDE)
        data_view_mock = self.view.data_view
        data_view_mock.plot_MDH = mock.Mock()

        presenter = SliceViewer(None, model=self.model, view=self.view)

        data_view_mock.plot_MDH.reset_mock()  # clear initial plot call
        data_view_mock.create_axes_orthogonal.reset_mock()
        presenter.nonorthogonal_axes(True)

        data_view_mock.deactivate_and_disable_tool.assert_called_once_with(
            ToolItemText.REGIONSELECTION)
        data_view_mock.create_axes_nonorthogonal.assert_called_once()
        data_view_mock.create_axes_orthogonal.assert_not_called()
        data_view_mock.plot_MDH.assert_called_once()
        data_view_mock.disable_tool_button.assert_has_calls(
            [mock.call(ToolItemText.LINEPLOTS)])
示例#6
0
    def test_non_orthogonal_axes_toggled_on(self, _):
        self.model.get_ws_type = mock.Mock(return_value=WS_TYPE.MDE)
        self.model.get_dim_limits.return_value = ((-1, 1), (-2, 2))
        self.model.is_ragged_matrix_plotted.return_value = False
        data_view_mock = self.view.data_view
        data_view_mock.plot_MDH = mock.Mock()

        presenter = SliceViewer(None, model=self.model, view=self.view)

        data_view_mock.plot_MDH.reset_mock()  # clear initial plot call
        data_view_mock.create_axes_orthogonal.reset_mock()
        presenter.nonorthogonal_axes(True)

        data_view_mock.deactivate_and_disable_tool.assert_called_once_with(
            ToolItemText.REGIONSELECTION)
        data_view_mock.create_axes_nonorthogonal.assert_called_once()
        data_view_mock.create_axes_orthogonal.assert_not_called()
        self.assertEqual(data_view_mock.plot_MDH.call_count, 2)
        data_view_mock.disable_tool_button.assert_has_calls(
            [mock.call(ToolItemText.LINEPLOTS)])