Skip to content
Snippets Groups Projects
Commit 4c98ad9c authored by Stephen's avatar Stephen
Browse files

Adding ABCMeta class to interfaces

parent 52dbf014
No related branches found
No related tags found
No related merge requests found
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
# Copyright © 2020 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
......@@ -8,8 +8,7 @@ import abc
from typing import List
class PlottingCanvasPresenterInterface(object):
__metaclass__ = abc.ABCMeta
class PlottingCanvasPresenterInterface(abc.ABC):
@abc.abstractmethod
def plot_workspaces(self, workspace_names: List[str], workspace_indices: List[int],
......
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
import abc
from typing import List
from qtpy import QtWidgets
from Muon.GUI.Common.plotting_widget.plotting_canvas_model import WorkspacePlotInformation
# This metaclass is required in order to implement the (strict) interface for the QtWidget
class PlottingViewMeta(type(QtWidgets.QWidget), abc.ABCMeta):
pass
class PlottingCanvasViewInterface(metaclass=PlottingViewMeta):
@property
@abc.abstractmethod
def num_plotted_workspaces(self):
"""Number of workspaces plotted in the figure"""
pass
@property
@abc.abstractmethod
def number_of_axes(self):
"""Number of axes present in the figure"""
pass
@abc.abstractmethod
def create_new_plot_canvas(self, num_axes):
"""Creates a new blank plotting canvas"""
pass
@abc.abstractmethod
def clear_all_workspaces_from_plot(self):
"""Clears all workspaces from the plot"""
pass
@abc.abstractmethod
def add_workspaces_to_plot(self, workspace_plot_info_list: List[WorkspacePlotInformation]):
"""Add a list of workspaces to the plot - The workspaces are contained in a list PlotInformation
The PlotInformation contains the workspace name, workspace index and target axis."""
pass
@abc.abstractmethod
def remove_workspace_from_plot(self, workspace):
"""Remove a list of workspaces to the plot - The workspaces are contained in a list PlotInformation
The PlotInformation contains the workspace name, workspace index and target axis."""
pass
@abc.abstractmethod
def replace_specified_workspace_in_plot(self, workspace):
"""Replace specified workspace in the plot with a new and presumably updated instance"""
pass
@abc.abstractmethod
def replot_workspace_with_error_state(self, workspace_name, with_errors: bool):
"""Replace specified workspace in the plot with a new and presumably updated instance"""
pass
@abc.abstractmethod
def set_axis_xlimits(self, axis_number, xlims):
"""Set the xlimits of the specified axis"""
pass
@abc.abstractmethod
def set_axis_ylimits(self, axis_number, ylims):
"""Set the ylimits of the specified axis"""
pass
@abc.abstractmethod
def set_title(self, axis_number, title):
"""Set the title of the specified axis"""
pass
@abc.abstractmethod
def get_axis_limits(self, axis_number):
"""Get the x and y limits if the specified axis"""
pass
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2020 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
from Muon.GUI.FrequencyDomainAnalysis.frequency_context import FREQUENCY_EXTENSIONS
COUNTS_PLOT_TYPE = 'Counts'
ASYMMETRY_PLOT_TYPE = 'Asymmetry'
TILED_BY_GROUP_TYPE = 'Group/Pair'
TILED_BY_RUN_TYPE = 'Run'
FREQ_PLOT_TYPE = "Frequency "
class PlotWidgetModel(object):
def __init__(self, context):
self.context = context
@property
def tiled_by_group(self):
return TILED_BY_GROUP_TYPE
@property
def tiled_by_run(self):
return TILED_BY_RUN_TYPE
@property
def counts_plot(self):
return COUNTS_PLOT_TYPE
@property
def asymmetry_plot(self):
return ASYMMETRY_PLOT_TYPE
def get_workspace_list_to_plot(self, is_raw, plot_type):
"""
:return: a list of workspace names to plot
"""
workspace_list = self.get_workspaces_to_plot(is_raw, plot_type)
return workspace_list
def get_workspace_list_and_indices_to_plot(self, is_raw, plot_type):
"""
:return: a list of workspace names to plot
"""
workspace_list = self.get_workspaces_to_plot(is_raw, plot_type)
indices = self._generate_run_indicies(workspace_list)
return workspace_list, indices
def get_workspace_and_indices_for_group_or_pair(self, group_or_pair, is_raw, plot_type):
"""
:return: a list of workspace names and corresponding indices to plot
"""
workspace_list = []
if FREQ_PLOT_TYPE in plot_type:
workspace_list += self.get_freq_workspaces_to_plot(group_or_pair, plot_type)
else:
workspace_list += self.get_time_workspaces_to_plot(group_or_pair, is_raw, plot_type)
indices = self._generate_run_indicies(workspace_list)
return workspace_list, indices
def get_workspaces_to_plot(self, is_raw, plot_type):
"""
:param is_raw: Whether to use raw or rebinned data
:param plot_type: plotting type, e.g Counts, Frequency Re
:return: a list of workspace names
"""
currently_selected_groups = self.context.group_pair_context.selected_groups
currently_selected_pairs = self.context.group_pair_context.selected_pairs
workspace_list = []
if FREQ_PLOT_TYPE in plot_type:
for grouppair in currently_selected_groups + currently_selected_pairs:
workspace_list += self.get_freq_workspaces_to_plot(grouppair, plot_type)
return workspace_list
else:
for grouppair in currently_selected_groups + currently_selected_pairs:
workspace_list += self.get_time_workspaces_to_plot(grouppair, is_raw, plot_type)
return workspace_list
def get_freq_workspaces_to_plot(self, current_group_pair, plot_type):
"""
:param current_group_pair: The group/pair currently selected
:param plot_type: Whether to plot counts or asymmetry
:return: a list of workspace names
"""
try:
runs = ""
seperator = ""
for run in self.context.data_context.current_runs:
runs += seperator + str(run[0])
seperator = ", "
workspace_list = self.context.get_names_of_frequency_domain_workspaces_to_fit(
runs, current_group_pair, True, plot_type[len(FREQ_PLOT_TYPE):])
return workspace_list
except AttributeError:
return []
def get_time_workspaces_to_plot(self, current_group_pair, is_raw, plot_type):
"""
:param current_group_pair: The group/pair currently selected
:param is_raw: Whether to use raw or rebinned data
:param plot_type: Whether to plot counts or asymmetry
:return: a list of workspace names
"""
try:
if is_raw:
workspace_list = self.context.group_pair_context[current_group_pair].get_asymmetry_workspace_names(
self.context.data_context.current_runs)
else:
workspace_list = self.context.group_pair_context[
current_group_pair].get_asymmetry_workspace_names_rebinned(
self.context.data_context.current_runs)
if plot_type == COUNTS_PLOT_TYPE:
workspace_list = [item.replace(ASYMMETRY_PLOT_TYPE, COUNTS_PLOT_TYPE)
for item in workspace_list if ASYMMETRY_PLOT_TYPE in item]
return workspace_list
except AttributeError:
return []
def create_tiled_keys(self, tiled_by):
if tiled_by == TILED_BY_GROUP_TYPE:
keys = self.context.group_pair_context.selected_groups + self.context.group_pair_context.selected_pairs
else:
keys = [str(item) for sublist in self.context.data_context.current_runs for item in sublist]
return keys
def get_tiled_by_types(self):
return [TILED_BY_GROUP_TYPE, TILED_BY_RUN_TYPE]
def get_plot_types(self):
plot_types = [ASYMMETRY_PLOT_TYPE, COUNTS_PLOT_TYPE]
if self.context._frequency_context:
for ext in FREQUENCY_EXTENSIONS.keys():
plot_types.insert(FREQ_PLOT_TYPE + FREQUENCY_EXTENSIONS[ext])
plot_types.insert(FREQ_PLOT_TYPE + "All")
return plot_types
def _generate_run_indicies(self, workspace_list):
indices = [0 for _ in workspace_list]
return indices
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
# Copyright © 2020 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
import re
from time import sleep
from Muon.GUI.Common.home_tab.home_tab_presenter import HomeTabSubWidget
from Muon.GUI.Common.plotting_widget.external_plotting_model import ExternalPlottingModel
from Muon.GUI.Common.plotting_widget.external_plotting_view import ExternalPlottingView
from Muon.GUI.Common.plotting_widget.plotting_canvas_presenter_interface import PlottingCanvasPresenterInterface
from Muon.GUI.Common.plotting_widget.plotting_widget_view1 import PlotWidgetView1
from Muon.GUI.Common.plotting_widget.plotting_widget_model1 import PlotWidgetModel
from Muon.GUI.Common.plotting_widget.plotting_widget_view_interface import PlottingWidgetViewInterface
from mantidqt.utils.observer_pattern import GenericObservable, GenericObserver, GenericObserverWithArgPassing
from Muon.GUI.Common.utilities.run_string_utils import run_list_to_string
from Muon.GUI.FrequencyDomainAnalysis.frequency_context import FREQUENCY_EXTENSIONS
from Muon.GUI.Common.plotting_widget.workspace_finder import WorkspaceFinder
from Muon.GUI.Common.ADSHandler.workspace_naming import TF_ASYMMETRY_PREFIX
COUNTS_PLOT_TYPE = 'Counts'
ASYMMETRY_PLOT_TYPE = 'Asymmetry'
TILED_BY_GROUP_TYPE = 'Group/Pair'
TILED_BY_RUN_TYPE = 'Run'
class PlotWidgetPresenterCommmon(HomeTabSubWidget):
class PlotWidgetPresenterCommon(HomeTabSubWidget):
def __init__(self, view: PlottingWidgetViewInterface, model, context,
def __init__(self, view: PlottingWidgetViewInterface, model: PlotWidgetModel, context,
figure_presenter: PlottingCanvasPresenterInterface):
"""
:param view: A reference to the QWidget object for plotting
......@@ -40,23 +28,24 @@ class PlotWidgetPresenterCommmon(HomeTabSubWidget):
self._view = view
self._model = model
self.context = context
self.workspace_finder = WorkspaceFinder(self.context)
self._model = self.workspace_finder
# figure presenter - the common presenter talks to this through an interface
self._figure_presenter = figure_presenter
self._plotting_view = ExternalPlottingView()
self._plotting_model = ExternalPlottingModel()
# gui observers
self._setup_gui_observers()
# Connect to the view
self._view.on_plot_tiled_checkbox_changed(self.handle_plot_tiled_state_changed)
self._view.on_tiled_by_type_changed(self.handle_tiled_by_type_changed)
self._view.on_plot_type_changed(self.handle_plot_type_changed)
self._setup_view_connections()
# setup view options
self._view.setup_plot_type_options([ASYMMETRY_PLOT_TYPE, COUNTS_PLOT_TYPE])
self._view.setup_tiled_by_options(([TILED_BY_GROUP_TYPE, TILED_BY_RUN_TYPE]))
self.update_view_from_model()
def update_view_from_model(self):
""""Updates the view based on data in the model """
plot_types = self._model.get_plot_types()
self._view.setup_plot_type_options(plot_types)
tiled_types = self._model.get_tiled_by_types()
self._view.setup_tiled_by_options(tiled_types)
def _setup_gui_observers(self):
self.input_workspace_observer = GenericObserver(self.handle_data_updated)
......@@ -64,23 +53,32 @@ class PlotWidgetPresenterCommmon(HomeTabSubWidget):
self.workspace_replaced_in_ads_observer = GenericObserverWithArgPassing(self.handle_workspace_replaced_in_ads)
self.added_group_or_pair_observer = GenericObserverWithArgPassing(
self.handle_added_or_removed_group_or_pair_to_plot)
self.instrument_observer = GenericObserver(self.handle_instrument_changed)
def _setup_view_connections(self):
self._view.on_plot_tiled_checkbox_changed(self.handle_plot_tiled_state_changed)
self._view.on_tiled_by_type_changed(self.handle_tiled_by_type_changed)
self._view.on_plot_type_changed(self.handle_plot_type_changed)
self._view.on_external_plot_pressed(self.handle_external_plot_requested)
self._view.on_rebin_options_changed(self.handle_use_raw_workspaces_changed)
def handle_data_updated(self):
"""
Handles the group, pair calculation finishing
"""
if self._view.tiled_plot_checkbox.isChecked():
if self._view.is_tiled_plot():
tiled_by = self._view.tiled_by()
keys = self._create_tiled_keys(tiled_by)
keys = self._model.create_tiled_keys(tiled_by)
self._figure_presenter.create_tiled_plot(keys, tiled_by)
workspace_list = self.workspace_finder.get_workspace_list_to_plot(True, self._view.get_plot_type())
indices = [0 for _ in range(len(workspace_list))]
workspace_list, indices = self._model.get_workspace_list_and_indices_to_plot(self._view.is_raw_plot(),
self._view.get_plot_type())
self._figure_presenter.plot_workspaces(workspace_list, indices, hold_on=False, autoscale=False)
def handle_workspace_deleted_from_ads(self, workspace):
"""
Handles the workspace being deleted from ads
Handles a workspace being deleted from ads by removing the workspace from the plot
"""
workspace_name = workspace.name()
plotted_workspaces, _ = self._figure_presenter.get_plotted_workspaces_and_indices()
......@@ -89,7 +87,7 @@ class PlotWidgetPresenterCommmon(HomeTabSubWidget):
def handle_workspace_replaced_in_ads(self, workspace):
"""
Handles the use raw workspaces being changed (e.g rebinned) in ads
Handles the use raw workspaces being changed (e.g rebinned) in the ADS.
"""
workspace_name = workspace.name()
plotted_workspaces, _ = self._figure_presenter.get_plotted_workspaces_and_indices()
......@@ -98,42 +96,58 @@ class PlotWidgetPresenterCommmon(HomeTabSubWidget):
def handle_plot_type_changed(self):
"""
Handles the use raw workspaces being changed (e.g rebinned) in ads
Handles the plot type being changed in the view by plotting the workspaces corresponding to the new plot type
"""
if len(self.context.group_pair_context.selected_pairs) != 0 and self._view.get_selected() == COUNTS_PLOT_TYPE:
self._view.plot_selector.blockSignals(True)
self._view.plot_selector.setCurrentText(ASYMMETRY_PLOT_TYPE)
self._view.plot_selector.blockSignals(False)
self._view.warning_popup(
'Pair workspaces have no counts workspace, plotting Asymmetry')
self._check_if_counts_and_groups_selected()
workspace_list = self.workspace_finder.get_workspace_list_to_plot(True, self._view.get_plot_type())
indices = [0 for _ in range(len(workspace_list))]
workspace_list, indices = self._model.get_workspace_list_and_indices_to_plot(self._view.is_raw_plot(),
self._view.get_plot_type())
self._figure_presenter.plot_workspaces(workspace_list, indices, hold_on=False, autoscale=True)
def handle_plot_tiled_state_changed(self):
"""
Handles the use raw workspaces being changed (e.g rebinned) in ads
Handles the tiled plots checkbox being changed in the view. This leads to two behaviors:
If switching to tiled plot, create a new figure based on the number of tiles and replot the data
If switching from a tiled plot, create a new single figure and replot the data
"""
if self._view.tiled_plot_checkbox.isChecked():
if self._view.is_tiled_plot():
tiled_by = self._view.tiled_by()
keys = self._create_tiled_keys(tiled_by)
keys = self._model.create_tiled_keys(tiled_by)
self._figure_presenter.convert_plot_to_tiled_plot(keys, tiled_by)
else:
self._figure_presenter.convert_plot_to_single_plot()
def handle_tiled_by_type_changed(self):
"""
Handles the use raw workspaces being changed (e.g rebinned) in ads
Handles the tiled type changing, this will cause the tiles (and the key for each tile) to change.
This is handled by generating the new keys and replotting the data based on these new tiles.
"""
if not self._view.tiled_plot_checkbox.isChecked():
if not self._view.is_tiled_plot():
return
tiled_by = self._view.tiled_by()
keys = self._create_tiled_keys(tiled_by)
keys = self._model.create_tiled_keys(tiled_by)
self._figure_presenter.convert_plot_to_tiled_plot(keys, tiled_by)
def handle_rebin_options_changed(self):
pass
"""
Handles rebin options changed on the home tab
"""
if self.context._do_rebin():
self._view.set_raw_checkbox_state(False)
else:
self._view.set_raw_checkbox_state(True)
def handle_use_raw_workspaces_changed(self):
"""
Handles plot raw changed in view
"""
if not self._view.is_raw_plot() and not self.context._do_rebin():
self._view.set_raw_checkbox_state(True)
self._view.warning_popup('No rebin options specified')
return
workspace_list, indices = self._model.get_workspace_list_and_indices_to_plot(self._view.is_raw_plot(),
self._view.get_plot_type())
self._figure_presenter.plot_workspaces(workspace_list, indices, hold_on=False, autoscale=False)
def handle_added_or_removed_group_or_pair_to_plot(self, group_pair_info):
"""
......@@ -151,21 +165,12 @@ class PlotWidgetPresenterCommmon(HomeTabSubWidget):
"""
Handles a group or pair being added from the view
"""
if len(self.context.group_pair_context.selected_pairs) != 0 and self._view.get_selected() == COUNTS_PLOT_TYPE:
self._view.plot_selector.blockSignals(True)
self._view.plot_selector.setCurrentText(ASYMMETRY_PLOT_TYPE)
self._view.plot_selector.blockSignals(False)
self._view.warning_popup(
'Pair workspaces have no counts workspace, plotting Asymmetry')
# # if tiled by group, we will need to recreate the tiles
if self._view.tiled_plot_checkbox.isChecked() and self._view.tiled_by() == TILED_BY_GROUP_TYPE:
self._check_if_counts_and_groups_selected()
# if tiled by group, we will need to recreate the tiles
if self._view.is_tiled_plot() and self._view.tiled_by() == self._model.tiled_by_group:
tiled_by = self._view.tiled_by()
keys = self._create_tiled_keys(tiled_by)
keys = self._model.create_tiled_keys(tiled_by)
self._figure_presenter.create_tiled_plot(keys, tiled_by)
workspace_list = self.workspace_finder.get_workspace_list_to_plot(True, self._view.get_plot_type())
indices = [0 for _ in range(len(workspace_list))]
self._figure_presenter.plot_workspaces(workspace_list, indices, hold_on=False, autoscale=False)
workspace_list, indices = self._model.get_workspace_and_indices_for_group_or_pair \
(group_or_pair_name, is_raw=True, plot_type=self._view.get_plot_type())
......@@ -175,31 +180,38 @@ class PlotWidgetPresenterCommmon(HomeTabSubWidget):
"""
Handles a group or pair being removed in grouping widget analysis table
"""
# # if tiled by group, we will need to recreate the tiles
if self._view.tiled_plot_checkbox.isChecked() and self._view.tiled_by() == TILED_BY_GROUP_TYPE:
# tiled by group, we will need to recreate the tiles
if self._view.is_tiled_plot() and self._view.tiled_by() == self._model.tiled_by_group:
tiled_by = self._view.tiled_by()
keys = self._create_tiled_keys(tiled_by)
keys = self._model.create_tiled_keys(tiled_by)
self._figure_presenter.create_tiled_plot(keys, tiled_by)
workspace_list = self.workspace_finder.get_workspace_list_to_plot(True, self._view.get_plot_type())
indices = [0 for _ in range(len(workspace_list))]
self._figure_presenter.plot_workspaces(workspace_list, indices, hold_on=False, autoscale=False)
workspace_list, indices = self._model.get_workspace_and_indices_for_group_or_pair \
(group_or_pair_name, is_raw=True, plot_type=self._view.get_plot_type())
(group_or_pair_name, is_raw=True, plot_type=self._view.get_plot_type())
self._figure_presenter.remove_workspace_names_from_plot(workspace_list)
def handle_instrument_changed(self):
pass
# Interface to plotting
# def plot_run_and_fit_workspaces(self, workspaces):
# pass
# #self._figure_presenter.plot_workspaces(workspace_list, indices, hold_on=True, autoscale=False)
def handle_external_plot_requested(self):
"""
Handles an external plot request
"""
axes = self._figure_presenter.get_fig_axes()
external_fig = self._plotting_view.create_external_plot_window(axes)
data = self._plotting_model.get_plotted_workspaces_and_indices_from_axes(axes)
self._plotting_view.plot_data(external_fig, data)
self._plotting_view.copy_axes_setup(external_fig, axes)
self._plotting_view.show(external_fig)
def _create_tiled_keys(self, tiled_by):
if tiled_by == TILED_BY_GROUP_TYPE:
keys = self.context.group_pair_context.selected_groups + self.context.group_pair_context.selected_pairs
else:
keys = [str(item) for sublist in self.context.data_context.current_runs for item in sublist]
return keys
def handle_instrument_changed(self):
"""
Handles the instrument being changed by creating a blank plot window
"""
self._figure_presenter.create_single_plot()
def _check_if_counts_and_groups_selected(self):
if len(self.context.group_pair_context.selected_pairs) != 0 and \
self._view.get_selected() == self._model.counts_plot:
self._view.plot_selector.blockSignals(True)
self._view.plot_selector.setCurrentText(self._model.asymmetry_plot)
self._view.plot_selector.blockSignals(False)
self._view.warning_popup(
'Pair workspaces have no counts workspace, plotting Asymmetry')
......@@ -44,6 +44,9 @@
<property name="text">
<string>Plot raw</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
......
......@@ -24,6 +24,9 @@ class PlotWidgetView1(QtWidgets.QWidget, PlottingWidgetViewInterface, ui_plottin
self.setupUi(self)
def setup_plot_type_options(self, options):
"""
Setup the options which are displayed in the plot type combo box
"""
self.plot_type_combo.blockSignals(True)
self.plot_type_combo.clear()
for option in options:
......@@ -31,6 +34,9 @@ class PlotWidgetView1(QtWidgets.QWidget, PlottingWidgetViewInterface, ui_plottin
self.plot_type_combo.blockSignals(False)
def setup_tiled_by_options(self, options):
"""
Setup to options which are shown in the tiled plots combo box
"""
self.tiled_by_combo.blockSignals(True)
self.tiled_by_combo.clear()
for option in options:
......@@ -38,29 +44,69 @@ class PlotWidgetView1(QtWidgets.QWidget, PlottingWidgetViewInterface, ui_plottin
self.tiled_by_combo.blockSignals(False)
def add_canvas_widget(self, canvas_widget):
"""
Adds the canvas widget (where the plotting will occur) to the widget view.
"""
canvas_layout = QtWidgets.QHBoxLayout(self)
self.canvasFrame.setLayout(canvas_layout)
canvas_layout.addWidget(canvas_widget)
def get_plot_type(self):
"""
Returns the current plot type
"""
return self.plot_type_combo.currentText()
def is_data_rebinned(self): pass
def is_tiled_plot(self):
"""
Checks if tiled plot is currently requested
"""
return self.tiled_plot_checkbox.isChecked()
def is_tiled_plot(self): pass
def is_raw_plot(self):
"""
Checks if plotting raw data
"""
return self.plot_raw_checkbox.isChecked()
def tiled_by(self):
"""
Returns the option which is currently selected in the 'tiled by' combo box
"""
return self.tiled_by_combo.currentText()
def on_plot_type_changed(self, slot):
"""
Connect the plot_type combo box to the input slot
"""
self.plot_type_combo.currentIndexChanged.connect(slot)
def on_plot_tiled_checkbox_changed(self, slot):
"""
Connect the tiled_plot checkbox to the input slot
"""
self.tiled_plot_checkbox.stateChanged.connect(slot)
def on_tiled_by_type_changed(self, slot):
"""
Connect the tiled_by combo box to the input slot
"""
self.tiled_by_combo.currentIndexChanged.connect(slot)
def on_rebin_options_changed(self, slot): pass
def on_external_plot_pressed(self, slot): pass
def on_rebin_options_changed(self, slot):
"""
Connect the plot_rebin checkbox to the input slot
"""
self.plot_raw_checkbox.clicked.connect(slot)
def on_external_plot_pressed(self, slot):
"""
Connect the external plot button to the input slot
"""
self.external_plot_button.clicked.connect(slot)
def set_raw_checkbox_state(self, state):
"""
Sets the raw checkbox state, which can be controlled externally through the home tab.
"""
self.plot_raw_checkbox.setChecked(state)
from abc import abstractmethod
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright &copy; 2020 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
from abc import abstractmethod, ABCMeta
from qtpy import QtWidgets
# THe purpose of this abstraction is to allow for changes in the plotting (view)
# These are somewhat planned, as a future goal the standard workbench plotting should
# be used in the GUI, as it provides far more flexibility.
class PlottingWidgetViewInterface(object):
# This metaclass is required in order to implement the (strict) interface for the QtWidget
class PlottingWidgetViewMeta(type(QtWidgets.QWidget), ABCMeta):
pass
# define some methods that the view must have
def __init__(self):
pass
@abstractmethod
def setup_plot_type_options(self, options): pass
class PlottingWidgetViewInterface(metaclass=PlottingWidgetViewMeta):
@abstractmethod
def setup_tiled_by_options(self, options): pass
def setup_plot_type_options(self, options):
"""
Setup the options which are displayed in the plot type combo box
"""
pass
@abstractmethod
def get_plot_type(self): pass
def setup_tiled_by_options(self, options):
"""
Setup to options which are shown in the tiled plots combo box
"""
pass
@abstractmethod
def is_data_rebinned(self): pass
def add_canvas_widget(self, canvas_widget):
"""
Adds the canvas widget (where the plotting will occur) to the widget view.
"""
pass
@abstractmethod
def is_tiled_plot(self): pass
def get_plot_type(self):
"""
Returns the current plot type
"""
pass
@abstractmethod
def tiled_by(self): pass
def is_tiled_plot(self):
"""
Checks if tiled plot is currently requested
"""
pass
@abstractmethod
def on_rebin_options_changed(self, slot): pass
def is_raw_plot(self):
"""
Checks if plotting raw data
"""
pass
@abstractmethod
def on_plot_type_changed(self, slot): pass
def tiled_by(self):
"""
Returns the option which is currently selected in the 'tiled by' combo box
"""
pass
@abstractmethod
def on_tiled_by_type_changed(self, slot): pass
def on_rebin_options_changed(self, slot):
"""
Connect the plot_rebin checkbox to the input slot
"""
pass
@abstractmethod
def on_plot_tiled_changed(self, slot): pass
def on_plot_type_changed(self, slot):
"""
Connect the plot_type combo box to the input slot
"""
pass
@abstractmethod
def on_external_plot_pressed(self, slot): pass
def on_tiled_by_type_changed(self, slot):
"""
Connect the tiled_by combo box to the input slot
"""
pass
@abstractmethod
def on_plot_tiled_checkbox_changed(self, slot):
"""
Connect the tiled_plot checkbox to the input slot
"""
pass
@abstractmethod
def on_external_plot_pressed(self, slot):
"""
Connect the external plot button to the input slot
"""
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment