- Timestamp:
- Jun 1, 2020 12:40:11 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIphsGUI.py
r4450 r4451 1096 1096 #### Phase editing routines 1097 1097 ################################################################################ 1098 def getAtomSelections(AtmTbl,action='action'): 1099 '''get selected atoms from table or ask user if none are selected''' 1098 def getAtomSelections(AtmTbl,cn=0,action='action'): 1099 '''get selected atoms from table or ask user if none are selected 1100 1101 param: AtmTbl list atom or draw atom table 1102 param: int cn atom name position 1103 action: str description 1104 returns: list indx selected atoms fr tom indices in table 1105 ''' 1100 1106 indx = AtmTbl.GetSelectedRows() 1101 1107 indx += [row for row,col in AtmTbl.GetSelectedCells()] … … 1107 1113 choices = [] 1108 1114 for i in range(AtmTbl.GetNumberRows()): 1109 val = AtmTbl.GetCellValue(i, 0)1115 val = AtmTbl.GetCellValue(i,cn) 1110 1116 if val in choices: 1111 1117 val += '_' + str(i) … … 1118 1124 dlg.Destroy() 1119 1125 return indx 1126 1127 def getAtomPtrs(data,draw=False): 1128 ''' get atom data pointers cx,ct,cs,cia in Atoms or Draw Atoms lists 1129 NB:may not match column numbers in displayed table 1130 1131 param: dict: data phase data structure 1132 draw: boolean True if Draw Atoms list pointers are required 1133 return: cx,ct,cs,cia pointers to atom xyz, type, site sym, uiso/aniso flag 1134 ''' 1135 if draw: 1136 return data['Drawing']['atomPtrs'] 1137 else: 1138 return data['General']['AtomPtrs'] 1120 1139 1121 1140 def SetPhaseWindow(phasePage,mainSizer=None,Scroll=0): … … 3532 3551 '''Inserts a new atom into list immediately before every selected atom 3533 3552 ''' 3534 indx = getAtomSelections(Atoms) 3553 cx,ct,cs,ci = getAtomPtrs(data) 3554 indx = getAtomSelections(Atoms,ct-1) 3535 3555 for a in reversed(sorted(indx)): 3536 3556 AtomInsert(a,0.,0.,0.) … … 3552 3572 '''Adds H atoms to fill out coordination sphere for selected atoms 3553 3573 ''' 3554 indx = getAtomSelections(Atoms) 3574 cx,ct,cs,ci = getAtomPtrs(data) 3575 indx = getAtomSelections(Atoms,ct-1) 3555 3576 if not indx: return 3556 3577 DisAglCtls = {} … … 3570 3591 dlg.Destroy() 3571 3592 generalData['DisAglCtls'] = DisAglCtls 3572 cx,ct,cs,cia = generalData['AtomPtrs']3573 3593 atomData = data['Atoms'] 3574 3594 AtNames = [atom[ct-1] for atom in atomData] … … 3675 3695 3676 3696 def OnAtomMove(event): 3697 cx,ct,cs,ci = getAtomPtrs(data) 3698 indx = getAtomSelections(Atoms,ct-1) 3677 3699 drawData = data['Drawing'] 3678 3700 atomData = data['Atoms'] … … 3681 3703 cx = colLabels.index('x') 3682 3704 ci = colLabels.index('I/A') 3683 indx = getAtomSelections(Atoms)3684 3705 if len(indx) != 1: 3685 3706 G2frame.ErrorDialog('Atom move error','Only one atom can be moved') … … 3777 3798 3778 3799 def AtomDelete(event): 3800 cx,ct,cs,ci = getAtomPtrs(data,ct-1) 3801 indx = getAtomSelections(Atoms) 3779 3802 colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())] 3780 3803 HydIds = data['General']['HydIds'] 3781 3804 ci = colLabels.index('I/A') 3782 indx = getAtomSelections(Atoms)3783 3805 IDs = [] 3784 3806 if not indx: return … … 3808 3830 3809 3831 def AtomRefine(event): 3832 cx,ct,cs,ci = getAtomPtrs(data) 3833 indx = getAtomSelections(Atoms,ct-1) 3834 if not indx: return 3810 3835 colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())] 3811 3836 c = colLabels.index('refine') 3812 indx = getAtomSelections(Atoms)3813 if not indx: return3814 3837 atomData = data['Atoms'] 3815 3838 generalData = data['General'] … … 3832 3855 3833 3856 def AtomModify(event): 3834 indx = getAtomSelections(Atoms) 3857 cx,ct,cs,ci = getAtomPtrs(data) 3858 indx = getAtomSelections(Atoms,ct-1) 3835 3859 if not indx: return 3836 3860 atomData = data['Atoms'] … … 3942 3966 3943 3967 def AtomTransform(event): 3944 indx = getAtomSelections(Atoms) 3968 cx,ct,cs,ci = getAtomPtrs(data) 3969 indx = getAtomSelections(Atoms,ct-1) 3945 3970 if not indx: return 3946 3971 generalData = data['General'] … … 4011 4036 # 'yz':np.array([[0,i,j] for i in range(3) for j in range(3)])-np.array([1,1,0]), 4012 4037 # 'xyz':np.array([[i,j,k] for i in range(3) for j in range(3) for k in range(3)])-np.array([1,1,1])} 4013 # indx = getAtomSelections(Atoms) 4038 # cx,ct,cs,ci = getAtomPtrs(data) 4039 # indx = getAtomSelections(Atoms,ct-1) 4014 4040 # if indx: 4015 4041 # generalData = data['General'] … … 4055 4081 4056 4082 def MakeMolecule(event): 4057 indx = getAtomSelections(Atoms) 4083 cx,ct,cs,ci = getAtomPtrs(data) 4084 indx = getAtomSelections(Atoms,ct-1) 4058 4085 DisAglCtls = {} 4059 4086 if indx is not None and len(indx) == 1: … … 4107 4134 def OnDistAngle(event,fp=None,hist=False): 4108 4135 'Compute distances and angles' 4109 indx = getAtomSelections(Atoms) 4136 cx,ct,cs,ci = getAtomPtrs(data) 4137 indx = getAtomSelections(Atoms,ct-1) 4110 4138 Oxyz = [] 4111 4139 xyz = [] … … 4148 4176 try: 4149 4177 if hist: 4150 AtomLabels,DistArray,AngArray = G2stMn.RetDistAngle(DisAglCtls,DisAglData) 4178 pgbar = wx.ProgressDialog('Distance Angle calculation','Atoms done=',len(Oxyz)+1, 4179 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE) 4180 AtomLabels,DistArray,AngArray = G2stMn.RetDistAngle(DisAglCtls,DisAglData,pgbar) 4181 pgbar.Destroy() 4151 4182 Bonds = [] 4152 4183 for dists in DistArray: … … 4154 4185 G2plt.PlotBarGraph(G2frame,Bonds,Xname=r'$\mathsf{Bonds,\AA}$', 4155 4186 Title='Bond distances for %s'%Atypes,PlotName='%s Bonds'%Atypes) 4187 print('Total number of bonds to %s is %d'%(Atypes,len(Bonds))) 4156 4188 Angles = [] 4157 4189 for angles in AngArray: … … 4159 4191 G2plt.PlotBarGraph(G2frame,Angles,Xname='$\mathsf{Angles,{^o}}$', 4160 4192 Title='Bond angles about %s'%Atypes,PlotName='%s Angles'%Atypes) 4193 print('Total number of angles about %s is %d'%(Atypes,len(Angles))) 4161 4194 4162 4195 elif fp: … … 7215 7248 drawingData['Atoms'].append(MakeDrawAtom(atom)) 7216 7249 7217 def OnRestraint(event): 7218 indx = getAtomSelections(drawAtoms) 7250 def OnRestraint(event): 7251 cx,ct,cs,ci = getAtomPtrs(data,draw=True) 7252 indx = getAtomSelections(drawAtoms,ct-1) 7219 7253 if not indx: return 7220 7254 indx = drawAtoms.GetSelectedRows() … … 7224 7258 generalData = data['General'] 7225 7259 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) 7226 cx,ct,cs,ci = drawingData['atomPtrs']7227 7260 atomData = drawingData['Atoms'] 7228 7261 atXYZ = [] … … 7272 7305 7273 7306 def OnDefineRB(event): 7274 indx = getAtomSelections(drawAtoms) 7307 cx,ct,cs,ci = getAtomPtrs(data,draw=True) 7308 indx = getAtomSelections(drawAtoms,ct-1) 7275 7309 if not indx: return 7276 7310 indx.sort() … … 7280 7314 generalData = data['General'] 7281 7315 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) 7282 cx,ct,cs,ci = drawingData['atomPtrs']7283 7316 atomData = drawingData['Atoms'] 7284 7317 rbXYZ = [] … … 7517 7550 7518 7551 def DrawAtomStyle(event): 7519 indx = getAtomSelections(drawAtoms) 7552 cx,ct,cs,ci = getAtomPtrs(data,draw=True) 7553 indx = getAtomSelections(drawAtoms,ct-1) 7520 7554 if not indx: return 7521 7555 generalData = data['General'] 7522 7556 atomData = data['Drawing']['Atoms'] 7523 cx,ct,cs,ci = data['Drawing']['atomPtrs']7524 7557 styleChoice = [' ','lines','vdW balls','sticks','balls & sticks','ellipsoids','polyhedra'] 7525 7558 if generalData['Type'] == 'macromolecular': … … 7539 7572 7540 7573 def DrawAtomLabel(event): 7541 indx = getAtomSelections(drawAtoms) 7574 cx,ct,cs,ci = getAtomPtrs(data,draw=True) 7575 indx = getAtomSelections(drawAtomsct-1) 7542 7576 if not indx: return 7543 7577 generalData = data['General'] 7544 7578 atomData = data['Drawing']['Atoms'] 7545 cx,ct,cs,ci = data['Drawing']['atomPtrs']7546 7579 styleChoice = [' ','type','name','number'] 7547 7580 if generalData['Type'] == 'macromolecular': … … 7559 7592 7560 7593 def DrawAtomColor(event): 7561 indx = getAtomSelections(drawAtoms) 7594 cx,ct,cs,ci = getAtomPtrs(data,draw=True) 7595 indx = getAtomSelections(drawAtoms,ct-1) 7562 7596 if not indx: return 7563 7597 if len(indx) > 1: … … 7566 7600 G2frame.GetStatusBar().SetStatusText('Change color, Add to Custom Colors, then OK',1) 7567 7601 atomData = data['Drawing']['Atoms'] 7568 cx,ct,cs,ci = data['Drawing']['atomPtrs']7569 7602 atmColors = [] 7570 7603 atmTypes = [] … … 7619 7652 7620 7653 def SetViewPoint(event): 7621 indx = getAtomSelections(drawAtoms) 7654 cx,ct,cs,ci = getAtomPtrs(data,draw=True) 7655 indx = getAtomSelections(drawAtoms,ct-1) 7622 7656 if not indx: return 7623 7657 atomData = data['Drawing']['Atoms'] 7624 cx = data['Drawing']['atomPtrs'][0]7625 7658 data['Drawing']['viewPoint'] = [atomData[indx[0]][cx:cx+3],[indx[0],0]] 7626 7659 # drawAtoms.ClearSelection() #do I really want to do this? … … 7635 7668 7636 7669 def AddSymEquiv(event): 7637 indx = getAtomSelections(drawAtoms) 7670 cx,ct,cs,ci = getAtomPtrs(data,draw=True) 7671 indx = getAtomSelections(drawAtoms,ct-1) 7638 7672 if not indx: return 7639 7673 indx.sort() 7640 7674 colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())] 7641 cx,ct,cs,cui = data['Drawing']['atomPtrs']7642 7675 cuij = cui+2 7643 7676 cmx = 0 … … 7690 7723 7691 7724 def AddSphere(event): 7692 indx = getAtomSelections(drawAtoms) 7725 cx,ct,cs,ci = getAtomPtrs(data,draw=True) 7726 indx = getAtomSelections(drawAtoms,ct-1) 7693 7727 if not indx: return 7694 7728 generalData = data['General'] … … 7696 7730 atomData = data['Drawing']['Atoms'] 7697 7731 numAtoms = len(atomData) 7698 cx,ct,cs,ci = data['Drawing']['atomPtrs']7699 7732 cuij = cs+5 7700 7733 colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())] -
trunk/GSASIIstrMain.py
r4450 r4451 575 575 return True,'Success' 576 576 577 def RetDistAngle(DisAglCtls,DisAglData ):577 def RetDistAngle(DisAglCtls,DisAglData,dlg=None): 578 578 '''Compute and return distances and angles 579 579 … … 635 635 DistArray = {} 636 636 AngArray = {} 637 for Oatom in origAtoms:637 for iO,Oatom in enumerate(origAtoms): 638 638 DistArray[Oatom[0]] = [] 639 639 AngArray[Oatom[0]] = [] … … 677 677 Vect.append([0.,0.,0.]) 678 678 VectA.append([]) 679 if dlg is not None: 680 dlg.Update(iO,newmsg='Atoms done=%d'%(iO)) 679 681 for D in Dist: 680 682 DistArray[Oatom[0]].append(D[1:])
Note: See TracChangeset
for help on using the changeset viewer.