diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/plot_presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/plot_presenter.py index 02f922bf0c570b29fc46414a650bf333182c9441..5c5d04f08c84d4b61fcd73e7e248bcfb7c12e4e3 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/plot_presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/plot_presenter.py @@ -5,13 +5,27 @@ # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 + +from mantidqt.utils.observer_pattern import GenericObserverWithArgPassing, GenericObserver +from Engineering.gui.engineering_diffraction.tabs.fitting.plotting.plot_model import FittingPlotModel +from Engineering.gui.engineering_diffraction.tabs.fitting.plotting.plot_view import FittingPlotView + PLOT_KWARGS = {"linestyle": "", "marker": "x", "markersize": "3"} class FittingPlotPresenter(object): - def __init__(self, model, view): - self.model = model - self.view = view + def __init__(self, parent, model=None, view=None): + if view is None: + self.view = FittingPlotView(parent) + else: + self.view = view + if model is None: + self.model = FittingPlotModel() + else: + self.model = model + + self.workspace_added_observer = GenericObserverWithArgPassing(self.add_workspace_to_plot) + self.workspace_removed_observer = GenericObserverWithArgPassing(self.remove_workspace_from_plot) + self.all_workspaces_removed_observer = GenericObserver(self.clear_plot) def add_workspace_to_plot(self, ws): axes = self.view.get_axes() diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/plot_widget.py b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/plot_widget.py deleted file mode 100644 index 6961ae2253232533a533e53ee2a89e7c2af93d90..0000000000000000000000000000000000000000 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/plot_widget.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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 -# SPDX - License - Identifier: GPL - 3.0 + - -from Engineering.gui.engineering_diffraction.tabs.fitting.plotting.plot_model import FittingPlotModel -from Engineering.gui.engineering_diffraction.tabs.fitting.plotting.plot_view import FittingPlotView -from Engineering.gui.engineering_diffraction.tabs.fitting.plotting.plot_presenter import FittingPlotPresenter - -from mantidqt.utils.observer_pattern import GenericObserverWithArgPassing, GenericObserver - - -class FittingPlotWidget(object): - def __init__(self, parent, view=None): - if view is None: - self.view = FittingPlotView(parent) - else: - self.view = view - self.model = FittingPlotModel() - self.presenter = FittingPlotPresenter(self.model, self.view) - - self.workspace_added_observer = GenericObserverWithArgPassing(self.presenter.add_workspace_to_plot) - self.workspace_removed_observer = GenericObserverWithArgPassing(self.presenter.remove_workspace_from_plot) - self.all_workspaces_removed_observer = GenericObserver(self.presenter.clear_plot) diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/test/test_plot_presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/test/test_plot_presenter.py index ae41fd62f798227868aff8dab4770e557843bbef..d3044a30583c49f0437b11c7a725053df3d43261 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/test/test_plot_presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/test/test_plot_presenter.py @@ -18,7 +18,7 @@ class FittingPlotPresenterTest(unittest.TestCase): def setUp(self): self.model = mock.create_autospec(plot_model.FittingPlotModel) self.view = mock.create_autospec(plot_view.FittingPlotView) - self.presenter = plot_presenter.FittingPlotPresenter(self.model, self.view) + self.presenter = plot_presenter.FittingPlotPresenter(None, self.model, self.view) def test_add_workspace_to_plot(self): self.view.get_axes.return_value = ["axis1", "axis2"] diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/presenter.py index b4ccf0c84e1a963d24538adc56e9de36ec617231..b4d7f649a9d4c67ee3d453ffad27d9dd07128e86 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/presenter.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + from Engineering.gui.engineering_diffraction.tabs.fitting.data_handling.data_widget import FittingDataWidget -from Engineering.gui.engineering_diffraction.tabs.fitting.plotting.plot_widget import FittingPlotWidget +from Engineering.gui.engineering_diffraction.tabs.fitting.plotting.plot_presenter import FittingPlotPresenter class FittingPresenter(object): @@ -14,7 +14,7 @@ class FittingPresenter(object): self.view = view self.data_widget = FittingDataWidget(self.view, view=self.view.get_data_widget()) - self.plot_widget = FittingPlotWidget(self.view, view=self.view.get_plot_widget()) + self.plot_widget = FittingPlotPresenter(self.view, view=self.view.get_plot_widget()) self.data_widget.presenter.plot_removed_notifier.add_subscriber( self.plot_widget.workspace_removed_observer)