Skip to content

Commit

Permalink
added get_roi back into model to remove later
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmeigh committed Dec 3, 2024
1 parent 2a1936c commit ebd1d10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions mantidimaging/gui/windows/spectrum_viewer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,3 +567,8 @@ 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]
4 changes: 1 addition & 3 deletions mantidimaging/gui/windows/spectrum_viewer/presenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,7 @@ 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._roi_ranges.get(roi_name)
if roi is None:
raise ValueError(f"ROI for {roi_name} is not valid.")
roi = self.model.get_roi(roi_name)
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)
Expand Down

0 comments on commit ebd1d10

Please sign in to comment.