diff --git a/mantidimaging/gui/windows/spectrum_viewer/model.py b/mantidimaging/gui/windows/spectrum_viewer/model.py index 50b0ab4c085..0bd036df350 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/model.py +++ b/mantidimaging/gui/windows/spectrum_viewer/model.py @@ -128,7 +128,11 @@ def set_stack(self, stack: ImageStack | None) -> None: self.tof_range = (0, stack.data.shape[0] - 1) self.tof_range_full = self.tof_range self.tof_data = self.get_stack_time_of_flight() - self.set_new_roi(ROI_ALL) + height, width = self.get_image_shape() + self._roi_ranges[ROI_ALL] = SensibleROI.from_list([0, 0, width, height]) + + def set_normalise_stack(self, normalise_stack: ImageStack | None) -> None: + self._normalise_stack = normalise_stack def set_new_roi(self, name: str) -> None: """ @@ -137,13 +141,7 @@ def set_new_roi(self, name: str) -> None: @param name: The name of the new ROI """ height, width = self.get_image_shape() - self.set_roi(name, SensibleROI.from_list([0, 0, width, height])) - - def set_normalise_stack(self, normalise_stack: ImageStack | None) -> None: - self._normalise_stack = normalise_stack - - def set_roi(self, roi_name: str, roi: SensibleROI) -> None: - self._roi_ranges[roi_name] = roi + self._roi_ranges[name] = SensibleROI.from_list([0, 0, width, height]) def get_averaged_image(self) -> np.ndarray | None: """ diff --git a/mantidimaging/gui/windows/spectrum_viewer/presenter.py b/mantidimaging/gui/windows/spectrum_viewer/presenter.py index 891d6c65d08..0dbfcfdf2b9 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/presenter.py +++ b/mantidimaging/gui/windows/spectrum_viewer/presenter.py @@ -202,7 +202,6 @@ def handle_roi_moved(self, force_new_spectrums: bool = False) -> None: """ for name in self.view.spectrum_widget.roi_dict: current_roi = self.view.spectrum_widget.get_roi(name) - self.model.set_roi(name, current_roi) if force_new_spectrums: spectrum = self.model.get_spectrum( current_roi, @@ -429,7 +428,6 @@ def change_selected_menu_option(self, opt: str) -> None: def do_adjust_roi(self) -> None: new_roi = self.convert_spinbox_roi_to_SensibleROI(self.view.roiPropertiesSpinBoxes) - self.model.set_roi(self.view.current_roi_name, new_roi) self.view.spectrum_widget.adjust_roi(new_roi, self.view.current_roi_name) def handle_storing_current_roi_name_on_tab_change(self) -> None: diff --git a/mantidimaging/gui/windows/spectrum_viewer/test/model_test.py b/mantidimaging/gui/windows/spectrum_viewer/test/model_test.py index 5597cff8b29..33533ec719d 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/test/model_test.py +++ b/mantidimaging/gui/windows/spectrum_viewer/test/model_test.py @@ -228,7 +228,7 @@ def test_save_rits_roi_dat(self): norm = ImageStack(np.full([10, 11, 12], 2)) stack.data[:, :, :5] *= 2 self.model.set_new_roi("rits_roi") - self.model.set_roi("rits_roi", SensibleROI.from_list([0, 0, 10, 11])) + self.model._roi_ranges["rits_roi"] = SensibleROI.from_list([0, 0, 10, 11]) self.model.set_normalise_stack(norm) self.model._roi_ranges["ROI_RITS"] = SensibleROI.from_list([0, 0, 10, 11]) @@ -475,7 +475,7 @@ def test_save_single_rits_spectrum(self, mock_save_rits_roi): norm = ImageStack(np.full([10, 11, 12], 2)) stack.data[:, :, :5] *= 2 self.model.set_new_roi("rits_roi") - self.model.set_roi("rits_roi", SensibleROI.from_list([0, 0, 5, 5])) + self.model._roi_ranges["rits_roi"] = SensibleROI.from_list([0, 0, 5, 5]) self.model.set_normalise_stack(norm) self.model._roi_ranges["ROI_RITS"] = SensibleROI.from_list([0, 0, 5, 5]) @@ -490,7 +490,7 @@ def test_save_rits_correct_transmision(self, mock_save_rits_roi): for i in range(10): stack.data[:, :, i] *= i self.model.set_new_roi("rits_roi") - self.model.set_roi("rits_roi", SensibleROI.from_list([1, 0, 6, 4])) + self.model._roi_ranges["rits_roi"] = SensibleROI.from_list([1, 0, 6, 4]) self.model.set_normalise_stack(norm) mock_path = mock.create_autospec(Path, instance=True)