Skip to content

Commit

Permalink
SpectrumViewerWindowView.set_roi_alpha() change arg from index to name
Browse files Browse the repository at this point in the history
  • Loading branch information
samtygier-stfc committed Oct 26, 2023
1 parent 09a4422 commit 1d08768
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions mantidimaging/gui/windows/spectrum_viewer/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,13 @@ def on_visibility_change(self) -> None:
if self.presenter.export_mode == ExportMode.ROI_MODE:
roi_name, _, roi_visible = self.roi_table_model.row_data(roi_item)
if roi_visible is False:
self.set_roi_alpha(0, roi_item)
self.set_roi_alpha(0, roi_name)
else:
self.set_roi_alpha(255, roi_item)
self.set_roi_alpha(255, roi_name)
self.presenter.redraw_spectrum(roi_name)
else:
self.set_roi_alpha(0, roi_item)
roi_name, _, _ = self.roi_table_model.row_data(roi_item)
self.set_roi_alpha(0, roi_name)

return

Expand Down Expand Up @@ -242,20 +243,18 @@ def set_new_roi(self) -> None:
"""
self.presenter.do_add_roi()

def set_roi_alpha(self, alpha: float, roi) -> None:
def set_roi_alpha(self, alpha: float, roi_name: str) -> None:
"""
Set the alpha value for the selected ROI and update the spectrum to reflect the change.
A check is made on the spectrum to see if it exists as it may not have been created yet.
@param alpha: The alpha value
"""
self.presenter.do_set_roi_alpha(self.roi_table_model.row_data(roi)[0], alpha)
self.presenter.do_set_roi_alpha(roi_name, alpha)
if alpha == 0:
self.spectrum.spectrum_data_dict[self.roi_table_model.row_data(roi)[0]] = np.zeros(
self.spectrum.spectrum_data_dict[self.roi_table_model.row_data(roi)[0]].shape)
self.spectrum.spectrum_data_dict[roi_name] = np.zeros(self.spectrum.spectrum_data_dict[roi_name].shape)
else:
self.spectrum.spectrum_data_dict[self.roi_table_model.row_data(roi)[0]] = self.spectrum.spectrum_data_dict[
self.roi_table_model.row_data(roi)[0]]
self.spectrum.spectrum_data_dict[roi_name] = self.spectrum.spectrum_data_dict[roi_name]

self.spectrum.spectrum.clearPlots()
self.spectrum.spectrum.update()
Expand Down

0 comments on commit 1d08768

Please sign in to comment.