Package schrodinger :: Package application :: Package jaguar :: Package gui :: Package tabs :: Package sub_tab_widgets :: Module charge_constraints_widgets :: Class AtomSelectionDelegate
[hide private]
[frames] | no frames]

Class AtomSelectionDelegate

     PyQt4.QtGui.QStyledItemDelegate --+        
                                       |        
input_tab_widgets.CommitMultipleDelegate --+    
                                           |    
      ui.qt.utils.DefaultMessageDelegate --+    
                                           |    
 input_tab_widgets_pka.AtomSelectionDelegate --+
                                               |
                                              AtomSelectionDelegate

A delegate for selecting atoms for the charge constraint.


Note: We currently don't allow the user to type in atom names. If the user doesn't click on an atom in the workspace, then we have no way to determine which entry the constraint refers to. Invalid atoms names (i.e. those not in the form <element><index>) would also cause issues for the weights pop- up. Additionally, we'd have to add atom name validation to the model in order to color cells with errors and to give a tool tip explaining the problem, as is done for pKa atoms. We'd also have to implement validate() for the sub-tab. It would be possible to solve these issues, but for now we simply require that the user select atoms from the workspace.

Instance Methods [hide private]
 
__init__(self, parent)
 
_ensureEntryIncluded(self, index)
Make sure that an entry is included in the workspace.
 
_setEditorAtom(self, ws_atom_num, editor, index)
Respond to the user clicking an atom in the workspace.
tuple
_getEid(self, index)
Get the entry id associated with a given model index
list
_getAtoms(self, eid, text)
Get the atom objects for the specified atoms
 
_clearModelMarkers(self, index)
Remove all markers associated with the specified model index
 
_clearEditorMarkers(self, index, editor)
Remove all markers associated with the specified editor
 
_markAtoms(self, atoms, index)
Mark the specified atoms
 
clearRowIfEmpty(self, editor, hint=None)
When the editor closes, erase a row if it does not contain any atom names.
 
createEditor(self, parent, option, index)
Create an editor as in the super-class, but mark it as read-only.
 
_resetMarker(self, editor, hint=None)
If a pKa atom was selected via the user clicking in the workspace, reset the currently marked atom to the table value.
 
setModelData(self, editor, model, index)
Before setting the model data, clear any workspace markers we have created and restore the markers to the model values.

Inherited from input_tab_widgets_pka.AtomSelectionDelegate: eventFilter, setEditorData

Class Variables [hide private]
  MAESTRO_STATUS_MESSAGE = "Pick an atom to be included in the c...
  TOOL_TIP_INSTRUCTIONS = "Click an atoms in the workspace to\n"...
  TOOL_TIP_WRONG_EID = "The atom you selected is not\n" "part of...
  DEFAULT_DATA = {}
Instance Variables [hide private]
PyQt4.QtCore.pyqtSignal addMarker = QtCore.pyqtSignal(list, QtCore.QModelIndex)
A signal emitted when a workspace marker should be added.
PyQt4.QtCore.pyqtSignal removeMarker = QtCore.pyqtSignal(list)
A signal emitted when a workspace marker should be removed.

Inherited from input_tab_widgets_pka.AtomSelectionDelegate: set_pka_marker

Inherited from input_tab_widgets.CommitMultipleDelegate: commitDataToSelected

Method Details [hide private]

__init__(self, parent)
(Constructor)

 
Overrides: input_tab_widgets_pka.AtomSelectionDelegate.__init__

_ensureEntryIncluded(self, index)

 

Make sure that an entry is included in the workspace. If it isn't, include only that structure.

Parameters:
  • index - The model index corresponding to the structure to include
Overrides: input_tab_widgets_pka.AtomSelectionDelegate._ensureEntryIncluded
(inherited documentation)

_setEditorAtom(self, ws_atom_num, editor, index)

 

Respond to the user clicking an atom in the workspace. If the atom does not belong to this structure, display a warning. Otherwise, enter the Jaguar-ified atom name into the line edit and display a marker on the atom. If atom is already included in the list of charge constraint atoms we remove it from the list.

