From e420a146d50302ea6e8081ac4e9447d6f96ba0c7 Mon Sep 17 00:00:00 2001 From: Waruna Wickramasingha Date: Wed, 9 Oct 2024 14:33:01 +0100 Subject: [PATCH 1/2] 34758 fixed sliceviewer non orthogonal view transpose view issue --- .../source/Testing/SliceViewer/SliceViewer.rst | 12 ++++++++++-- .../Workbench/SliceViewer/Bugfixes/34758.rst | 1 + .../sliceviewer/presenters/presenter.py | 2 ++ .../test/test_sliceviewer_presenter.py | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 docs/source/release/v6.12.0/Workbench/SliceViewer/Bugfixes/34758.rst diff --git a/dev-docs/source/Testing/SliceViewer/SliceViewer.rst b/dev-docs/source/Testing/SliceViewer/SliceViewer.rst index a19cb8e17e26..21692e23acf3 100644 --- a/dev-docs/source/Testing/SliceViewer/SliceViewer.rst +++ b/dev-docs/source/Testing/SliceViewer/SliceViewer.rst @@ -157,11 +157,19 @@ Test the :ref:`Nonorthogonal view` - Confirm the autoscaling of the colorbar works in non-orthogonal view -3. Change one of the viewing axes to be `L` (e.g. click `X` button next to L in top left of window) +3. Note the range of data in `X` and `Y` axes to be `0 to 2` for `H` and `-1 to +1` for `K` respectively. Swap the viewing axes by clicking `Y` button next to `H` in the top left of the window + + - `X` and `Y` axes should now display data for `K` and `H` respectively preserving their original ranges. + +4. Click on `X` button next to the `H` button to swap the axes again + + - Now `X` and `Y` axes should display data for `H` and `K` respectively preserving their original ranges. + +5. Change one of the viewing axes to be `L` (e.g. click `X` button next to L in top left of window) - Gridlines should now appear to be orthogonal -4. For ``md_4D`` only change one of the viewing axes to be `E` (e.g. click `Y` button next to `E` in top left of window) +6. For ``md_4D`` only change one of the viewing axes to be `E` (e.g. click `Y` button next to `E` in top left of window) - Nonorthogonal view should be disabled (only enabled for momentum axes) - Line plots and ROI should be enabled diff --git a/docs/source/release/v6.12.0/Workbench/SliceViewer/Bugfixes/34758.rst b/docs/source/release/v6.12.0/Workbench/SliceViewer/Bugfixes/34758.rst new file mode 100644 index 000000000000..3b24fb37530e --- /dev/null +++ b/docs/source/release/v6.12.0/Workbench/SliceViewer/Bugfixes/34758.rst @@ -0,0 +1 @@ +- Fixed a bug in the :ref:sliceviewer which was not showing data with correct ranges when doing a Transpose in non-orthogonal view. \ No newline at end of file diff --git a/qt/python/mantidqt/mantidqt/widgets/sliceviewer/presenters/presenter.py b/qt/python/mantidqt/mantidqt/widgets/sliceviewer/presenters/presenter.py index 9cedd9ef552e..4a5147e42bc8 100644 --- a/qt/python/mantidqt/mantidqt/widgets/sliceviewer/presenters/presenter.py +++ b/qt/python/mantidqt/mantidqt/widgets/sliceviewer/presenters/presenter.py @@ -231,6 +231,8 @@ def slicepoint_changed(self): self._call_peaks_presenter_if_created("notify", PeaksViewerPresenter.Event.SlicePointChanged) self._call_cutviewer_presenter_if_created("on_slicepoint_changed") self.update_plot_data() + if self.view.data_view.nonorthogonal_mode: + self.show_all_data_clicked() def export_roi(self, limits): """Notify that an roi has been selected for export to a workspace diff --git a/qt/python/mantidqt/mantidqt/widgets/sliceviewer/test/test_sliceviewer_presenter.py b/qt/python/mantidqt/mantidqt/widgets/sliceviewer/test/test_sliceviewer_presenter.py index 8bc3d6fee0d8..49f2cf025887 100644 --- a/qt/python/mantidqt/mantidqt/widgets/sliceviewer/test/test_sliceviewer_presenter.py +++ b/qt/python/mantidqt/mantidqt/widgets/sliceviewer/test/test_sliceviewer_presenter.py @@ -787,6 +787,24 @@ def test_y_axes_editor_calls_dimensions_changed(self): presenter.dimensions_changed.assert_called_once() + def test_slicepoint_changed_on_non_orthogonal_mode(self): + presenter = SliceViewer(None, model=self.model, view=self.view) + presenter.show_all_data_clicked = mock.MagicMock() + presenter.view.data_view.nonorthogonal_mode = True + + presenter.slicepoint_changed() + + presenter.show_all_data_clicked.assert_called_once() + + def test_slicepoint_changed_on_orthogonal_mode(self): + presenter = SliceViewer(None, model=self.model, view=self.view) + presenter.show_all_data_clicked = mock.MagicMock() + presenter.view.data_view.nonorthogonal_mode = False + + presenter.slicepoint_changed() + + presenter.show_all_data_clicked.assert_not_called() + if __name__ == "__main__": unittest.main() From ad83fa0244072ae221cf3a497cbf0e2877b0627e Mon Sep 17 00:00:00 2001 From: Waruna Wickramasingha Date: Fri, 11 Oct 2024 10:20:56 +0100 Subject: [PATCH 2/2] updated with PR comments --- .../sliceviewer/presenters/presenter.py | 4 ++-- .../test/test_sliceviewer_presenter.py | 22 ++++--------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/qt/python/mantidqt/mantidqt/widgets/sliceviewer/presenters/presenter.py b/qt/python/mantidqt/mantidqt/widgets/sliceviewer/presenters/presenter.py index 4a5147e42bc8..63d80dde2eaf 100644 --- a/qt/python/mantidqt/mantidqt/widgets/sliceviewer/presenters/presenter.py +++ b/qt/python/mantidqt/mantidqt/widgets/sliceviewer/presenters/presenter.py @@ -225,14 +225,14 @@ def dimensions_changed(self): else: self.new_plot() self._call_cutviewer_presenter_if_created("on_dimension_changed") + if self.view.data_view.nonorthogonal_mode: + self.show_all_data_clicked() def slicepoint_changed(self): """Indicates the slicepoint has been updated""" self._call_peaks_presenter_if_created("notify", PeaksViewerPresenter.Event.SlicePointChanged) self._call_cutviewer_presenter_if_created("on_slicepoint_changed") self.update_plot_data() - if self.view.data_view.nonorthogonal_mode: - self.show_all_data_clicked() def export_roi(self, limits): """Notify that an roi has been selected for export to a workspace diff --git a/qt/python/mantidqt/mantidqt/widgets/sliceviewer/test/test_sliceviewer_presenter.py b/qt/python/mantidqt/mantidqt/widgets/sliceviewer/test/test_sliceviewer_presenter.py index 49f2cf025887..6101dc89b5f7 100644 --- a/qt/python/mantidqt/mantidqt/widgets/sliceviewer/test/test_sliceviewer_presenter.py +++ b/qt/python/mantidqt/mantidqt/widgets/sliceviewer/test/test_sliceviewer_presenter.py @@ -370,10 +370,12 @@ def test_dimensions_changed_when_transpose_2D_MD_workspace(self, mock_sliceinfo_ self.model.get_number_dimensions.return_value = 2 mock_sliceinfo_cls.slicepoint = [None, None] # no slicepoint as 2D ws data_view_mock.dimensions.get_previous_states.return_value = [0, 1] # no None that indicates integrated dim + presenter.show_all_data_clicked = mock.MagicMock() presenter.dimensions_changed() mock_new_plot.assert_called_with(dimensions_transposing=True) + presenter.show_all_data_clicked.assert_not_called() @mock.patch("mantidqt.widgets.sliceviewer.presenters.presenter.SliceInfo") def test_changing_dimensions_in_nonortho_mode_switches_to_ortho_when_dim_not_Q(self, mock_sliceinfo_cls): @@ -381,12 +383,14 @@ def test_changing_dimensions_in_nonortho_mode_switches_to_ortho_when_dim_not_Q(s self.model, self.view, mock_sliceinfo_cls, enable_nonortho_axes=True, supports_nonortho=False ) self.model.get_number_dimensions.return_value = 2 + presenter.show_all_data_clicked = mock.MagicMock() presenter.dimensions_changed() data_view_mock.disable_tool_button.assert_called_once_with(ToolItemText.NONORTHOGONAL_AXES) data_view_mock.create_axes_orthogonal.assert_called_once() data_view_mock.create_axes_nonorthogonal.assert_not_called() + presenter.show_all_data_clicked.assert_called_once() @mock.patch("mantidqt.widgets.sliceviewer.presenters.presenter.SliceInfo") def test_changing_dimensions_in_nonortho_mode_keeps_nonortho_when_dim_is_Q(self, mock_sliceinfo_cls): @@ -787,24 +791,6 @@ def test_y_axes_editor_calls_dimensions_changed(self): presenter.dimensions_changed.assert_called_once() - def test_slicepoint_changed_on_non_orthogonal_mode(self): - presenter = SliceViewer(None, model=self.model, view=self.view) - presenter.show_all_data_clicked = mock.MagicMock() - presenter.view.data_view.nonorthogonal_mode = True - - presenter.slicepoint_changed() - - presenter.show_all_data_clicked.assert_called_once() - - def test_slicepoint_changed_on_orthogonal_mode(self): - presenter = SliceViewer(None, model=self.model, view=self.view) - presenter.show_all_data_clicked = mock.MagicMock() - presenter.view.data_view.nonorthogonal_mode = False - - presenter.slicepoint_changed() - - presenter.show_all_data_clicked.assert_not_called() - if __name__ == "__main__": unittest.main()