diff --git a/mantidimaging/gui/test/gui_system_spectrum_test.py b/mantidimaging/gui/test/gui_system_spectrum_test.py index 49b37d6aa4c..56b6f8ae47e 100644 --- a/mantidimaging/gui/test/gui_system_spectrum_test.py +++ b/mantidimaging/gui/test/gui_system_spectrum_test.py @@ -118,7 +118,7 @@ def test_adjust_roi(self): roi_widget.movePoint(handle_index, new_position) QTest.qWait(SHORT_DELAY) - updated_roi = self.spectrum_window.presenter.model.get_roi(roi_name) + updated_roi = self.spectrum_window.presenter.view.spectrum_widget.get_roi(roi_name) self.assertEqual(updated_roi.right, new_position[0]) self.assertEqual(updated_roi.bottom, new_position[1]) self.assertEqual(updated_roi.top, 0) diff --git a/mantidimaging/gui/windows/spectrum_viewer/model.py b/mantidimaging/gui/windows/spectrum_viewer/model.py index 9044fbb70ea..dda8097fb50 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/model.py +++ b/mantidimaging/gui/windows/spectrum_viewer/model.py @@ -567,8 +567,3 @@ def set_tof_unit_mode_for_stack(self) -> None: else: self.tof_mode = ToFUnitMode.WAVELENGTH self.presenter.change_selected_menu_option("Wavelength") - - def get_roi(self, roi_name: str) -> SensibleROI: - if roi_name not in self._roi_ranges.keys(): - raise KeyError(f"ROI {roi_name} does not exist in roi_ranges {self._roi_ranges.keys()}") - return self._roi_ranges[roi_name] diff --git a/mantidimaging/gui/windows/spectrum_viewer/presenter.py b/mantidimaging/gui/windows/spectrum_viewer/presenter.py index 9a7d4b4293d..1a5aa58605e 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/presenter.py +++ b/mantidimaging/gui/windows/spectrum_viewer/presenter.py @@ -331,7 +331,9 @@ def do_add_roi(self) -> None: if roi_name in self.view.spectrum_widget.roi_dict: raise ValueError(f"ROI name already exists: {roi_name}") self.model.set_new_roi(roi_name) - roi = self.model.get_roi(roi_name) + roi = self.model._roi_ranges.get(roi_name) + if roi is None: + raise ValueError(f"ROI for {roi_name} is not valid.") self.view.spectrum_widget.add_roi(roi, roi_name) spectrum = self.model.get_spectrum(roi, self.spectrum_mode, self.view.shuttercount_norm_enabled()) self.view.set_spectrum(roi_name, spectrum) @@ -456,4 +458,4 @@ def check_action(action: QAction, param: bool) -> None: def convert_spinbox_roi_to_SensibleROI(self, spinboxes: dict[str, QSpinBox]) -> SensibleROI: roi_iter_order = ["Left", "Top", "Right", "Bottom"] new_points = [spinboxes[prop].value() for prop in roi_iter_order] - return SensibleROI.from_list(new_points) + return SensibleROI.from_list(new_points) \ No newline at end of file