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

Source Code for Module Pmv.colorPaletteCommands

 1  ######################################################################## 
 2  # 
 3  # Date: April 2006 Authors: Guillaume Vareille, Michel Sanner 
 4  # 
 5  #    vareille@scripps.edu 
 6  #    sanner@scripps.edu 
 7  # 
 8  #       The Scripps Research Institute (TSRI) 
 9  #       Molecular Graphics Lab 
10  #       La Jolla, CA 92037, USA 
11  # 
12  # Copyright: Guillaume Vareille, Michel Sanner and TSRI 
13  # 
14  ######################################################################### 
15  # 
16  # $Header$ 
17  # 
18  # $Id$ 
19  # 
20   
21  import types 
22   
23  from ViewerFramework.VFCommand import CommandGUI 
24   
25  from Pmv.mvCommand import MVCommand 
26  from DejaVu.colorMap import ColorMap 
27  from mglutil.util.callback import CallBackFunction 
28   
29 -class EditColorPaletteByAtomType(MVCommand):
30
31 - def onAddCmdToViewer(self):
32 if not self.vf.commands.has_key('colorByAtomType'): 33 self.vf.loadCommand('colorCommands', 'colorByAtomType', 'Pmv', topCommand = 0)
34 35
36 - def __call__(self, ramp, labels, **kw):
37 """ 38 None <- editPaletteByAtomType(self, colorDict, **kw) 39 """ 40 #print "__call__" 41 apply(self.doitWrapper, (ramp, labels), kw)
42 43
44 - def guiCallback(self):
45 #print "guiCallback" 46 lFunc = CallBackFunction(self.guiApply_cb) 47 self.vf.colorByAtomType.palette.addCallback(lFunc) 48 self.vf.colorByAtomType.palette.showColormapSettings_cb()
49 50
51 - def guiApply_cb(self, colorPalette):
52 #print "guiApply_cb" 53 apply(self.doitWrapper, (colorPalette.ramp, colorPalette.labels), )
54 55
56 - def doit(self, ramp, labels):
57 #print "doit" 58 ColorMap.configure(self.vf.colorByAtomType.palette, ramp=ramp, labels=labels)
59 60 61 EditColorPaletteByAtomTypeGUI = CommandGUI() 62 EditColorPaletteByAtomTypeGUI.addMenuCommand('menuRoot', 63 'Edit', 64 'Edit Color By Atom Type Palette', 65 cascadeName='color palettes') 66 67 commandList = [ 68 {'name':'editColorPaletteByAtomType', 69 'cmd':EditColorPaletteByAtomType(), 70 'gui':EditColorPaletteByAtomTypeGUI }, 71 ] 72 73
74 -def initModule(viewer):
75 for dict in commandList: 76 viewer.addCommand( dict['cmd'], dict['name'], dict['gui'])
77