Skip to content

Commit

Permalink
made suggested changes and removed set_roi from widget
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmeigh committed Jan 8, 2025
1 parent 3882445 commit af3a9b0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 20 deletions.
2 changes: 0 additions & 2 deletions mantidimaging/gui/windows/spectrum_viewer/presenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.view.spectrum_widget.set_roi(name, current_roi)
if force_new_spectrums:
spectrum = self.model.get_spectrum(
current_roi,
Expand Down Expand Up @@ -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.view.spectrum_widget.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:
Expand Down
10 changes: 0 additions & 10 deletions mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,6 @@ def get_roi(self, roi_name: str) -> SensibleROI:
else:
raise KeyError(f"ROI with name {roi_name} does not exist in self.roi_dict or and is not 'all'")

def set_roi(self, roi_name: str, new_roi: SensibleROI) -> None:
if roi_name not in self.roi_dict:
raise KeyError(f"ROI '{roi_name}' does not exist.")
roi = self.roi_dict[roi_name]

roi.blockSignals(True)
roi.setPos((new_roi.left, new_roi.top))
roi.setSize((new_roi.width, new_roi.height))
roi.blockSignals(False)

def remove_roi(self, roi_name: str) -> None:
"""
Remove a given ROI by name unless it is 'roi' or 'all'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,6 @@ def test_WHEN_roi_removed_THEN_roi_name_removed_from_list_of_roi_names(self):
self.spectrum_widget.remove_roi("new_roi")
self.assertListEqual(list(self.spectrum_widget.roi_dict.keys()), ["all", "roi"])

def test_set_roi_updates_position_and_size(self):
self.spectrum_widget.roi_dict["test_roi"] = SpectrumROI("test_roi", SensibleROI(10, 20, 30, 40))
new_roi = SensibleROI(50, 60, 120, 140)
self.spectrum_widget.set_roi("test_roi", new_roi)
roi = self.spectrum_widget.roi_dict["test_roi"]
self.assertEqual(roi.pos(), Point(50, 60))
self.assertEqual(roi.size(), Point(70, 80))

def test_WHEN_remove_roi_called_with_default_roi_THEN_raise_runtime_error(self):
self.spectrum_widget.roi_dict = {"all": mock.Mock(), "roi": mock.Mock()}
with self.assertRaises(RuntimeError):
Expand Down

0 comments on commit af3a9b0

Please sign in to comment.