From 1d087681a5dafb4d49318cdde783c047704bc706 Mon Sep 17 00:00:00 2001 From: Sam Tygier Date: Wed, 25 Oct 2023 09:17:53 +0100 Subject: [PATCH 1/2] SpectrumViewerWindowView.set_roi_alpha() change arg from index to name --- .../gui/windows/spectrum_viewer/view.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mantidimaging/gui/windows/spectrum_viewer/view.py b/mantidimaging/gui/windows/spectrum_viewer/view.py index 145e4e6c87d..6cd83bfabe9 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/view.py +++ b/mantidimaging/gui/windows/spectrum_viewer/view.py @@ -146,12 +146,13 @@ def on_visibility_change(self) -> None: if self.presenter.export_mode == ExportMode.ROI_MODE: roi_name, _, roi_visible = self.roi_table_model.row_data(roi_item) if roi_visible is False: - self.set_roi_alpha(0, roi_item) + self.set_roi_alpha(0, roi_name) else: - self.set_roi_alpha(255, roi_item) + self.set_roi_alpha(255, roi_name) self.presenter.redraw_spectrum(roi_name) else: - self.set_roi_alpha(0, roi_item) + roi_name, _, _ = self.roi_table_model.row_data(roi_item) + self.set_roi_alpha(0, roi_name) return @@ -242,20 +243,18 @@ def set_new_roi(self) -> None: """ self.presenter.do_add_roi() - def set_roi_alpha(self, alpha: float, roi) -> None: + def set_roi_alpha(self, alpha: float, roi_name: str) -> None: """ Set the alpha value for the selected ROI and update the spectrum to reflect the change. A check is made on the spectrum to see if it exists as it may not have been created yet. @param alpha: The alpha value """ - self.presenter.do_set_roi_alpha(self.roi_table_model.row_data(roi)[0], alpha) + self.presenter.do_set_roi_alpha(roi_name, alpha) if alpha == 0: - self.spectrum.spectrum_data_dict[self.roi_table_model.row_data(roi)[0]] = np.zeros( - self.spectrum.spectrum_data_dict[self.roi_table_model.row_data(roi)[0]].shape) + self.spectrum.spectrum_data_dict[roi_name] = np.zeros(self.spectrum.spectrum_data_dict[roi_name].shape) else: - self.spectrum.spectrum_data_dict[self.roi_table_model.row_data(roi)[0]] = self.spectrum.spectrum_data_dict[ - self.roi_table_model.row_data(roi)[0]] + self.spectrum.spectrum_data_dict[roi_name] = self.spectrum.spectrum_data_dict[roi_name] self.spectrum.spectrum.clearPlots() self.spectrum.spectrum.update() From 35ad142dbf15b579992fdcd9710db41cd87f9869 Mon Sep 17 00:00:00 2001 From: Sam Tygier Date: Thu, 26 Oct 2023 14:12:55 +0100 Subject: [PATCH 2/2] Remove pass through SpectrumViewerWindowPresenter.do_set_roi_alpha() --- mantidimaging/gui/windows/spectrum_viewer/presenter.py | 9 --------- mantidimaging/gui/windows/spectrum_viewer/view.py | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/mantidimaging/gui/windows/spectrum_viewer/presenter.py b/mantidimaging/gui/windows/spectrum_viewer/presenter.py index 6bed9c87043..3796921f4d3 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/presenter.py +++ b/mantidimaging/gui/windows/spectrum_viewer/presenter.py @@ -144,15 +144,6 @@ def redraw_all_rois(self) -> None: self.model.set_roi(name, self.view.spectrum.get_roi(name)) self.view.set_spectrum(name, self.model.get_spectrum(name, self.spectrum_mode)) - def do_set_roi_alpha(self, name: str, alpha: float) -> None: - """ - Set the alpha value of the ROI with the given name - - :param name: The name of the ROI - :param alpha: The new alpha value (0-255) - """ - self.view.spectrum.set_roi_alpha(name, alpha) - def handle_button_enabled(self) -> None: """ Enable the export button if the current stack is not None and normalisation is valid diff --git a/mantidimaging/gui/windows/spectrum_viewer/view.py b/mantidimaging/gui/windows/spectrum_viewer/view.py index 6cd83bfabe9..9a1aa45dd39 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/view.py +++ b/mantidimaging/gui/windows/spectrum_viewer/view.py @@ -250,7 +250,7 @@ def set_roi_alpha(self, alpha: float, roi_name: str) -> None: @param alpha: The alpha value """ - self.presenter.do_set_roi_alpha(roi_name, alpha) + self.spectrum.set_roi_alpha(roi_name, alpha) if alpha == 0: self.spectrum.spectrum_data_dict[roi_name] = np.zeros(self.spectrum.spectrum_data_dict[roi_name].shape) else: