""" python/ui/ColourLegend.py: CCP4MG Molecular Graphics Program Copyright (C) 2001-2008 University of York, CCLRC Copyright (C) 2009 University of York This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3, modified in accordance with the provisions of the license to address the requirements of UK law. You should have received a copy of the modified GNU Lesser General Public License along with this library. If not, copies may be downloaded from http://www.ccp4.ac.uk/ccp4license.php This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. """ from Legend import * from dataobj import * from global_definitions import * class ColourLegend(Legend): #------------------------------------------------------------------------ def __init__(self,parent='',visible='1',name='', \ params = {}, restore_from_version=0, **keywords): #------------------------------------------------------------------------ params.update(keywords) self.master = params.get('master','') if not params.has_key('font'): params['font'] = FONTMANAGER().getFont('legend') Legend.__init__(self,parent=parent,visible=visible,name=name,params=params) master = get_dispobj(object_type='MolDisp',name=self.master) if master: self.add_dependency(master,['colour','delete'],[self.set_do_redraw,self.delete]) self.do_redraw = 2 #---------------------------------------------------------------------------- def set_do_redraw(self,**kw): #---------------------------------------------------------------------------- print 'ColourLegend.set_do_redraw' self.do_redraw == 2 #---------------------------------------------------------------------------- def draw(self,**keywords): #---------------------------------------------------------------------------- if not self.do_redraw: return 0 print 'ColourLegend.draw', self.do_redraw if self.do_redraw == 2: master = get_dispobj(object_type='MolDisp',name=self.master) if master: self.set_selection(text=master.getLegend()) if self.do_redraw>0: return Legend.draw(self) else: return 0 #------------------------------------------------------------------ def params(self): #------------------------------------------------------------------ pars = Legend.params(self) pars['master'] = self.master return pars