Changeset 2229
- Timestamp:
- Apr 28, 2016 1:40:56 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIgrid.py
r2228 r2229 69 69 wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,wxID_ATOMMOVE,wxID_MAKEMOLECULE, 70 70 wxID_ASSIGNATMS2RB,wxID_ATOMSPDISAGL, wxID_ISODISP,wxID_ADDHATOM,wxID_UPDATEHATOM, 71 wxID_WAVEVARY, 72 ] = [wx.NewId() for item in range(1 8)]71 wxID_WAVEVARY,wxID_ATOMSROTATE, 72 ] = [wx.NewId() for item in range(19)] 73 73 74 74 [ wxID_DRAWATOMSTYLE, wxID_DRAWATOMLABEL, wxID_DRAWATOMCOLOR, wxID_DRAWATOMRESETCOLOR, … … 516 516 parent = self.GetParent() 517 517 parent.Raise() 518 self.EndModal(wx.ID_CANCEL) 518 self.EndModal(wx.ID_CANCEL) 519 520 ################################################################################ 521 class RotationDialog(wx.Dialog): 522 ''' Get Rotate & translate matrix & vector 523 524 ''' 525 def __init__(self,parent): 526 wx.Dialog.__init__(self,parent,wx.ID_ANY,'Atom group rotation/translation', 527 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 528 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw! 529 self.Trans = np.eye(3) 530 self.Vec = np.zeros(3) 531 self.rotAngle = 0. 532 self.rotVec = np.array([0.,0.,1.]) 533 self.Expand = '' 534 self.Draw() 535 536 def Draw(self): 537 538 def OnMatValue(event): 539 Obj = event.GetEventObject() 540 ix,iy = Ind[Obj.GetId()] 541 val = Obj.GetValue() 542 if '/' in val: 543 vals = val.split('/') 544 self.Trans[iy,ix] = float(vals[0])/float(vals[1]) 545 else: 546 self.Trans[iy,ix] = float(Obj.GetValue()) 547 Obj.SetValue('%5.3f'%(self.Trans[iy,ix])) 548 549 550 def OnVecValue(event): 551 Obj = event.GetEventObject() 552 iy = Ind[Obj.GetId()] 553 val = Obj.GetValue() 554 if '/' in val: 555 vals = val.split('/') 556 self.Vec[iy] = float(vals[0])/float(vals[1]) 557 else: 558 self.Vec[iy] = float(Obj.GetValue()) 559 Obj.SetValue('%5.3f'%(self.Vec[iy])) 560 561 def OnExpand(event): 562 self.Expand = expand.GetValue() 563 564 def OnRotAngle(event): 565 self.rotAngle = float(rotangle.GetValue()) 566 rotangle.SetValue('%5.3f'%(self.rotAngle)) 567 Q = G2mth.AVdeg2Q(self.rotAngle,self.rotVec) 568 self.Trans = G2mth.Q2Mat(Q) 569 self.Draw() 570 571 def OnRotVec(event): 572 vals = rotvec.GetValue() 573 vals = vals.split() 574 self.rotVec = np.array([float(val) for val in vals]) 575 rotvec.SetValue('%5.3f %5.3f %5.3f'%(self.rotVec[0],self.rotVec[1],self.rotVec[2])) 576 Q = G2mth.AVdeg2Q(self.rotAngle,self.rotVec) 577 self.Trans = G2mth.Q2Mat(Q) 578 self.Draw() 579 580 self.panel.Destroy() 581 self.panel = wx.Panel(self) 582 Ind = {} 583 mainSizer = wx.BoxSizer(wx.VERTICAL) 584 MatSizer = wx.BoxSizer(wx.HORIZONTAL) 585 transSizer = wx.BoxSizer(wx.VERTICAL) 586 transSizer.Add(wx.StaticText(self.panel,label=" XYZ Transformation matrix && vector: "+ \ 587 "\n B*M*A*(X-V)+V = X'\n A,B: Cartesian transformation matrices")) 588 Trmat = wx.FlexGridSizer(3,5,0,0) 589 for iy,line in enumerate(self.Trans): 590 for ix,val in enumerate(line): 591 item = wx.TextCtrl(self.panel,value='%5.3f'%(val), 592 size=(50,25),style=wx.TE_PROCESS_ENTER) 593 Ind[item.GetId()] = [ix,iy] 594 item.Bind(wx.EVT_TEXT_ENTER,OnMatValue) 595 item.Bind(wx.EVT_KILL_FOCUS,OnMatValue) 596 Trmat.Add(item) 597 Trmat.Add((25,0),0) 598 vec = wx.TextCtrl(self.panel,value='%5.3f'%(self.Vec[iy]), 599 size=(50,25),style=wx.TE_PROCESS_ENTER) 600 Ind[vec.GetId()] = [iy] 601 vec.Bind(wx.EVT_TEXT_ENTER,OnVecValue) 602 vec.Bind(wx.EVT_KILL_FOCUS,OnVecValue) 603 Trmat.Add(vec) 604 transSizer.Add(Trmat) 605 MatSizer.Add((10,0),0) 606 MatSizer.Add(transSizer) 607 mainSizer.Add(MatSizer) 608 rotationBox = wx.BoxSizer(wx.HORIZONTAL) 609 rotationBox.Add(wx.StaticText(self.panel,label=' Rotation angle: '),0,WACV) 610 rotangle = wx.TextCtrl(self.panel,value='%5.3f'%(self.rotAngle), 611 size=(50,25),style=wx.TE_PROCESS_ENTER) 612 rotangle.Bind(wx.EVT_TEXT_ENTER,OnRotAngle) 613 rotangle.Bind(wx.EVT_KILL_FOCUS,OnRotAngle) 614 rotationBox.Add(rotangle,0,WACV) 615 rotationBox.Add(wx.StaticText(self.panel,label=' about vector: '),0,WACV) 616 rotvec = wx.TextCtrl(self.panel,value='%5.3f %5.3f %5.3f'%(self.rotVec[0],self.rotVec[1],self.rotVec[2]), 617 size=(100,25),style=wx.TE_PROCESS_ENTER) 618 rotvec.Bind(wx.EVT_TEXT_ENTER,OnRotVec) 619 rotvec.Bind(wx.EVT_KILL_FOCUS,OnRotVec) 620 rotationBox.Add(rotvec,0,WACV) 621 mainSizer.Add(rotationBox,0,WACV) 622 expandChoice = ['','xy','xz','yz','xyz'] 623 expandBox = wx.BoxSizer(wx.HORIZONTAL) 624 expandBox.Add(wx.StaticText(self.panel,label=' Expand -1 to +1 on: '),0,WACV) 625 expand = wx.ComboBox(self.panel,value=self.Expand,choices=expandChoice, 626 style=wx.CB_READONLY|wx.CB_DROPDOWN) 627 expand.Bind(wx.EVT_COMBOBOX,OnExpand) 628 expandBox.Add(expand,0,WACV) 629 expandBox.Add(wx.StaticText(self.panel,label=' and find unique atoms '),0,WACV) 630 mainSizer.Add(expandBox) 631 632 OkBtn = wx.Button(self.panel,-1,"Ok") 633 OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) 634 cancelBtn = wx.Button(self.panel,-1,"Cancel") 635 cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) 636 btnSizer = wx.BoxSizer(wx.HORIZONTAL) 637 btnSizer.Add((20,20),1) 638 btnSizer.Add(OkBtn) 639 btnSizer.Add((20,20),1) 640 btnSizer.Add(cancelBtn) 641 btnSizer.Add((20,20),1) 642 643 mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 644 self.panel.SetSizer(mainSizer) 645 self.panel.Fit() 646 self.Fit() 647 648 def GetSelection(self): 649 return self.Trans,self.Vec,self.Expand 650 651 def OnOk(self,event): 652 parent = self.GetParent() 653 parent.Raise() 654 self.EndModal(wx.ID_OK) 655 656 def OnCancel(self,event): 657 parent = self.GetParent() 658 parent.Raise() 659 self.EndModal(wx.ID_CANCEL) 519 660 520 661 ################################################################################ … … 1761 1902 self.AtomEdit.Append(id=wxID_ATOMSTRANSFORM, kind=wx.ITEM_NORMAL,text='Transform atoms', 1762 1903 help='Select atoms to transform first') 1904 self.AtomEdit.Append(id=wxID_ATOMSROTATE, kind=wx.ITEM_NORMAL,text='Rotate atoms', 1905 help='Select atoms to rotate first') 1763 1906 self.AtomEdit.Append(id=wxID_MAKEMOLECULE, kind=wx.ITEM_NORMAL,text='Assemble molecule', 1764 1907 help='Assemble molecule from scatterd atom positions') -
trunk/GSASIIphsGUI.py
r2218 r2229 2043 2043 css = colLabels.index('site sym') 2044 2044 atomData = data['Atoms'] 2045 generalData = data['General']2046 2045 SGData = generalData['SGData'] 2047 2046 dlg = G2gd.SymOpDialog(G2frame,SGData,True,True) … … 2085 2084 else: 2086 2085 print "select one or more rows of atoms" 2087 G2frame.ErrorDialog('Select atom',"select one or more atoms then redo") 2086 G2frame.ErrorDialog('Select atom',"select one or more atoms then redo") 2087 2088 def AtomRotate(event): 2089 Units = {'':np.zeros(3), 2090 'xy':np.array([[i,j,0] for i in range(3) for j in range(3)])-np.array([1,1,0]), 2091 'xz':np.array([[i,0,j] for i in range(3) for j in range(3)])-np.array([1,1,0]), 2092 'yz':np.array([[0,i,j] for i in range(3) for j in range(3)])-np.array([1,1,0]), 2093 '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])} 2094 indx = Atoms.GetSelectedRows() 2095 if indx: 2096 generalData = data['General'] 2097 A,B = G2lat.cell2AB(generalData['Cell'][1:7]) 2098 colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())] 2099 cx = colLabels.index('x') 2100 cuia = colLabels.index('I/A') #need to not do aniso atoms - stop with error? or force isotropic? 2101 css = colLabels.index('site sym') 2102 atomData = data['Atoms'] 2103 SGData = generalData['SGData'] 2104 dlg = G2gd.RotationDialog(G2frame) 2105 try: 2106 if dlg.ShowModal() == wx.ID_OK: 2107 M,T,Expand = dlg.GetSelection() 2108 Unit = Units[Expand] 2109 for ind in indx: 2110 XYZ = np.array(atomData[ind][cx:cx+3]) 2111 for unit in Unit: 2112 XYZ += unit 2113 XYZ -= T 2114 XYZ = np.inner(A,XYZ) #to Cartesian 2115 XYZ = np.inner(M,XYZ) #rotate 2116 XYZ = np.inner(B,XYZ)+T #back to crystal & translate 2117 if np.all(XYZ>=0.) and np.all(XYZ<1.0): 2118 atom = atomData[ind] 2119 atom[cx:cx+3] = XYZ 2120 atom[css:css+2] = G2spc.SytSym(XYZ,SGData) 2121 break 2122 finally: 2123 dlg.Destroy() 2124 Atoms.ClearSelection() 2125 Atoms.ForceRefresh() 2126 else: 2127 print "select one or more rows of atoms" 2128 G2frame.ErrorDialog('Select atom',"select one or more atoms then redo") 2088 2129 2089 2130 def MakeMolecule(event): … … 7293 7334 G2frame.dataFrame.Bind(wx.EVT_MENU, AtomModify, id=G2gd.wxID_ATOMSMODIFY) 7294 7335 G2frame.dataFrame.Bind(wx.EVT_MENU, AtomTransform, id=G2gd.wxID_ATOMSTRANSFORM) 7336 G2frame.dataFrame.Bind(wx.EVT_MENU, AtomRotate, id=G2gd.wxID_ATOMSROTATE) 7295 7337 G2frame.dataFrame.Bind(wx.EVT_MENU, MakeMolecule, id=G2gd.wxID_MAKEMOLECULE) 7296 7338 G2frame.dataFrame.Bind(wx.EVT_MENU, OnReloadDrawAtoms, id=G2gd.wxID_RELOADDRAWATOMS) -
trunk/GSASIIpwd.py
r2206 r2229 2081 2081 # result as Spec 2082 2082 x0 = profile[0] 2083 profile[3] = np.zeros(len(profile[0])) 2084 profile[4] = np.zeros(len(profile[0])) 2085 profile[5] = np.zeros(len(profile[0])) 2083 2086 iBeg = np.searchsorted(x0,limits[0]) 2084 2087 iFin = np.searchsorted(x0,limits[1])
Note: See TracChangeset
for help on using the changeset viewer.