From 6b1282b4ba98676c3431b3381c509d5071c13f2c Mon Sep 17 00:00:00 2001 From: Conor Finn <conor.finn@stfc.ac.uk> Date: Tue, 21 Jan 2020 09:17:08 +0000 Subject: [PATCH] RE #27188 Add cropping controls to view and presenter Adds basic controls to presenter for showing and hiding. --- .../tabs/focus/presenter.py | 12 +++++++++++ .../tabs/focus/view.py | 21 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/presenter.py index 6a6a3ae77f5..4f2309c2483 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/presenter.py @@ -10,6 +10,7 @@ from __future__ import (absolute_import, division, print_function) from Engineering.gui.engineering_diffraction.tabs.common import INSTRUMENT_DICT, create_error_message from Engineering.gui.engineering_diffraction.tabs.common.calibration_info import CalibrationInfo from Engineering.gui.engineering_diffraction.tabs.common.vanadium_corrections import check_workspaces_exist +from Engineering.gui.engineering_diffraction.tabs.common.cropping.cropping_widget import CroppingWidget from mantidqt.utils.asynchronous import AsyncTask from mantidqt.utils.observer_pattern import Observer from mantid.simpleapi import logger @@ -25,12 +26,17 @@ class FocusPresenter(object): # Connect view signals to local methods. self.view.set_on_focus_clicked(self.on_focus_clicked) self.view.set_enable_controls_connection(self.set_focus_controls_enabled) + self.view.set_on_check_cropping_state_changed(self.show_cropping) # Variables from other GUI tabs. self.current_calibration = CalibrationInfo() self.instrument = "ENGINX" self.rb_num = None + # Cropping Options + self.cropping_widget = CroppingWidget(self.view, view=self.view.get_cropping_widget()) + self.view.set_cropping_widget_hidden() + def on_focus_clicked(self): banks = self._get_banks() if not self._validate(banks): @@ -115,6 +121,12 @@ class FocusPresenter(object): """ self.current_calibration = calibration + def show_cropping(self, visible): + if visible: + self.view.set_cropping_widget_visible() + else: + self.view.set_cropping_widget_hidden() + # ----------------------- # Observers / Observables # ----------------------- diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/view.py b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/view.py index 9d6d74b8914..d2700053e97 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/view.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/view.py @@ -33,6 +33,9 @@ class FocusView(QtWidgets.QWidget, Ui_focus): def set_enable_controls_connection(self, slot): self.sig_enable_controls.connect(slot) + def set_on_check_cropping_state_changed(self, slot): + self.check_cropFocus.stateChanged.connect(slot) + # ================= # Component Setters # ================= @@ -46,6 +49,18 @@ class FocusView(QtWidgets.QWidget, Ui_focus): def set_plot_output_enabled(self, enabled): self.check_plotOutput.setEnabled(enabled) + def set_cropping_widget_hidden(self): + self.widget_cropping.hide() + + def set_cropping_widget_visible(self): + self.widget_cropping.show() + + def set_check_cropping_enabled(self, enabled): + self.check_cropFocus.setEnabled(enabled) + + def set_check_cropping_state(self, state): + self.check_cropFocus.setCheckState(state) + # ================= # Component Getters # ================= @@ -65,6 +80,12 @@ class FocusView(QtWidgets.QWidget, Ui_focus): def get_plot_output(self): return self.check_plotOutput.isChecked() + def get_crop_checked(self): + return self.check_cropFocus.isChecked() + + def get_cropping_widget(self): + return self.widget_cropping + # ================= # State Getters # ================= -- GitLab