Changeset 835
- Timestamp:
- Jan 17, 2013 2:05:19 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ElementTable.py
r762 r835 11 11 White = (255, 255, 255) 12 12 ElTable = [ 13 (["H","H-1","D","D-1","T","T-1"],0,0, "Hydrogen", White, 0.0000,(255,255,255)),14 13 (["D","D-1"], 0,0, "Deuterium", White, 0.0000,(255,255,255)), 15 14 (["T","T-1"], 0,0, "Tritium", White, 0.0000,(255,255,255)), 15 (["H","H-1","D","D-1","T","T-1"],0,0, "Hydrogen", White, 0.0000,(255,255,255)), 16 16 (["He",], 17,0, "Helium", Noblecolor, 0.0000,(217,255,255)), 17 17 (["Li","Li+1"], 0,1, "Lithium", Alkcolor, 0.0004,(204,128,255)), -
trunk/GSASII.py
r831 r835 1285 1285 if not G2gd.GetPatternTreeItemId(self,self.root,'Rigid bodies'): 1286 1286 sub = self.PatternTree.AppendItem(parent=self.root,text='Rigid bodies') 1287 self.PatternTree.SetItemPyData(sub,{'Vector':{},'Residue':{},'Z-matrix':{}}) 1287 self.PatternTree.SetItemPyData(sub,{'Vector':{'AtInfo':{}}, 1288 'Residue':{'AtInfo':{}},'Z-matrix':{'AtInfo':{}}}) 1288 1289 1289 1290 class CopyDialog(wx.Dialog): -
trunk/GSASIIconstrGUI.py
r831 r835 626 626 ''' 627 627 if not data: 628 data.update({'Vector':{ },'Residue':{},'Z-matrix':{}}) #empty dict - fill it628 data.update({'Vector':{'AtInfo':{}},'Residue':{'AtInfo':{}},'Z-matrix':{'AtInfo':{}}}) #empty dict - fill it 629 629 630 630 Indx = {} … … 648 648 UpdateZMatrixRB() 649 649 650 def getMacroFile(macName): 651 defDir = os.path.join(os.path.split(__file__)[0],'GSASIImacros') 652 dlg = wx.FileDialog(G2frame,message='Choose '+macName+' rigid body macro file', 653 defaultDir=defDir,defaultFile="",wildcard="GSAS-II macro file (*.mac)|*.mac", 654 style=wx.OPEN | wx.CHANGE_DIR) 655 try: 656 if dlg.ShowModal() == wx.ID_OK: 657 macfile = dlg.GetPath() 658 macro = open(macfile,'Ur') 659 head = macro.readline() 660 if macName not in head: 661 print head 662 print '**** ERROR - wrong restraint macro file selected, try again ****' 663 macro = [] 664 else: # cancel was pressed 665 macxro = [] 666 finally: 667 dlg.Destroy() 668 return macro #advanced past 1st line 669 650 670 def OnAddRigidBody(event): 651 671 page = G2frame.dataDisplay.GetSelection() … … 658 678 659 679 def AddVectorRB(): 680 AtInfo = data['Vector']['AtInfo'] 660 681 dlg = MultiIntegerDialog(G2frame.dataDisplay,'New Rigid Body',['No. atoms','No. translations'],[1,1]) 661 682 if dlg.ShowModal() == wx.ID_OK: … … 668 689 rbTypes = ['C' for i in range(nAtoms)] 669 690 Info = G2elem.GetAtomInfo('C') 670 AtInfo = {'C':[Info['Drad'],Info['Color']]}691 AtInfo['C'] = [Info['Drad'],Info['Color']] 671 692 data['Vector'][rbId] = {'RBname':'UNKRB','VectMag':vecMag, 672 'VectRef':vecRef,'rbTypes':rbTypes,'rbVect':vecVal ,'AtInfo':AtInfo}693 'VectRef':vecRef,'rbTypes':rbTypes,'rbVect':vecVal} 673 694 dlg.Destroy() 674 695 UpdateVectorRB() 675 696 676 697 def AddResidueRB(): 677 pass 698 AtInfo = data['Residue']['AtInfo'] 699 macro = getMacroFile('rigid body') 700 if not macro: 701 return 702 macStr = macro.readline() 703 while macStr: 704 items = macStr.split() 705 print items 706 if 'I' == items[0]: 707 rbId = ran.randint(0,sys.maxint) 708 rbName = items[1] 709 rbTypes = [] 710 rbXYZ = [] 711 rbSeq = [] 712 atNames = [] 713 nAtms,nSeq,nOrig,mRef,nRef = [int(items[i]) for i in [2,3,4,5,6]] 714 for iAtm in range(nAtms): 715 macStr = macro.readline().split() 716 atName = macStr[0] 717 atNames.append(atName) 718 rbXYZ.append([float(macStr[i]) for i in [1,2,3]]) 719 atNames.append(atName[0]) #might not always work 720 if atName[0] not in AtInfo: 721 Info = G2elem.GetAtomInfo(atName[0]) 722 AtInfo[atName[0]] = [Info['Drad'],Info['Color']] 723 rbXYZ = np.array(rbXYZ)-np.array(rbXYZ[nOrig-1]) 724 for iSeq in range(nSeq): 725 macStr = macro.readline().split() 726 mSeq = int(macStr[0]) 727 rbseq = [] 728 for jSeq in range(mSeq): 729 macStr = macro.readline().split() 730 iBeg = int(macStr[0])-1 731 iFin = int(macStr[1])-1 732 nMove = int(macStr[2]) 733 iMove = [int(macStr[i]) for i in range(3,nMove+3)] 734 rbseq.append([iBeg,iFin,iMove]) 735 rbSeq.append(rbseq) 736 data['Residue'][rbId] = {'RBname':rbName,'rbXYZ':rbXYZ,'rbTypes':rbTypes, 737 'atNames':atNames,'rbRef':[nOrig-1,mRef-1,nRef-1],'rbSeq':rbSeq} 738 macStr = macro.readline() 739 macro.close() 678 740 679 741 def AddZMatrixRB(): … … 681 743 682 744 def UpdateVectorRB(): 745 AtInfo = data['Vector']['AtInfo'] 683 746 SetStatusLine(' You may use e.g. "sind(60)", "cos(60)", "c60" or "s60" for a vector entry') 684 747 def rbNameSizer(rbId,rbData): … … 699 762 rbId = Indx[Obj.GetId()] 700 763 Obj.SetValue(False) 701 G2plt.PlotRigidBody(G2frame,'Vector', data['Vector'][rbId],plotDefaults)764 G2plt.PlotRigidBody(G2frame,'Vector',AtInfo,rbData,plotDefaults) 702 765 703 766 nameSizer = wx.BoxSizer(wx.HORIZONTAL) … … 735 798 Obj.SetValue('%8.3f'%(val)) 736 799 UpdateVectorRB() 737 G2plt.PlotRigidBody(G2frame,'Vector', data['Vector'][rbId],plotDefaults)800 G2plt.PlotRigidBody(G2frame,'Vector',AtInfo,data['Vector'][rbId],plotDefaults) 738 801 739 802 def OnRBVectorRef(event): … … 758 821 return magSizer 759 822 760 def OnRBVectorVal(event):761 Obj = event.GetEventObject()762 rbId,imag,i = Indx[Obj.GetId()]763 try:764 val = float(Obj.GetValue())765 data['Vector'][rbId]['rbVect'][imag][i] = val766 except ValueError:767 pass768 UpdateVectorRB()769 G2plt.PlotRigidBody(G2frame,'Vector',data['Vector'][rbId],plotDefaults)770 771 823 def rbVectors(rbId,imag,mag,XYZ,rbData): 772 824 773 825 def TypeSelect(event): 826 AtInfo = data['Vector']['AtInfo'] 774 827 r,c = event.GetRow(),event.GetCol() 775 828 if vecGrid.GetColLabelValue(c) == 'Type': … … 778 831 if PE.Elem != 'None': 779 832 El = PE.Elem.strip().lower().capitalize() 780 if El not in rbData['rbRadii']: 781 rbData['rbRadii'][El] = G2elem.GetAtomInfo(El)['Drad'] 833 if El not in AtInfo: 834 Info = G2elem.GetAtomInfo(El) 835 AtInfo[El] = [Info['Drad']['Color']] 782 836 rbData['rbTypes'][r] = El 783 837 vecGrid.SetCellValue(r,c,El) … … 821 875 VectorRBSizer = wx.BoxSizer(wx.VERTICAL) 822 876 for rbId in data['Vector']: 823 rbData = data['Vector'][rbId] 824 VectorRBSizer.Add(rbNameSizer(rbId,rbData),0) 825 XYZ = np.array([[0.,0.,0.] for Ty in rbData['rbTypes']]) 826 for imag,mag in enumerate(rbData['VectMag']): 827 XYZ += mag*rbData['rbVect'][imag] 828 VectorRBSizer.Add(rbVectMag(rbId,imag,rbData),0) 829 VectorRBSizer.Add(rbVectors(rbId,imag,mag,XYZ,rbData),0) 830 VectorRBSizer.Add((5,5),0) 877 if rbId != 'AtInfo': 878 rbData = data['Vector'][rbId] 879 VectorRBSizer.Add(rbNameSizer(rbId,rbData),0) 880 XYZ = np.array([[0.,0.,0.] for Ty in rbData['rbTypes']]) 881 for imag,mag in enumerate(rbData['VectMag']): 882 XYZ += mag*rbData['rbVect'][imag] 883 VectorRBSizer.Add(rbVectMag(rbId,imag,rbData),0) 884 VectorRBSizer.Add(rbVectors(rbId,imag,mag,XYZ,rbData),0) 885 VectorRBSizer.Add((5,5),0) 831 886 VectorRBSizer.Layout() 832 887 VectorRBDisplay.SetSizer(VectorRBSizer,True) -
trunk/GSASIImacros/residue-rb.mac
r812 r835 78 78 1 79 79 2 3 1 4 80 2 80 3 81 81 2 5 4 6 7 8 9 82 82 5 6 3 7 8 9 -
trunk/GSASIIphsGUI.py
r834 r835 376 376 return 377 377 char = chr(key) 378 if char in '.+-/0123456789 ':378 if char in '.+-/0123456789cosind()': 379 379 self._tc.WriteText(char) 380 380 else: … … 1796 1796 rbXYZ = [] 1797 1797 rbType = [] 1798 AtInfo = {}1798 AtInfo = RBData['Vector']['AtInfo'] 1799 1799 for item in indx: 1800 1800 rbtype = atomData[item][ct] … … 1808 1808 rbId = ran.randint(0,sys.maxint) 1809 1809 RBData['Vector'][rbId] = {'RBname':'UNKRB','VectMag':[1.0,], 1810 'VectRef':[False,],'rbTypes':rbType,'rbVect':[rbXYZ,] ,'AtInfo':AtInfo}1810 'VectRef':[False,],'rbTypes':rbType,'rbVect':[rbXYZ,]} 1811 1811 print 'New rigid body added to set of rigid bodies' 1812 1812 -
trunk/GSASIIplot.py
r834 r835 3376 3376 ################################################################################ 3377 3377 3378 def PlotRigidBody(G2frame,rbType, rbData,defaults):3378 def PlotRigidBody(G2frame,rbType,AtInfo,rbData,defaults): 3379 3379 '''RB plotting package. Can show rigid body structures as balls & sticks 3380 3380 ''' 3381 3381 3382 def FindBonds(XYZ ,rbData): #uses numpy & masks - very fast even for proteins!3382 def FindBonds(XYZ): #uses numpy & masks - very fast even for proteins! 3383 3383 import numpy.ma as ma 3384 AtInfo = rbData['AtInfo']3385 3384 rbTypes = rbData['rbTypes'] 3386 3385 Radii = [] … … 3410 3409 for imag,mag in enumerate(rbData['VectMag']): 3411 3410 XYZ += mag*rbData['rbVect'][imag] 3412 Bonds = FindBonds(XYZ ,rbData)3411 Bonds = FindBonds(XYZ) 3413 3412 elif rbType == 'Residue': 3414 3413 pass … … 3580 3579 for iat,atom in enumerate(XYZ): 3581 3580 x,y,z = atom 3582 CL = rbData['AtInfo'][rbData['rbTypes'][iat]][1]3581 CL = AtInfo[rbData['rbTypes'][iat]][1] 3583 3582 color = np.array(CL)/255. 3584 3583 RenderSphere(x,y,z,radius,color) -
trunk/GSASIIpwdGUI.py
r814 r835 819 819 data['Lam'] = [data['Lam1'][0],data['Lam1'][0],0] 820 820 del(data['Lam1']) 821 UpdateInstrumentGrid(G2frame,data)821 wx.CallAfter(UpdateInstrumentGrid,data) 822 822 823 823 def OnLamPick(event):
Note: See TracChangeset
for help on using the changeset viewer.