Source code for schrodinger.ui.qt.forcefield_widgets.ffcustomoplssettingwidget

from schrodinger.Qt import QtWidgets
from . import ffcustomoplssettingwidget_ui
from schrodinger.ui.qt.forcefield_widgets import ffglobalpreferencewidget
from schrodinger.ui.qt.forcefield_widgets import ffprojectsettingsdlg
from . import stylesheet
from schrodinger.ui.qt import forcefield
from schrodinger.Qt import QtGui
from schrodinger.Qt import QtCore
from schrodinger.ui.qt.standard.icons import icons
from schrodinger.ui import maestro_ui

maestro_hub = maestro_ui.MaestroHub.instance()


[docs]class FFCustomOPLSSettingWidget(QtWidgets.QWidget): """ Widget used to change/customize opls settings for a job. Emits a custom signal with a bool defining 'use custom force field' checkbox check state. :cvar useCustomParameterStateChanged: signal indication that use custom forcefield checkbox state is changed. :vartype useCustomParameterStateChanged: QtCore.pyqtSignal """ useCustomParameterStateChanged = QtCore.pyqtSignal(bool) _CUSTOMIZE_TOOLTIP = ( 'Change custom parameters location or add parameters via Customize... ' 'button') _CUSTOMIZATION_REQUIRED_TOOLTIP = ( 'The specified customizations are either unavailable or ' 'incompatible with the OPLS4 force field. New custom ' 'parameters are needed to accurately model your structures.' '<br><br>' 'This job may run without customizations, but we do not ' 'recommend it. Click this button to choose a different set of ' 'customizations (if available), or to create them using the ' 'Force Field Builder, accessible via the Customize button.')
[docs] def __init__(self, parent): super().__init__(parent) self.ui = ffcustomoplssettingwidget_ui.Ui_CustomOPLSSettingWidget() self.ui.setupUi(self) self.setStyleSheet(stylesheet.FF_CUSTOM_OPLS_SETTINGS_WIDGET_STYLESHEET) self._updateUI() self.ui.project_setting_btn.clicked.connect( lambda: ffprojectsettingsdlg.show_ff_project_settings_dlg(self)) self.ui.use_customized_version_cb.toggled.connect(self._updateUI) self.ui.use_customized_version_cb.toggled.connect( self.useCustomParameterStateChanged) maestro_hub.projectPreferenceChanged.connect(self._onPreferenceChanged) ff_global_preference_widget = ffglobalpreferencewidget.FFGlobalPreferenceWidget.getInstance( ) ff_global_preference_widget.useCustomForceFieldToggled.connect( self.setUseCustomizedVersionCBState) ff_global_preference_widget.customOPLSPathChanged.connect( self._updateAndEmitSignal)
def _onPreferenceChanged(self, pref_name): """ Updates the widget state whenever Maestro preferences are changed """ if forcefield.PROJECT_OPLS_DIR_CMD_OPTION in pref_name: self._updateAndEmitSignal()
[docs] def event(self, e): """ Handle the window activation. :param e: the event object :rtype: QTCore.QEvent """ # update the selector based on possible change to the contents of the # S-OPLS preferences directory if e.type() == QtCore.QEvent.WindowActivate: # ensure that the checkbox update happens after the activate event # is finished so we can display message boxes if necessary QtCore.QTimer.singleShot(0, self._updateAndEmitSignal) return super().event(e)
def _updateAndEmitSignal(self): self._updateUI() self.useCustomParameterStateChanged.emit( self.isUseCustomizedVersionChecked()) def _updateUI(self): """ Updates UI of widget """ btn_tooltip = "" btn_icon = icons.MORE_OPTIONS_LB cb_stylesheet = "QCheckBox { color: #444444 }" if self.isUseCustomizedVersionChecked(): if forcefield.has_valid_custom_OPLS_preference(): btn_tooltip = self._CUSTOMIZE_TOOLTIP else: btn_tooltip = self._CUSTOMIZATION_REQUIRED_TOOLTIP btn_icon = icons.VALIDATION_WARNING_LB cb_stylesheet = "QCheckBox { color: #aa6d09 }" btn_tooltip += f'<br><br>Using: <i>{forcefield.get_custom_opls_dir()}</i>' self.ui.project_setting_btn.setToolTip(btn_tooltip) self.ui.project_setting_btn.setIcon(QtGui.QIcon(btn_icon)) self.ui.use_customized_version_cb.setStyleSheet(cb_stylesheet)
[docs] def isUseCustomizedVersionChecked(self): """ Returns True if use customized option is checked, False otherwise. :rtype: bool :return: use customized version checked state. """ return self.ui.use_customized_version_cb.isChecked()
[docs] def setUseCustomizedVersionCBState(self, cb_state): """ Sets 'use customized version' checkbox state to on/off. :param cb_state: check state of checkbox. :type cb_state: bool """ self.ui.use_customized_version_cb.setChecked(cb_state)