Source code for schrodinger.application.jaguar.gui.tabs.input_sub_tabs.base_sub_tab

import schrodinger
from schrodinger.Qt import QtCore
from schrodinger.Qt import QtWidgets

from ..sub_tab_widgets import base_widgets

maestro = schrodinger.get_maestro()


[docs]class BaseSubTab(QtWidgets.QWidget): """ A base-class for all Input tab sub-tabs. This class is not intended to be instantiated directly and should be subclassed. Subclasses must redefine NAME, UI_MODULE, TABLE_MODEL_CLASS, saveSettings, and loadSettings. Subclasses must include a `schrodinger.application.jaguar.gui.tabs.tabs. sub_tab_widgets.base_widgets.SubTabTableView` (or a subclass) instance accessible as self.ui.table_view. Subclasses will also likely need to redefine setup, activate, and deactivate. :cvar NAME: The name of the tab. This name will be shown in the tab bar. :vartype NAME: str :cvar UI_MODULE: A module containing a Ui_Form for the sub tab :vartype UI_MODULE: module :cvar TABLE_MODEL_CLASS: The class of the table model. An instance of this class will be made available at self._table_model. This variable must be redefined in `BaseSubTab` subclasses with a subclass of `schrodinger.application.jaguar.gui.tabs.sub_tab_widgets.base_widgets. SubTabModel` :vartype TABLE_MODEL_CLASS: type :cvar PROXY_MODEL_CLASS: The class of the proxy model. An instance of this class will be made available at self._proxy_model. This proxy model filters out rows related to entry ids that are no longer selected in the project table. This variable may be refined in `BaseSubTab` subclasses, but it is not required. :vartype PROXY_MODEL_CLASS: type :ivar countChanged: A signal emitted when the number of rows in the table has changed. The input tab uses this to update the row count in the tab name. The signal is emitted with: - The sub tab instance (`BaseSubTab` - The row count (int) :vartype countChanged: `PyQt5.QtCore.pyqtSignal` :ivar addJaguarMarker: A signal emitted when a workspace marker should be added. Emitted with: - The list of atoms to add the marker for (list) - The marker settings (dict) - The name of the sub-tab (str) :vartype addJaguarMarker: `PyQt5.QtCore.pyqtSignal` :ivar removeJaguarMarker: A signal emitted when a workspace marker should be removed. Emitted with: - The list of atoms to remove the marker for (list) - The name of the sub-tab (str) :vartype removeJaguarMarker: `PyQt5.QtCore.pyqtSignal` :ivar setMarkerHighlighting: A signal emitted when the highlighting of a workspace marker should be changed. Emitted with: - The list of atoms to change the highlighting for (list) - Whether the marker should be highlighted (True) or unhighlighted (False) (bool) - The name of the sub-tab (str) :vartype setMarkerHighlighting: `PyQt5.QtCore.pyqtSignal` """ NAME = "" UI_MODULE = None TABLE_MODEL_CLASS = base_widgets.SubTabModel PROXY_MODEL_CLASS = base_widgets.SubTabProxyModel countChanged = QtCore.pyqtSignal(QtWidgets.QWidget, int) addJaguarMarker = QtCore.pyqtSignal(list, dict, str) removeJaguarMarker = QtCore.pyqtSignal(list, str) setMarkerHighlighting = QtCore.pyqtSignal(list, bool, str)
[docs] def __init__(self, parent=None): super(BaseSubTab, self).__init__(parent) self.ui = self.UI_MODULE.Ui_Form() self.ui.setupUi(self) self._table_model = self.TABLE_MODEL_CLASS(self) self._proxy_model = self.PROXY_MODEL_CLASS(self) self._proxy_model.setSourceModel(self._table_model) self.ui.table_view.setModel(self._proxy_model) self._proxy_model.rowsInserted.connect(self.emitCountChanged) self._proxy_model.rowsRemoved.connect(self.emitCountChanged) self._proxy_model.modelReset.connect(self.emitCountChanged) self._table_model.addJaguarMarker.connect(self.emitAddMarker) self._table_model.removeJaguarMarker.connect(self.emitRemoveMarker) self.ui.table_view.setMarkerHighlighting.connect( self.emitSetMarkerHighlighting) self.setup()
[docs] def setup(self): """ Sub-tab-specific initialization. This function may be redefined in subclasses. """
# This function intentionally left blank
[docs] def validate(self): """ Make sure that the sub-tab settings will allow a job to be run successfully. :return: If the validation passes, returns None. If the validation fails, returns a string that describes the error. :rtype: str or NoneType """
# This function intentionally left blank
[docs] def saveSettings(self, jag_input, eid): """ Save sub-tab settings for the specified entry into the given Jaguar handle. This function should be redefined in subclasses. :param jag_input: The Jaguar handle to save settings into :type jag_input: `schrodinger.application.jaguar.input.JaguarInput` :param eid: The entry id of the structure to save settings for :type eid: string """
# This function intentionally left blank
[docs] def loadSettings(self, jag_input, eid, title, struc): """ Restore sub-tab settings from the Jaguar handle. This function should be redefined in subclasses. Note that existing settings for the given entry id should be cleared before the new settings are loaded. :param jag_input: The Jaguar handle to load settings from :type jag_input: `schrodinger.application.jaguar.input.JaguarInput` :param eid: The entry id of the structure to load settings for :type eid: string :param title: The title of the structure :type title: str :param struc: The structure that settings are being loaded for. Primarily intended for looking up atom names. :type struc: `schrodinger.structure.Structure` """
# This function intentionally left blank
[docs] def activate(self): """ Activate the sub-tab, e.g., check the picking check box. """
# This function intentionally left blank
[docs] def deactivate(self): """ Deactivate the sub-tab, e.g., stop picking and/or uncheck the picking check box """
# This function intentionally left blank
[docs] def setActive(self, activate): """ Activate or deactivate the sub-tab :param activate: Whether to activate (True) or de-activate (False) the sub-tab :type activate: bool """ if activate: self.activate() else: self.deactivate()
[docs] def setDisplayedEids(self, eids): """ Set the entry ids to display in the table. This should correspond to the entry ids currently selected in the project table. :param eids: The entry ids to display :type eids: list """ self._proxy_model.setDisplayedEids(eids)
[docs] def updateEntryTitles(self, eids_to_titles): """ Update the entry titles in case they have changed in the project table :param eids_to_titles: A dictionary of {entry id: title} :type eids_to_titles: dict """ self._table_model.updateEntryTitles(eids_to_titles)
[docs] def emitCountChanged(self): """ Emit the `countChanged` signal with the appropriate row count """ count = self._proxy_model.rowCount() self.countChanged.emit(self, count)
[docs] def reset(self): self._table_model.reset()
[docs] def emitAddMarker(self, atoms, settings): """ Pass along the addJaguarMarker signal received from the table model after adding the sub-tab name. :param atoms: A list of atoms to add the marker for :type atoms: list :param settings: The marker settings :type settings: dict """ self.addJaguarMarker.emit(atoms, settings, self.NAME)
[docs] def emitRemoveMarker(self, atoms): """ Pass along the removeJaguarMarker signal received from the table model after adding the sub-tab name to the signal. :param atoms: A list of atoms to remove the marker for :type atoms: list """ self.removeJaguarMarker.emit(atoms, self.NAME)
[docs] def emitSetMarkerHighlighting(self, atoms, highlight): """ Pass along the setMarkerHighlighting signal received from the table view after adding the sub-tab name to the signal. :param atoms: A list of atoms to change the highlighting for :type atoms: list :param highlight: Whether to highlight (True) or unhighlight (False) the specified marker :type highlight: bool """ self.setMarkerHighlighting.emit(atoms, highlight, self.NAME)
[docs] def warning(self, msg): """ Display a warning dialog with the specified message :param msg: The message to include in the warning dialog :type msg: str """ QtWidgets.QMessageBox.warning(self, "Warning", msg)