diff --git a/docs/release_notes/next/feature-2046-ROI_Colors _table b/docs/release_notes/next/feature-2046-ROI_Colors _table new file mode 100644 index 00000000000..aee4c69e6fa --- /dev/null +++ b/docs/release_notes/next/feature-2046-ROI_Colors _table @@ -0,0 +1 @@ +#2046 : Enhancement: Implement Click Dialog for Changing ROI Colors in Table diff --git a/mantidimaging/gui/windows/spectrum_viewer/presenter.py b/mantidimaging/gui/windows/spectrum_viewer/presenter.py index 2b77a9aea23..a6946db0f92 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/presenter.py +++ b/mantidimaging/gui/windows/spectrum_viewer/presenter.py @@ -241,7 +241,7 @@ def change_roi_colour(self, roi_name: str, new_colour: tuple) -> None: """ if roi_name in self.view.spectrum_widget.roi_dict: self.view.spectrum_widget.roi_dict[roi_name].colour = new_colour - self.view.update_roi_color_in_table(roi_name, new_colour) + self.view.update_roi_color(roi_name, new_colour) def add_rits_roi(self) -> None: roi_name = ROI_RITS diff --git a/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py b/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py index d9f3e8902ca..aae1afbdf56 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py +++ b/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py @@ -43,9 +43,9 @@ def __init__(self, name: str, sensible_roi: SensibleROI, *args, **kwargs): self.roi.setAcceptedMouseButtons(Qt.MouseButton.LeftButton) self.menu = QMenu() - change_color_action = QAction("Change ROI Colour", self) - change_color_action.triggered.connect(self.onChangeColor) - self.menu.addAction(change_color_action) + self.change_color_action = QAction("Change ROI Colour", self) + self.change_color_action.triggered.connect(self.onChangeColor) + self.menu.addAction(self.change_color_action) def onChangeColor(self): current_color = QColor(*self._colour) diff --git a/mantidimaging/gui/windows/spectrum_viewer/view.py b/mantidimaging/gui/windows/spectrum_viewer/view.py index 2d875c3b47a..e24da73d5c2 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/view.py +++ b/mantidimaging/gui/windows/spectrum_viewer/view.py @@ -108,6 +108,7 @@ def __init__(self, main_window: 'MainWindowView'): self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows) self.tableView.setSelectionMode(QAbstractItemView.SingleSelection) self.tableView.setAlternatingRowColors(True) + self.tableView.clicked.connect(self.handle_table_click) # Roi Prop table self.roi_table_properties = ["Top", "Bottom", "Left", "Right"] @@ -340,10 +341,18 @@ def set_new_roi(self) -> None: spinbox.setEnabled(True) self.set_roi_properties() - def update_roi_color_in_table(self, roi_name: str, new_color: tuple): + def handle_table_click(self, index): + if index.isValid() and index.column() == 1: + roi_name = self.roi_table_model.index(index.row(), 0).data() + self.set_spectum_roi_color(roi_name) + + def set_spectum_roi_color(self, roi_name: str) -> None: + spectrum_roi = self.spectrum_widget.roi_dict[roi_name] + spectrum_roi.change_color_action.trigger() + + def update_roi_color(self, roi_name: str, new_color: tuple) -> None: """ Finds ROI by name in table and updates colour. - @param roi_name: Name of the ROI to update. @param new_color: The new color for the ROI in (R, G, B) format. """ @@ -354,7 +363,6 @@ def update_roi_color_in_table(self, roi_name: str, new_color: tuple): def find_row_for_roi(self, roi_name: str) -> Optional[int]: """ Returns row index for ROI name, or None if not found. - @param roi_name: Name ROI find. @return: Row index ROI or None. """