diff --git a/mantidimaging/gui/windows/spectrum_viewer/presenter.py b/mantidimaging/gui/windows/spectrum_viewer/presenter.py index 761ec8ef1fa..5fa41f5244e 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/presenter.py +++ b/mantidimaging/gui/windows/spectrum_viewer/presenter.py @@ -78,7 +78,8 @@ def handle_normalise_stack_change(self, normalise_uuid: Optional['UUID']) -> Non return self.model.set_normalise_stack(self.main_window.get_stack(normalise_uuid)) self.view.set_normalise_error(self.model.normalise_issue()) - self.redraw_all_rois() + if self.view.normalisation_enabled(): + self.redraw_all_rois() def auto_find_flat_stack(self, new_dataset_id): if self.view.current_dataset_id != new_dataset_id: @@ -103,8 +104,6 @@ def show_new_sample(self) -> None: self.view.set_image(self.model.get_averaged_image()) self.view.spectrum.add_range(*self.model.tof_range) self.view.auto_range_image() - self.view.spectrum.reset_roi_size(self.model.get_image_shape()) - self.handle_roi_moved(True) def handle_range_slide_moved(self, tof_range) -> None: self.model.tof_range = tof_range @@ -181,8 +180,8 @@ def do_add_roi(self) -> None: """ roi_name = self.model.roi_name_generator() self.model.set_new_roi(roi_name) - self.view.set_spectrum(roi_name, self.model.get_spectrum(roi_name, self.spectrum_mode)) self.view.spectrum.add_roi(self.model.get_roi(roi_name), roi_name) + self.view.set_spectrum(roi_name, self.model.get_spectrum(roi_name, self.spectrum_mode)) self.view.auto_range_image() self.do_add_roi_to_table(roi_name) diff --git a/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py b/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py index 7848575e723..bc3b08f4fd1 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py +++ b/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py @@ -228,18 +228,3 @@ def rename_roi(self, old_name: str, new_name: str) -> None: if old_name in self.roi_dict.keys() and new_name not in self.roi_dict.keys(): self.roi_dict[new_name] = self.roi_dict.pop(old_name) self.spectrum_data_dict[new_name] = self.spectrum_data_dict.pop(old_name) - - def reset_roi_size(self, image_shape) -> None: - """ - Reset the size of the ROI to the maximum size of the image. - - @param image_shape: The shape of the image. - """ - roi_name = list(self.roi_dict.keys())[0] - height, width = image_shape - - self.roi_dict[roi_name].setSize([width, height]) - self.roi_dict[roi_name].setPos([0, 0]) - self.roi_dict[roi_name].maxBounds = self.roi_dict[roi_name].parentBounds() - self.image.vb.addItem(self.roi_dict[roi_name]) - self.roi_dict[roi_name].sigRegionChanged.connect(self.roi_changed.emit) diff --git a/mantidimaging/gui/windows/spectrum_viewer/test/spectrum_test.py b/mantidimaging/gui/windows/spectrum_viewer/test/spectrum_test.py index 27b73c3c0f7..bf3689d00a5 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/test/spectrum_test.py +++ b/mantidimaging/gui/windows/spectrum_viewer/test/spectrum_test.py @@ -161,17 +161,3 @@ def test_WHEN_rename_roi_called_with_default_roi_THEN_roi_name_not_changed(self) self.assertIn("roi_1", self.spectrum_widget.roi_dict.keys()) self.spectrum_widget.rename_roi("roi_1", "roi") self.assertIn("roi_1", self.spectrum_widget.roi_dict) - - def test_WHEN_reset_size_called_THEN_roi_size_reset(self): - image_shape = (100, 100) - spectrum_roi = SpectrumROI("roi", - self.sensible_roi, - pos=(0, 0), - rotatable=False, - scaleSnap=True, - translateSnap=True) - self.spectrum_widget.roi_dict["roi"] = spectrum_roi - self.spectrum_widget.spectrum_data_dict["roi"] = np.array([0, 0, 0, 0]) - self.spectrum_widget.reset_roi_size(image_shape) - img_x, img_y = spectrum_roi.size() - self.assertEqual((img_x, img_y), (100, 100)) diff --git a/mantidimaging/gui/windows/spectrum_viewer/view.py b/mantidimaging/gui/windows/spectrum_viewer/view.py index 4465d34dbe4..25deee64f34 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/view.py +++ b/mantidimaging/gui/windows/spectrum_viewer/view.py @@ -53,7 +53,7 @@ def __init__(self, main_window: 'MainWindowView'): self._current_dataset_id = None self.sampleStackSelector.stack_selected_uuid.connect(self.presenter.handle_sample_change) self.normaliseStackSelector.stack_selected_uuid.connect(self.presenter.handle_normalise_stack_change) - self.normaliseCheckBox.stateChanged.connect(self.set_normalise_dropdown_state) + self.normaliseCheckBox.stateChanged.connect(self.normaliseStackSelector.setEnabled) self.normaliseCheckBox.stateChanged.connect(self.presenter.handle_enable_normalised) # ROI action buttons @@ -158,12 +158,6 @@ def _configure_dropdown(self, selector: DatasetSelectorWidgetView) -> None: selector.presenter.show_stacks = True selector.subscribe_to_main_window(self.main_window) - def set_normalise_dropdown_state(self) -> None: - if self.normaliseCheckBox.isChecked(): - self.normaliseStackSelector.setEnabled(True) - else: - self.normaliseStackSelector.setEnabled(False) - def try_to_select_relevant_normalise_stack(self, name: str) -> None: self.normaliseStackSelector.try_to_select_relevant_stack(name) @@ -206,13 +200,16 @@ def set_normalise_error(self, norm_issue: str): self.display_normalise_error() def display_normalise_error(self): - if self.normalise_error_issue and self.normaliseCheckBox.isChecked(): + if self.normalise_error_issue and self.normalisation_enabled(): self.normaliseErrorIcon.setPixmap(self.normalise_error_icon_pixmap) self.normaliseErrorIcon.setToolTip(self.normalise_error_issue) else: self.normaliseErrorIcon.setPixmap(QPixmap()) self.normaliseErrorIcon.setToolTip("") + def normalisation_enabled(self): + return self.normaliseCheckBox.isChecked() + def set_new_roi(self) -> None: """ Set a new ROI on the image