Changeset 4615 for trunk


Ignore:
Timestamp:
Oct 21, 2020 9:08:35 PM (5 years ago)
Author:
toby
Message:

Add DrawAtoms_default config option to set default drawing type; add enumeration option for config vars

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIconstrGUI.py

    r4609 r4615  
    260260    'Convert atom to format needed to draw it'
    261261    generalData = data['General']
     262    deftype = G2obj.validateAtomDrawType(
     263        GSASIIpath.GetConfigValue('DrawAtoms_default'),generalData)
    262264    if generalData['Type'] in ['nuclear','faulted',]:
    263         atomInfo = [atom[:2]+atom[3:6]+['1',]+['vdW balls',]+
    264                     ['',]+[[255,255,255],]+atom[9:]+[[],[]]][0]
     265        atomInfo = [atom[:2]+atom[3:6]+['1']+[deftype]+
     266                    ['']+[[255,255,255]]+atom[9:]+[[],[]]][0]
    265267    ct,cs = [1,8]         #type & color
    266268    atNum = generalData['AtomTypes'].index(atom[ct])
  • TabularUnified trunk/GSASIIctrlGUI.py

    r4604 r4615  
    51895189        self.helpIndex = helpIndex
    51905190        self.wrap = wrap
     5191        self.msg = self.msg.replace(' & ',' && ')
    51915192    def _onClose(self,event):
    51925193        self.dlg.EndModal(wx.ID_CANCEL)
     
    56525653        self.sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
    56535654        self.choice = {}
    5654         btn = G2ChoiceButton(self, sorted(self.vars.keys(),key=lambda s: s.lower()),
     5655        choices = sorted([k for k in self.vars if not k.startswith('enum_')],
     5656                         key=lambda s: s.lower())
     5657        btn = G2ChoiceButton(self, choices,
    56555658            strLoc=self.choice,strKey=0,onChoice=self.OnSelection)
    56565659        btn.SetLabel("")
     
    57555758        if var not in self.vars:
    57565759            raise Exception("How did this happen?")
    5757         if type(self.vars[var][0]) is int:
     5760        if 'enum_'+var in self.vars:
     5761            choices = self.vars['enum_'+var][0]
     5762            self.colSel = EnumSelector(self,self.vars[var],1,choices,
     5763                                               OnChange=self.OnChange)       
     5764            self.varsizer.Add(self.colSel, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     5765        elif type(self.vars[var][0]) is int:
    57585766            ed = ValidatedTxtCtrl(self,self.vars[var],1,typeHint=int,OKcontrol=self.OnChange)
    57595767            self.varsizer.Add(ed, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     
    58295837        self.varsizer.Add(self.resetBtn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
    58305838        # show meaning, if defined
    5831         self.doclbl.SetLabel("Description of "+str(var))
    5832         if self.vars[var][3]:
    5833             self.docinfo.SetLabel(self.vars[var][3])
     5839        self.doclbl.SetLabel("Description of "+str(var))
     5840        vartxt = self.vars[var][3]
     5841        vartxt = StripIndents(vartxt.replace(' & ',' && '),True)
     5842        if vartxt:
     5843            self.docinfo.SetLabel(vartxt)
    58345844        else:
    58355845            self.docinfo.SetLabel("(not documented)")
     5846        self.docinfo.Wrap(500)
    58365847        self.sizer.Fit(self)
    58375848        self.CenterOnParent()
  • TabularUnified trunk/GSASIIobj.py

    r4590 r4615  
    32703270#%%
    32713271
     3272def validateAtomDrawType(typ,generalData={}):
     3273    '''Confirm that the selected Atom drawing type is valid for the current
     3274    phase. If not, use 'vdW balls'. This is currently used only for setting a
     3275    default when atoms are added to the atoms draw list.
     3276    '''
     3277    if typ in ('lines','vdW balls','sticks','balls & sticks','ellipsoids'):
     3278        return typ
     3279    elif generalData.get('Type','') == 'macromolecular':
     3280        if typ in ('backbone','ribbons','schematic'):
     3281            return typ
     3282    elif typ == 'polyhedra':
     3283        return 'polyhedra'
     3284    return 'vdW balls'
     3285
    32723286if __name__ == "__main__":
    32733287    # test variable descriptions
  • TabularUnified trunk/GSASIIphsGUI.py

    r4614 r4615  
    11191119    Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
    11201120    SGData = generalData['SGData']
     1121    deftype = G2obj.validateAtomDrawType(
     1122        GSASIIpath.GetConfigValue('DrawAtoms_default'),generalData)
    11211123    if generalData['Type'] in ['nuclear','faulted',]:
    11221124        if oldatom:
     
    11291131                atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:]+oldatom[17:]][0]
    11301132        else:
    1131             atomInfo = [atom[:2]+atom[3:6]+['1',]+['vdW balls',]+
     1133            atomInfo = [atom[:2]+atom[3:6]+['1',]+[deftype]+
    11321134                ['',]+[[255,255,255],]+atom[9:]+[[],[]]][0]
    11331135        ct,cs = [1,8]         #type & color
     
    11481150                atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:]+oldatom[20:]][0]
    11491151        else:
    1150             atomInfo = [atom[:2]+atom[3:6]+atom[7:10]+['1',]+['vdW balls',]+
     1152            atomInfo = [atom[:2]+atom[3:6]+atom[7:10]+['1',]+[deftype]+
    11511153                ['',]+[[255,255,255],]+atom[12:]+[[],[]]][0]
    11521154        ct,cs = [1,11]         #type & color
     
    11581160        atomInfo = [[atom[1].strip()+atom[0],]+
    11591161            [AA1letter[oneLetter]+atom[0],]+atom[2:5]+
    1160             atom[6:9]+['1',]+['vdW balls',]+['',]+[[255,255,255],]+atom[12:]+[[],[]]][0]
     1162            atom[6:9]+['1',]+[deftype]+['',]+[[255,255,255],]+atom[12:]+[[],[]]][0]
    11611163        ct,cs = [4,11]         #type & color
    11621164    atNum = generalData['AtomTypes'].index(atom[ct])
  • TabularUnified trunk/config_example.py

    r4345 r4615  
    223223newly-read images, but if changed the new value will be saved.
    224224'''
     225
     226enum_DrawAtoms_default = ['','lines','vdW balls','sticks','balls & sticks',
     227       'ellipsoids','polyhedra','backbone','ribbons','schematic']
     228'choices for DrawAtoms_default'
     229DrawAtoms_default = ''
     230'''Allows selection of the default plotting mode for structures
     231in Draw Atoms. The only valid values are:
     232'lines', 'vdW balls', 'sticks', 'balls & sticks', 'ellipsoids', 'polyhedra',
     233'backbone', 'ribbons', 'schematic', where 'polyhedra' is invalid for
     234macromolecular phases and 'backbone', 'ribbons' & 'schematic' is invalid for
     235non-macromolecular phases. %% If a non-valid choice is used (the default)
     236'vdW balls' is used.
     237'''
     238
Note: See TracChangeset for help on using the changeset viewer.