Package Pmv :: Module labelCommands :: Class LabelByExpression
[hide private]
[frames] | no frames]

Class LabelByExpression

source code

 ViewerFramework.VFCommand.Command --+        
                                     |        
                   mvCommand.MVCommand --+    
                                         |    
ViewerFramework.VFCommand.ICOM --+       |    
                                 |       |    
                  mvCommand.MVICOM --+   |    
                                     |   |    
                  mvCommand.MVAtomICOM --+    
                                         |    
                         LabelByProperties --+
                                             |
                                            LabelByExpression

Command to label the current selection items according to different expressions of the selection level (Actually of the first item in the current selection.) Color can be specified as 'red','green','blue','white' or 'yellow'. Other values can be entered as a RGB tuple.One font can selected per label level: Atom,Residue,Chain,Molecule.Labels can be centered on first atom of selection level item, last atom of item or on the center of the item which is found by averaging the coordinates of all the atoms in the item. (eg all atoms in a residue if labelling at the Residue Level)
   
Package : Pmv
   
Module  : labelCommands
   
Class   : LabelByExpression
   
Command : labelByExpression
   
Synopsis:
     
        None <--- labelByExpression(nodes,function='lambda x: x.full_name()',
                 lambdaFunc = 1, textcolor='white', font='arial1.glf',
                 location='Center', only=0, negate=0, format=None, **kw)
   
Required Arguments:
     
        nodes --- TreeNode, TreeNodeSet or string representing a TreeNode
                    or a TreeNodeSet holding the current selection.
   
Optional Arguments:
      
        function  --- function definition or lambda function returning a
                    list of strings that will used to label the selection.
        
lambdaFunc --- Boolean flag when set to True the function is a lambda function
                    otherwise it is a regular function.
        
textcolor --- string representing the color of the label can also be
                    a rgb tuple (r,g,b).
        
font  ---  Font of the label
        
location  --- Can be one of Center, First or Last specifies the location
                    of the label.
        
format --- Default is None string format of the label can be %4.2f
        
only --- Boolean flag when set to True only the selection is labeled when set
                    to 0 label are added to the existing labels.
        
negate --- Boolean flag when set to True the selection is unlabeled
        



Instance Methods [hide private]
  updateInfo_cb(self, value)
  update_cb(self, tag)
  buildFormDescr(self, formName='default')
  guiCallback(self)
  __call__(self, nodes, function='lambda x: x.full_name()', lambdaFunc=True, textcolor='white', font='arial1.glf', location='Center', only=False, negate=False, format=None, **kw)
None <--- labelByExpression(nodes,function='lambda x: x.full_name()', lambdaFunc = 1, textcolor='white', font='arial1.glf', location='Center', only=0, negate=0, format=None, **kw) nodes --- TreeNode, TreeNodeSet or string representing a TreeNode or a TreeNodeSet holding the current selection.
  doit(self, nodes, function='lambda x: x.full_name()', lambdaFunc=True, textcolor='white', font='arial1.glf', location='Center', only=False, negate=False, format=None)

Inherited from LabelByProperties: __init__, atomPropToVertices, chooseColor_cb, configureButton, dismiss_cb, getLastUsedValues, getRelatedLabelsGeom, labelsSettings_cb, onAddCmdToViewer, onAddObjectToViewer, updateChooser

Inherited from mvCommand.MVCommand: strArg

Inherited from mvCommand.MVCommand (private): _strArg

Inherited from ViewerFramework.VFCommand.Command: __repr__, addCallbackAfter, addCallbackBefore, addUndoCall, afterDoit, beforeDoit, buildLogArgList, checkDependencies, cleanup, customizeGUI, doitWrapper, getArguments, getHelp, getLogArgs, getValNamedArgs, log, logString, onAddNewCmd, onCmdRun, setLastUsedValues, setupUndoAfter, setupUndoBefore, showForm, tkCb, updateGeom, warningMsg

Inherited from mvCommand.MVAtomICOM: getObjects

Inherited from ViewerFramework.VFCommand.ICOM: initICOM, startICOM, stopICOM


Class Variables [hide private]
  mapLabel = 'Define a function or a lambda function to be applie...
  mapText = '#def foo(node):\n#\t#property <- foo(node)\n#\t#pro...
  funcLabel = 'Define a function to be applied to\nthe current sel...
  funcText = '#def foo(selection):\n#\t#values <- foo(node)\n#\t#...

Inherited from ViewerFramework.VFCommand.Command: negateKw, objArgOnly


Method Details [hide private]

updateInfo_cb(self, value)

source code 
None

update_cb(self, tag)

source code 
None
Overrides: LabelByProperties.update_cb

buildFormDescr(self, formName='default')

source code 
None
Overrides: LabelByProperties.buildFormDescr

guiCallback(self)

source code 
None
Overrides: LabelByProperties.guiCallback

__call__(self, nodes, function='lambda x: x.full_name()', lambdaFunc=True, textcolor='white', font='arial1.glf', location='Center', only=False, negate=False, format=None, **kw)
(Call operator)

source code 
None <--- labelByExpression(nodes,function='lambda x: x.full_name()',
                 lambdaFunc = 1, textcolor='white', font='arial1.glf',
                 location='Center', only=0, negate=0, format=None, **kw)
        
nodes  --- TreeNode, TreeNodeSet or string representing a TreeNode
                    or a TreeNodeSet holding the current selection.
        
function  --- function definition or lambda function returning a
                    list of strings that will used to label the selection.
        
lambdaFunc --- Boolean flag when set to True the function is a lambda function
                    otherwise it is a regular function.
        
textcolor --- string representing the color of the label can also be
                    a rgb tuple (r,g,b).
        
font --- Font of the label
        
location  --- Can be one of Center, First or Last specifies the location
                    of the label.
        
format --- Default is None string format of the label can be %4.2f
        
only --- Boolean flag when set to True only the selection is labeled when set
                    to 0 label are added to the existing labels.
        
negate --- Boolean flag when set to True the selection is unlabeled
        

Overrides: LabelByProperties.__call__

doit(self, nodes, function='lambda x: x.full_name()', lambdaFunc=True, textcolor='white', font='arial1.glf', location='Center', only=False, negate=False, format=None)

source code 
None
Overrides: LabelByProperties.doit

Class Variable Details [hide private]

mapLabel

None
Value:
'''Define a function or a lambda function to be applied
on each node of the current selection: '''                             
      

mapText

None
Value:
'''#def foo(node):
#\t#property <- foo(node)
#\t#property    : string that will be used for labelling
#\t#node        : node from the current selection
#\t#foo will then be applied to each node from the current selection.
#\treturn str(node.full_name())
#OR
#lambda x: str(x.full_name())
...                                                                    
      

funcLabel

None
Value:
'''Define a function to be applied to
the current selection:'''                                              
      

funcText

None
Value:
'''#def foo(selection):
#\t#values <- foo(node)
#\t#values   : list of string used for labelling
#\t#selection: current selection.
#\tvalues = []
#\t#loop on the current selection
#\tfor i in xrange(len(selection)):
#\t\t#build a list of values to label the current selection.
...