Source code for mantidimaging.gui.widgets.auto_colour_menu.auto_color_menu
# Copyright (C) 2024 ISIS Rutherford Appleton Laboratory UKRI
# SPDX - License - Identifier: GPL-3.0-or-later
from __future__ import annotations
from typing import TYPE_CHECKING
from PyQt5.QtWidgets import QAction
from mantidimaging.gui.widgets.palette_changer.view import PaletteChangerView
if TYPE_CHECKING:
from pyqtgraph import HistogramLUTItem
import numpy as np
from PyQt5.QtWidgets import QWidget
DEFAULT_MENU_POSITION = 12
[docs]
class AutoColorMenu:
"""
Mixin class to be used with MIImageView and MIMiniImageView
"""
def __init__(self) -> None:
self.auto_color_action: QAction | None = None
@property
def histogram(self) -> HistogramLUTItem:
raise NotImplementedError('Required histogram property not implemented')
@property
def image_data(self) -> np.ndarray:
raise NotImplementedError('Required image_data property not implemented')
@property
def other_histograms(self) -> list[HistogramLUTItem]:
return []
[docs]
def set_auto_color_enabled(self, enabled: bool = True) -> None:
if self.auto_color_action is not None:
self.auto_color_action.setEnabled(enabled)
def _on_colour_change_palette(self) -> None:
"""
Opens the Palette Changer window
"""
change_colour_palette = PaletteChangerView(parent=self.auto_color_parent,
main_hist=self.histogram,
image=self.image_data,
other_hists=self.other_histograms,
recon_mode=self.auto_color_recon_mode)
change_colour_palette.show()