Package Pmv :: Module bondsCommands
[hide private]
[frames] | no frames]

Source Code for Module Pmv.bondsCommands

  1  ############################################################################# 
  2  # 
  3  # Author: Michel F. SANNER, Sophie COON 
  4  # 
  5  # Copyright: M. Sanner TSRI 2000 
  6  # 
  7  ############################################################################# 
  8   
  9  # 
 10  # $Header: /opt/cvs/python/packages/share1.5/Pmv/bondsCommands.py,v 1.43.4.1 2007/08/16 21:10:48 vareille Exp $ 
 11  # 
 12  # $Id: bondsCommands.py,v 1.43.4.1 2007/08/16 21:10:48 vareille Exp $ 
 13  # 
 14  # 
 15  import Numeric 
 16  from opengltk.OpenGL import GL 
 17   
 18  from ViewerFramework.VF import EditAtomsEvent 
 19  from Pmv.mvCommand import MVCommand, MVAtomICOM, MVBondICOM 
 20  from DejaVu.Geom import Geom 
 21  from DejaVu.Spheres import Spheres 
 22  #from DejaVu.Labels import Labels 
 23  from DejaVu.IndexedPolylines import IndexedPolylines 
 24  from ViewerFramework.VFCommand import CommandGUI 
 25  from MolKit.molecule import Atom, AtomSet, Bond, BondSet 
 26  from MolKit.protein import Chain 
 27  from types import StringType 
 28  var=0 
 29  """ 
 30  Package: Pmv 
 31  Module : bondsCommands 
 32  This module provides a set of commands: 
 33  - BuildBondsByDistance (buildBondsByDistance) to compute the bonds between 
 34    atoms of the given nodes and connect the residues when necessary. 
 35  - AddBondsCommands (addBonds) to create a bond instance between two given atoms. 
 36      -no gui 
 37  - AddBondsGUICCommands (addBondsGC) to create a bond between two picked 
 38    atoms. If a group of atoms is selected by dragging, it will 
 39    buildBondsByDistance between them.   
 40    This is an interactive command (ICOM) and the GUI version of addBonds. 
 41  - RemoveBondsCommands (removeBonds) to delete an existing bonds between the 
 42    two given atoms. 
 43      -no gui 
 44  - RemoveBondsGUICCommands (removeBondsGC) to delete the picked bond. If a 
 45    groups of atoms is selected by dragging, it will remove all the bonds 
 46    between them.  
 47    This is the GUI command of the removeBonds and it is an ICOM. 
 48   
 49  The menubuttons for BondsCommands are located under the 'Bonds' entry in the 'Edit' menu. 
 50  """ 
 51   