Parameters:
  • ws_atom_num (int) - The atom number (relative to the workspace structure) that was selected.
  • editor (PyQt4.QtGui.QLineEdit) - The line edit to enter the atom name into
  • index (PyQt4.QCore.QModelIndex) - The index of the cell being edited
Overrides: input_tab_widgets_pka.AtomSelectionDelegate._setEditorAtom

_getEid(self, index)

 

Get the entry id associated with a given model index

Parameters:
  • index (QtCore.QModelIndex) - The model index to get the entry id for
Returns: tuple
A tuple of:
  • entry id
  • the model index of the entry id cell

_getAtoms(self, eid, text)

 

Get the atom objects for the specified atoms

Parameters:
  • eid (str) - The entry id to get atoms from
  • text (str) - A comma-separated list of atoms
Returns: list
A list of schrodinger.structure._StructureAtom objects
Overrides: input_tab_widgets_pka.AtomSelectionDelegate._getAtoms

_clearModelMarkers(self, index)

 

Remove all markers associated with the specified model index

Parameters:
  • index (QtCore.QModelIndex) - The model index

_clearEditorMarkers(self, index, editor)

 

Remove all markers associated with the specified editor

Parameters:
  • index (QtCore.QModelIndex) - The model index that the editor is editing
  • editor (PyQt4.QtGui.QLineEdit) - The editor

_markAtoms(self, atoms, index)

 

Mark the specified atoms

Parameters:
  • index (QtCore.QModelIndex) - The model index that the editor is editing

clearRowIfEmpty(self, editor, hint=None)

 

When the editor closes, erase a row if it does not contain any atom names. Without any atom names, the row is meaningless. By clearing the rows immediately, we avoid the need to later warn the user about them.

Parameters:
  • editor (PyQt4.QtGui.QLineEdit) - The recently-closed editor
  • hint - Ignored, but present for compatibility with the Qt signal

createEditor(self, parent, option, index)

 

Create an editor as in the super-class, but mark it as read-only. See the @note in the class documentation for an explanation of why.

See Qt documentation for an explanation of arguments and return values

Overrides: input_tab_widgets_pka.AtomSelectionDelegate.createEditor

_resetMarker(self, editor, hint=None)

 

If a pKa atom was selected via the user clicking in the workspace, reset the currently marked atom to the table value.

Parameters:
  • editor - The delegate editor
  • hint - Not used, but present for Qt compatibility
Overrides: input_tab_widgets_pka.AtomSelectionDelegate._resetMarker
(inherited documentation)

setModelData(self, editor, model, index)

 

Before setting the model data, clear any workspace markers we have created and restore the markers to the model values. This avoids having the model trying to clear a marker that no longer exists, which would raise an exception.

See parent class and PyQt documentation for an explanation of arguments.

Overrides: input_tab_widgets_pka.AtomSelectionDelegate.setModelData

Class Variable Details [hide private]

MAESTRO_STATUS_MESSAGE

Value:
"Pick an atom to be included in the charge " "constraint"

TOOL_TIP_INSTRUCTIONS

Value:
"Click an atoms in the workspace to\n" "set them as a charge constrain\
t atom.\n" "Click again to remove."

TOOL_TIP_WRONG_EID

Value:
"The atom you selected is not\n" "part of this structure."

Instance Variable Details [hide private]

addMarker

A signal emitted when a workspace marker should be added. Emitted with:
  • The list of atoms to add the marker for (list)
  • The index that the atom is being marked for. (Used to determine whether the marker should be highlighted or not.) (QtCore.QModelIndex)
Type:
PyQt4.QtCore.pyqtSignal
Value:
QtCore.pyqtSignal(list, QtCore.QModelIndex)

removeMarker

A signal emitted when a workspace marker should be removed. Emitted with:
  • The list of atoms to remove the marker for (list)
Type:
PyQt4.QtCore.pyqtSignal
Value:
QtCore.pyqtSignal(list)