Changeset 152


Ignore:
Timestamp:
Aug 9, 2010 10:59:07 AM (11 years ago)
Author:
vondreel
Message:

Atom types now forced to be in standard form, implement fully atom changes to type, name, etc.
Atom colors now follow the JMOL choices as found on Wikipedia!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r146 r152  
    131131       
    132132    def FillGeneralGrid():
     133        rowLabels = ['Phase name','Phase type','Space group',
     134            'Lattice ',' parameters','Scale factor','Elements','No. per cell',
     135            'Atom weight','','Bond radii','Angle radii','Color']
    133136        def SetLatticeParametersStyle(SGData,table):
    134137            clist = [1,2,3,4,5,6]
     
    197200            generalData['Scale'][1] = float(General.GetCellValue(5,1))
    198201            General.ForceRefresh()
    199                        
    200         rowLabels = ['Phase name','Phase type','Space group',
    201             'Lattice ',' parameters','Scale factor','Elements','No. per cell','Atom weight','','Bond radii','Angle radii']
     202           
    202203        generalData = data['General']
    203204        atomData = data['Atoms']
     
    207208        generalData['AngleRadii'] = []
    208209        generalData['AtomMass'] = []
     210        generalData['Color'] = []
    209211        colType = 1
    210212        colSS = 7
     
    214216            colSS = 10
    215217        for atom in atomData:
     218            atom[colType] = atom[colType].lower().capitalize()              #force to standard form
    216219            if generalData['AtomTypes'].count(atom[colType]):
    217220                generalData['NoAtoms'][atom[colType]] += atom[colSS-1]*atom[colSS+1]
    218             else:
     221            elif atom[colType] != 'UNK':
    219222                Info = G2elem.GetAtomInfo(atom[colType])
    220                 generalData['AtomTypes'].append(Info['Symbol'])
     223                generalData['AtomTypes'].append(atom[colType])
    221224                generalData['BondRadii'].append(Info['Drad'])
    222225                generalData['AngleRadii'].append(Info['Arad'])
    223226                generalData['AtomMass'].append(Info['Mass'])
    224227                generalData['NoAtoms'][atom[colType]] = atom[colSS-1]*atom[colSS+1]
     228                generalData['Color'].append(Info['Color'])
    225229        colLabels = []
    226230        colLabels += ['' for i in range(max(8,len(generalData['AtomTypes'])))]
     
    252256            table.append(generalData['BondRadii']+['' for i in range(max(8,len(generalData['AtomTypes'])))])
    253257            table.append(generalData['AngleRadii']+['' for i in range(max(8,len(generalData['AtomTypes'])))])
     258            table.append(['','','','','','','',''])                        #contains colors
    254259        Types = [wg.GRID_VALUE_STRING for i in range(max(8,len(generalData['AtomTypes'])))]
    255260        generalTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     
    259264        General.SetColSize(0,100)
    260265        General.SetColLabelSize(0)
     266        attr = wg.GridCellAttr()
    261267        for c in range(max(8,len(generalData['AtomTypes']))):
    262268            if c > 0:
     
    275281            for r in range(6,12):
    276282                General.SetReadOnly(r,c,isReadOnly=True)
     283        r = rowLabels.index('Color')
     284        for c in range(len(generalData['AtomTypes'])):
     285            General.SetCellBackgroundColour(r,c,generalData['Color'][c])
     286
    277287        General.SetReadOnly(4,7,isReadOnly=True)                            #cell volume - no edit
    278288        General.SetCellEditor(1,0,wg.GridCellChoiceEditor(['nuclear','modulated',   #phase type
     
    292302    def FillAtomsGrid():
    293303       
     304        generalData = data['General']
     305        atomData = data['Atoms']
     306        Types = [wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,wg.GRID_VALUE_CHOICE+": ,X,XU,U,F,FX,FXU,FU",
     307            wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_FLOAT+':10,4', #x,y,z,frac
     308            wg.GRID_VALUE_STRING,wg.GRID_VALUE_NUMBER,wg.GRID_VALUE_CHOICE+":I,A",
     309            wg.GRID_VALUE_FLOAT+':10,4',                                                            #Uiso
     310            wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,                         #Uij - placeholders
     311            wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING]
     312        colLabels = ['Name','Type','refine','x','y','z','frac','site sym','mult','I/A','Uiso','U11','U22','U33','U12','U13','U23']
     313        if generalData['Type'] == 'magnetic':
     314            colLabels += ['Mx','My','Mz']
     315            Types[2] = wg.GRID_VALUE_CHOICE+": ,X,XU,U,M,MX,MXU,MU,F,FX,FXU,FU,FM,FMX,FMU,"
     316            Types += [
     317                wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_FLOAT+':10,4']
     318        elif generalData['Type'] == 'macromolecular':
     319            colLabels = ['res no','residue','chain'] + colLabels
     320            Types = [wg.GRID_VALUE_NUMBER,
     321                wg.GRID_VALUE_CHOICE+": ,ALA,ARG,ASN,ASP,CYS,GLN,GLU,GLY,HIS,ILE,LEU,LYS,MET,PHE,PRO,SER,THR,TRP,TYR,VAL,MSE,HOH,UNK",
     322                wg.GRID_VALUE_STRING] + Types
     323        elif generalData['Type'] == 'modulated':
     324            Types += []
     325            colLabels += []
     326                   
    294327        def RefreshAtomGrid(event):
    295328           
     
    412445            elif c < 0:                    #picked atom row
    413446                self.SelectedRow = r
     447            elif Atoms.GetColLabelValue(c) in ['Name']:
     448                atomData[r][c] = Atoms.GetCellValue(r,c)
    414449            elif Atoms.GetColLabelValue(c) in ['x','y','z']:
    415450                ci = colLabels.index('x')
     
    463498                for i in range(6):
    464499                    if iUij == CSI[0][i]:
    465                         atomData[r][i+colLabels.index('U11')] = value*CSI[1][i]               
     500                        atomData[r][i+colLabels.index('U11')] = value*CSI[1][i]
    466501            Atoms.ForceRefresh()
    467502           
     
    487522                if PE.ShowModal() == wx.ID_OK:
    488523                    atomData[r][c] = PE.Elem.strip()
     524                    name = atomData[r][c]
     525                    if len(name) in [2,4]:
     526                        atomData[r][c-1] = name[:2]+'(%d)'%(r+1)
     527                    else:
     528                        atomData[r][c-1] = name[:1]+'(%d)'%(r+1)
    489529                PE.Destroy()
    490530                Atoms.ForceRefresh()
     
    492532                event.Skip()
    493533       
    494         generalData = data['General']
    495         atomData = data['Atoms']
    496         Types = [wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,wg.GRID_VALUE_CHOICE+": ,X,XU,U,F,FX,FXU,FU",
    497             wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_FLOAT+':10,4', #x,y,z,frac
    498             wg.GRID_VALUE_STRING,wg.GRID_VALUE_NUMBER,wg.GRID_VALUE_CHOICE+":I,A",
    499             wg.GRID_VALUE_FLOAT+':10,4',                                                            #Uiso
    500             wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,                         #Uij - placeholders
    501             wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING]
    502         colLabels = ['Name','Type','refine','x','y','z','frac','site sym','mult','I/A','Uiso','U11','U22','U33','U12','U13','U23']
    503         if generalData['Type'] == 'magnetic':
    504             colLabels += ['Mx','My','Mz']
    505             Types[2] = wg.GRID_VALUE_CHOICE+": ,X,XU,U,M,MX,MXU,MU,F,FX,FXU,FU,FM,FMX,FMU,"
    506             Types += [
    507                 wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_FLOAT+':10,4']
    508         elif generalData['Type'] == 'macromolecular':
    509             colLabels = ['res no','residue','chain'] + colLabels
    510             Types = [wg.GRID_VALUE_NUMBER,
    511                 wg.GRID_VALUE_CHOICE+": ,ALA,ARG,ASN,ASP,CYS,GLN,GLU,GLY,HIS,ILE,LEU,LYS,MET,PHE,PRO,SER,THR,TRP,TYR,VAL,MSE,HOH,UNK",
    512                 wg.GRID_VALUE_STRING] + Types
    513         elif generalData['Type'] == 'modulated':
    514             Types += []
    515             colLabels += []       
    516534        table = []
    517535        rowLabels = []
     
    568586        FillAtomsGrid()           
    569587        event.StopPropagation()
    570            
     588               
    571589    def AtomInsert(event):
    572590        indx = Atoms.GetSelectedRows()
     
    593611            indx.reverse()
    594612            for ind in indx:
     613                atom = atomData[ind]
    595614                del atomData[ind]               
    596615            FillAtomsGrid()           
     
    691710            self.dataFrame.Bind(wx.EVT_MENU, AtomModify, id=G2gd.wxID_ATOMSMODIFY)
    692711            self.dataFrame.Bind(wx.EVT_MENU, AtomTransform, id=G2gd.wxID_ATOMSTRANSFORM)
    693             FillAtomsGrid()           
     712            FillAtomsGrid()
     713        elif text == 'General':
     714            FillGeneralGrid()                   
     715            self.dataFrame.SetMenuBar(self.dataFrame.BlankMenu)
    694716        else:
    695717            self.dataFrame.SetMenuBar(self.dataFrame.BlankMenu)
Note: See TracChangeset for help on using the changeset viewer.