52 -class BuildBondsByDistance(MVCommand, MVAtomICOM):
53 """This command creates the bonds between atoms of the given set of nodes and connect the residues when necessary. The cut_off distance is based on the bond order radius of the two atoms to be bound. The command will use the bhtree functionality to find the pairs of atoms to be found when available.This command can be applied on a current selection or used interactively when bound to the mouse event. 54 \nPackage : Pmv 55 \nModule : bondsCommands 56 \nClass : BuildBondsByDistance 57 \nCommand : buildBondsByDistance 58 \nSynopsis:\n 59 None<---buildBondsByDistance( nodes, display = True, **kw)\n 60 \nRequired Arguments:\n 61 nodes --- any set for MolKit nodes describing molecular components\n 62 display --- when set to 1 the displayLines command is called and th 63 bonds are displayed as lines.\n 64 \nOptional Arguments:\n 65 kw --- any of the additional optional keywords supported by commands 66 (see ViewerFramework.VFCommands.Command documentation).\n 67 \nRequired Commands:\n 68 displayLines 69 \nKnown bugs:\n 70 None\n 71 \nExamples:\n 72 mol = mv.Mols[ 0 ]\n 73 mv.buildBondsByDistance(mol, display=1)\n 74 """ 75
76 - def __init__(self, func = None):
77 MVCommand.__init__(self, func) 78 MVAtomICOM.__init__(self) 79 self.flag = self.flag | self.objArgOnly
80 81
82 - def onAddCmdToViewer(self):
83 # this command when called interactively triggers the display of 84 # the newly built bonds using lines. 85 if self.vf.hasGui and not self.vf.commands.has_key('displayLines'): 86 self.vf.loadCommand('displayCommands', 'displayLines', 'Pmv', 87 topCommand=0) 88 # try to import bhtree package and set the command flag hasBhtree 89 # to the proper value. 90 try: 91 import bhtree 92 self.hasBhtree = 1 93 except: 94 self.hasBhtree = 0
95 96
97 - def doit(self, nodes, display=False):
98 # Get the molecules and the atomSets per molecules in the set of nodes. 99 molecules, atomSets = self.vf.getNodesByMolecule(nodes, Atom) 100 # Loop over the molecules and the sets of atoms 101 for mol, atm in map(None, molecules, atomSets): 102 if self.hasBhtree: 103 mol.buildBondsByDistance() 104 else: 105 # Need to build the bonds in a chain so loop over the chains. 106 for chain in mol.chains: 107 atmInChain = AtomSet(filter(lambda x, name = chain.id: 108 x.parent.parent.id == name , atm)) 109 if not len(atmInChain): 110 continue 111 residues = atmInChain.parent.uniq() 112 residues.sort() 113 residues[0].buildBondsByDistance() 114 for ind in xrange(len(residues)-1): 115 res1 = residues[ind] 116 res2 = residues[ind+1] 117 res2.buildBondsByDistance() 118 chain.connectResidues(res1, res2) 119 120 if display: 121 # when we call it from the GUI we want the result to be displayed 122 self.vf.displayLines(nodes, topCommand=0)
123 124
125 - def __call__(self, nodes, display=False, **kw):
126 """None <- buildBondsByDistance(nodes, display=1,**kw) 127 \nnodes : TreeNodeSet holding the current selection 128 \ndisplay : Boolean flag if set to True the displayLines 129 commands are called. 130 \nThe buildBondsByDistance commands connects atoms and residues in the 131 given set of nodes based on the covalent radius of each atoms to be 132 connected. 133 """ 134 if not kw.has_key('redraw'): 135 kw['redraw']=1 136 kw['display']=display 137 if type(nodes) is StringType: 138 self.nodeLogString = "'"+nodes+"'" 139 140 apply(self.doitWrapper, (nodes,), kw)
141 142
143 - def guiCallback(self, event=None):
144 """Default callback function called by the gui""" 145 if self.vf.userpref['expandNodeLogString']['value'] == 0: 146 self.nodeLogString = "self.getSelection()" 147 self.doitWrapper( self.vf.getSelection(), display = 1, redraw=0)
148 149 150 buildBondsByDistanceDescr = {'widgeType':'Menu', 'menuBarName':'Edit', 151 'menuCascadeName': 'Bonds', 152 'menuButtonName':'Build By Distance'} 153 154 BuildBondsByDistanceGUI = CommandGUI() 155 BuildBondsByDistanceGUI.addMenuCommand('menuRoot', 'Edit', 156 'Build By Distance', cascadeName='Bonds') 157 158 159
160 -class AddBondsGUICommand(MVCommand, MVAtomICOM):
161 """ 162 The AddBondGUICommand provides an interactive way of creating bonds between two given atoms by picking on them. To use this command you need first to load it into PMV. Then you can find the entry 'addBonds' under the Edit menu. To add bonds you just need to pick on the 2 atoms you want to bind. If you drag select a bunch of atoms, the command will buildBondsByDistance between them.This command is undoable. 163 \nPackage : Pmv 164 \nModule : bondsCommands 165 \nClass : AddBondsGUICommand 166 \nCommand : addBondsGC 167 \nSynopsis:\n 168 None<-addBondsGC(atoms)\n 169 \nRequired Arguments:\n 170 atoms : atom(s)\n 171 """ 172
173 - def __init__(self, func=None):
174 MVCommand.__init__(self, func) 175 MVAtomICOM.__init__(self) 176 self.atomList = AtomSet([]) 177 self.undoAtList = AtomSet([]) 178 self.labelStrs = []
179 180
181 - def onRemoveObjectFromViewer(self, obj):
182 removeAts = AtomSet([]) 183 for at in self.atomList: 184 if at in obj.allAtoms: 185 removeAts.append(at) 186 self.atomList = self.atomList - removeAts 187 removeAts = AtomSet([]) 188 for at in self.undoAtList: 189 if at in obj.allAtoms: 190 removeAts.append(at) 191 self.undoAtList = self.undoAtList - removeAts 192 self.update()
193 194
195 - def onAddCmdToViewer(self):
196 if self.vf.hasGui: 197 if not self.vf.commands.has_key('setICOM'): 198 self.vf.loadCommand('interactiveCommands', 'setICOM', 'Pmv', 199 topCommand=0) 200 if not self.vf.commands.has_key('addBonds'): 201 self.vf.loadCommand('bondsCommands', 'addBonds', 'Pmv', 202 topCommand=0) 203 if not self.vf.commands.has_key('removeBondsGC'): 204 self.vf.loadCommand('bondsCommands', 'removeBondsGC', 'Pmv', 205 topCommand=0) 206 miscGeom = self.vf.GUI.miscGeom 207 self.masterGeom = Geom('addBondsGeom',shape=(0,0), 208 pickable=0, protected=True) 209 self.masterGeom.isScalable = 0 210 self.vf.GUI.VIEWER.AddObject(self.masterGeom, parent=miscGeom) 211 self.spheres = Spheres(name='addBondsSpheres', shape=(0,3), 212 inheritMaterial=0, 213 radii=0.2, quality=15, 214 materials = ((1.,1.,0.),), protected=True) 215 self.vf.GUI.VIEWER.AddObject(self.spheres, parent=self.masterGeom) 216 if not self.vf.commands.has_key('labelByExpression'): 217 self.vf.loadCommand('labelCommands', 218 ['labelByExpression',], 'Pmv', topCommand=0) 219 else: 220 return "ERROR"
221 222
223 - def __call__(self, atoms, **kw):
224 """None<-addBondsGC(atoms) 225 \natoms : atom(s)""" 226 if type(atoms) is StringType: 227 self.nodeLogString = "'"+atoms+"'" 228 ats = self.vf.expandNodes(atoms) 229 if not len(ats): return 'ERROR' 230 return apply(self.doitWrapper, (ats,), kw)
231 232
233 - def doit(self, ats):
234 if len(ats)>2: 235 if len(self.atomList): 236 atSet = ats + self.atomList 237 else: atSet = ats 238 parent = atSet[0].parent 239 parent.buildBondsByDistanceOnAtoms(atSet) 240 self.atomList = AtomSet([]) 241 self.update() 242 else: 243 lenAts = len(self.atomList) 244 last = None 245 if lenAts: 246 last = self.atomList[-1] 247 top = self.atomList[0].top 248 for at in ats: 249 #check for repeats of same atom 250 if lenAts and at==last: 251 continue 252 #lenAts = len(self.atomList) 253 #if lenAts and at==self.atomList[-1]: 254 # continue 255 if lenAts and at.top!=self.atomList[-1].top: 256 msg = "intermolecular bond to %s disallowed"%(at.full_name()) 257 self.warningMsg(msg) 258 self.atomList.append(at) 259 self.undoAtList.append(at) 260 lenAts = len(self.atomList) 261 self.update() 262 #if only have one atom, there is nothing else to do 263 if lenAts<2: return 264 #now build bonds between pairs of atoms 265 atSet = self.atomList 266 if lenAts%2!=0: 267 atSet = atSet[:-1] 268 #all pairs of atoms will be bonded 269 #so keep only the last one 270 self.atomList = atSet[-1:] 271 lenAts = lenAts -1 272 else: 273 self.vf.labelByExpression(self.atomList, negate=1, topCommand=0) 274 self.atomList = AtomSet([]) 275 for i in range(0, lenAts, 2): 276 at1 = atSet[i] 277 at2 = atSet[i+1] 278 self.vf.addBonds(at1, at2, origin='UserDefined', topCommand=0) 279 self.update()
280 281
282 - def applyTransformation(self, pt, mat):
283 pth = [pt[0], pt[1], pt[2], 1.0] 284 return Numeric.matrixmultiply(mat, pth)[:3]
285 286
287 - def getTransformedCoords(self, atom):
288 if not atom.top.geomContainer: 289 return atom.coords 290 g = atom.top.geomContainer.geoms['master'] 291 c = self.applyTransformation(atom.coords, g.GetMatrix(g)) 292 return c.astype('f')
293 294
295 - def update(self, event=None):
296 if not len(self.atomList): 297 self.spheres.Set(vertices=[], tagModified=False) 298 self.vf.labelByExpression(self.atomList, negate=1, topCommand=0) 299 self.vf.GUI.VIEWER.Redraw() 300 return 301 self.lineVertices=[] 302 #each time have to recalculate lineVertices 303 for at in self.atomList: 304 c1 = self.getTransformedCoords(at) 305 self.lineVertices.append(tuple(c1)) 306 self.spheres.Set(vertices=self.lineVertices, tagModified=False) 307 self.vf.labelByExpression(self.atomList, 308 function = 'lambda x: x.full_name()', 309 lambdaFunc = 1, 310 textcolor = 'yellow', 311 format = '', negate = 0, 312 location = 'Last', log = 0, 313 font = 'arial1.glf', only = 1, 314 topCommand=0) 315 #setting spheres doesn't trigger redraw so do it explicitly 316 self.vf.GUI.VIEWER.Redraw()
317 318
319 - def guiCallback(self, event=None):
320 self.vf.setICOM(self, topCommand=0)
321 322
323 - def setupUndoAfter(self, ats, **kw):
324 325 lenUndoAts = len(self.undoAtList) 326 lenAts = len(ats) 327 if lenAts==1: 328 #after adding 1 self.atomList would be 1 or 0 329 if len(self.atomList)==1: 330 s = '0' 331 ustr='"c=self.addBondsGC; self.labelByExpression(c.atomList, negate=1, topCommand=0);c.atomList=c.atomList[:'+s+'];c.undoAtList=c.undoAtList[:-1];c.update()"' 332 else: 333 ind = str(lenUndoAts - 2) 334 ustr = '"c=self.addBondsGC;nodes=self.expandNodes('+'\''+self.undoAtList[-2:].full_name()+'\''+'); bonds=nodes.bonds[0];self.removeBondsGC(bonds, topCommand=0);c.atomList=nodes[:1];c.undoAtList=c.undoAtList[:'+ind+'];c.update()"' 335 elif lenUndoAts>lenAts: 336 ustr='"c=self.addBondsGC;nodes=self.expandNodes('+'\''+ats.full_name()+'\''+');bonds = nodes.bonds[0];self.removeBondsGC(bonds, topCommand=0);c.undoAtList=c.undoAtList[:'+str(lenAts)+']"' 337 else: 338 ustr='"c=self.addBondsGC;nodes=self.expandNodes('+'\''+ats.full_name()+'\''+');bonds = nodes.bonds[0];self.removeBondsGC(bonds, topCommand=0);c.undoAtList=c.undoAtList[:0]"' 339 if len(self.atomList) and lenAts>1: 340 atStr = self.atomList.full_name() 341 estr = ';nodes=self.expandNodes('+'\''+self.atomList.full_name()+'\''+');c.atomList=nodes;c.update()"' 342 ustr = ustr + estr 343 self.undoCmds = "exec("+ustr+")"
344 345
346 - def startICOM(self):
347 self.vf.setIcomLevel( Atom )
348
349 - def stopICOM(self):
350 if len(self.atomList)!=0: 351 self.vf.labelByExpression(self.atomList, negate=1, topCommand = 0) 352 del self.atomList[:] 353 self.labelStrs = [] 354 self.spheres.Set(vertices=[], tagModified=False) 355 self.vf.GUI.VIEWER.Redraw()
356 357 358 AddBondsGUICommandGUI=CommandGUI() 359 AddBondsGUICommandGUI.addMenuCommand('menuRoot', 'Edit', 'Add', 360 cascadeName='Bonds') 361 362 363
364 -class AddBondsCommand(MVCommand):
365 """ 366 The AddBondsCommand is a command to connect two given atoms.This command will not allow the creation inter-molecular bonds.This command doesn't have a GUI interface and can only be called through the pyShell. 367 \nPackage : Pmv 368 \nModule : bondsCommands 369 \nClass : AddBondsCommand 370 \nCommand : addBonds 371 \nSynopsis:\n 372 None<-addBonds(atom1,atom2)\n 373 \nRequired Arguments:\n 374 atom1 : first atom\n 375 atom2 : second atom \n 376 \nOptional Arguments:\n 377 bondOrder : Integer specifying the bondOrder of the bond that is going to be created between atom1 and atom2.The bondOrder by default is 1.\n 378 origin : string describing how bond was specified \n 379 """ 380
381 - def onAddCmdToViewer(self):
382 if not self.vf.commands.has_key('removeBonds'): 383 self.vf.loadCommand('bondsCommands', 'removeBonds', 'Pmv', 384 topCommand=0)
385 386
387 - def setupUndoBefore(self, atom1, atom2, bondOrder=1, origin='UserDefined'):
388 389 self.addUndoCall((atom1.full_name(),atom2.full_name()), 390 {'topCommand':0}, self.vf.removeBonds.name)
391 392
393 - def undo(self, atom1, atom2, **kw):
394 395 self.vf.removeBonds(atom1, atom2, topCommand=0)
396 397
398 - def __call__(self, atom1, atom2, bondOrder=1, origin='UserDefined', **kw):
399 """None<-addBonds(atom1, atom2) 400 \natom1 : first atom 401 \natom2 : second atom 402 \nbondOrder : Integer specifying the bondOrder of the bond that is going to be created between atom1 and atom2.The bondOrder by default is 1. 403 \norigin : string describing how bond was specified""" 404 405 ats = self.vf.expandNodes(atom1) 406 if not len(ats): return 'ERROR' 407 at1 = ats[0] 408 ats = self.vf.expandNodes(atom2) 409 if not len(ats): return 'ERROR' 410 at2 = ats[0] 411 if at1.top!=at2.top: 412 msg = "intermolecular bond between %s and %s \ 413 disallowed"%(at1.full_name(), at2.full_name()) 414 self.warningMsg(msg) 415 return 'ERROR' 416 417 bnds = AtomSet([at1, at2]).bonds[0] 418 if len(bnds): 419 msg = " bond between %s and %s already \ 420 exists"%(at1.full_name(), at2.full_name()) 421 return 'ERROR' 422 kw['bondOrder'] = bondOrder 423 kw['origin'] = origin 424 return apply(self.doitWrapper, (at1, at2), kw)
425 426
427 - def doit(self, atom1, atom2, **kw):
428 origin = kw['origin'] 429 bondOrder = kw['bondOrder'] 430 bond = Bond( atom1, atom2, origin=origin, bondOrder=bondOrder) 431 event = EditAtomsEvent('coords', AtomSet([atom1, atom2])) 432 self.vf.dispatchEvent(event)
433 434
435 -class RemoveBondsGUICommand(MVCommand, MVBondICOM):
436 """ The RemoveBondsGUICommands provides an interactive way of deleting picked bonds. To use this command you need to first load it in the application. Once loaded you will find an entry called 'delete bonds' under the bonds entry in the Edit menu. You can then pick on the bonds you wish to delete. This command is undoable. 437 \nPackage : Pmv 438 \nModule : bondsCommands 439 \nClass : RemoveBondsGUICommand 440 \nCommand : removeBondsGC 441 \nSynopsis:\n 442 None<---removeBondsGC(bonds)\n 443 \nRequired Arguments:\n 444 bonds : bond(s)\n 445 """ 446
447 - def onAddCmdToViewer(self):
448 if self.vf.hasGui: 449 if not hasattr(self.vf, 'addBondsGC'): 450 self.vf.loadCommand("bondsCommands", "addBondsGC", "Pmv") 451 if not self.vf.commands.has_key('removeBonds'): 452 self.vf.loadCommand('bondsCommands', 'removeBonds', 'Pmv', 453 topCommand=0) 454 else: 455 return "ERROR"
456 457
458 - def __init__(self, func = None):
459 MVCommand.__init__(self, func) 460 MVBondICOM.__init__(self) 461 self.pickLevel = 'parts' 462 self.undoBondList = []
463 464
465 - def guiCallback(self):
466 self.save = self.vf.ICmdCaller.commands.value[None] 467 self.vf.setICOM(self, topCommand = 0) 468 self.vf.setIcomLevel( Atom )
469 470
471 - def stop(self):
472 self.done_cb()
473 474
475 - def getObjects(self, pick):
476 for o, val in pick.hits.items(): #loop over geometries 477 primInd = map(lambda x: x[0], val) 478 g = o.mol.geomContainer 479 if g.geomPickToBonds.has_key(o.name): 480 func = g.geomPickToBonds[o.name] 481 if func: return func(o, primInd) 482 else: 483 l = [] 484 bonds = g.atoms[o.name].bonds[0] 485 if not len(bonds): return BondSet() 486 for i in range(len(primInd)): 487 l.append(bonds[int(primInd[i])]) 488 return BondSet(l)
489 490
491 - def dismiss(self):
492 self.vf.setICOM(self.save, topCommand = 0) 493 self.save = None 494 self.done_cb()
495 496
497 - def done_cb(self):
498 pass
499 500
501 - def __call__(self, bonds, **kw):
502 """None <- removeBondsGC(bonds, **kw) 503 \nbonds: bonds 504 """ 505 kw['log'] = 0 506 if not len(bonds): 507 return 'ERROR' 508 apply(self.doitWrapper, (bonds,), kw)
509 510 511
512 - def doit(self, bonds):
513 global var 514 var=1 515 ats = AtomSet([]) 516 for bond in bonds: 517 ats.append(bond.atom1) 518 ats.append(bond.atom2) 519 self.vf.removeBonds(bond.atom1, bond.atom2) 520 var=0 521 self.vf.GUI.VIEWER.Redraw()
522 523
524 - def setupUndoBefore(self, bonds):
525 for b in bonds: 526 nameStr = AtomSet([b.atom1, b.atom2]).full_name() 527 self.addUndoCall((nameStr,),{}, self.vf.addBondsGC.name)
528 529 530 RemoveBondsGUICommandGUI=CommandGUI() 531 RemoveBondsGUICommandGUI.addMenuCommand('menuRoot', 'Edit', 532 'Remove Bonds', cascadeName='Bonds') 533 534 535
536 -class RemoveBondsCommand(MVCommand):
537 """ 538 The RemoveBondsCommand allows the user to remove the bond existing between two given atoms (atom1 and atom2). This command doesn't have a gui and therefore can only be called through the pyShell. 539 \nPackage : Pmv 540 \nModule : bondsCommands 541 \nClass : RemoveBondsCommand 542 \nCommand : removeBonds 543 \nSynopsis:\n 544 None<---removeBonds(atom1,atom2)\n 545 \nRequired Arguments:\n 546 atom1 : first atom\n 547 atom2 : second atom\n 548 """ 549
550 - def onAddCmdToViewer(self):
551 if not hasattr(self.vf, 'addBonds'): 552 self.vf.loadCommand("bondsCommands", "addBonds", "Pmv")
553 554 555 #def undo(self, atom1, atom2, **kw): 556 #self.vf.addBonds(atom1, atom2) 557
558 - def setupUndoBefore(self, atom1, atom2):
559 # The undo is to recreate the bond you just deleted.when 560 # removebondsCommand called 561 global var 562 if var ==0: 563 self.addUndoCall( (atom1, atom2), {} ,self.vf.addBonds.name)
564 565
566 - def __call__(self, atom1, atom2, **kw):
567 """None<-removeBonds(atom1, atom2) 568 \natom1 : first atom 569 \natom2 : second atom """ 570 ats = self.vf.expandNodes(atom1) 571 if not len(ats): return 'ERROR' 572 at1 = ats[0] 573 ats = self.vf.expandNodes(atom2) 574 if not len(ats): return 'ERROR' 575 at2 = ats[0] 576 return apply(self.doitWrapper, (at1, at2), kw)
577 578
579 - def doit(self, atom1, atom2):
580 #Have to find the bond first 581 582 theBond = None 583 for b in atom1.bonds: 584 at2 = b.atom1 585 if at2 == atom1: 586 at2 = b.atom2 587 if at2 == atom2: 588 #remove this bond 589 theBond = b 590 atom2.bonds.remove(theBond) 591 #this may not be possible 592 atom1.bonds.remove(theBond) 593 atom1.parent.hasBonds=0 594 if atom2.parent!=atom1.parent: 595 atom2.parent.hasBonds = 0 596 if atom1.parent.parent: 597 atom1.parent.parent.hasBonds = 0 598 if atom2.parent.parent: 599 atom2.parent.parent.hasBonds = 0 600 break 601 602 if not theBond: 603 from warnings import warn 604 warn('bond not found %s-%s'%(atom1, atom2)) 605 return 'ERROR' 606 else: 607 event = EditAtomsEvent('coords', AtomSet([atom1, atom2])) 608 self.vf.dispatchEvent(event)
609 610 611 commandList = [ 612 {'name':'buildBondsByDistance', 'cmd':BuildBondsByDistance(), 613 'gui':BuildBondsByDistanceGUI}, 614 {'name':'addBonds', 'cmd':AddBondsCommand(), 'gui':None}, 615 {'name':'addBondsGC','cmd':AddBondsGUICommand(), 616 'gui':AddBondsGUICommandGUI}, 617 {'name':'removeBonds', 'cmd':RemoveBondsCommand(), 'gui':None}, 618 {'name':'removeBondsGC','cmd':RemoveBondsGUICommand(), 619 'gui':RemoveBondsGUICommandGUI} 620 621 ] 622
623 -def initModule(viewer):
624 for dict in commandList: 625 viewer.addCommand(dict['cmd'], dict['name'], dict['gui'])
626