1 | # -*- coding: utf-8 -*- |
---|
2 | #GSASII - phase data display routines |
---|
3 | ########### SVN repository information ################### |
---|
4 | # $Date: 2013-07-25 23:04:52 +0000 (Thu, 25 Jul 2013) $ |
---|
5 | # $Author: vondreele $ |
---|
6 | # $Revision: 1011 $ |
---|
7 | # $URL: trunk/GSASIIphsGUI.py $ |
---|
8 | # $Id: GSASIIphsGUI.py 1011 2013-07-25 23:04:52Z vondreele $ |
---|
9 | ########### SVN repository information ################### |
---|
10 | ''' |
---|
11 | *GSASIIphsGUI: Phase GUI* |
---|
12 | ------------------------- |
---|
13 | |
---|
14 | Module to create the GUI for display of phase information |
---|
15 | in the data display window when a phase is selected. |
---|
16 | Phase information is stored in one or more |
---|
17 | :ref:`Phase Tree Item <Phase_table>` objects. |
---|
18 | Note that there are functions |
---|
19 | that respond to some tabs in the phase GUI in other modules |
---|
20 | (such as GSASIIddata). |
---|
21 | |
---|
22 | ''' |
---|
23 | import wx |
---|
24 | import wx.grid as wg |
---|
25 | import wx.lib.gridmovers as wgmove |
---|
26 | import wx.wizard as wz |
---|
27 | import matplotlib as mpl |
---|
28 | import math |
---|
29 | import copy |
---|
30 | import time |
---|
31 | import sys |
---|
32 | import random as ran |
---|
33 | import cPickle |
---|
34 | import GSASIIpath |
---|
35 | GSASIIpath.SetVersionNumber("$Revision: 1011 $") |
---|
36 | import GSASIIlattice as G2lat |
---|
37 | import GSASIIspc as G2spc |
---|
38 | import GSASIIElem as G2elem |
---|
39 | import GSASIIElemGUI as G2elemGUI |
---|
40 | import GSASIIddataGUI as G2ddG |
---|
41 | import GSASIIplot as G2plt |
---|
42 | import GSASIIgrid as G2gd |
---|
43 | import GSASIIIO as G2IO |
---|
44 | import GSASIIstrMain as G2stMn |
---|
45 | import GSASIImath as G2mth |
---|
46 | import GSASIIpwd as G2pwd |
---|
47 | import numpy as np |
---|
48 | import numpy.linalg as nl |
---|
49 | import numpy.ma as ma |
---|
50 | |
---|
51 | VERY_LIGHT_GREY =Â wx.Colour(235,235,235) |
---|
52 | WHITE =Â wx.Colour(255,255,255) |
---|
53 | BLACK =Â wx.Colour(0,0,0) |
---|
54 | mapDefault =Â {'MapType':'','RefList':'','Resolution':0.5,'Show bonds':True, |
---|
55 | Â Â Â Â Â Â Â Â 'rho':[],'rhoMax':0.,'mapSize':10.0,'cutOff':50.,'Flip':False} |
---|
56 | # trig functions in degrees |
---|
57 | sind = lambda x: np.sin(x*np.pi/180.) |
---|
58 | tand = lambda x: np.tan(x*np.pi/180.) |
---|
59 | cosd = lambda x: np.cos(x*np.pi/180.) |
---|
60 | asind = lambda x: 180.*np.arcsin(x)/np.pi |
---|
61 | acosd = lambda x: 180.*np.arccos(x)/np.pi |
---|
62 | |
---|
63 | def SetPhaseWindow(mainFrame,phasePage,mainSizer): |
---|
64 | Â Â Â Â phasePage.SetSizer(mainSizer) |
---|
65 | Â Â Â Â Size =Â mainSizer.GetMinSize() |
---|
66 | Â Â Â Â Size[0]Â +=Â 40 |
---|
67 | Â Â Â Â Size[1]Â =Â max(Size[1],430)Â +Â 35 |
---|
68 | Â Â Â Â phasePage.SetSize(Size) |
---|
69 | Â Â Â Â phasePage.SetScrollbars(10,10,Size[0]/10-4,Size[1]/10-1) |
---|
70 | Â Â Â Â mainFrame.setSizePosLeft(Size) |
---|
71 | |
---|
72 | def UpdatePhaseData(G2frame,Item,data,oldPage): |
---|
73 | Â Â '''Create the data display window contents when a phase is clicked on |
---|
74 | Â Â in the man (data tree) window. |
---|
75 | Â Â Called only from :meth:`GSASIIgrid.MovePatternTreeToGrid`, |
---|
76 | Â Â which in turn is called from :meth:`GSASII.GSASII.OnPatternTreeSelChanged` |
---|
77 | Â Â when a tree item is selected. |
---|
78 | |
---|
79 | Â Â :param wx.frame G2frame: the main GSAS-II frame object |
---|
80 | Â Â :param wx.TreeItemId Item: the tree item that was selected |
---|
81 | Â Â :param dict data: all the information on the phase in a dictionary |
---|
82 | Â Â :param int oldPage: This sets a tab to select when moving |
---|
83 | Â Â Â from one phase to another, in which case the same tab is selected |
---|
84 | Â Â Â to display first. This is set only when the previous data tree |
---|
85 | Â Â Â selection is a phase, if not the value is None. The default action |
---|
86 | Â Â Â is to bring up the General tab. |
---|
87 | |
---|
88 | Â Â ''' |
---|
89 | Â Â Â Â |
---|
90 | #patch |
---|
91 |   if 'RBModels' not in data: |
---|
92 | Â Â Â Â data['RBModels']Â =Â {} |
---|
93 |   if 'MCSA' not in data: |
---|
94 | Â Â Â Â data['MCSA']Â =Â {'Models':[{'Type':'MD','Coef':[1.0,False,[0.3,3.],],'axis':[0,0,1]}],'Results':[],'AtInfo':{}} |
---|
95 |   if isinstance(data['MCSA']['Results'],dict): |
---|
96 | Â Â Â Â data['MCSA']['Results']Â =Â [] |
---|
97 | #end patch  |
---|
98 | |
---|
99 |   global rbAtmDict  |
---|
100 | Â Â rbAtmDict =Â {} |
---|
101 |   if G2frame.dataDisplay: |
---|
102 | Â Â Â Â G2frame.dataDisplay.Destroy() |
---|
103 | Â Â PhaseName =Â G2frame.PatternTree.GetItemText(Item) |
---|
104 | Â Â G2gd.SetDataMenuBar(G2frame) |
---|
105 | Â Â G2frame.dataFrame.SetLabel('Phase Data for '+PhaseName) |
---|
106 | Â Â G2frame.dataFrame.CreateStatusBar() |
---|
107 | Â Â G2frame.dataDisplay =Â G2gd.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize()) |
---|
108 | Â Â G2frame.dataDisplay.gridList =Â []Â # list of all grids in notebook |
---|
109 | Â Â |
---|
110 |   def SetupGeneral(): |
---|
111 | Â Â Â Â generalData =Â data['General'] |
---|
112 | Â Â Â Â atomData =Â data['Atoms'] |
---|
113 | Â Â Â Â generalData['AtomTypes']Â =Â [] |
---|
114 | Â Â Â Â generalData['Isotopes']Â =Â {} |
---|
115 | # various patches |
---|
116 |     if 'Isotope' not in generalData: |
---|
117 | Â Â Â Â Â Â generalData['Isotope']Â =Â {} |
---|
118 |     if 'Data plot type' not in generalData: |
---|
119 | Â Â Â Â Â Â generalData['Data plot type']Â =Â 'Mustrain' |
---|
120 |     if 'POhkl' not in generalData: |
---|
121 | Â Â Â Â Â Â generalData['POhkl']Â =Â [0,0,1] |
---|
122 |     if 'Map' not in generalData: |
---|
123 | Â Â Â Â Â Â generalData['Map']Â =Â mapDefault |
---|
124 |     if 'Flip' not in generalData: |
---|
125 | Â Â Â Â Â Â generalData['Flip']Â =Â {'RefList':'','Resolution':0.5,'Norm element':'None', |
---|
126 | Â Â Â Â Â Â Â Â 'k-factor':0.1,'k-Max':20.} |
---|
127 |     if 'doPawley' not in generalData: |
---|
128 | Â Â Â Â Â Â generalData['doPawley']Â =Â False |
---|
129 |     if 'Pawley dmin' not in generalData: |
---|
130 | Â Â Â Â Â Â generalData['Pawley dmin']Â =Â 1.0 |
---|
131 |     if 'Pawley neg wt' not in generalData: |
---|
132 | Â Â Â Â Â Â generalData['Pawley neg wt']Â =Â 0.0 |
---|
133 |     if 'Algolrithm' in generalData.get('MCSA controls',{}) or \ |
---|
134 |       'MCSA controls' not in generalData: |
---|
135 | Â Â Â Â Â Â generalData['MCSA controls']Â =Â {'Data source':'','Annealing':[50.,0.001,50], |
---|
136 | Â Â Â Â Â Â 'dmin':2.0,'Algorithm':'fast','Jump coeff':[0.95,0.5],'boltzmann':1.0, |
---|
137 | Â Â Â Â Â Â 'fast parms':[1.0,1.0,1.0],'log slope':0.9,'Cycles':1,'Results':[]} |
---|
138 | # end of patches |
---|
139 | Â Â Â Â generalData['NoAtoms']Â =Â {} |
---|
140 | Â Â Â Â generalData['BondRadii']Â =Â [] |
---|
141 | Â Â Â Â generalData['AngleRadii']Â =Â [] |
---|
142 | Â Â Â Â generalData['vdWRadii']Â =Â [] |
---|
143 | Â Â Â Â generalData['AtomMass']Â =Â [] |
---|
144 | Â Â Â Â generalData['Color']Â =Â [] |
---|
145 | Â Â Â Â generalData['Mydir']Â =Â G2frame.dirname |
---|
146 | Â Â Â Â cx,ct,cs,cia =Â [3,1,7,9] |
---|
147 |     if generalData['Type'] =='macromolecular': |
---|
148 | Â Â Â Â Â Â cx,ct,cs,cia =Â [6,4,10,12] |
---|
149 | Â Â Â Â generalData['AtomPtrs']Â =Â [cx,ct,cs,cia] |
---|
150 |     for atom in atomData: |
---|
151 | Â Â Â Â Â Â atom[ct]Â =Â atom[ct].lower().capitalize()Â Â Â Â Â Â Â #force to standard form |
---|
152 |       if generalData['AtomTypes'].count(atom[ct]): |
---|
153 | Â Â Â Â Â Â Â Â generalData['NoAtoms'][atom[ct]]Â +=Â atom[cs-1]*float(atom[cs+1]) |
---|
154 |       elif atom[ct] != 'UNK': |
---|
155 | Â Â Â Â Â Â Â Â Info =Â G2elem.GetAtomInfo(atom[ct]) |
---|
156 | Â Â Â Â Â Â Â Â generalData['AtomTypes'].append(atom[ct]) |
---|
157 | Â Â Â Â Â Â Â Â generalData['Z']Â =Â Info['Z'] |
---|
158 | Â Â Â Â Â Â Â Â generalData['Isotopes'][atom[ct]]Â =Â Info['Isotopes'] |
---|
159 | Â Â Â Â Â Â Â Â generalData['BondRadii'].append(Info['Drad']) |
---|
160 | Â Â Â Â Â Â Â Â generalData['AngleRadii'].append(Info['Arad']) |
---|
161 | Â Â Â Â Â Â Â Â generalData['vdWRadii'].append(Info['Vdrad']) |
---|
162 |         if atom[ct] in generalData['Isotope']: |
---|
163 | Â Â Â Â Â Â Â Â Â Â generalData['AtomMass'].append(Info['Isotopes'][generalData['Isotope'][atom[ct]]][0]) |
---|
164 | Â Â Â Â Â Â Â Â else: |
---|
165 | Â Â Â Â Â Â Â Â Â Â generalData['Isotope'][atom[ct]]Â =Â 'Nat. Abund.' |
---|
166 | Â Â Â Â Â Â Â Â Â Â generalData['AtomMass'].append(Info['Mass']) |
---|
167 | Â Â Â Â Â Â Â Â generalData['NoAtoms'][atom[ct]]Â =Â atom[cs-1]*float(atom[cs+1]) |
---|
168 | Â Â Â Â Â Â Â Â generalData['Color'].append(Info['Color']) |
---|
169 | Â Â Â Â F000X =Â 0. |
---|
170 | Â Â Â Â F000N =Â 0. |
---|
171 |     for i,elem in enumerate(generalData['AtomTypes']): |
---|
172 | Â Â Â Â Â Â F000X +=Â generalData['NoAtoms'][elem]*generalData['Z'] |
---|
173 | Â Â Â Â Â Â isotope =Â generalData['Isotope'][elem] |
---|
174 | Â Â Â Â Â Â F000N +=Â generalData['NoAtoms'][elem]*generalData['Isotopes'][elem][isotope][1] |
---|
175 | Â Â Â Â generalData['F000X']Â =Â F000X |
---|
176 | Â Â Â Â generalData['F000N']Â =Â F000N |
---|
177 | Â Â Â Â |
---|
178 | |
---|
179 | ################################################################################ |
---|
180 | ##### General phase routines |
---|
181 | ################################################################################ |
---|
182 | |
---|
183 |   def UpdateGeneral(): |
---|
184 | Â Â Â Â '''Draw the controls for the General phase data subpage |
---|
185 | Â Â Â Â ''' |
---|
186 | Â Â Â Â |
---|
187 | Â Â Â Â """ This is the default dictionary structure for phase data |
---|
188 | Â Â Â Â (taken from GSASII.py) |
---|
189 | Â Â Â Â 'General':{ |
---|
190 | Â Â Â Â Â Â 'Name':PhaseName |
---|
191 | Â Â Â Â Â Â 'Type':'nuclear' |
---|
192 | Â Â Â Â Â Â 'SGData':SGData |
---|
193 | Â Â Â Â Â Â 'Cell':[False,10.,10.,10.,90.,90.,90,1000.] |
---|
194 | Â Â Â Â Â Â 'AtomPtrs':[] |
---|
195 | Â Â Â Â Â Â 'Histogram list':['',] |
---|
196 | Â Â Â Â Â Â 'Pawley dmin':1.0, |
---|
197 | Â Â Â Â Â Â 'Pawley neg wt':0.0} |
---|
198 | Â Â Â Â 'Atoms':[] |
---|
199 | Â Â Â Â 'Drawing':{} |
---|
200 | Â Â Â Â """Â Â Â Â |
---|
201 | Â Â Â Â # UpdateGeneral execution starts here |
---|
202 | Â Â Â Â phaseTypes =Â ['nuclear','modulated','magnetic','macromolecular'] |
---|
203 | Â Â Â Â SetupGeneral() |
---|
204 | Â Â Â Â generalData =Â data['General'] |
---|
205 | Â Â Â Â Map =Â generalData['Map'] |
---|
206 | Â Â Â Â Flip =Â generalData['Flip'] |
---|
207 | Â Â Â Â MCSA =Â generalData['MCSA controls']Â |
---|
208 |     PWDR = any(['PWDR' in item for item in data['Histograms'].keys()]) |
---|
209 | Â Â Â Â # UpdateGeneral execution continues below |
---|
210 | Â Â Â Â |
---|
211 |     def NameSizer():          |
---|
212 |       def OnPhaseName(event): |
---|
213 | Â Â Â Â Â Â Â Â oldName =Â generalData['Name'] |
---|
214 | Â Â Â Â Â Â Â Â generalData['Name']Â =Â NameTxt.GetValue() |
---|
215 | Â Â Â Â Â Â Â Â G2frame.G2plotNB.Rename(oldName,generalData['Name']) |
---|
216 | Â Â Â Â Â Â Â Â G2frame.dataFrame.SetLabel('Phase Data for '+generalData['Name']) |
---|
217 | Â Â Â Â Â Â Â Â G2frame.PatternTree.SetItemText(Item,generalData['Name']) |
---|
218 | Â Â Â Â Â Â Â Â #Hmm, need to change phase name key in Reflection Lists for each histogram |
---|
219 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
220 |       def OnPhaseType(event): |
---|
221 |         if not generalData['AtomTypes']:       #can change only if no atoms! |
---|
222 | Â Â Â Â Â Â Â Â Â Â generalData['Type']Â =Â TypeTxt.GetValue() |
---|
223 | Â Â Â Â Â Â Â Â Â Â wx.CallAfter(UpdateGeneral) |
---|
224 | Â Â Â Â Â Â Â Â else: |
---|
225 | Â Â Â Â Â Â Â Â Â Â TypeTxt.SetValue(generalData['Type'])Â Â Â Â Â Â Â Â |
---|
226 | Â Â Â Â Â Â Â Â |
---|
227 |       def OnSpaceGroup(event): |
---|
228 | Â Â Â Â Â Â Â Â SpcGp =Â SGTxt.GetValue() |
---|
229 | Â Â Â Â Â Â Â Â SGErr,SGData =Â G2spc.SpcGroup(SpcGp) |
---|
230 | Â Â Â Â Â Â Â Â # try a lookup on the user-supplied name |
---|
231 |         if SGErr: |
---|
232 | Â Â Â Â Â Â Â Â Â Â SpGrpNorm =Â G2spc.StandardizeSpcName(SpcGp) |
---|
233 |           if SpGrpNorm: |
---|
234 | Â Â Â Â Â Â Â Â Â Â Â Â E,SGData =Â G2spc.SpcGroup(SpGrpNorm) |
---|
235 |             if not E: SGErr = False |
---|
236 |         if SGErr: |
---|
237 | Â Â Â Â Â Â Â Â Â Â text =Â [G2spc.SGErrors(SGErr)+'\nSpace Group set to previous'] |
---|
238 | Â Â Â Â Â Â Â Â Â Â SGTxt.SetValue(generalData['SGData']['SpGrp']) |
---|
239 | Â Â Â Â Â Â Â Â Â Â msg =Â 'Space Group Error' |
---|
240 | Â Â Â Â Â Â Â Â Â Â Style =Â wx.ICON_EXCLAMATION |
---|
241 | Â Â Â Â Â Â Â Â else: |
---|
242 | Â Â Â Â Â Â Â Â Â Â text =Â G2spc.SGPrint(SGData) |
---|
243 | Â Â Â Â Â Â Â Â Â Â generalData['SGData']Â =Â SGData |
---|
244 | Â Â Â Â Â Â Â Â Â Â msg =Â 'Space Group Information' |
---|
245 | Â Â Â Â Â Â Â Â Â Â Style =Â wx.ICON_INFORMATION |
---|
246 | Â Â Â Â Â Â Â Â Text =Â '' |
---|
247 |         for line in text: |
---|
248 | Â Â Â Â Â Â Â Â Â Â Text +=Â line+'\n' |
---|
249 | Â Â Â Â Â Â Â Â wx.MessageBox(Text,caption=msg,style=Style) |
---|
250 | #Â Â Â Â Â Â Â Â General.DestroyChildren()Â Â Â Â Â Â #needed to clear away bad cellSizer, etc. |
---|
251 | Â Â Â Â Â Â Â Â wx.CallAfter(UpdateGeneral) |
---|
252 | Â Â Â Â Â Â Â Â |
---|
253 | Â Â Â Â Â Â nameSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
254 | Â Â Â Â Â Â nameSizer.Add(wx.StaticText(General,-1,' Phase name: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
255 | Â Â Â Â Â Â NameTxt =Â wx.TextCtrl(General,-1,value=generalData['Name'],style=wx.TE_PROCESS_ENTER) |
---|
256 | Â Â Â Â Â Â NameTxt.Bind(wx.EVT_TEXT_ENTER,OnPhaseName) |
---|
257 | Â Â Â Â Â Â NameTxt.Bind(wx.EVT_KILL_FOCUS,OnPhaseName) |
---|
258 | Â Â Â Â Â Â nameSizer.Add(NameTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
259 | Â Â Â Â Â Â nameSizer.Add(wx.StaticText(General,-1,'Â Phase type: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
260 | Â Â Â Â Â Â TypeTxt =Â wx.ComboBox(General,-1,value=generalData['Type'],choices=phaseTypes, |
---|
261 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
262 |       TypeTxt.Bind(wx.EVT_COMBOBOX, OnPhaseType) |
---|
263 | Â Â Â Â Â Â nameSizer.Add(TypeTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
264 | Â Â Â Â Â Â nameSizer.Add(wx.StaticText(General,-1,'Â Space group: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
265 | Â Â Â Â Â Â SGTxt =Â wx.TextCtrl(General,-1,value=generalData['SGData']['SpGrp'],style=wx.TE_PROCESS_ENTER) |
---|
266 | Â Â Â Â Â Â SGTxt.Bind(wx.EVT_TEXT_ENTER,OnSpaceGroup) |
---|
267 | Â Â Â Â Â Â nameSizer.Add(SGTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
268 |       return nameSizer |
---|
269 | Â Â Â Â Â Â |
---|
270 |     def CellSizer(): |
---|
271 | Â Â Â Â Â Â |
---|
272 | Â Â Â Â Â Â cellGUIlist =Â [[['m3','m3m'],4,zip([" Unit cell: a = "," Vol = "],["%.5f","%.3f"],[True,False],[0,0])], |
---|
273 | Â Â Â Â Â Â [['3R','3mR'],6,zip([" a = "," alpha = "," Vol = "],["%.5f","%.3f","%.3f"],[True,True,False],[0,2,0])], |
---|
274 | Â Â Â Â Â Â [['3','3m1','31m','6/m','6/mmm','4/m','4/mmm'],6,zip([" a = "," c = "," Vol = "],["%.5f","%.5f","%.3f"],[True,True,False],[0,2,0])], |
---|
275 | Â Â Â Â Â Â [['mmm'],8,zip([" a = "," b = "," c = "," Vol = "],["%.5f","%.5f","%.5f","%.3f"], |
---|
276 | Â Â Â Â Â Â Â Â [True,True,True,False],[0,1,2,0])], |
---|
277 | Â Â Â Â Â Â [['2/m'+'a'],10,zip([" a = "," b = "," c = "," alpha = "," Vol = "], |
---|
278 | Â Â Â Â Â Â Â Â ["%.5f","%.5f","%.5f","%.3f","%.3f"],[True,True,True,True,False],[0,1,2,4,0])], |
---|
279 | Â Â Â Â Â Â [['2/m'+'b'],10,zip([" a = "," b = "," c = "," beta = "," Vol = "], |
---|
280 | Â Â Â Â Â Â Â Â ["%.5f","%.5f","%.5f","%.3f","%.3f"],[True,True,True,True,False],[0,1,2,4,0])], |
---|
281 | Â Â Â Â Â Â [['2/m'+'c'],10,zip([" a = "," b = "," c = "," gamma = "," Vol = "], |
---|
282 | Â Â Â Â Â Â Â Â ["%.5f","%.5f","%.5f","%.3f","%.3f"],[True,True,True,True,False],[0,1,2,4,0])], |
---|
283 | Â Â Â Â Â Â [['-1'],8,zip([" a = "," b = "," c = "," Vol = "," alpha = "," beta = "," gamma = "], |
---|
284 | Â Â Â Â Â Â Â Â ["%.5f","%.5f","%.5f","%.3f","%.3f","%.3f","%.3f"], |
---|
285 | Â Â Â Â Â Â Â Â [True,True,True,False,True,True,True],[0,1,2,0,3,4,5])]] |
---|
286 | Â Â Â Â Â Â Â Â |
---|
287 |       def OnCellRef(event): |
---|
288 | Â Â Â Â Â Â Â Â generalData['Cell'][0]Â =Â cellRef.GetValue() |
---|
289 | Â Â Â Â Â Â Â Â |
---|
290 |       def OnCellChange(event): |
---|
291 | Â Â Â Â Â Â Â Â SGData =Â generalData['SGData'] |
---|
292 | Â Â Â Â Â Â Â Â laue =Â SGData['SGLaue'] |
---|
293 |         if laue == '2/m': |
---|
294 | Â Â Â Â Â Â Â Â Â Â laue +=Â SGData['SGUniq'] |
---|
295 | Â Â Â Â Â Â Â Â cell =Â generalData['Cell'] |
---|
296 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
297 | Â Â Â Â Â Â Â Â ObjId =Â cellList.index(Obj.GetId()) |
---|
298 | Â Â Â Â Â Â Â Â try: |
---|
299 | Â Â Â Â Â Â Â Â Â Â value =Â max(1.0,float(Obj.GetValue())) |
---|
300 |         except ValueError: |
---|
301 |           if ObjId < 3:        #bad cell edge - reset |
---|
302 | Â Â Â Â Â Â Â Â Â Â Â Â value =Â controls[6+ObjId] |
---|
303 | Â Â Â Â Â Â Â Â Â Â else:Â Â Â Â Â Â Â Â Â Â Â Â #bad angle |
---|
304 | Â Â Â Â Â Â Â Â Â Â Â Â value =Â 90. |
---|
305 |         if laue in ['m3','m3m']: |
---|
306 | Â Â Â Â Â Â Â Â Â Â cell[1]Â =Â cell[2]Â =Â cell[3]Â =Â value |
---|
307 | Â Â Â Â Â Â Â Â Â Â cell[4]Â =Â cell[5]Â =Â cell[6]Â =Â 90.0 |
---|
308 | Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.5f"%(cell[1])) |
---|
309 |         elif laue in ['3R','3mR']: |
---|
310 |           if ObjId == 0: |
---|
311 | Â Â Â Â Â Â Â Â Â Â Â Â cell[1]Â =Â cell[2]Â =Â cell[3]Â =Â value |
---|
312 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.5f"%(cell[1])) |
---|
313 | Â Â Â Â Â Â Â Â Â Â else: |
---|
314 | Â Â Â Â Â Â Â Â Â Â Â Â cell[4]Â =Â cell[5]Â =Â cell[6]Â =Â value |
---|
315 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.5f"%(cell[4])) |
---|
316 |         elif laue in ['3','3m1','31m','6/m','6/mmm','4/m','4/mmm']:          |
---|
317 | Â Â Â Â Â Â Â Â Â Â cell[4]Â =Â cell[5]Â =Â 90. |
---|
318 | Â Â Â Â Â Â Â Â Â Â cell[6]Â =Â 120. |
---|
319 |           if laue in ['4/m','4/mmm']: |
---|
320 | Â Â Â Â Â Â Â Â Â Â Â Â cell[6]Â =Â 90. |
---|
321 |           if ObjId == 0: |
---|
322 | Â Â Â Â Â Â Â Â Â Â Â Â cell[1]Â =Â cell[2]Â =Â value |
---|
323 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.5f"%(cell[1])) |
---|
324 | Â Â Â Â Â Â Â Â Â Â else: |
---|
325 | Â Â Â Â Â Â Â Â Â Â Â Â cell[3]Â =Â value |
---|
326 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.5f"%(cell[3])) |
---|
327 |         elif laue in ['mmm']: |
---|
328 | Â Â Â Â Â Â Â Â Â Â cell[ObjId+1]Â =Â value |
---|
329 | Â Â Â Â Â Â Â Â Â Â cell[4]Â =Â cell[5]Â =Â cell[6]Â =Â 90. |
---|
330 | Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.5f"%(cell[ObjId+1])) |
---|
331 |         elif laue in ['2/m'+'a']: |
---|
332 | Â Â Â Â Â Â Â Â Â Â cell[5]Â =Â cell[6]Â =Â 90. |
---|
333 |           if ObjId != 3: |
---|
334 | Â Â Â Â Â Â Â Â Â Â Â Â cell[ObjId+1]Â =Â value |
---|
335 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.5f"%(cell[ObjId+1])) |
---|
336 | Â Â Â Â Â Â Â Â Â Â else: |
---|
337 | Â Â Â Â Â Â Â Â Â Â Â Â cell[4]Â =Â value |
---|
338 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.3f"%(cell[4])) |
---|
339 |         elif laue in ['2/m'+'b']: |
---|
340 | Â Â Â Â Â Â Â Â Â Â cell[4]Â =Â cell[6]Â =Â 90. |
---|
341 |           if ObjId != 3: |
---|
342 | Â Â Â Â Â Â Â Â Â Â Â Â cell[ObjId+1]Â =Â value |
---|
343 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.5f"%(cell[ObjId+1])) |
---|
344 | Â Â Â Â Â Â Â Â Â Â else: |
---|
345 | Â Â Â Â Â Â Â Â Â Â Â Â cell[5]Â =Â value |
---|
346 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.3f"%(cell[5])) |
---|
347 |         elif laue in ['2/m'+'c']: |
---|
348 | Â Â Â Â Â Â Â Â Â Â cell[5]Â =Â cell[6]Â =Â 90. |
---|
349 |           if ObjId != 3: |
---|
350 | Â Â Â Â Â Â Â Â Â Â Â Â cell[ObjId+1]Â =Â value |
---|
351 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.5f"%(cell[ObjId+1])) |
---|
352 | Â Â Â Â Â Â Â Â Â Â else: |
---|
353 | Â Â Â Â Â Â Â Â Â Â Â Â cell[6]Â =Â value |
---|
354 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.3f"%(cell[6])) |
---|
355 | Â Â Â Â Â Â Â Â else: |
---|
356 | Â Â Â Â Â Â Â Â Â Â cell[ObjId+1]Â =Â value |
---|
357 |           if ObjId < 3: |
---|
358 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.5f"%(cell[1+ObjId])) |
---|
359 | Â Â Â Â Â Â Â Â Â Â else: |
---|
360 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue("%.3f"%(cell[1+ObjId]))Â Â Â Â Â Â Â Â Â Â Â Â |
---|
361 | Â Â Â Â Â Â Â Â cell[7]Â =Â G2lat.calc_V(G2lat.cell2A(cell[1:7])) |
---|
362 | Â Â Â Â Â Â Â Â volVal.SetValue("%.3f"%(cell[7])) |
---|
363 | Â Â Â Â Â Â Â Â density,mattCoeff =Â G2mth.getDensity(generalData) |
---|
364 |         if denSizer: |
---|
365 | Â Â Â Â Â Â Â Â Â Â denSizer[1].SetValue('%.3f'%(density)) |
---|
366 |           if denSizer[2]: |
---|
367 | Â Â Â Â Â Â Â Â Â Â Â Â denSizer[2].SetValue('%.3f'%(mattCoeff)) |
---|
368 | Â Â Â Â Â Â Â Â generalData['Cell']Â =Â cell |
---|
369 | Â Â Â Â Â Â |
---|
370 | Â Â Â Â Â Â cell =Â generalData['Cell'] |
---|
371 | Â Â Â Â Â Â laue =Â generalData['SGData']['SGLaue'] |
---|
372 |       if laue == '2/m': |
---|
373 | Â Â Â Â Â Â Â Â laue +=Â generalData['SGData']['SGUniq'] |
---|
374 |       for cellGUI in cellGUIlist: |
---|
375 |         if laue in cellGUI[0]: |
---|
376 | Â Â Â Â Â Â Â Â Â Â useGUI =Â cellGUI |
---|
377 | Â Â Â Â Â Â cellSizer =Â wx.FlexGridSizer(2,useGUI[1]+1,5,5) |
---|
378 |       if PWDR: |
---|
379 | Â Â Â Â Â Â Â Â cellRef =Â wx.CheckBox(General,-1,label='Refine unit cell:') |
---|
380 | Â Â Â Â Â Â Â Â cellSizer.Add(cellRef,0,wx.ALIGN_CENTER_VERTICAL) |
---|
381 |         cellRef.Bind(wx.EVT_CHECKBOX, OnCellRef) |
---|
382 | Â Â Â Â Â Â Â Â cellRef.SetValue(cell[0]) |
---|
383 | Â Â Â Â Â Â cellList =Â [] |
---|
384 |       for txt,fmt,ifEdit,Id in useGUI[2]: |
---|
385 | Â Â Â Â Â Â Â Â cellSizer.Add(wx.StaticText(General,label=txt),0,wx.ALIGN_CENTER_VERTICAL) |
---|
386 |         if ifEdit:     #a,b,c,etc. |
---|
387 | Â Â Â Â Â Â Â Â Â Â cellVal =Â wx.TextCtrl(General,value=(fmt%(cell[Id+1])), |
---|
388 | Â Â Â Â Â Â Â Â Â Â Â Â style=wx.TE_PROCESS_ENTER) |
---|
389 | Â Â Â Â Â Â Â Â Â Â cellVal.Bind(wx.EVT_TEXT_ENTER,OnCellChange)Â Â Â Â |
---|
390 | Â Â Â Â Â Â Â Â Â Â cellVal.Bind(wx.EVT_KILL_FOCUS,OnCellChange) |
---|
391 | Â Â Â Â Â Â Â Â Â Â cellSizer.Add(cellVal,0,wx.ALIGN_CENTER_VERTICAL) |
---|
392 | Â Â Â Â Â Â Â Â Â Â cellList.append(cellVal.GetId()) |
---|
393 | Â Â Â Â Â Â Â Â else:Â Â Â Â Â Â Â Â #volume |
---|
394 | Â Â Â Â Â Â Â Â Â Â volVal =Â wx.TextCtrl(General,value=(fmt%(cell[7])),style=wx.TE_READONLY) |
---|
395 | Â Â Â Â Â Â Â Â Â Â volVal.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
396 | Â Â Â Â Â Â Â Â Â Â cellSizer.Add(volVal,0,wx.ALIGN_CENTER_VERTICAL) |
---|
397 |       return cellSizer |
---|
398 | Â Â Â Â Â Â |
---|
399 |     def ElemSizer(): |
---|
400 | Â Â Â Â Â Â |
---|
401 |       def OnIsotope(event): |
---|
402 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
403 | Â Â Â Â Â Â Â Â item =Â Indx[Obj.GetId()] |
---|
404 | Â Â Â Â Â Â Â Â isotope =Â Obj.GetValue() |
---|
405 | Â Â Â Â Â Â Â Â generalData['Isotope'][item]Â =Â isotope |
---|
406 | Â Â Â Â Â Â Â Â indx =Â generalData['AtomTypes'].index(item) |
---|
407 | Â Â Â Â Â Â Â Â data['General']['AtomMass'][indx]Â =Â generalData['Isotopes'][item][isotope][0] |
---|
408 | Â Â Â Â Â Â Â Â density,mattCoeff =Â G2mth.getDensity(generalData) |
---|
409 | Â Â Â Â Â Â Â Â denSizer[1].SetValue('%.3f'%(density)) |
---|
410 |         if denSizer[2]: |
---|
411 | Â Â Â Â Â Â Â Â Â Â denSizer[2].SetValue('%.3f'%(mattCoeff)) |
---|
412 | Â Â Â Â Â Â Â Â |
---|
413 | Â Â Â Â Â Â elemSizer =Â wx.FlexGridSizer(8,len(generalData['AtomTypes'])+1,1,1) |
---|
414 | Â Â Â Â Â Â elemSizer.Add(wx.StaticText(General,label=' Elements'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
415 |       for elem in generalData['AtomTypes']: |
---|
416 | Â Â Â Â Â Â Â Â typTxt =Â wx.TextCtrl(General,value=elem,style=wx.TE_READONLY) |
---|
417 | Â Â Â Â Â Â Â Â typTxt.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
418 | Â Â Â Â Â Â Â Â elemSizer.Add(typTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
419 | Â Â Â Â Â Â elemSizer.Add(wx.StaticText(General,label=' Isotope'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
420 |       for elem in generalData['AtomTypes']: |
---|
421 | Â Â Â Â Â Â Â Â choices =Â generalData['Isotopes'][elem].keys() |
---|
422 | Â Â Â Â Â Â Â Â isoSel =Â wx.ComboBox(General,-1,value=generalData['Isotope'][elem],choices=choices, |
---|
423 | Â Â Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
424 | Â Â Â Â Â Â Â Â isoSel.Bind(wx.EVT_COMBOBOX,OnIsotope) |
---|
425 | Â Â Â Â Â Â Â Â Indx[isoSel.GetId()]Â =Â elem |
---|
426 | Â Â Â Â Â Â Â Â elemSizer.Add(isoSel,1,wx.ALIGN_CENTER_VERTICAL|wx.EXPAND) |
---|
427 | Â Â Â Â Â Â elemSizer.Add(wx.StaticText(General,label=' No. per cell'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
428 |       for elem in generalData['AtomTypes']: |
---|
429 | Â Â Â Â Â Â Â Â numbTxt =Â wx.TextCtrl(General,value='%.1f'%(generalData['NoAtoms'][elem]), |
---|
430 | Â Â Â Â Â Â Â Â Â Â style=wx.TE_READONLY) |
---|
431 | Â Â Â Â Â Â Â Â numbTxt.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
432 | Â Â Â Â Â Â Â Â elemSizer.Add(numbTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
433 | Â Â Â Â Â Â elemSizer.Add(wx.StaticText(General,label=' Atom weight'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
434 |       for wt in generalData['AtomMass']: |
---|
435 | Â Â Â Â Â Â Â Â wtTxt =Â wx.TextCtrl(General,value='%.3f'%(wt),style=wx.TE_READONLY) |
---|
436 | Â Â Â Â Â Â Â Â wtTxt.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
437 | Â Â Â Â Â Â Â Â elemSizer.Add(wtTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
438 | Â Â Â Â Â Â elemSizer.Add(wx.StaticText(General,label=' Bond radii'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
439 |       for rad in generalData['BondRadii']: |
---|
440 | Â Â Â Â Â Â Â Â bondRadii =Â wx.TextCtrl(General,value='%.2f'%(rad),style=wx.TE_READONLY) |
---|
441 | Â Â Â Â Â Â Â Â bondRadii.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
442 | Â Â Â Â Â Â Â Â elemSizer.Add(bondRadii,0,wx.ALIGN_CENTER_VERTICAL) |
---|
443 | Â Â Â Â Â Â elemSizer.Add(wx.StaticText(General,label=' Angle radii'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
444 |       for rad in generalData['AngleRadii']: |
---|
445 | Â Â Â Â Â Â Â Â elemTxt =Â wx.TextCtrl(General,value='%.2f'%(rad),style=wx.TE_READONLY) |
---|
446 | Â Â Â Â Â Â Â Â elemTxt.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
447 | Â Â Â Â Â Â Â Â elemSizer.Add(elemTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
448 | Â Â Â Â Â Â elemSizer.Add(wx.StaticText(General,label=' van der Waals radii'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
449 |       for rad in generalData['vdWRadii']: |
---|
450 | Â Â Â Â Â Â Â Â elemTxt =Â wx.TextCtrl(General,value='%.2f'%(rad),style=wx.TE_READONLY) |
---|
451 | Â Â Â Â Â Â Â Â elemTxt.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
452 | Â Â Â Â Â Â Â Â elemSizer.Add(elemTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
453 | Â Â Â Â Â Â elemSizer.Add(wx.StaticText(General,label=' Default color'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
454 |       for R,G,B in generalData['Color']: |
---|
455 | Â Â Â Â Â Â Â Â colorTxt =Â wx.TextCtrl(General,value='',style=wx.TE_READONLY) |
---|
456 | Â Â Â Â Â Â Â Â colorTxt.SetBackgroundColour(wx.Colour(R,G,B)) |
---|
457 | Â Â Â Â Â Â Â Â elemSizer.Add(colorTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
458 |       return elemSizer |
---|
459 | Â Â Â Â |
---|
460 |     def DenSizer(): |
---|
461 | Â Â Â Â Â Â |
---|
462 | Â Â Â Â Â Â mass =Â G2mth.getMass(generalData) |
---|
463 | Â Â Â Â Â Â density,mattCoeff =Â G2mth.getDensity(generalData) |
---|
464 | Â Â Â Â Â Â denSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
465 | Â Â Â Â Â Â denSizer.Add(wx.StaticText(General,-1,' Density: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
466 | Â Â Â Â Â Â denTxt =Â wx.TextCtrl(General,-1,'%.3f'%(density),style=wx.TE_READONLY) |
---|
467 | Â Â Â Â Â Â denTxt.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
468 | Â Â Â Â Â Â denSizer.Add(denTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
469 |       mattTxt = None    |
---|
470 |       if generalData['Type'] == 'macromolecular' and mass > 0.0: |
---|
471 | Â Â Â Â Â Â Â Â denSizer.Add(wx.StaticText(General,-1,' Matthews coeff.: '), |
---|
472 | Â Â Â Â Â Â Â Â Â Â 0,wx.ALIGN_CENTER_VERTICAL) |
---|
473 | Â Â Â Â Â Â Â Â mattTxt =Â wx.TextCtrl(General,-1,'%.3f'%(mattCoeff),style=wx.TE_READONLY) |
---|
474 | Â Â Â Â Â Â Â Â mattTxt.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
475 | Â Â Â Â Â Â Â Â denSizer.Add(mattTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
476 |       return denSizer,denTxt,mattTxt |
---|
477 | Â Â Â Â Â Â |
---|
478 |     def PawleySizer(): |
---|
479 | Â Â Â Â Â Â |
---|
480 |       def OnPawleyRef(event): |
---|
481 | Â Â Â Â Â Â Â Â generalData['doPawley']Â =Â pawlRef.GetValue() |
---|
482 | Â Â Â Â Â Â |
---|
483 |       def OnPawleyVal(event): |
---|
484 | Â Â Â Â Â Â Â Â try: |
---|
485 | Â Â Â Â Â Â Â Â Â Â dmin =Â float(pawlVal.GetValue()) |
---|
486 |           if 0.25 <= dmin <= 20.: |
---|
487 | Â Â Â Â Â Â Â Â Â Â Â Â generalData['Pawley dmin']Â =Â dmin |
---|
488 |         except ValueError: |
---|
489 | Â Â Â Â Â Â Â Â Â Â pass |
---|
490 |         pawlVal.SetValue("%.3f"%(generalData['Pawley dmin']))     #reset in case of error        |
---|
491 | Â Â Â Â Â Â |
---|
492 |       def OnPawleyNegWt(event): |
---|
493 | Â Â Â Â Â Â Â Â try: |
---|
494 | Â Â Â Â Â Â Â Â Â Â wt =Â float(pawlNegWt.GetValue()) |
---|
495 |           if 0. <= wt <= 1.: |
---|
496 | Â Â Â Â Â Â Â Â Â Â Â Â generalData['Pawley neg wt']Â =Â wt |
---|
497 |         except ValueError: |
---|
498 | Â Â Â Â Â Â Â Â Â Â pass |
---|
499 |         pawlNegWt.SetValue("%.4f"%(generalData['Pawley neg wt']))     #reset in case of error        |
---|
500 | |
---|
501 | Â Â Â Â Â Â pawleySizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
502 | Â Â Â Â Â Â pawleySizer.Add(wx.StaticText(General,label=' Pawley controls: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
503 | Â Â Â Â Â Â pawlRef =Â wx.CheckBox(General,-1,label=' Do Pawley refinement?') |
---|
504 | Â Â Â Â Â Â pawlRef.SetValue(generalData['doPawley']) |
---|
505 | Â Â Â Â Â Â pawlRef.Bind(wx.EVT_CHECKBOX,OnPawleyRef) |
---|
506 | Â Â Â Â Â Â pawleySizer.Add(pawlRef,0,wx.ALIGN_CENTER_VERTICAL) |
---|
507 | Â Â Â Â Â Â pawleySizer.Add(wx.StaticText(General,label=' Pawley dmin: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
508 | Â Â Â Â Â Â pawlVal =Â wx.TextCtrl(General,value='%.3f'%(generalData['Pawley dmin']),style=wx.TE_PROCESS_ENTER) |
---|
509 | Â Â Â Â Â Â pawlVal.Bind(wx.EVT_TEXT_ENTER,OnPawleyVal)Â Â Â Â |
---|
510 | Â Â Â Â Â Â pawlVal.Bind(wx.EVT_KILL_FOCUS,OnPawleyVal) |
---|
511 | Â Â Â Â Â Â pawleySizer.Add(pawlVal,0,wx.ALIGN_CENTER_VERTICAL) |
---|
512 | Â Â Â Â Â Â pawleySizer.Add(wx.StaticText(General,label=' Pawley neg. wt.: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
513 | Â Â Â Â Â Â pawlNegWt =Â wx.TextCtrl(General,value='%.4f'%(generalData['Pawley neg wt']),style=wx.TE_PROCESS_ENTER) |
---|
514 | Â Â Â Â Â Â pawlNegWt.Bind(wx.EVT_TEXT_ENTER,OnPawleyNegWt)Â Â Â Â |
---|
515 | Â Â Â Â Â Â pawlNegWt.Bind(wx.EVT_KILL_FOCUS,OnPawleyNegWt) |
---|
516 | Â Â Â Â Â Â pawleySizer.Add(pawlNegWt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
517 |       return pawleySizer |
---|
518 | Â Â Â Â Â Â |
---|
519 |     def MapSizer(): |
---|
520 | Â Â Â Â Â Â |
---|
521 |       def OnMapType(event): |
---|
522 | Â Â Â Â Â Â Â Â Map['MapType']Â =Â mapType.GetValue() |
---|
523 | Â Â Â Â Â Â Â Â |
---|
524 |       def OnRefList(event): |
---|
525 | Â Â Â Â Â Â Â Â Map['RefList']Â =Â refList.GetValue() |
---|
526 | Â Â Â Â Â Â Â Â |
---|
527 |       def OnResVal(event): |
---|
528 | Â Â Â Â Â Â Â Â try: |
---|
529 | Â Â Â Â Â Â Â Â Â Â res =Â float(mapRes.GetValue()) |
---|
530 |           if 0.25 <= res <= 20.: |
---|
531 | Â Â Â Â Â Â Â Â Â Â Â Â Map['Resolution']Â =Â res |
---|
532 |         except ValueError: |
---|
533 | Â Â Â Â Â Â Â Â Â Â pass |
---|
534 | Â Â Â Â Â Â Â Â mapRes.SetValue("%.2f"%(Map['Resolution']))Â Â Â Â Â #reset in case of error |
---|
535 | Â Â Â Â Â Â |
---|
536 |       def OnCutOff(event): |
---|
537 | Â Â Â Â Â Â Â Â try: |
---|
538 | Â Â Â Â Â Â Â Â Â Â res =Â float(cutOff.GetValue()) |
---|
539 |           if 10.0 <= res <= 100.: |
---|
540 | Â Â Â Â Â Â Â Â Â Â Â Â Map['cutOff']Â =Â res |
---|
541 |         except ValueError: |
---|
542 | Â Â Â Â Â Â Â Â Â Â pass |
---|
543 | Â Â Â Â Â Â Â Â cutOff.SetValue("%.1f"%(Map['cutOff']))Â Â Â Â Â #reset in case of error |
---|
544 | Â Â Â Â Â Â |
---|
545 | Â Â Â Â Â Â #patch |
---|
546 |       if 'cutOff' not in Map: |
---|
547 | Â Â Â Â Â Â Â Â Map['cutOff']Â =Â 100.0 |
---|
548 | Â Â Â Â Â Â mapTypes =Â ['Fobs','Fcalc','delt-F','2*Fo-Fc','Omit','Patterson'] |
---|
549 | Â Â Â Â Â Â refList =Â data['Histograms'].keys() |
---|
550 |       if not generalData['AtomTypes']: |
---|
551 | Â Â Â Â Â Â Â Â Â mapTypes =Â ['Patterson',] |
---|
552 | Â Â Â Â Â Â Â Â Â Map['MapType']Â =Â 'Patterson' |
---|
553 | Â Â Â Â Â Â mapSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
554 | Â Â Â Â Â Â lineSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
555 | Â Â Â Â Â Â lineSizer.Add(wx.StaticText(General,label=' Fourier map controls: Map type: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
556 | Â Â Â Â Â Â mapType =Â wx.ComboBox(General,-1,value=Map['MapType'],choices=mapTypes, |
---|
557 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
558 | Â Â Â Â Â Â mapType.Bind(wx.EVT_COMBOBOX,OnMapType) |
---|
559 | Â Â Â Â Â Â lineSizer.Add(mapType,0,wx.ALIGN_CENTER_VERTICAL) |
---|
560 | Â Â Â Â Â Â lineSizer.Add(wx.StaticText(General,label=' Reflection set from: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
561 | Â Â Â Â Â Â refList =Â wx.ComboBox(General,-1,value=Map['RefList'],choices=refList, |
---|
562 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
563 | Â Â Â Â Â Â refList.Bind(wx.EVT_COMBOBOX,OnRefList) |
---|
564 | Â Â Â Â Â Â lineSizer.Add(refList,0,wx.ALIGN_CENTER_VERTICAL) |
---|
565 | Â Â Â Â Â Â mapSizer.Add(lineSizer,0,wx.ALIGN_CENTER_VERTICAL) |
---|
566 | Â Â Â Â Â Â line2Sizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
567 | Â Â Â Â Â Â line2Sizer.Add(wx.StaticText(General,label=' Resolution: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
568 | Â Â Â Â Â Â mapRes =Â wx.TextCtrl(General,value='%.2f'%(Map['Resolution']),style=wx.TE_PROCESS_ENTER) |
---|
569 | Â Â Â Â Â Â mapRes.Bind(wx.EVT_TEXT_ENTER,OnResVal)Â Â Â Â |
---|
570 | Â Â Â Â Â Â mapRes.Bind(wx.EVT_KILL_FOCUS,OnResVal) |
---|
571 | Â Â Â Â Â Â line2Sizer.Add(mapRes,0,wx.ALIGN_CENTER_VERTICAL) |
---|
572 | Â Â Â Â Â Â line2Sizer.Add(wx.StaticText(General,label=' Peak cutoff %: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
573 | Â Â Â Â Â Â cutOff =Â wx.TextCtrl(General,value='%.1f'%(Map['cutOff']),style=wx.TE_PROCESS_ENTER) |
---|
574 | Â Â Â Â Â Â cutOff.Bind(wx.EVT_TEXT_ENTER,OnCutOff)Â Â Â Â |
---|
575 | Â Â Â Â Â Â cutOff.Bind(wx.EVT_KILL_FOCUS,OnCutOff) |
---|
576 | Â Â Â Â Â Â line2Sizer.Add(cutOff,0,wx.ALIGN_CENTER_VERTICAL) |
---|
577 | Â Â Â Â Â Â mapSizer.Add(line2Sizer,0,wx.ALIGN_CENTER_VERTICAL) |
---|
578 |       return mapSizer |
---|
579 | Â Â Â Â Â Â Â Â |
---|
580 |     def FlipSizer(): |
---|
581 |       if 'k-Max' not in Flip: Flip['k-Max'] = 20. |
---|
582 | Â Â Â Â Â Â |
---|
583 |       def OnRefList(event): |
---|
584 | Â Â Â Â Â Â Â Â Flip['RefList']Â =Â refList.GetValue() |
---|
585 | Â Â Â Â Â Â Â Â |
---|
586 |       def OnNormElem(event): |
---|
587 | Â Â Â Â Â Â Â Â PE =Â G2elemGUI.PickElement(G2frame,ifNone=True) |
---|
588 |         if PE.ShowModal() == wx.ID_OK: |
---|
589 | Â Â Â Â Â Â Â Â Â Â Flip['Norm element']Â =Â PE.Elem.strip() |
---|
590 | Â Â Â Â Â Â Â Â Â Â normElem.SetLabel(Flip['Norm element']) |
---|
591 | Â Â Â Â Â Â Â Â PE.Destroy()Â Â Â Â Â Â Â Â |
---|
592 | Â Â Â Â Â Â Â Â |
---|
593 |       def OnResVal(event): |
---|
594 | Â Â Â Â Â Â Â Â try: |
---|
595 | Â Â Â Â Â Â Â Â Â Â res =Â float(flipRes.GetValue()) |
---|
596 |           if 0.25 <= res <= 20.: |
---|
597 | Â Â Â Â Â Â Â Â Â Â Â Â Flip['Resolution']Â =Â res |
---|
598 |         except ValueError: |
---|
599 | Â Â Â Â Â Â Â Â Â Â pass |
---|
600 | Â Â Â Â Â Â Â Â flipRes.SetValue("%.2f"%(Flip['Resolution']))Â Â Â Â Â #reset in case of error |
---|
601 | Â Â Â Â Â Â |
---|
602 |       def OnkFactor(event): |
---|
603 | Â Â Â Â Â Â Â Â try: |
---|
604 | Â Â Â Â Â Â Â Â Â Â res =Â float(kFactor.GetValue()) |
---|
605 |           if 0.1 <= res <= 1.2: |
---|
606 | Â Â Â Â Â Â Â Â Â Â Â Â Flip['k-factor']Â =Â res |
---|
607 |         except ValueError: |
---|
608 | Â Â Â Â Â Â Â Â Â Â pass |
---|
609 | Â Â Â Â Â Â Â Â kFactor.SetValue("%.3f"%(Flip['k-factor']))Â Â Â Â Â #reset in case of error |
---|
610 | Â Â Â Â Â Â |
---|
611 |       def OnkMax(event): |
---|
612 | Â Â Â Â Â Â Â Â try: |
---|
613 | Â Â Â Â Â Â Â Â Â Â res =Â float(kMax.GetValue()) |
---|
614 |           if res >= 10.: |
---|
615 | Â Â Â Â Â Â Â Â Â Â Â Â Flip['k-Max']Â =Â res |
---|
616 |         except ValueError: |
---|
617 | Â Â Â Â Â Â Â Â Â Â pass |
---|
618 | Â Â Â Â Â Â Â Â kMax.SetValue("%.1f"%(Flip['k-Max']))Â Â Â Â Â #reset in case of error |
---|
619 | |
---|
620 | Â Â Â Â Â Â refList =Â data['Histograms'].keys() |
---|
621 | Â Â Â Â Â Â flipSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
622 | Â Â Â Â Â Â lineSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
623 | Â Â Â Â Â Â lineSizer.Add(wx.StaticText(General,label=' Charge flip controls: Reflection set from: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
624 | Â Â Â Â Â Â refList =Â wx.ComboBox(General,-1,value=Flip['RefList'],choices=refList, |
---|
625 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
626 | Â Â Â Â Â Â refList.Bind(wx.EVT_COMBOBOX,OnRefList) |
---|
627 | Â Â Â Â Â Â lineSizer.Add(refList,0,wx.ALIGN_CENTER_VERTICAL) |
---|
628 | Â Â Â Â Â Â lineSizer.Add(wx.StaticText(General,label=' Normalizing element: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
629 | Â Â Â Â Â Â normElem =Â wx.Button(General,label=Flip['Norm element'],style=wx.TE_READONLY) |
---|
630 | Â Â Â Â Â Â normElem.Bind(wx.EVT_BUTTON,OnNormElem) |
---|
631 | Â Â Â Â Â Â lineSizer.Add(normElem,0,wx.ALIGN_CENTER_VERTICAL) |
---|
632 | Â Â Â Â Â Â flipSizer.Add(lineSizer,0,wx.ALIGN_CENTER_VERTICAL) |
---|
633 | Â Â Â Â Â Â line2Sizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
634 | Â Â Â Â Â Â line2Sizer.Add(wx.StaticText(General,label=' Resolution: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
635 | Â Â Â Â Â Â flipRes =Â wx.TextCtrl(General,value='%.2f'%(Flip['Resolution']),style=wx.TE_PROCESS_ENTER) |
---|
636 | Â Â Â Â Â Â flipRes.Bind(wx.EVT_TEXT_ENTER,OnResVal)Â Â Â Â |
---|
637 | Â Â Â Â Â Â flipRes.Bind(wx.EVT_KILL_FOCUS,OnResVal) |
---|
638 | Â Â Â Â Â Â line2Sizer.Add(flipRes,0,wx.ALIGN_CENTER_VERTICAL) |
---|
639 | Â Â Â Â Â Â line2Sizer.Add(wx.StaticText(General,label=' k-Factor (0.1-1.2): '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
640 | Â Â Â Â Â Â kFactor =Â wx.TextCtrl(General,value='%.3f'%(Flip['k-factor']),style=wx.TE_PROCESS_ENTER) |
---|
641 | Â Â Â Â Â Â kFactor.Bind(wx.EVT_TEXT_ENTER,OnkFactor)Â Â Â Â |
---|
642 | Â Â Â Â Â Â kFactor.Bind(wx.EVT_KILL_FOCUS,OnkFactor) |
---|
643 | Â Â Â Â Â Â line2Sizer.Add(kFactor,0,wx.ALIGN_CENTER_VERTICAL) |
---|
644 | Â Â Â Â Â Â line2Sizer.Add(wx.StaticText(General,label=' k-Max (>=10.0): '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
645 | Â Â Â Â Â Â kMax =Â wx.TextCtrl(General,value='%.1f'%(Flip['k-Max']),style=wx.TE_PROCESS_ENTER) |
---|
646 | Â Â Â Â Â Â kMax.Bind(wx.EVT_TEXT_ENTER,OnkMax)Â Â Â Â |
---|
647 | Â Â Â Â Â Â kMax.Bind(wx.EVT_KILL_FOCUS,OnkMax) |
---|
648 | Â Â Â Â Â Â line2Sizer.Add(kMax,0,wx.ALIGN_CENTER_VERTICAL) |
---|
649 | Â Â Â Â Â Â flipSizer.Add(line2Sizer,0,wx.ALIGN_CENTER_VERTICAL) |
---|
650 |       return flipSizer |
---|
651 | Â Â Â Â Â Â |
---|
652 |     def MCSASizer(): |
---|
653 | Â Â Â Â Â Â Ind =Â {} |
---|
654 | Â Â Â Â Â Â |
---|
655 |       def OnRefList(event): |
---|
656 | Â Â Â Â Â Â Â Â MCSA['Data source']Â =Â refList.GetValue() |
---|
657 | Â Â Â Â Â Â |
---|
658 |       def OnDmin(event): |
---|
659 | Â Â Â Â Â Â Â Â try: |
---|
660 | Â Â Â Â Â Â Â Â Â Â val =Â float(dmin.GetValue()) |
---|
661 |           if 1.0 <= val < 5.0: |
---|
662 | Â Â Â Â Â Â Â Â Â Â Â Â MCSA['dmin']Â =Â val |
---|
663 |         except ValueError: |
---|
664 | Â Â Â Â Â Â Â Â Â Â pass |
---|
665 | Â Â Â Â Â Â Â Â dmin.SetValue("%.3f"%(MCSA['dmin']))Â Â Â Â Â #reset in case of error |
---|
666 | |
---|
667 |       def OnCycles(event): |
---|
668 | Â Â Â Â Â Â Â Â MCSA['Cycles']Â =Â int(cycles.GetValue()) |
---|
669 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
670 |       def OnAlist(event): |
---|
671 | Â Â Â Â Â Â Â Â MCSA['Algorithm']Â =Â Alist.GetValue() |
---|
672 | Â Â Â Â Â Â Â Â wx.CallAfter(UpdateGeneral) |
---|
673 | Â Â Â Â Â Â Â Â |
---|
674 |       def OnSlope(event): |
---|
675 | Â Â Â Â Â Â Â Â try: |
---|
676 | Â Â Â Â Â Â Â Â Â Â val =Â float(slope.GetValue()) |
---|
677 |           if .25 <= val < 1.0: |
---|
678 | Â Â Â Â Â Â Â Â Â Â Â Â MCSA['log slope']Â =Â val |
---|
679 |         except ValueError: |
---|
680 | Â Â Â Â Â Â Â Â Â Â pass |
---|
681 |         slope.SetValue("%.3f"%(MCSA['log slope']))     #reset in case of error        |
---|
682 | Â Â Â Â Â Â |
---|
683 |       def OnAjump(event): |
---|
684 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
685 | Â Â Â Â Â Â Â Â name,ind =Â Indx[Obj.GetId()] |
---|
686 | Â Â Â Â Â Â Â Â try: |
---|
687 | Â Â Â Â Â Â Â Â Â Â val =Â float(Obj.GetValue()) |
---|
688 |           if .0 <= val <= 1.0: |
---|
689 | Â Â Â Â Â Â Â Â Â Â Â Â MCSA[name][ind]Â =Â val |
---|
690 |         except ValueError: |
---|
691 | Â Â Â Â Â Â Â Â Â Â pass |
---|
692 | Â Â Â Â Â Â Â Â Obj.SetValue("%.3f"%(MCSA[name][ind])) |
---|
693 | Â Â Â Â Â Â Â Â |
---|
694 |       def OnRanStart(event): |
---|
695 | Â Â Â Â Â Â Â Â MCSA['ranStart']Â =Â ranStart.GetValue() |
---|
696 | Â Â Â Â Â Â |
---|
697 |       def OnAnneal(event): |
---|
698 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
699 | Â Â Â Â Â Â Â Â ind,fmt =Â Indx[Obj.GetId()] |
---|
700 |         if ind == 2:    #No. trials |
---|
701 | Â Â Â Â Â Â Â Â Â Â try: |
---|
702 | Â Â Â Â Â Â Â Â Â Â Â Â val =Â int(Obj.GetValue()) |
---|
703 |             if 1 <= val: |
---|
704 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â MCSA['Annealing'][ind]Â =Â val |
---|
705 |           except ValueError: |
---|
706 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue(fmt%(MCSA['Annealing'][ind])) |
---|
707 | Â Â Â Â Â Â Â Â else: |
---|
708 | Â Â Â Â Â Â Â Â Â Â try: |
---|
709 | Â Â Â Â Â Â Â Â Â Â Â Â val =Â float(Obj.GetValue()) |
---|
710 |             if .0 <= val: |
---|
711 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â MCSA['Annealing'][ind]Â =Â val |
---|
712 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue(fmt%(MCSA['Annealing'][ind])) |
---|
713 |           except ValueError: |
---|
714 |             MCSA['Annealing'][ind] = None          |
---|
715 | Â Â Â Â Â Â Â Â Â Â Â Â Obj.SetValue(str(MCSA['Annealing'][ind])) |
---|
716 | Â Â Â Â Â Â Â Â Â Â Â Â |
---|
717 | Â Â Â Â Â Â refList =Â [] |
---|
718 |       if len(data['Pawley ref']): |
---|
719 | Â Â Â Â Â Â Â Â refList =Â ['Pawley reflections'] |
---|
720 |       for item in data['Histograms'].keys(): |
---|
721 |         if 'HKLF' in item or 'PWDR' in item: |
---|
722 | Â Â Â Â Â Â Â Â Â Â refList.append(item) |
---|
723 | Â Â Â Â Â Â mcsaSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
724 | Â Â Â Â Â Â lineSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
725 | Â Â Â Â Â Â lineSizer.Add(wx.StaticText(General,label=' Monte Carlo/Simulated Annealing controls: Reflection set from: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
726 | Â Â Â Â Â Â refList =Â wx.ComboBox(General,-1,value=MCSA['Data source'],choices=refList, |
---|
727 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
728 | Â Â Â Â Â Â refList.Bind(wx.EVT_COMBOBOX,OnRefList) |
---|
729 | Â Â Â Â Â Â lineSizer.Add(refList,0,wx.ALIGN_CENTER_VERTICAL) |
---|
730 | Â Â Â Â Â Â lineSizer.Add(wx.StaticText(General,label=' d-min: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
731 | Â Â Â Â Â Â dmin =Â wx.TextCtrl(General,-1,value='%.3f'%(MCSA['dmin']),style=wx.TE_PROCESS_ENTER) |
---|
732 | Â Â Â Â Â Â dmin.Bind(wx.EVT_TEXT_ENTER,OnDmin)Â Â Â Â |
---|
733 | Â Â Â Â Â Â dmin.Bind(wx.EVT_KILL_FOCUS,OnDmin) |
---|
734 | Â Â Â Â Â Â lineSizer.Add(dmin,0,wx.ALIGN_CENTER_VERTICAL) |
---|
735 | Â Â Â Â Â Â mcsaSizer.Add(lineSizer) |
---|
736 | Â Â Â Â Â Â mcsaSizer.Add((5,5),) |
---|
737 | Â Â Â Â Â Â line2Sizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
738 | Â Â Â Â Â Â line2Sizer.Add(wx.StaticText(General,label=' MC/SA runs: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
739 | Â Â Â Â Â Â Cchoice =Â ['1','2','3','6','10','20','30','60','100'] |
---|
740 | Â Â Â Â Â Â cycles =Â wx.ComboBox(General,-1,value=str(MCSA.get('Cycles',1)),choices=Cchoice, |
---|
741 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
742 | Â Â Â Â Â Â cycles.Bind(wx.EVT_COMBOBOX,OnCycles)Â Â Â Â |
---|
743 | Â Â Â Â Â Â line2Sizer.Add(cycles,0,wx.ALIGN_CENTER_VERTICAL) |
---|
744 | Â Â Â Â Â Â line2Sizer.Add((5,0),) |
---|
745 | Â Â Â Â Â Â ranStart =Â wx.CheckBox(General,-1,label=' Random start? (ignored if Start temp = None)') |
---|
746 |       ranStart.Bind(wx.EVT_CHECKBOX, OnRanStart) |
---|
747 | Â Â Â Â Â Â ranStart.SetValue(MCSA.get('ranStart',True)) |
---|
748 | Â Â Â Â Â Â line2Sizer.Add(ranStart,0,wx.ALIGN_CENTER_VERTICAL)Â Â Â Â Â Â |
---|
749 | Â Â Â Â Â Â mcsaSizer.Add(line2Sizer) |
---|
750 | Â Â Â Â Â Â mcsaSizer.Add((5,5),) |
---|
751 | Â Â Â Â Â Â line3Sizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
752 | Â Â Â Â Â Â Achoice =Â ['log','fast']Â Â Â Â Â Â Â Â #these work |
---|
753 | #Â Â Â Â Â Â Achoice = ['log','fast','cauchy','boltzmann','Tremayne'] |
---|
754 | Â Â Â Â Â Â line3Sizer.Add(wx.StaticText(General,label=' MC/SA schedule: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
755 | Â Â Â Â Â Â Alist =Â wx.ComboBox(General,-1,value=MCSA['Algorithm'],choices=Achoice, |
---|
756 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
757 | Â Â Â Â Â Â Alist.Bind(wx.EVT_COMBOBOX,OnAlist) |
---|
758 | Â Â Â Â Â Â line3Sizer.Add(Alist,0,wx.ALIGN_CENTER_VERTICAL) |
---|
759 |       if MCSA['Algorithm'] in ['Tremayne','fast','boltzmann','cauchy']: |
---|
760 | Â Â Â Â Â Â Â Â Names =Â [' A-jump: ',' B-jump: '] |
---|
761 | Â Â Â Â Â Â Â Â parms =Â 'Jump coeff' |
---|
762 |         if MCSA['Algorithm'] in ['boltzmann','cauchy']: |
---|
763 | Â Â Â Â Â Â Â Â Â Â Names =Â [' A-jump: '] |
---|
764 |         elif 'fast' in MCSA['Algorithm']: |
---|
765 | Â Â Â Â Â Â Â Â Â Â Names =Â [' quench: ',' m-factor: ',' n-factor: '] |
---|
766 | Â Â Â Â Â Â Â Â Â Â parms =Â 'fast parms' |
---|
767 |         for i,name in enumerate(Names): |
---|
768 | Â Â Â Â Â Â Â Â Â Â line3Sizer.Add(wx.StaticText(General,label=name),0,wx.ALIGN_CENTER_VERTICAL) |
---|
769 | Â Â Â Â Â Â Â Â Â Â Ajump =Â wx.TextCtrl(General,-1,value='%.3f'%(MCSA[parms][i]),style=wx.TE_PROCESS_ENTER) |
---|
770 | Â Â Â Â Â Â Â Â Â Â Ajump.Bind(wx.EVT_TEXT_ENTER,OnAjump)Â Â Â Â |
---|
771 | Â Â Â Â Â Â Â Â Â Â Ajump.Bind(wx.EVT_KILL_FOCUS,OnAjump) |
---|
772 | Â Â Â Â Â Â Â Â Â Â Indx[Ajump.GetId()]Â =Â [parms,i] |
---|
773 | Â Â Â Â Â Â Â Â Â Â line3Sizer.Add(Ajump,0,wx.ALIGN_CENTER_VERTICAL) |
---|
774 |       elif 'log' in MCSA['Algorithm']: |
---|
775 | Â Â Â Â Â Â Â Â line3Sizer.Add(wx.StaticText(General,label=' slope: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
776 | Â Â Â Â Â Â Â Â slope =Â wx.TextCtrl(General,-1,value='%.3f'%(MCSA['log slope']),style=wx.TE_PROCESS_ENTER) |
---|
777 | Â Â Â Â Â Â Â Â slope.Bind(wx.EVT_TEXT_ENTER,OnSlope)Â Â Â Â |
---|
778 | Â Â Â Â Â Â Â Â slope.Bind(wx.EVT_KILL_FOCUS,OnSlope) |
---|
779 | Â Â Â Â Â Â Â Â line3Sizer.Add(slope,0,wx.ALIGN_CENTER_VERTICAL) |
---|
780 | Â Â Â Â Â Â mcsaSizer.Add(line3Sizer) |
---|
781 | Â Â Â Â Â Â mcsaSizer.Add((5,5),) |
---|
782 | Â Â Â Â Â Â line3Sizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
783 | Â Â Â Â Â Â line3Sizer.Add(wx.StaticText(General,label=' Annealing schedule: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
784 | Â Â Â Â Â Â names =Â [' Start temp: ',' Final temp: ',' No. trials: '] |
---|
785 | Â Â Â Â Â Â fmts =Â ['%.1f','%.5f','%d'] |
---|
786 |       for i,[name,fmt] in enumerate(zip(names,fmts)): |
---|
787 |         if MCSA['Annealing'][i]: |
---|
788 | Â Â Â Â Â Â Â Â Â Â text =Â fmt%(MCSA['Annealing'][i]) |
---|
789 | Â Â Â Â Â Â Â Â else: |
---|
790 | Â Â Â Â Â Â Â Â Â Â text =Â 'None' |
---|
791 | Â Â Â Â Â Â Â Â line3Sizer.Add(wx.StaticText(General,label=name),0,wx.ALIGN_CENTER_VERTICAL) |
---|
792 | Â Â Â Â Â Â Â Â anneal =Â wx.TextCtrl(General,-1,value=text,style=wx.TE_PROCESS_ENTER) |
---|
793 | Â Â Â Â Â Â Â Â anneal.Bind(wx.EVT_TEXT_ENTER,OnAnneal)Â Â Â Â |
---|
794 | Â Â Â Â Â Â Â Â anneal.Bind(wx.EVT_KILL_FOCUS,OnAnneal) |
---|
795 | Â Â Â Â Â Â Â Â Indx[anneal.GetId()]Â =Â [i,fmt] |
---|
796 | Â Â Â Â Â Â Â Â line3Sizer.Add(anneal,0,wx.ALIGN_CENTER_VERTICAL) |
---|
797 | Â Â Â Â Â Â mcsaSizer.Add(line3Sizer)Â Â Â Â Â Â |
---|
798 |       return mcsaSizer |
---|
799 | |
---|
800 | Â Â Â Â # UpdateGeneral execution continues here |
---|
801 |     if General.GetSizer(): |
---|
802 | Â Â Â Â Â Â General.GetSizer().Clear(True) |
---|
803 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
804 | Â Â Â Â mainSizer.Add((5,5),0) |
---|
805 | Â Â Â Â mainSizer.Add(NameSizer(),0) |
---|
806 | Â Â Â Â mainSizer.Add((5,5),0)Â Â Â Â |
---|
807 | Â Â Â Â mainSizer.Add(CellSizer(),0) |
---|
808 | Â Â Â Â mainSizer.Add((5,5),0) |
---|
809 | Â Â Â Â |
---|
810 | Â Â Â Â Indx =Â {} |
---|
811 | Â Â Â Â denSizer =Â None |
---|
812 |     if len(generalData['AtomTypes']): |
---|
813 | Â Â Â Â Â Â denSizer =Â DenSizer() |
---|
814 | Â Â Â Â Â Â mainSizer.Add(denSizer[0]) |
---|
815 | Â Â Â Â Â Â mainSizer.Add((5,5),0)Â Â Â Â Â Â |
---|
816 | Â Â Â Â Â Â mainSizer.Add(ElemSizer()) |
---|
817 | Â Â Â Â G2gd.HorizontalLine(mainSizer,General) |
---|
818 | |
---|
819 | Â Â Â Â mainSizer.Add(PawleySizer()) |
---|
820 | Â Â Â Â G2gd.HorizontalLine(mainSizer,General) |
---|
821 | Â Â Â Â |
---|
822 | Â Â Â Â mainSizer.Add(MapSizer()) |
---|
823 | Â Â Â Â G2gd.HorizontalLine(mainSizer,General) |
---|
824 | |
---|
825 | Â Â Â Â mainSizer.Add(FlipSizer()) |
---|
826 | Â Â Â Â G2gd.HorizontalLine(mainSizer,General) |
---|
827 | |
---|
828 | Â Â Â Â mainSizer.Add(MCSASizer()) |
---|
829 | Â Â Â Â SetPhaseWindow(G2frame.dataFrame,General,mainSizer) |
---|
830 | Â Â Â Â G2frame.dataFrame.SetStatusText('') |
---|
831 | |
---|
832 | ################################################################################ |
---|
833 | #####Â Atom routines |
---|
834 | ################################################################################ |
---|
835 | |
---|
836 |   def FillAtomsGrid(Atoms): |
---|
837 | Â Â Â Â '''Display the contents of the Atoms tab |
---|
838 | Â Â Â Â ''' |
---|
839 |     def RefreshAtomGrid(event): |
---|
840 | |
---|
841 | Â Â Â Â Â Â r,c =Â event.GetRow(),event.GetCol() |
---|
842 |       if r < 0 and c < 0: |
---|
843 |         for row in range(Atoms.GetNumberRows()): |
---|
844 | Â Â Â Â Â Â Â Â Â Â Atoms.SelectRow(row,True)Â Â Â Â Â Â Â Â Â Â |
---|
845 |       if r < 0:             #double click on col label! Change all atoms! |
---|
846 | Â Â Â Â Â Â Â Â sel =Â -1 |
---|
847 | Â Â Â Â Â Â Â Â noSkip =Â True |
---|
848 |         if Atoms.GetColLabelValue(c) == 'refine': |
---|
849 | Â Â Â Â Â Â Â Â Â Â Type =Â generalData['Type'] |
---|
850 |           if Type in ['nuclear','macromolecular']: |
---|
851 | Â Â Â Â Â Â Â Â Â Â Â Â choice =Â ['F - site fraction','X - coordinates','U - thermal parameters'] |
---|
852 |           elif Type in ['magnetic',]: |
---|
853 | Â Â Â Â Â Â Â Â Â Â Â Â choice =Â ['F - site fraction','X - coordinates','U - thermal parameters','M - magnetic moment'] |
---|
854 | Â Â Â Â Â Â Â Â Â Â dlg =Â wx.MultiChoiceDialog(G2frame,'Select','Refinement controls',choice) |
---|
855 |           if dlg.ShowModal() == wx.ID_OK: |
---|
856 | Â Â Â Â Â Â Â Â Â Â Â Â sel =Â dlg.GetSelections() |
---|
857 | Â Â Â Â Â Â Â Â Â Â Â Â parms =Â '' |
---|
858 |             for x in sel: |
---|
859 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â parms +=Â choice[x][0] |
---|
860 | Â Â Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
861 |         elif Atoms.GetColLabelValue(c) == 'I/A': |
---|
862 | Â Â Â Â Â Â Â Â Â Â choice =Â ['Isotropic','Anisotropic'] |
---|
863 | Â Â Â Â Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select','Thermal Motion',choice) |
---|
864 |           if dlg.ShowModal() == wx.ID_OK: |
---|
865 | Â Â Â Â Â Â Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
866 | Â Â Â Â Â Â Â Â Â Â Â Â parms =Â choice[sel][0] |
---|
867 | Â Â Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
868 |         elif Atoms.GetColLabelValue(c) == 'Type': |
---|
869 | Â Â Â Â Â Â Â Â Â Â choice =Â generalData['AtomTypes'] |
---|
870 | Â Â Â Â Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select','Atom types',choice) |
---|
871 |           if dlg.ShowModal() == wx.ID_OK: |
---|
872 | Â Â Â Â Â Â Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
873 | Â Â Â Â Â Â Â Â Â Â Â Â parms =Â choice[sel] |
---|
874 | Â Â Â Â Â Â Â Â Â Â Â Â noSkip =Â False |
---|
875 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.ClearSelection() |
---|
876 |             for row in range(Atoms.GetNumberRows()): |
---|
877 |               if parms == atomData[row][c]: |
---|
878 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SelectRow(row,True) |
---|
879 | Â Â Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
880 | Â Â Â Â Â Â Â Â Â Â SetupGeneral() |
---|
881 |         elif Atoms.GetColLabelValue(c) == 'residue': |
---|
882 | Â Â Â Â Â Â Â Â Â Â choice =Â [] |
---|
883 |           for r in range(Atoms.GetNumberRows()): |
---|
884 |             if str(atomData[r][c]) not in choice: |
---|
885 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â choice.append(str(atomData[r][c])) |
---|
886 | Â Â Â Â Â Â Â Â Â Â choice.sort() |
---|
887 | Â Â Â Â Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select','Residue',choice) |
---|
888 |           if dlg.ShowModal() == wx.ID_OK: |
---|
889 | Â Â Â Â Â Â Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
890 | Â Â Â Â Â Â Â Â Â Â Â Â parms =Â choice[sel] |
---|
891 | Â Â Â Â Â Â Â Â Â Â Â Â noSkip =Â False |
---|
892 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.ClearSelection() |
---|
893 |             for row in range(Atoms.GetNumberRows()): |
---|
894 |               if parms == atomData[row][c]: |
---|
895 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SelectRow(row,True) |
---|
896 | Â Â Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
897 |         elif Atoms.GetColLabelValue(c) == 'res no': |
---|
898 | Â Â Â Â Â Â Â Â Â Â choice =Â [] |
---|
899 |           for r in range(Atoms.GetNumberRows()): |
---|
900 |             if str(atomData[r][c]) not in choice: |
---|
901 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â choice.append(str(atomData[r][c])) |
---|
902 | Â Â Â Â Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select','Residue no.',choice) |
---|
903 |           if dlg.ShowModal() == wx.ID_OK: |
---|
904 | Â Â Â Â Â Â Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
905 | Â Â Â Â Â Â Â Â Â Â Â Â parms =Â choice[sel] |
---|
906 | Â Â Â Â Â Â Â Â Â Â Â Â noSkip =Â False |
---|
907 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.ClearSelection() |
---|
908 |             for row in range(Atoms.GetNumberRows()): |
---|
909 |               if int(parms) == atomData[row][c]: |
---|
910 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SelectRow(row,True) |
---|
911 | Â Â Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
912 |         elif Atoms.GetColLabelValue(c) == 'chain': |
---|
913 | Â Â Â Â Â Â Â Â Â Â choice =Â [] |
---|
914 |           for r in range(Atoms.GetNumberRows()): |
---|
915 |             if atomData[r][c] not in choice: |
---|
916 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â choice.append(atomData[r][c]) |
---|
917 | Â Â Â Â Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select','Chain',choice) |
---|
918 |           if dlg.ShowModal() == wx.ID_OK: |
---|
919 | Â Â Â Â Â Â Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
920 | Â Â Â Â Â Â Â Â Â Â Â Â parms =Â choice[sel] |
---|
921 | Â Â Â Â Â Â Â Â Â Â Â Â noSkip =Â False |
---|
922 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.ClearSelection() |
---|
923 |             for row in range(Atoms.GetNumberRows()): |
---|
924 |               if parms == atomData[row][c]: |
---|
925 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SelectRow(row,True) |
---|
926 | Â Â Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
927 |         elif Atoms.GetColLabelValue(c) == 'Uiso':    #this needs to ask for value |
---|
928 |           pass                    #& then change all 'I' atoms |
---|
929 |         if sel >= 0 and noSkip: |
---|
930 | Â Â Â Â Â Â Â Â Â Â ui =Â colLabels.index('U11') |
---|
931 | Â Â Â Â Â Â Â Â Â Â us =Â colLabels.index('Uiso') |
---|
932 | Â Â Â Â Â Â Â Â Â Â ss =Â colLabels.index('site sym') |
---|
933 |           for r in range(Atoms.GetNumberRows()): |
---|
934 | Â Â Â Â Â Â Â Â Â Â Â Â ID =Â atomData[r][-1] |
---|
935 |             if parms != atomData[r][c] and Atoms.GetColLabelValue(c) == 'I/A': |
---|
936 |               if parms == 'A':        #'I' --> 'A' |
---|
937 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Uiso =Â float(Atoms.GetCellValue(r,us)) |
---|
938 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sytsym =Â atomData[r][ss] |
---|
939 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CSI =Â G2spc.GetCSuinel(sytsym) |
---|
940 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][ui:ui+6]Â =Â Uiso*np.array(CSI[3]) |
---|
941 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][us]Â =Â 0.0 |
---|
942 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(r,us,VERY_LIGHT_GREY,True) |
---|
943 |                 for i in range(6): |
---|
944 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ci =Â ui+i |
---|
945 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(r,ci,VERY_LIGHT_GREY,True) |
---|
946 |                   if CSI[2][i]: |
---|
947 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(r,ci,WHITE,False) |
---|
948 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â else:Â Â Â Â Â Â Â Â Â Â Â Â Â Â #'A' --> 'I' |
---|
949 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Uij =Â atomData[r][ui:ui+6] |
---|
950 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Uiso =Â (Uij[0]+Uij[1]+Uij[2])/3.0 |
---|
951 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][us]Â =Â Uiso |
---|
952 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(r,us,WHITE,False) |
---|
953 |                 for i in range(6): |
---|
954 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ci =Â ui+i |
---|
955 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][ci]Â =Â 0.0 |
---|
956 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(r,ci,VERY_LIGHT_GREY,True) |
---|
957 |             if not Atoms.IsReadOnly(r,c): |
---|
958 |               if Atoms.GetColLabelValue(c) == 'refine': |
---|
959 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbExcl =Â rbAtmDict.get(atomData[r][-1],'') |
---|
960 |                 if rbExcl: |
---|
961 |                   for excl in rbExcl: |
---|
962 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c]Â =Â parms.replace(excl,'') |
---|
963 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
964 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c]Â =Â parms |
---|
965 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â else:Â |
---|
966 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c]Â =Â parms |
---|
967 |             if 'Atoms' in data['Drawing']: |
---|
968 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â DrawAtomsReplaceByID(data['Drawing'],atomData[r],ID) |
---|
969 | Â Â Â Â Â Â Â Â Â Â wx.CallAfter(Paint) |
---|
970 | Â Â Â Â Â Â Â Â Â Â |
---|
971 |     def ChangeAtomCell(event): |
---|
972 | |
---|
973 |       def chkUij(Uij,CSI): #needs to do something!!! |
---|
974 |         return Uij |
---|
975 | |
---|
976 | Â Â Â Â Â Â r,c =Â event.GetRow(),event.GetCol() |
---|
977 |       if r >= 0 and c >= 0: |
---|
978 | Â Â Â Â Â Â Â Â ID =Â atomData[r][-1] |
---|
979 |         if Atoms.GetColLabelValue(c) in ['x','y','z']: |
---|
980 | Â Â Â Â Â Â Â Â Â Â ci =Â colLabels.index('x') |
---|
981 | Â Â Â Â Â Â Â Â Â Â XYZ =Â atomData[r][ci:ci+3] |
---|
982 |           if None in XYZ: |
---|
983 | Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â [0,0,0] |
---|
984 | Â Â Â Â Â Â Â Â Â Â SScol =Â colLabels.index('site sym') |
---|
985 | Â Â Â Â Â Â Â Â Â Â Mulcol =Â colLabels.index('mult') |
---|
986 | Â Â Â Â Â Â Â Â Â Â E,SGData =Â G2spc.SpcGroup(generalData['SGData']['SpGrp']) |
---|
987 | Â Â Â Â Â Â Â Â Â Â Sytsym,Mult =Â G2spc.SytSym(XYZ,SGData) |
---|
988 | Â Â Â Â Â Â Â Â Â Â atomData[r][SScol]Â =Â Sytsym |
---|
989 | Â Â Â Â Â Â Â Â Â Â atomData[r][Mulcol]Â =Â Mult |
---|
990 |           if atomData[r][colLabels.index('I/A')] == 'A': |
---|
991 | Â Â Â Â Â Â Â Â Â Â Â Â ui =Â colLabels.index('U11') |
---|
992 | Â Â Â Â Â Â Â Â Â Â Â Â CSI =Â G2spc.GetCSuinel(Sytsym) |
---|
993 | Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][ui:ui+6]Â =Â chkUij(atomData[r][ui:ui+6],Sytsym) |
---|
994 |             for i in range(6): |
---|
995 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ci =Â i+ui |
---|
996 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(r,ci,VERY_LIGHT_GREY,True) |
---|
997 |               if CSI[2][i]: |
---|
998 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(r,ci,WHITE,False) |
---|
999 | Â Â Â Â Â Â Â Â Â Â SetupGeneral() |
---|
1000 |         elif Atoms.GetColLabelValue(c) == 'I/A':      #note use of text color to make it vanish! |
---|
1001 |           if atomData[r][c] == 'I': |
---|
1002 | Â Â Â Â Â Â Â Â Â Â Â Â Uij =Â atomData[r][c+2:c+8] |
---|
1003 | Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c+1]Â =Â (Uij[0]+Uij[1]+Uij[2])/3.0 |
---|
1004 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(r,c+1,WHITE,False) |
---|
1005 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellTextColour(r,c+1,BLACK) |
---|
1006 |             for i in range(6): |
---|
1007 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ci =Â i+colLabels.index('U11') |
---|
1008 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(r,ci,VERY_LIGHT_GREY,True) |
---|
1009 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellTextColour(r,ci,VERY_LIGHT_GREY) |
---|
1010 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][ci]Â =Â 0.0 |
---|
1011 | Â Â Â Â Â Â Â Â Â Â else: |
---|
1012 | Â Â Â Â Â Â Â Â Â Â Â Â value =Â atomData[r][c+1] |
---|
1013 | Â Â Â Â Â Â Â Â Â Â Â Â CSI =Â G2spc.GetCSuinel(atomData[r][colLabels.index('site sym')]) |
---|
1014 | Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c+1]Â =Â 0.0 |
---|
1015 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(r,c+1,VERY_LIGHT_GREY,True) |
---|
1016 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellTextColour(r,c+1,VERY_LIGHT_GREY) |
---|
1017 |             for i in range(6): |
---|
1018 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ci =Â i+colLabels.index('U11') |
---|
1019 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][ci]Â =Â value*CSI[3][i] |
---|
1020 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(r,ci,VERY_LIGHT_GREY,True) |
---|
1021 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellTextColour(r,ci,BLACK) |
---|
1022 |               if CSI[2][i]: |
---|
1023 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(r,ci,WHITE,False) |
---|
1024 |         elif Atoms.GetColLabelValue(c) in ['U11','U22','U33','U12','U13','U23']: |
---|
1025 | Â Â Â Â Â Â Â Â Â Â value =Â atomData[r][c] |
---|
1026 | Â Â Â Â Â Â Â Â Â Â CSI =Â G2spc.GetCSuinel(atomData[r][colLabels.index('site sym')]) |
---|
1027 | Â Â Â Â Â Â Â Â Â Â iUij =Â CSI[0][c-colLabels.index('U11')] |
---|
1028 |           for i in range(6): |
---|
1029 |             if iUij == CSI[0][i]: |
---|
1030 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][i+colLabels.index('U11')]Â =Â value*CSI[1][i] |
---|
1031 |         elif Atoms.GetColLabelValue(c) == 'refine': |
---|
1032 | Â Â Â Â Â Â Â Â Â Â atomData[r][c]Â =Â atomData[r][c].replace(rbAtmDict.get(atomData[r][-1],''),'') |
---|
1033 |         if 'Atoms' in data['Drawing']: |
---|
1034 | Â Â Â Â Â Â Â Â Â Â DrawAtomsReplaceByID(data['Drawing'],atomData[r],ID) |
---|
1035 | Â Â Â Â Â Â Â Â wx.CallAfter(Paint) |
---|
1036 | |
---|
1037 |     def AtomTypeSelect(event): |
---|
1038 | Â Â Â Â Â Â r,c =Â event.GetRow(),event.GetCol() |
---|
1039 |       if Atoms.GetColLabelValue(c) == 'Type': |
---|
1040 | Â Â Â Â Â Â Â Â PE =Â G2elemGUI.PickElement(G2frame) |
---|
1041 |         if PE.ShowModal() == wx.ID_OK: |
---|
1042 |           if PE.Elem != 'None':            |
---|
1043 | Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c]Â =Â PE.Elem.strip() |
---|
1044 | Â Â Â Â Â Â Â Â Â Â Â Â name =Â atomData[r][c] |
---|
1045 |             if len(name) in [2,4]: |
---|
1046 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c-1]Â =Â name[:2]+'(%d)'%(r+1) |
---|
1047 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
1048 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c-1]Â =Â name[:1]+'(%d)'%(r+1) |
---|
1049 | Â Â Â Â Â Â Â Â PE.Destroy() |
---|
1050 | Â Â Â Â Â Â Â Â SetupGeneral() |
---|
1051 | Â Â Â Â Â Â Â Â wx.CallAfter(Paint) |
---|
1052 | Â Â Â Â Â Â Â Â value =Â Atoms.GetCellValue(r,c) |
---|
1053 | Â Â Â Â Â Â Â Â atomData[r][c]Â =Â value |
---|
1054 | Â Â Â Â Â Â Â Â ID =Â atomData[r][-1] |
---|
1055 |         if 'Atoms' in data['Drawing']: |
---|
1056 | Â Â Â Â Â Â Â Â Â Â DrawAtomsReplaceByID(data['Drawing'],atomData[r],ID) |
---|
1057 | Â Â Â Â Â Â Â Â SetupGeneral() |
---|
1058 | Â Â Â Â Â Â else: |
---|
1059 | Â Â Â Â Â Â Â Â event.Skip() |
---|
1060 | |
---|
1061 |     def RowSelect(event): |
---|
1062 | Â Â Â Â Â Â r,c =Â event.GetRow(),event.GetCol() |
---|
1063 |       if not event.AltDown(): |
---|
1064 | Â Â Â Â Â Â Â Â Atoms.frm =Â -1 |
---|
1065 | Â Â Â Â Â Â Â Â G2frame.dataFrame.SetStatusText('')Â Â Â Â Â Â Â Â Â Â |
---|
1066 |       if r < 0 and c < 0: |
---|
1067 |         if Atoms.IsSelection(): |
---|
1068 | Â Â Â Â Â Â Â Â Â Â Atoms.ClearSelection() |
---|
1069 |       elif c < 0:          #only row clicks |
---|
1070 |         if event.ControlDown():          |
---|
1071 |           if r in Atoms.GetSelectedRows(): |
---|
1072 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.DeselectRow(r) |
---|
1073 | Â Â Â Â Â Â Â Â Â Â else: |
---|
1074 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SelectRow(r,True) |
---|
1075 |         elif event.ShiftDown(): |
---|
1076 | Â Â Â Â Â Â Â Â Â Â indxs =Â Atoms.GetSelectedRows() |
---|
1077 | Â Â Â Â Â Â Â Â Â Â Atoms.ClearSelection() |
---|
1078 | Â Â Â Â Â Â Â Â Â Â ibeg =Â 0 |
---|
1079 |           if indxs: |
---|
1080 | Â Â Â Â Â Â Â Â Â Â Â Â ibeg =Â indxs[-1] |
---|
1081 |           for row in range(ibeg,r+1): |
---|
1082 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SelectRow(row,True) |
---|
1083 |         elif event.AltDown(): |
---|
1084 |           if atomData[r][-1] in rbAtmDict: |
---|
1085 | Â Â Â Â Â Â Â Â Â Â Â Â G2frame.dataFrame.SetStatusText('**** ERROR - atom is in a rigid body and can not be moved ****') |
---|
1086 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.frm =Â -1 |
---|
1087 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.ClearSelection() |
---|
1088 | Â Â Â Â Â Â Â Â Â Â else:Â Â |
---|
1089 |             if Atoms.frm < 0:      #pick atom to be moved |
---|
1090 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.frm =Â r |
---|
1091 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SelectRow(r,True) |
---|
1092 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â n =Â colLabels.index('Name') |
---|
1093 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â G2frame.dataFrame.SetStatusText('Atom '+atomData[r][n]+' is to be moved') |
---|
1094 | Â Â Â Â Â Â Â Â Â Â Â Â else:Â Â Â Â Â Â Â Â Â Â Â Â #move it |
---|
1095 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â item =Â atomData.pop(Atoms.frm) |
---|
1096 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData.insert(r,item) |
---|
1097 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.frm =Â -1 |
---|
1098 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â G2frame.dataFrame.SetStatusText('') |
---|
1099 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â wx.CallAfter(Paint) |
---|
1100 | Â Â Â Â Â Â Â Â else: |
---|
1101 | Â Â Â Â Â Â Â Â Â Â Atoms.ClearSelection() |
---|
1102 | Â Â Â Â Â Â Â Â Â Â Atoms.SelectRow(r,True) |
---|
1103 | Â Â Â Â Â Â Â Â |
---|
1104 |     def ChangeSelection(event): |
---|
1105 | Â Â Â Â Â Â r,c =Â event.GetRow(),event.GetCol() |
---|
1106 |       if r < 0 and c < 0: |
---|
1107 | Â Â Â Â Â Â Â Â Atoms.ClearSelection() |
---|
1108 |       if c < 0: |
---|
1109 |         if r in Atoms.GetSelectedRows(): |
---|
1110 | Â Â Â Â Â Â Â Â Â Â Atoms.DeselectRow(r) |
---|
1111 | Â Â Â Â Â Â Â Â else: |
---|
1112 | Â Â Â Â Â Â Â Â Â Â Atoms.SelectRow(r,True) |
---|
1113 |       if r < 0: |
---|
1114 |         if c in Atoms.GetSelectedCols(): |
---|
1115 | Â Â Â Â Â Â Â Â Â Â Atoms.DeselectCol(c) |
---|
1116 | Â Â Â Â Â Â Â Â else: |
---|
1117 | Â Â Â Â Â Â Â Â Â Â Atoms.SelectCol(c,True) |
---|
1118 | Â Â Â Â Â Â Â Â Â Â |
---|
1119 |     def Paint(): |
---|
1120 | Â Â Â Â |
---|
1121 | Â Â Â Â Â Â table =Â [] |
---|
1122 | Â Â Â Â Â Â rowLabels =Â [] |
---|
1123 |       for i,atom in enumerate(atomData): |
---|
1124 | Â Â Â Â Â Â Â Â table.append(atom) |
---|
1125 | Â Â Â Â Â Â Â Â rowLabels.append(str(i)) |
---|
1126 | Â Â Â Â Â Â atomTable =Â G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) |
---|
1127 |       Atoms.SetTable(atomTable, True) |
---|
1128 | Â Â Â Â Â Â Atoms.frm =Â -1Â Â Â Â Â Â |
---|
1129 | Â Â Â Â Â Â colType =Â colLabels.index('Type') |
---|
1130 | Â Â Â Â Â Â colR =Â colLabels.index('refine') |
---|
1131 | Â Â Â Â Â Â colSS =Â colLabels.index('site sym') |
---|
1132 | Â Â Â Â Â Â colX =Â colLabels.index('x') |
---|
1133 | Â Â Â Â Â Â colIA =Â colLabels.index('I/A') |
---|
1134 | Â Â Â Â Â Â colU11 =Â colLabels.index('U11') |
---|
1135 | Â Â Â Â Â Â colUiso =Â colLabels.index('Uiso') |
---|
1136 | Â Â Â Â Â Â attr =Â wx.grid.GridCellAttr() |
---|
1137 | Â Â Â Â Â Â attr.IncRef()Â Â Â Â Â Â Â Â #fix from Jim Hester |
---|
1138 | Â Â Â Â Â Â attr.SetEditor(G2gd.GridFractionEditor(Atoms)) |
---|
1139 |       for c in range(colX,colX+3): |
---|
1140 |         Atoms.SetColAttr(c, attr) |
---|
1141 |       for i in range(colU11-1,colU11+6): |
---|
1142 | Â Â Â Â Â Â Â Â Atoms.SetColSize(i,50)Â Â Â Â Â Â |
---|
1143 |       for row in range(Atoms.GetNumberRows()): |
---|
1144 | Â Â Â Â Â Â Â Â atId =Â atomData[row][-1] |
---|
1145 | Â Â Â Â Â Â Â Â rbExcl =Â rbAtmDict.get(atId,'') |
---|
1146 | Â Â Â Â Â Â Â Â Atoms.SetReadOnly(row,colSS,True)Â Â Â Â Â Â Â Â Â Â Â Â Â #site sym |
---|
1147 | Â Â Â Â Â Â Â Â Atoms.SetReadOnly(row,colSS+1,True)Â Â Â Â Â Â Â Â Â Â Â Â #Mult |
---|
1148 |         if Atoms.GetCellValue(row,colIA) == 'A': |
---|
1149 | Â Â Â Â Â Â Â Â Â Â CSI =Â G2spc.GetCSuinel(atomData[row][colLabels.index('site sym')]) |
---|
1150 | Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(row,colUiso,VERY_LIGHT_GREY,True) |
---|
1151 | Â Â Â Â Â Â Â Â Â Â Atoms.SetCellTextColour(row,colUiso,VERY_LIGHT_GREY) |
---|
1152 |           for i in range(6): |
---|
1153 | Â Â Â Â Â Â Â Â Â Â Â Â ci =Â colU11+i |
---|
1154 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellTextColour(row,ci,BLACK) |
---|
1155 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(row,ci,VERY_LIGHT_GREY,True) |
---|
1156 |             if CSI[2][i] and 'U' not in rbExcl: |
---|
1157 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(row,ci,WHITE,False) |
---|
1158 | Â Â Â Â Â Â Â Â else: |
---|
1159 | Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(row,colUiso,WHITE,False) |
---|
1160 | Â Â Â Â Â Â Â Â Â Â Atoms.SetCellTextColour(row,colUiso,BLACK) |
---|
1161 |           if 'U' in rbExcl: |
---|
1162 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(row,colUiso,VERY_LIGHT_GREY,True) |
---|
1163 |           for i in range(6): |
---|
1164 | Â Â Â Â Â Â Â Â Â Â Â Â ci =Â colU11+i |
---|
1165 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(row,ci,VERY_LIGHT_GREY,True) |
---|
1166 | Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellTextColour(row,ci,VERY_LIGHT_GREY) |
---|
1167 |         if 'X' in rbExcl: |
---|
1168 |           for c in range(0,colX+3): |
---|
1169 |             if c != colR: |
---|
1170 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Atoms.SetCellStyle(row,c,VERY_LIGHT_GREY,True) |
---|
1171 | Â Â Â Â Â Â Atoms.AutoSizeColumns(False) |
---|
1172 | |
---|
1173 | Â Â Â Â # FillAtomsGrid executable code starts here |
---|
1174 | Â Â Â Â generalData =Â data['General'] |
---|
1175 | Â Â Â Â atomData =Â data['Atoms'] |
---|
1176 | Â Â Â Â DData =Â data['Drawing'] |
---|
1177 | Â Â Â Â resRBData =Â data['RBModels'].get('Residue',[]) |
---|
1178 | Â Â Â Â vecRBData =Â data['RBModels'].get('Vector',[]) |
---|
1179 | Â Â Â Â rbAtmDict =Â {} |
---|
1180 |     for rbObj in resRBData+vecRBData: |
---|
1181 |       exclList = ['X' for i in range(len(rbObj['Ids']))] |
---|
1182 | Â Â Â Â Â Â rbAtmDict.update(dict(zip(rbObj['Ids'],exclList))) |
---|
1183 |       if rbObj['ThermalMotion'][0] != 'None': |
---|
1184 |         for id in rbObj['Ids']: |
---|
1185 | Â Â Â Â Â Â Â Â Â Â rbAtmDict[id]Â +=Â 'U'Â Â Â Â Â Â |
---|
1186 | Â Â Â Â # exclList will be 'x' or 'xu' if TLS used in RB |
---|
1187 |     Items = [G2gd.wxID_ATOMSEDITINSERT,G2gd.wxID_ATOMSEDITDELETE,G2gd.wxID_ATOMSREFINE, |
---|
1188 | Â Â Â Â Â Â G2gd.wxID_ATOMSMODIFY,G2gd.wxID_ATOMSTRANSFORM,G2gd.wxID_ATOMVIEWINSERT,G2gd.wxID_ATOMMOVE] |
---|
1189 |     if atomData: |
---|
1190 |       for item in Items:  |
---|
1191 | Â Â Â Â Â Â Â Â G2frame.dataFrame.AtomsMenu.Enable(item,True) |
---|
1192 | Â Â Â Â else: |
---|
1193 |       for item in Items: |
---|
1194 | Â Â Â Â Â Â Â Â G2frame.dataFrame.AtomsMenu.Enable(item,False) |
---|
1195 |     Items = [G2gd.wxID_ATOMVIEWINSERT, G2gd.wxID_ATOMSVIEWADD,G2gd.wxID_ATOMMOVE] |
---|
1196 |     if 'showABC' in data['Drawing']: |
---|
1197 |       for item in Items: |
---|
1198 | Â Â Â Â Â Â Â Â G2frame.dataFrame.AtomsMenu.Enable(item,True) |
---|
1199 | Â Â Â Â else: |
---|
1200 |       for item in Items: |
---|
1201 | Â Â Â Â Â Â Â Â G2frame.dataFrame.AtomsMenu.Enable(item,False) |
---|
1202 | |
---|
1203 | Â Â Â Â AAchoice =Â ": ,ALA,ARG,ASN,ASP,CYS,GLN,GLU,GLY,HIS,ILE,LEU,LYS,MET,PHE,PRO,SER,THR,TRP,TYR,VAL,MSE,HOH,UNK" |
---|
1204 | Â Â Â Â Types =Â [wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,wg.GRID_VALUE_CHOICE+": ,X,XU,U,F,FX,FXU,FU",]+Â \ |
---|
1205 |       3*[wg.GRID_VALUE_FLOAT+':10,5',]+[wg.GRID_VALUE_FLOAT+':10,4', #x,y,z,frac |
---|
1206 | Â Â Â Â Â Â wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,wg.GRID_VALUE_CHOICE+":I,A",] |
---|
1207 | Â Â Â Â Types +=Â 7*[wg.GRID_VALUE_FLOAT+':10,5',] |
---|
1208 | Â Â Â Â colLabels =Â ['Name','Type','refine','x','y','z','frac','site sym','mult','I/A','Uiso','U11','U22','U33','U12','U13','U23'] |
---|
1209 |     if generalData['Type'] == 'magnetic': |
---|
1210 | Â Â Â Â Â Â colLabels +=Â ['Mx','My','Mz'] |
---|
1211 | Â Â Â Â Â Â Types[2]Â =Â wg.GRID_VALUE_CHOICE+": ,X,XU,U,M,MX,MXU,MU,F,FX,FXU,FU,FM,FMX,FMU," |
---|
1212 | Â Â Â Â Â Â Types +=Â 3*[wg.GRID_VALUE_FLOAT+':10,4',] |
---|
1213 |     elif generalData['Type'] == 'macromolecular': |
---|
1214 | Â Â Â Â Â Â colLabels =Â ['res no','residue','chain']Â +Â colLabels |
---|
1215 | Â Â Â Â Â Â Types =Â [wg.GRID_VALUE_STRING, |
---|
1216 | Â Â Â Â Â Â Â Â wg.GRID_VALUE_CHOICE+AAchoice, |
---|
1217 | Â Â Â Â Â Â Â Â wg.GRID_VALUE_STRING]Â +Â Types |
---|
1218 |     elif generalData['Type'] == 'modulated': |
---|
1219 | Â Â Â Â Â Â Types +=Â [] |
---|
1220 | Â Â Â Â Â Â colLabels +=Â [] |
---|
1221 | Â Â Â Â SGData =Â data['General']['SGData'] |
---|
1222 | Â Â Â Â G2frame.dataFrame.SetStatusText('') |
---|
1223 |     if SGData['SGPolax']: |
---|
1224 | Â Â Â Â Â Â G2frame.dataFrame.SetStatusText('Warning: The location of the origin is arbitrary in '+SGData['SGPolax']) |
---|
1225 |     Atoms.Bind(wg.EVT_GRID_CELL_CHANGE, ChangeAtomCell) |
---|
1226 |     Atoms.Bind(wg.EVT_GRID_CELL_LEFT_DCLICK, AtomTypeSelect) |
---|
1227 |     Atoms.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK, RefreshAtomGrid) |
---|
1228 |     Atoms.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK, RowSelect) |
---|
1229 |     Atoms.Bind(wg.EVT_GRID_LABEL_RIGHT_CLICK, ChangeSelection) |
---|
1230 | Â Â Â Â Atoms.SetMargins(0,0) |
---|
1231 | Â Â Â Â |
---|
1232 | Â Â Â Â G2frame.dataFrame.setSizePosLeft([700,300]) |
---|
1233 | Â Â Â Â Paint() |
---|
1234 | |
---|
1235 |   def OnAtomAdd(event): |
---|
1236 | Â Â Â Â AtomAdd(0,0,0) |
---|
1237 | Â Â Â Â FillAtomsGrid(Atoms) |
---|
1238 | Â Â Â Â event.StopPropagation() |
---|
1239 | Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
1240 | Â Â Â Â |
---|
1241 |   def OnAtomViewAdd(event): |
---|
1242 | Â Â Â Â try: |
---|
1243 | Â Â Â Â Â Â drawData =Â data['Drawing'] |
---|
1244 | Â Â Â Â Â Â x,y,z =Â drawData['viewPoint'][0] |
---|
1245 | Â Â Â Â Â Â AtomAdd(x,y,z) |
---|
1246 | Â Â Â Â except: |
---|
1247 | Â Â Â Â Â Â AtomAdd(0,0,0) |
---|
1248 | Â Â Â Â FillAtomsGrid(Atoms) |
---|
1249 | Â Â Â Â event.StopPropagation() |
---|
1250 | Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
1251 | Â Â Â Â Â Â Â Â |
---|
1252 |   def AtomAdd(x,y,z,El='H',Name='UNK'): |
---|
1253 | Â Â Â Â atomData =Â data['Atoms'] |
---|
1254 | Â Â Â Â generalData =Â data['General'] |
---|
1255 | Â Â Â Â Ncol =Â Atoms.GetNumberCols() |
---|
1256 | Â Â Â Â atId =Â ran.randint(0,sys.maxint) |
---|
1257 | Â Â Â Â E,SGData =Â G2spc.SpcGroup(generalData['SGData']['SpGrp']) |
---|
1258 | Â Â Â Â Sytsym,Mult =Â G2spc.SytSym([x,y,z],SGData) |
---|
1259 |     if generalData['Type'] == 'macromolecular': |
---|
1260 | Â Â Â Â Â Â atomData.append([0,Name,'',Name,El,'',x,y,z,1,Sytsym,Mult,'I',0.10,0,0,0,0,0,0,atId]) |
---|
1261 |     elif generalData['Type'] == 'nuclear': |
---|
1262 | Â Â Â Â Â Â atomData.append([Name,El,'',x,y,z,1,Sytsym,Mult,'I',0.01,0,0,0,0,0,0,atId]) |
---|
1263 |     elif generalData['Type'] == 'magnetic': |
---|
1264 | Â Â Â Â Â Â atomData.append([Name,El,'',x,y,z,1,Sytsym,Mult,0,'I',0.01,0,0,0,0,0,0,0,0,0,atId]) |
---|
1265 | Â Â Â Â SetupGeneral() |
---|
1266 |     if 'Atoms' in data['Drawing']:      |
---|
1267 | Â Â Â Â Â Â DrawAtomAdd(data['Drawing'],atomData[-1]) |
---|
1268 | |
---|
1269 |   def OnAtomInsert(event): |
---|
1270 | Â Â Â Â AtomInsert(0,0,0) |
---|
1271 | Â Â Â Â FillAtomsGrid(Atoms) |
---|
1272 | Â Â Â Â event.StopPropagation() |
---|
1273 | Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
1274 | Â Â Â Â |
---|
1275 |   def OnAtomViewInsert(event): |
---|
1276 |     if 'Drawing' in data: |
---|
1277 | Â Â Â Â Â Â drawData =Â data['Drawing'] |
---|
1278 | Â Â Â Â Â Â x,y,z =Â drawData['viewPoint'][0] |
---|
1279 | Â Â Â Â Â Â AtomAdd(x,y,z) |
---|
1280 | Â Â Â Â Â Â FillAtomsGrid(Atoms) |
---|
1281 | Â Â Â Â event.StopPropagation() |
---|
1282 | Â Â Â Â |
---|
1283 |   def OnAtomMove(event): |
---|
1284 | Â Â Â Â drawData =Â data['Drawing'] |
---|
1285 | Â Â Â Â atomData =Â data['Atoms'] |
---|
1286 | Â Â Â Â x,y,z =Â drawData['viewPoint'][0] |
---|
1287 |     colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())] |
---|
1288 | Â Â Â Â cx =Â colLabels.index('x') |
---|
1289 | Â Â Â Â indx =Â Atoms.GetSelectedRows() |
---|
1290 |     if len(indx) != 1: |
---|
1291 |       print '**** ERROR - only one atom can be moved ****' |
---|
1292 |     elif atomData[indx[0]][-1] in rbAtmDict: |
---|
1293 |       print '**** ERROR - Atoms in rigid bodies can not be moved ****' |
---|
1294 | Â Â Â Â else: |
---|
1295 | Â Â Â Â Â Â atomData[indx[0]][cx:cx+3]Â =Â [x,y,z] |
---|
1296 | Â Â Â Â Â Â SetupGeneral() |
---|
1297 | Â Â Â Â Â Â FillAtomsGrid(Atoms) |
---|
1298 | Â Â Â Â Â Â ID =Â atomData[indx[0]][-1] |
---|
1299 | Â Â Â Â Â Â DrawAtomsReplaceByID(data['Drawing'],atomData[indx[0]],ID) |
---|
1300 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
1301 | Â Â Â Â event.StopPropagation() |
---|
1302 | Â Â Â Â Â Â |
---|
1303 |   def DrawAtomsReplaceByID(drawingData,atom,ID): |
---|
1304 | Â Â Â Â IDs =Â [ID,] |
---|
1305 | Â Â Â Â atomData =Â drawingData['Atoms'] |
---|
1306 | Â Â Â Â indx =Â G2mth.FindAtomIndexByIDs(atomData,IDs) |
---|
1307 |     for ind in indx: |
---|
1308 | Â Â Â Â Â Â atomData[ind]Â =Â MakeDrawAtom(atom,atomData[ind]) |
---|
1309 | Â Â Â Â Â Â Â Â |
---|
1310 |   def MakeDrawAtom(atom,oldatom=None): |
---|
1311 | Â Â Â Â AA3letter =Â ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE', |
---|
1312 | Â Â Â Â Â Â 'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE','HOH','WAT','UNK'] |
---|
1313 | Â Â Â Â AA1letter =Â ['A','R','N','D','C','Q','E','G','H','I', |
---|
1314 | Â Â Â Â Â Â 'L','K','M','F','P','S','T','W','Y','V','M',' ',' ',' '] |
---|
1315 | Â Â Â Â generalData =Â data['General'] |
---|
1316 | Â Â Â Â SGData =Â generalData['SGData'] |
---|
1317 |     if generalData['Type'] == 'nuclear': |
---|
1318 |       if oldatom: |
---|
1319 | Â Â Â Â Â Â Â Â opr =Â oldatom[5] |
---|
1320 |         if atom[9] == 'A':          |
---|
1321 | Â Â Â Â Â Â Â Â Â Â X,U =Â G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[11:17]) |
---|
1322 | Â Â Â Â Â Â Â Â Â Â atomInfo =Â [atom[:2]+list(X)+oldatom[5:9]+atom[9:11]+list(U)+oldatom[17:]][0] |
---|
1323 | Â Â Â Â Â Â Â Â else: |
---|
1324 | Â Â Â Â Â Â Â Â Â Â X =Â G2spc.ApplyStringOps(opr,SGData,atom[3:6]) |
---|
1325 | Â Â Â Â Â Â Â Â Â Â atomInfo =Â [atom[:2]+list(X)+oldatom[5:9]+atom[9:]+oldatom[17:]][0] |
---|
1326 | Â Â Â Â Â Â else: |
---|
1327 | Â Â Â Â Â Â Â Â atomInfo =Â [atom[:2]+atom[3:6]+['1',]+['vdW balls',]+ |
---|
1328 | Â Â Â Â Â Â Â Â Â Â ['',]+[[255,255,255],]+atom[9:]+[[],[]]][0] |
---|
1329 | Â Â Â Â Â Â ct,cs =Â [1,8]Â Â Â Â Â #type & color |
---|
1330 |     elif generalData['Type'] == 'macromolecular': |
---|
1331 | Â Â Â Â Â Â try: |
---|
1332 | Â Â Â Â Â Â Â Â oneLetter =Â AA3letter.index(atom[1]) |
---|
1333 |       except ValueError: |
---|
1334 | Â Â Â Â Â Â Â Â oneLetter =Â -1 |
---|
1335 | Â Â Â Â Â Â atomInfo =Â [[atom[1].strip()+atom[0],]+ |
---|
1336 | Â Â Â Â Â Â Â Â [AA1letter[oneLetter]+atom[0],]+atom[2:5]+ |
---|
1337 | Â Â Â Â Â Â Â Â atom[6:9]+['1',]+['sticks',]+['',]+[[255,255,255],]+atom[12:]+[[],[]]][0] |
---|
1338 | Â Â Â Â Â Â ct,cs =Â [4,11]Â Â Â Â Â #type & color |
---|
1339 |     elif generalData['Type'] == 'magnetic': |
---|
1340 |       if oldatom: |
---|
1341 | Â Â Â Â Â Â Â Â atomInfo =Â [atom[:2]+oldatom[3:]][0] |
---|
1342 | Â Â Â Â Â Â else: |
---|
1343 | Â Â Â Â Â Â Â Â atomInfo =Â [atom[:2]+atom[3:6]+['vdW balls',]+['',]+atom[9:]+[[],[]]][0] |
---|
1344 | Â Â Â Â Â Â ct,cs =Â [1,8]Â Â Â Â Â #type & color |
---|
1345 | Â Â #Â Â Â elif generalData['Type'] == 'modulated': |
---|
1346 |   #    ?????  for future |
---|
1347 | Â Â Â Â atNum =Â generalData['AtomTypes'].index(atom[ct]) |
---|
1348 | Â Â Â Â atomInfo[cs]Â =Â list(generalData['Color'][atNum]) |
---|
1349 |     return atomInfo |
---|
1350 | Â Â Â Â |
---|
1351 |   def AtomInsert(x,y,z): |
---|
1352 | Â Â Â Â indx =Â Atoms.GetSelectedRows() |
---|
1353 |     if indx: |
---|
1354 | Â Â Â Â Â Â indx =Â indx[0] |
---|
1355 | Â Â Â Â Â Â atomData =Â data['Atoms'] |
---|
1356 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
1357 | Â Â Â Â Â Â Ncol =Â Atoms.GetNumberCols() |
---|
1358 | Â Â Â Â Â Â E,SGData =Â G2spc.SpcGroup(generalData['SGData']['SpGrp']) |
---|
1359 | Â Â Â Â Â Â Sytsym,Mult =Â G2spc.SytSym([0,0,0],SGData) |
---|
1360 | Â Â Â Â Â Â atId =Â ran.randint(0,sys.maxint) |
---|
1361 |       if generalData['Type'] == 'macromolecular': |
---|
1362 | Â Â Â Â Â Â Â Â atomData.insert(indx,[0,'UNK','','UNK','UNK','',x,y,z,1,Sytsym,Mult,'I',0.10,0,0,0,0,0,0,atId]) |
---|
1363 |       elif generalData['Type'] == 'nuclear': |
---|
1364 | Â Â Â Â Â Â Â Â atomData.insert(indx,['UNK','UNK','',x,y,z,1,Sytsym,Mult,'I',0.01,0,0,0,0,0,0,atId]) |
---|
1365 |       elif generalData['Type'] == 'magnetic': |
---|
1366 | Â Â Â Â Â Â Â Â atomData.insert(indx,['UNK','UNK','',x,y,z,1,Sytsym,Mult,0,'I',0.01,0,0,0,0,0,0,0,0,0,atId]) |
---|
1367 | Â Â Â Â Â Â SetupGeneral() |
---|
1368 | |
---|
1369 |   def AtomDelete(event): |
---|
1370 | Â Â Â Â indx =Â Atoms.GetSelectedRows() |
---|
1371 | Â Â Â Â IDs =Â [] |
---|
1372 |     if indx: |
---|
1373 | Â Â Â Â Â Â atomData =Â data['Atoms'] |
---|
1374 | Â Â Â Â Â Â indx.reverse() |
---|
1375 |       for ind in indx: |
---|
1376 | Â Â Â Â Â Â Â Â atom =Â atomData[ind] |
---|
1377 |         if atom[-1] in rbAtmDict: |
---|
1378 | Â Â Â Â Â Â Â Â Â Â G2frame.dataFrame.SetStatusText('**** ERROR - atom is in a rigid body and can not be deleted ****') |
---|
1379 | Â Â Â Â Â Â Â Â else: |
---|
1380 | Â Â Â Â Â Â Â Â Â Â IDs.append(atom[-1]) |
---|
1381 |           del atomData[ind] |
---|
1382 |       if 'Atoms' in data['Drawing']: |
---|
1383 | Â Â Â Â Â Â Â Â DrawAtomsDeleteByIDs(IDs) |
---|
1384 | Â Â Â Â Â Â Â Â wx.CallAfter(FillAtomsGrid,Atoms) |
---|
1385 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
1386 | Â Â Â Â Â Â SetupGeneral() |
---|
1387 | Â Â Â Â event.StopPropagation() |
---|
1388 | |
---|
1389 |   def AtomRefine(event): |
---|
1390 |     colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())] |
---|
1391 | Â Â Â Â c =Â colLabels.index('refine') |
---|
1392 | Â Â Â Â indx =Â Atoms.GetSelectedRows() |
---|
1393 |     if indx: |
---|
1394 | Â Â Â Â Â Â atomData =Â data['Atoms'] |
---|
1395 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
1396 | Â Â Â Â Â Â Type =Â generalData['Type'] |
---|
1397 |       if Type in ['nuclear','macromolecular']: |
---|
1398 | Â Â Â Â Â Â Â Â choice =Â ['F - site fraction','X - coordinates','U - thermal parameters'] |
---|
1399 |       elif Type == 'magnetic': |
---|
1400 | Â Â Â Â Â Â Â Â choice =Â ['F - site fraction','X - coordinates','U - thermal parameters','M - magnetic moment'] |
---|
1401 | Â Â Â Â Â Â dlg =Â wx.MultiChoiceDialog(G2frame,'Select','Refinement controls',choice) |
---|
1402 |       if dlg.ShowModal() == wx.ID_OK: |
---|
1403 | Â Â Â Â Â Â Â Â sel =Â dlg.GetSelections() |
---|
1404 | Â Â Â Â Â Â Â Â parms =Â '' |
---|
1405 |         for x in sel: |
---|
1406 | Â Â Â Â Â Â Â Â Â Â parms +=Â choice[x][0] |
---|
1407 |         for r in indx: |
---|
1408 |           if not Atoms.IsReadOnly(r,c): |
---|
1409 | Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c]Â =Â parms |
---|
1410 | Â Â Â Â Â Â Â Â Atoms.ForceRefresh() |
---|
1411 | Â Â Â Â Â Â dlg.Destroy() |
---|
1412 | |
---|
1413 |   def AtomModify(event): |
---|
1414 | Â Â Â Â indx =Â Atoms.GetSelectedRows() |
---|
1415 |     if indx: |
---|
1416 | Â Â Â Â Â Â atomData =Â data['Atoms'] |
---|
1417 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
1418 |       colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())] |
---|
1419 | Â Â Â Â Â Â choices =Â ['Type','Name','x','y','z','frac','I/A','Uiso'] |
---|
1420 | Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select','Atom parameter',choices) |
---|
1421 | Â Â Â Â Â Â parm =Â '' |
---|
1422 |       if dlg.ShowModal() == wx.ID_OK: |
---|
1423 | Â Â Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
1424 | Â Â Â Â Â Â Â Â parm =Â choices[sel] |
---|
1425 | Â Â Â Â Â Â Â Â cid =Â colLabels.index(parm) |
---|
1426 | Â Â Â Â Â Â dlg.Destroy() |
---|
1427 |       if parm in ['Type']: |
---|
1428 | Â Â Â Â Â Â Â Â dlg =Â G2elemGUI.PickElement(G2frame) |
---|
1429 |         if dlg.ShowModal() == wx.ID_OK: |
---|
1430 |           if dlg.Elem not in ['None']: |
---|
1431 | Â Â Â Â Â Â Â Â Â Â Â Â El =Â dlg.Elem.strip() |
---|
1432 |             for r in indx:            |
---|
1433 |               if not Atoms.IsReadOnly(r,cid): |
---|
1434 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][cid]Â =Â El |
---|
1435 |                 if len(El) in [2,4]: |
---|
1436 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][cid-1]Â =Â El[:2]+'(%d)'%(r+1) |
---|
1437 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
1438 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][cid-1]Â =Â El[:1]+'(%d)'%(r+1) |
---|
1439 | Â Â Â Â Â Â Â Â Â Â Â Â SetupGeneral() |
---|
1440 |             if 'Atoms' in data['Drawing']: |
---|
1441 |               for r in indx: |
---|
1442 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ID =Â atomData[r][-1] |
---|
1443 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â DrawAtomsReplaceByID(data['Drawing'],atomData[r],ID) |
---|
1444 | Â Â Â Â Â Â Â Â Â Â FillAtomsGrid(Atoms) |
---|
1445 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1446 |       elif parm in ['Name',]: |
---|
1447 |         dlg = wx.MessageDialog(G2frame,'Do you really want to rename the selected atoms?','Rename', |
---|
1448 | Â Â Â Â Â Â Â Â Â Â wx.YES_NO |Â wx.ICON_QUESTION) |
---|
1449 | Â Â Â Â Â Â Â Â try: |
---|
1450 | Â Â Â Â Â Â Â Â Â Â result =Â dlg.ShowModal() |
---|
1451 |           if result == wx.ID_YES: |
---|
1452 |             for r in indx: |
---|
1453 |               if not Atoms.IsReadOnly(r,cid+1): |
---|
1454 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â El =Â atomData[r][cid+1] |
---|
1455 |                 if len(El) in [2,4]: |
---|
1456 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][cid]Â =Â El[:2]+'(%d)'%(r+1) |
---|
1457 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
1458 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][cid]Â =Â El[:1]+'(%d)'%(r+1) |
---|
1459 | Â Â Â Â Â Â Â Â Â Â FillAtomsGrid(Atoms) |
---|
1460 | Â Â Â Â Â Â Â Â finally: |
---|
1461 | Â Â Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1462 | Â Â Â Â Â Â Â Â Â Â |
---|
1463 |       elif parm in ['I/A']: |
---|
1464 | Â Â Â Â Â Â Â Â choices =Â ['Isotropic','Anisotropic'] |
---|
1465 | Â Â Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select','Thermal parameter model',choices) |
---|
1466 |         if dlg.ShowModal() == wx.ID_OK: |
---|
1467 | Â Â Â Â Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
1468 | Â Â Â Â Â Â Â Â Â Â parm =Â choices[sel][0] |
---|
1469 |           for r in indx:            |
---|
1470 |             if not Atoms.IsReadOnly(r,cid): |
---|
1471 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][cid]Â =Â parm |
---|
1472 | Â Â Â Â Â Â Â Â Â Â FillAtomsGrid(Atoms) |
---|
1473 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1474 |       elif parm in ['frac','Uiso']: |
---|
1475 | Â Â Â Â Â Â Â Â limits =Â [0.,1.] |
---|
1476 | Â Â Â Â Â Â Â Â val =Â 1.0 |
---|
1477 |         if parm in ['Uiso']: |
---|
1478 | Â Â Â Â Â Â Â Â Â Â limits =Â [0.,0.25] |
---|
1479 | Â Â Â Â Â Â Â Â Â Â val =Â 0.01 |
---|
1480 | Â Â Â Â Â Â Â Â dlg =Â G2gd.SingleFloatDialog(G2frame,'New value','Enter new value for '+parm,val,limits) |
---|
1481 |         if dlg.ShowModal() == wx.ID_OK: |
---|
1482 | Â Â Â Â Â Â Â Â Â Â parm =Â dlg.GetValue() |
---|
1483 |           for r in indx:            |
---|
1484 |             if not Atoms.IsReadOnly(r,cid): |
---|
1485 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][cid]Â =Â parm |
---|
1486 | Â Â Â Â Â Â Â Â Â Â SetupGeneral() |
---|
1487 | Â Â Â Â Â Â Â Â Â Â FillAtomsGrid(Atoms) |
---|
1488 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1489 |       elif parm in ['x','y','z']: |
---|
1490 | Â Â Â Â Â Â Â Â limits =Â [-1.,1.] |
---|
1491 | Â Â Â Â Â Â Â Â val =Â 0. |
---|
1492 | Â Â Â Â Â Â Â Â dlg =Â G2gd.SingleFloatDialog(G2frame,'Atom shift','Enter shift for '+parm,val,limits) |
---|
1493 |         if dlg.ShowModal() == wx.ID_OK: |
---|
1494 | Â Â Â Â Â Â Â Â Â Â parm =Â dlg.GetValue() |
---|
1495 |           for r in indx:            |
---|
1496 |             if not Atoms.IsReadOnly(r,cid): |
---|
1497 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][cid]Â +=Â parm |
---|
1498 | Â Â Â Â Â Â Â Â Â Â SetupGeneral() |
---|
1499 | Â Â Â Â Â Â Â Â Â Â FillAtomsGrid(Atoms) |
---|
1500 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1501 | |
---|
1502 |   def AtomTransform(event): |
---|
1503 | Â Â Â Â indx =Â Atoms.GetSelectedRows() |
---|
1504 |     if indx: |
---|
1505 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
1506 |       colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())] |
---|
1507 | Â Â Â Â Â Â cx =Â colLabels.index('x') |
---|
1508 | Â Â Â Â Â Â cuia =Â colLabels.index('I/A') |
---|
1509 | Â Â Â Â Â Â cuij =Â colLabels.index('U11') |
---|
1510 | Â Â Â Â Â Â css =Â colLabels.index('site sym') |
---|
1511 | Â Â Â Â Â Â atomData =Â data['Atoms'] |
---|
1512 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
1513 | Â Â Â Â Â Â SGData =Â generalData['SGData'] |
---|
1514 | Â Â Â Â Â Â dlg =Â G2gd.SymOpDialog(G2frame,SGData,True,True) |
---|
1515 | Â Â Â Â Â Â New =Â False |
---|
1516 | Â Â Â Â Â Â try: |
---|
1517 |         if dlg.ShowModal() == wx.ID_OK: |
---|
1518 | Â Â Â Â Â Â Â Â Â Â Inv,Cent,Opr,Cell,New,Force =Â dlg.GetSelection() |
---|
1519 | Â Â Â Â Â Â Â Â Â Â Cell =Â np.array(Cell) |
---|
1520 | Â Â Â Â Â Â Â Â Â Â cent =Â SGData['SGCen'][Cent] |
---|
1521 | Â Â Â Â Â Â Â Â Â Â M,T =Â SGData['SGOps'][Opr] |
---|
1522 |           for ind in indx: |
---|
1523 | Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â np.array(atomData[ind][cx:cx+3]) |
---|
1524 | Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â np.inner(M,XYZ)+T |
---|
1525 |             if Inv: |
---|
1526 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â -XYZ |
---|
1527 | Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â XYZ+cent+Cell |
---|
1528 |             if Force: |
---|
1529 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â G2spc.MoveToUnitCell(XYZ) |
---|
1530 |             if New: |
---|
1531 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom =Â copy.copy(atomData[ind]) |
---|
1532 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
1533 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom =Â atomData[ind] |
---|
1534 | Â Â Â Â Â Â Â Â Â Â Â Â atom[cx:cx+3]Â =Â XYZ |
---|
1535 | Â Â Â Â Â Â Â Â Â Â Â Â atom[css:css+2]Â =Â G2spc.SytSym(XYZ,SGData) |
---|
1536 |             if atom[cuia] == 'A': |
---|
1537 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Uij =Â atom[cuij:cuij+6] |
---|
1538 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â U =Â G2spc.Uij2U(Uij) |
---|
1539 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â U =Â np.inner(np.inner(M,U),M) |
---|
1540 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Uij =Â G2spc.U2Uij(U) |
---|
1541 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cuij:cuij+6]Â =Â Uij |
---|
1542 |             if New: |
---|
1543 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData.append(atom) |
---|
1544 | Â Â Â Â Â Â finally: |
---|
1545 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1546 | Â Â Â Â Â Â Atoms.ClearSelection() |
---|
1547 |       if New: |
---|
1548 | Â Â Â Â Â Â Â Â FillAtomsGrid(Atoms) |
---|
1549 | Â Â Â Â Â Â else: |
---|
1550 | Â Â Â Â Â Â Â Â Atoms.ForceRefresh() |
---|
1551 | |
---|
1552 |   def OnDistAngle(event): |
---|
1553 | Â Â Â Â indx =Â Atoms.GetSelectedRows() |
---|
1554 | Â Â Â Â Oxyz =Â [] |
---|
1555 | Â Â Â Â xyz =Â [] |
---|
1556 | Â Â Â Â DisAglData =Â {} |
---|
1557 | Â Â Â Â DisAglCtls =Â {} |
---|
1558 |     if indx: |
---|
1559 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
1560 | Â Â Â Â Â Â DisAglData['OrigIndx']Â =Â indx |
---|
1561 |       if 'DisAglCtls' in generalData: |
---|
1562 | Â Â Â Â Â Â Â Â DisAglCtls =Â generalData['DisAglCtls'] |
---|
1563 | Â Â Â Â Â Â dlg =Â G2gd.DisAglDialog(G2frame,DisAglCtls,generalData) |
---|
1564 |       if dlg.ShowModal() == wx.ID_OK: |
---|
1565 | Â Â Â Â Â Â Â Â DisAglCtls =Â dlg.GetData() |
---|
1566 | Â Â Â Â Â Â dlg.Destroy() |
---|
1567 | Â Â Â Â Â Â generalData['DisAglCtls']Â =Â DisAglCtls |
---|
1568 | Â Â Â Â Â Â atomData =Â data['Atoms'] |
---|
1569 |       colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())] |
---|
1570 | Â Â Â Â Â Â cx =Â colLabels.index('x') |
---|
1571 | Â Â Â Â Â Â cn =Â colLabels.index('Name') |
---|
1572 |       for i,atom in enumerate(atomData): |
---|
1573 | Â Â Â Â Â Â Â Â xyz.append([i,]+atom[cn:cn+2]+atom[cx:cx+3]) |
---|
1574 |         if i in indx: |
---|
1575 | Â Â Â Â Â Â Â Â Â Â Oxyz.append([i,]+atom[cn:cn+2]+atom[cx:cx+3]) |
---|
1576 | Â Â Â Â Â Â DisAglData['OrigAtoms']Â =Â Oxyz |
---|
1577 | Â Â Â Â Â Â DisAglData['TargAtoms']Â =Â xyz |
---|
1578 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
1579 | Â Â Â Â Â Â DisAglData['SGData']Â =Â generalData['SGData'] |
---|
1580 | Â Â Â Â Â Â DisAglData['Cell']Â =Â generalData['Cell'][1:]Â #+ volume |
---|
1581 |       if 'pId' in data: |
---|
1582 | Â Â Â Â Â Â Â Â DisAglData['pId']Â =Â data['pId'] |
---|
1583 |         DisAglData['covData'] = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Covariance')) |
---|
1584 | Â Â Â Â Â Â try: |
---|
1585 | Â Â Â Â Â Â Â Â G2stMn.DistAngle(DisAglCtls,DisAglData) |
---|
1586 |       except KeyError:    # inside DistAngle for missing atom types in DisAglCtls |
---|
1587 |         print '**** ERROR - try again but do "Reset" to fill in missing atom types ****' |
---|
1588 | Â Â Â Â Â Â Â Â |
---|
1589 |   def OnReImport(event): |
---|
1590 |     print 'reimport atoms from file to be developed' |
---|
1591 | Â Â Â Â reqrdr =Â G2frame.dataFrame.ReImportMenuId.get(event.GetId()) |
---|
1592 | Â Â Â Â rdlist =Â G2frame.OnImportGeneric(reqrdr, |
---|
1593 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â G2frame.ImportPhaseReaderlist, |
---|
1594 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'phase') |
---|
1595 |     if len(rdlist) == 0: return |
---|
1596 | Â Â Â Â # for now rdlist is only expected to have one element |
---|
1597 | Â Â Â Â # for now always use the first phase for when multiple phases are ever implemented |
---|
1598 | Â Â Â Â # but it would be better to loop until we find a phase that matches the one in data |
---|
1599 |     for rd in rdlist: |
---|
1600 | Â Â Â Â Â Â # rd contains all info for a phase |
---|
1601 | Â Â Â Â Â Â PhaseName =Â rd.Phase['General']['Name'] |
---|
1602 |       print 'Read phase '+str(PhaseName)+' from file '+str(G2frame.lastimport) |
---|
1603 |       print rd.Phase['Atoms'] |
---|
1604 | Â Â Â Â Â Â return |
---|
1605 | Â Â Â Â Â Â Â Â Â Â Â Â |
---|
1606 | ################################################################################ |
---|
1607 | #Structure drawing GUI stuff        |
---|
1608 | ################################################################################ |
---|
1609 | |
---|
1610 |   def SetupDrawingData(): |
---|
1611 | Â Â Â Â generalData =Â data['General'] |
---|
1612 | Â Â Â Â Amat,Bmat =Â G2lat.cell2AB(generalData['Cell'][1:7]) |
---|
1613 | Â Â Â Â atomData =Â data['Atoms'] |
---|
1614 | Â Â Â Â AA3letter =Â ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE', |
---|
1615 | Â Â Â Â Â Â 'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE','HOH','WAT','UNK'] |
---|
1616 | Â Â Â Â AA1letter =Â ['A','R','N','D','C','Q','E','G','H','I', |
---|
1617 | Â Â Â Â Â Â 'L','K','M','F','P','S','T','W','Y','V','M',' ',' ',' '] |
---|
1618 | Â Â Â Â defaultDrawing =Â {'Atoms':[],'viewPoint':[[0.5,0.5,0.5],[]],'showHydrogen':True, |
---|
1619 | Â Â Â Â Â Â 'backColor':[0,0,0],'depthFog':False,'Zclip':50.0,'cameraPos':50.,'Zstep':0.5, |
---|
1620 | Â Â Â Â Â Â 'radiusFactor':0.85,'contourLevel':1.,'bondRadius':0.1,'ballScale':0.33, |
---|
1621 | Â Â Â Â Â Â 'vdwScale':0.67,'ellipseProb':50,'sizeH':0.50,'unitCellBox':True, |
---|
1622 | Â Â Â Â Â Â 'showABC':True,'selectedAtoms':[],'Atoms':[],'oldxy':[], |
---|
1623 | Â Â Â Â Â Â 'bondList':{},'viewDir':[1,0,0]} |
---|
1624 | Â Â Â Â V0 =Â np.array([0,0,1]) |
---|
1625 | Â Â Â Â V =Â np.inner(Amat,V0) |
---|
1626 | Â Â Â Â V /=Â np.sqrt(np.sum(V**2)) |
---|
1627 | Â Â Â Â A =Â np.arccos(np.sum(V*V0)) |
---|
1628 | Â Â Â Â defaultDrawing['Quaternion']Â =Â G2mth.AV2Q(A,[0,1,0]) |
---|
1629 | Â Â Â Â try: |
---|
1630 | Â Â Â Â Â Â drawingData =Â data['Drawing'] |
---|
1631 |     except KeyError: |
---|
1632 | Â Â Â Â Â Â data['Drawing']Â =Â {} |
---|
1633 | Â Â Â Â Â Â drawingData =Â data['Drawing'] |
---|
1634 |     if not drawingData:         #fill with defaults if empty |
---|
1635 | Â Â Â Â Â Â drawingData.update(defaultDrawing) |
---|
1636 |     if 'Zstep' not in drawingData: |
---|
1637 | Â Â Â Â Â Â drawingData['Zstep']Â =Â 0.5 |
---|
1638 |     if 'contourLevel' not in drawingData: |
---|
1639 | Â Â Â Â Â Â drawingData['contourLevel']Â =Â 1. |
---|
1640 |     if 'viewDir' not in drawingData: |
---|
1641 | Â Â Â Â Â Â drawingData['viewDir']Â =Â [0,0,1] |
---|
1642 |     if 'Quaternion' not in drawingData: |
---|
1643 | Â Â Â Â Â Â drawingData['Quaternion']Â =Â G2mth.AV2Q(2*np.pi,np.inner(Amat,[0,0,1])) |
---|
1644 |     if 'showRigidBodies' not in drawingData: |
---|
1645 | Â Â Â Â Â Â drawingData['showRigidBodies']Â =Â True |
---|
1646 | Â Â Â Â cx,ct,cs,ci =Â [0,0,0,0] |
---|
1647 |     if generalData['Type'] == 'nuclear': |
---|
1648 | Â Â Â Â Â Â cx,ct,cs,ci =Â [2,1,6,17]Â Â Â Â Â #x, type, style & index |
---|
1649 |     elif generalData['Type'] == 'macromolecular': |
---|
1650 | Â Â Â Â Â Â cx,ct,cs,ci =Â [5,4,9,20]Â Â Â Â Â #x, type, style & index |
---|
1651 |     elif generalData['Type'] == 'magnetic': |
---|
1652 | Â Â Â Â Â Â cx,ct,cs,ci =Â [2,1,6,20]Â Â Â Â Â #x, type, style & index |
---|
1653 | #Â Â Â Â elif generalData['Type'] == 'modulated': |
---|
1654 | #      ?????  for future |
---|
1655 | Â Â Â Â drawingData['atomPtrs']Â =Â [cx,ct,cs,ci] |
---|
1656 |     if not drawingData.get('Atoms'): |
---|
1657 |       for atom in atomData: |
---|
1658 | Â Â Â Â Â Â Â Â DrawAtomAdd(drawingData,atom) |
---|
1659 | Â Â Â Â Â Â data['Drawing']Â =Â drawingData |
---|
1660 | Â Â Â Â Â Â |
---|
1661 |   def DrawAtomAdd(drawingData,atom): |
---|
1662 | Â Â Â Â drawingData['Atoms'].append(MakeDrawAtom(atom)) |
---|
1663 | Â Â Â Â |
---|
1664 |   def OnRestraint(event):    |
---|
1665 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
1666 | Â Â Â Â restData =Â G2frame.PatternTree.GetItemPyData(Â Â |
---|
1667 | Â Â Â Â Â Â G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Restraints')) |
---|
1668 | Â Â Â Â drawingData =Â data['Drawing'] |
---|
1669 | Â Â Â Â generalData =Â data['General'] |
---|
1670 | Â Â Â Â Amat,Bmat =Â G2lat.cell2AB(generalData['Cell'][1:7])Â Â Â Â Â Â |
---|
1671 | Â Â Â Â cx,ct,cs,ci =Â drawingData['atomPtrs'] |
---|
1672 | Â Â Â Â atomData =Â drawingData['Atoms'] |
---|
1673 | Â Â Â Â atNames =Â [] |
---|
1674 | Â Â Â Â atXYZ =Â [] |
---|
1675 | Â Â Â Â atSymOp =Â [] |
---|
1676 | Â Â Â Â atIndx =Â [] |
---|
1677 |     for item in indx: |
---|
1678 | Â Â Â Â Â Â atXYZ.append(np.array(atomData[item][cx:cx+3])) |
---|
1679 | Â Â Â Â Â Â atSymOp.append(atomData[item][cs-1]) |
---|
1680 | Â Â Â Â Â Â atIndx.append(atomData[item][ci]) |
---|
1681 |     if event.GetId() == G2gd.wxID_DRAWRESTRBOND and len(indx) == 2: |
---|
1682 | Â Â Â Â Â Â try: |
---|
1683 | Â Â Â Â Â Â Â Â bondData =Â restData[PhaseName]['Bond'] |
---|
1684 |       except KeyError: |
---|
1685 | Â Â Â Â Â Â Â Â bondData =Â {'wtFactor':1.0,'Bonds':[],'Use':True} |
---|
1686 | Â Â Â Â Â Â Â Â restData[PhaseName]Â =Â {} |
---|
1687 | Â Â Â Â Â Â Â Â restData[PhaseName]['Bond']Â =Â bondData |
---|
1688 | Â Â Â Â Â Â dist =Â G2mth.getRestDist(atXYZ,Amat) |
---|
1689 | Â Â Â Â Â Â bondData['Bonds'].append([atIndx,atSymOp,1.54,0.01]) |
---|
1690 |     elif event.GetId() == G2gd.wxID_DRAWRESTRANGLE and len(indx) == 3: |
---|
1691 | Â Â Â Â Â Â try: |
---|
1692 | Â Â Â Â Â Â Â Â angleData =Â restData[PhaseName]['Angle'] |
---|
1693 |       except KeyError: |
---|
1694 | Â Â Â Â Â Â Â Â angleData =Â {'wtFactor':1.0,'Angles':[],'Use':True} |
---|
1695 | Â Â Â Â Â Â Â Â restData[PhaseName]Â =Â {} |
---|
1696 | Â Â Â Â Â Â Â Â restData[PhaseName]['Angle']Â =Â angleData |
---|
1697 | Â Â Â Â Â Â angle =Â G2mth.getRestAngle(atXYZ,Amat) |
---|
1698 | Â Â Â Â Â Â angleData['Angles'].append([atIndx,atSymOp,109.5,1.0])Â Â Â Â Â Â |
---|
1699 |     elif event.GetId() == G2gd.wxID_DRAWRESTRPLANE and len(indx) > 3: |
---|
1700 | Â Â Â Â Â Â try: |
---|
1701 | Â Â Â Â Â Â Â Â planeData =Â restData[PhaseName]['Plane'] |
---|
1702 |       except KeyError: |
---|
1703 | Â Â Â Â Â Â Â Â planeData =Â {'wtFactor':1.0,'Planes':[],'Use':True} |
---|
1704 | Â Â Â Â Â Â Â Â restData[PhaseName]Â =Â {} |
---|
1705 | Â Â Â Â Â Â Â Â restData[PhaseName]['Plane']Â =Â planeData |
---|
1706 | Â Â Â Â Â Â plane =Â G2mth.getRestPlane(atXYZ,Amat) |
---|
1707 | Â Â Â Â Â Â planeData['Planes'].append([atIndx,atSymOp,0.0,0.01])Â Â Â Â Â Â |
---|
1708 |     elif event.GetId() == G2gd.wxID_DRAWRESTRCHIRAL and len(indx) == 4: |
---|
1709 | Â Â Â Â Â Â try: |
---|
1710 | Â Â Â Â Â Â Â Â chiralData =Â restData[PhaseName]['Chiral'] |
---|
1711 |       except KeyError: |
---|
1712 | Â Â Â Â Â Â Â Â chiralData =Â {'wtFactor':1.0,'Volumes':[],'Use':True} |
---|
1713 | Â Â Â Â Â Â Â Â restData[PhaseName]Â =Â {} |
---|
1714 | Â Â Â Â Â Â Â Â restData[PhaseName]['Chiral']Â =Â chiralData |
---|
1715 | Â Â Â Â Â Â volume =Â G2mth.getRestChiral(atXYZ,Amat) |
---|
1716 | Â Â Â Â Â Â chiralData['Volumes'].append([atIndx,atSymOp,2.5,0.1])Â Â Â Â Â Â |
---|
1717 | Â Â Â Â else: |
---|
1718 |       print '**** ERROR wrong number of atoms selected for this restraint' |
---|
1719 | Â Â Â Â Â Â return |
---|
1720 | Â Â Â Â G2frame.PatternTree.SetItemPyData(Â Â |
---|
1721 | Â Â Â Â Â Â G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Restraints'),restData) |
---|
1722 | |
---|
1723 |   def OnDefineRB(event): |
---|
1724 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
1725 | Â Â Â Â indx.sort() |
---|
1726 | Â Â Â Â RBData =Â G2frame.PatternTree.GetItemPyData(Â Â |
---|
1727 | Â Â Â Â Â Â G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Rigid bodies')) |
---|
1728 | Â Â Â Â drawingData =Â data['Drawing'] |
---|
1729 | Â Â Â Â generalData =Â data['General'] |
---|
1730 | Â Â Â Â Amat,Bmat =Â G2lat.cell2AB(generalData['Cell'][1:7])Â Â Â Â Â Â |
---|
1731 | Â Â Â Â cx,ct,cs,ci =Â drawingData['atomPtrs'] |
---|
1732 | Â Â Â Â atomData =Â drawingData['Atoms'] |
---|
1733 | Â Â Â Â rbXYZ =Â [] |
---|
1734 | Â Â Â Â rbType =Â [] |
---|
1735 | Â Â Â Â atNames =Â [] |
---|
1736 | Â Â Â Â AtInfo =Â RBData['Residue']['AtInfo'] |
---|
1737 |     for i,item in enumerate(indx): |
---|
1738 | Â Â Â Â Â Â rbtype =Â atomData[item][ct] |
---|
1739 | Â Â Â Â Â Â atNames.append(rbtype+str(i)) |
---|
1740 | Â Â Â Â Â Â rbType.append(rbtype) |
---|
1741 |       if rbtype not in AtInfo: |
---|
1742 | Â Â Â Â Â Â Â Â Info =Â G2elem.GetAtomInfo(rbtype) |
---|
1743 | Â Â Â Â Â Â Â Â AtInfo[rbtype]Â =Â [Info['Drad'],Info['Color']] |
---|
1744 | Â Â Â Â Â Â rbXYZ.append(np.inner(np.array(atomData[item][cx:cx+3]),Amat)) |
---|
1745 | Â Â Â Â rbXYZ =Â np.array(rbXYZ) |
---|
1746 | Â Â Â Â rbXYZ -=Â rbXYZ[0] |
---|
1747 | Â Â Â Â rbId =Â ran.randint(0,sys.maxint) |
---|
1748 | Â Â Â Â rbName =Â 'UNKRB' |
---|
1749 | Â Â Â Â dlg =Â wx.TextEntryDialog(G2frame,'Enter the name for the new rigid body', |
---|
1750 | Â Â Â Â Â Â 'Edit rigid body name',rbName ,style=wx.OK) |
---|
1751 |     if dlg.ShowModal() == wx.ID_OK: |
---|
1752 | Â Â Â Â Â Â rbName =Â dlg.GetValue() |
---|
1753 | Â Â Â Â dlg.Destroy() |
---|
1754 | Â Â Â Â RBData['Residue'][rbId]Â =Â {'RBname':rbName,'rbXYZ':rbXYZ,'rbTypes':rbType, |
---|
1755 | Â Â Â Â Â Â 'atNames':atNames,'rbRef':[0,1,2,False],'rbSeq':[],'SelSeq':[0,0],'useCount':0} |
---|
1756 | Â Â Â Â RBData['RBIds']['Residue'].append(rbId) |
---|
1757 | Â Â Â Â G2frame.dataFrame.SetStatusText('New rigid body UNKRB added to set of Residue rigid bodies') |
---|
1758 | |
---|
1759 | ################################################################################ |
---|
1760 | ##### Atom draw routines |
---|
1761 | ################################################################################ |
---|
1762 | Â Â Â Â Â Â |
---|
1763 |   def UpdateDrawAtoms(atomStyle=''): |
---|
1764 |     def RefreshAtomGrid(event): |
---|
1765 |       def SetChoice(name,c,n=0): |
---|
1766 | Â Â Â Â Â Â Â Â choice =Â [] |
---|
1767 |         for r in range(len(atomData)): |
---|
1768 |           if n: |
---|
1769 | Â Â Â Â Â Â Â Â Â Â Â Â srchStr =Â str(atomData[r][c][:n]) |
---|
1770 | Â Â Â Â Â Â Â Â Â Â else: |
---|
1771 | Â Â Â Â Â Â Â Â Â Â Â Â srchStr =Â str(atomData[r][c]) |
---|
1772 |           if srchStr not in choice: |
---|
1773 |             if n: |
---|
1774 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â choice.append(str(atomData[r][c][:n])) |
---|
1775 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
1776 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â choice.append(str(atomData[r][c])) |
---|
1777 | Â Â Â Â Â Â Â Â choice.sort() |
---|
1778 | |
---|
1779 | Â Â Â Â Â Â Â Â dlg =Â wx.MultiChoiceDialog(G2frame,'Select',name,choice) |
---|
1780 |         if dlg.ShowModal() == wx.ID_OK: |
---|
1781 | Â Â Â Â Â Â Â Â Â Â sel =Â dlg.GetSelections() |
---|
1782 | Â Â Â Â Â Â Â Â Â Â parms =Â [] |
---|
1783 |           for x in sel: |
---|
1784 | Â Â Â Â Â Â Â Â Â Â Â Â parms.append(choice[x]) |
---|
1785 | Â Â Â Â Â Â Â Â Â Â noSkip =Â False |
---|
1786 | Â Â Â Â Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
1787 | Â Â Â Â Â Â Â Â Â Â drawingData['selectedAtoms']Â =Â [] |
---|
1788 |           for row in range(len(atomData)): |
---|
1789 | Â Â Â Â Â Â Â Â Â Â Â Â test =Â atomData[row][c] |
---|
1790 |             if n: |
---|
1791 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â test =Â test[:n] |
---|
1792 |             if test in parms: |
---|
1793 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â drawAtoms.SelectRow(row,True) |
---|
1794 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â drawingData['selectedAtoms'].append(row) |
---|
1795 | Â Â Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data)Â Â Â Â Â Â Â Â Â Â |
---|
1796 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1797 | Â Â Â Â Â Â Â Â |
---|
1798 | Â Â Â Â Â Â r,c =Â event.GetRow(),event.GetCol() |
---|
1799 |       if r < 0 and c < 0: |
---|
1800 |         for row in range(drawAtoms.GetNumberRows()): |
---|
1801 | Â Â Â Â Â Â Â Â Â Â drawingData['selectedAtoms'].append(row) |
---|
1802 | Â Â Â Â Â Â Â Â Â Â drawAtoms.SelectRow(row,True)Â Â Â Â Â Â Â Â Â Â |
---|
1803 |       elif r < 0:             #dclick on col label |
---|
1804 | Â Â Â Â Â Â Â Â sel =Â -1 |
---|
1805 | Â Â Â Â Â Â Â Â Parms =Â False |
---|
1806 | Â Â Â Â Â Â Â Â noSkip =Â True |
---|
1807 |         if drawAtoms.GetColLabelValue(c) == 'Style': |
---|
1808 | Â Â Â Â Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select','Atom drawing style',styleChoice) |
---|
1809 |           if dlg.ShowModal() == wx.ID_OK: |
---|
1810 | Â Â Â Â Â Â Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
1811 | Â Â Â Â Â Â Â Â Â Â Â Â parms =Â styleChoice[sel] |
---|
1812 |             for r in range(len(atomData)): |
---|
1813 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c]Â =Â parms |
---|
1814 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â drawAtoms.SetCellValue(r,c,parms) |
---|
1815 | Â Â Â Â Â Â Â Â Â Â Â Â FindBondsDraw() |
---|
1816 | Â Â Â Â Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
1817 | Â Â Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1818 |         elif drawAtoms.GetColLabelValue(c) == 'Label': |
---|
1819 | Â Â Â Â Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select','Atom labelling style',labelChoice) |
---|
1820 |           if dlg.ShowModal() == wx.ID_OK: |
---|
1821 | Â Â Â Â Â Â Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
1822 | Â Â Â Â Â Â Â Â Â Â Â Â parms =Â labelChoice[sel] |
---|
1823 |             for r in range(len(atomData)): |
---|
1824 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c]Â =Â parms |
---|
1825 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â drawAtoms.SetCellValue(r,c,parms) |
---|
1826 | Â Â Â Â Â Â Â Â Â Â dlg.Destroy()Â Â Â Â Â Â Â Â Â Â |
---|
1827 |         elif drawAtoms.GetColLabelValue(c) == 'Color': |
---|
1828 | Â Â Â Â Â Â Â Â Â Â dlg =Â wx.ColourDialog(G2frame) |
---|
1829 |           if dlg.ShowModal() == wx.ID_OK: |
---|
1830 | Â Â Â Â Â Â Â Â Â Â Â Â color =Â dlg.GetColourData().GetColour() |
---|
1831 | Â Â Â Â Â Â Â Â Â Â Â Â attr =Â wg.GridCellAttr()Â Â Â Â Â Â Â Â #needs to be here - gets lost if outside loop! |
---|
1832 | Â Â Â Â Â Â Â Â Â Â Â Â attr.SetReadOnly(True) |
---|
1833 | Â Â Â Â Â Â Â Â Â Â Â Â attr.SetBackgroundColour(color) |
---|
1834 |             for r in range(len(atomData)): |
---|
1835 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c]Â =Â color |
---|
1836 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â drawingData['Atoms'][r][c]Â =Â color |
---|
1837 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â drawAtoms.SetAttr(r,c,attr) |
---|
1838 | Â Â Â Â Â Â Â Â Â Â Â Â UpdateDrawAtoms() |
---|
1839 | Â Â Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1840 |         elif drawAtoms.GetColLabelValue(c) == 'Residue': |
---|
1841 | Â Â Â Â Â Â Â Â Â Â SetChoice('Residue',c,3) |
---|
1842 |         elif drawAtoms.GetColLabelValue(c) == '1-letter': |
---|
1843 | Â Â Â Â Â Â Â Â Â Â SetChoice('1-letter',c,1) |
---|
1844 |         elif drawAtoms.GetColLabelValue(c) == 'Chain': |
---|
1845 | Â Â Â Â Â Â Â Â Â Â SetChoice('Chain',c) |
---|
1846 |         elif drawAtoms.GetColLabelValue(c) == 'Name': |
---|
1847 | Â Â Â Â Â Â Â Â Â Â SetChoice('Name',c) |
---|
1848 |         elif drawAtoms.GetColLabelValue(c) == 'Sym Op': |
---|
1849 | Â Â Â Â Â Â Â Â Â Â SetChoice('Name',c) |
---|
1850 |         elif drawAtoms.GetColLabelValue(c) == 'Type': |
---|
1851 | Â Â Â Â Â Â Â Â Â Â SetChoice('Type',c) |
---|
1852 |         elif drawAtoms.GetColLabelValue(c) in ['x','y','z','I/A']: |
---|
1853 | Â Â Â Â Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
1854 | Â Â Â Â Â Â else: |
---|
1855 |         if drawAtoms.GetColLabelValue(c) in ['Style','Label']: |
---|
1856 | Â Â Â Â Â Â Â Â Â Â atomData[r][c]Â =Â drawAtoms.GetCellValue(r,c) |
---|
1857 | Â Â Â Â Â Â Â Â Â Â FindBondsDraw() |
---|
1858 |         elif drawAtoms.GetColLabelValue(c) == 'Color': |
---|
1859 | Â Â Â Â Â Â Â Â Â Â dlg =Â wx.ColourDialog(G2frame) |
---|
1860 |           if dlg.ShowModal() == wx.ID_OK: |
---|
1861 | Â Â Â Â Â Â Â Â Â Â Â Â color =Â dlg.GetColourData().GetColour() |
---|
1862 | Â Â Â Â Â Â Â Â Â Â Â Â attr =Â wg.GridCellAttr()Â Â Â Â Â Â Â Â #needs to be here - gets lost if outside loop! |
---|
1863 | Â Â Â Â Â Â Â Â Â Â Â Â attr.SetReadOnly(True) |
---|
1864 | Â Â Â Â Â Â Â Â Â Â Â Â attr.SetBackgroundColour(color) |
---|
1865 | Â Â Â Â Â Â Â Â Â Â Â Â atomData[r][c]Â =Â color |
---|
1866 | Â Â Â Â Â Â Â Â Â Â Â Â drawingData['Atoms'][r][c]Â =Â color |
---|
1867 | Â Â Â Â Â Â Â Â Â Â Â Â drawAtoms.SetAttr(i,cs+2,attr) |
---|
1868 | Â Â Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1869 | Â Â Â Â Â Â Â Â Â Â UpdateDrawAtoms() |
---|
1870 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
1871 | Â Â Â Â Â Â Â Â Â Â |
---|
1872 |     def RowSelect(event): |
---|
1873 | Â Â Â Â Â Â r,c =Â event.GetRow(),event.GetCol() |
---|
1874 |       if r < 0 and c < 0: |
---|
1875 |         if drawAtoms.IsSelection(): |
---|
1876 | Â Â Â Â Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
1877 |       elif c < 0:          #only row clicks |
---|
1878 |         if event.ControlDown():          |
---|
1879 |           if r in drawAtoms.GetSelectedRows(): |
---|
1880 | Â Â Â Â Â Â Â Â Â Â Â Â drawAtoms.DeselectRow(r) |
---|
1881 | Â Â Â Â Â Â Â Â Â Â else: |
---|
1882 | Â Â Â Â Â Â Â Â Â Â Â Â drawAtoms.SelectRow(r,True) |
---|
1883 |         elif event.ShiftDown(): |
---|
1884 | Â Â Â Â Â Â Â Â Â Â indxs =Â drawAtoms.GetSelectedRows() |
---|
1885 | Â Â Â Â Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
1886 | Â Â Â Â Â Â Â Â Â Â ibeg =Â 0 |
---|
1887 |           if indxs: |
---|
1888 | Â Â Â Â Â Â Â Â Â Â Â Â ibeg =Â indxs[-1] |
---|
1889 |           for row in range(ibeg,r+1): |
---|
1890 | Â Â Â Â Â Â Â Â Â Â Â Â drawAtoms.SelectRow(row,True) |
---|
1891 | Â Â Â Â Â Â Â Â else: |
---|
1892 | Â Â Â Â Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
1893 | Â Â Â Â Â Â Â Â Â Â drawAtoms.SelectRow(r,True)Â Â Â Â Â Â Â Â |
---|
1894 | Â Â Â Â Â Â drawingData['selectedAtoms']Â =Â [] |
---|
1895 | Â Â Â Â Â Â drawingData['selectedAtoms']Â =Â drawAtoms.GetSelectedRows() |
---|
1896 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data)Â Â Â Â Â Â Â Â Â Â |
---|
1897 | |
---|
1898 | Â Â Â Â # UpdateDrawAtoms executable code starts here |
---|
1899 | Â Â Â Â G2frame.dataFrame.SetStatusText('') |
---|
1900 | Â Â Â Â generalData =Â data['General'] |
---|
1901 | Â Â Â Â SetupDrawingData() |
---|
1902 | Â Â Â Â drawingData =Â data['Drawing'] |
---|
1903 | Â Â Â Â cx,ct,cs,ci =Â drawingData['atomPtrs'] |
---|
1904 | Â Â Â Â atomData =Â drawingData['Atoms'] |
---|
1905 |     if atomStyle: |
---|
1906 |       for atom in atomData: |
---|
1907 | Â Â Â Â Â Â Â Â atom[cs]Â =Â atomStyle |
---|
1908 | Â Â Â Â Types =Â [wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,]+3*[wg.GRID_VALUE_FLOAT+':10,5',]+Â \ |
---|
1909 | Â Â Â Â Â Â [wg.GRID_VALUE_STRING,wg.GRID_VALUE_CHOICE+": ,lines,vdW balls,sticks,balls & sticks,ellipsoids,polyhedra", |
---|
1910 | Â Â Â Â Â Â wg.GRID_VALUE_CHOICE+": ,type,name,number",wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,] |
---|
1911 | Â Â Â Â styleChoice =Â [' ','lines','vdW balls','sticks','balls & sticks','ellipsoids','polyhedra'] |
---|
1912 | Â Â Â Â labelChoice =Â [' ','type','name','number'] |
---|
1913 | Â Â Â Â colLabels =Â ['Name','Type','x','y','z','Sym Op','Style','Label','Color','I/A'] |
---|
1914 |     if generalData['Type'] == 'macromolecular': |
---|
1915 | Â Â Â Â Â Â colLabels =Â ['Residue','1-letter','Chain']Â +Â colLabels |
---|
1916 | Â Â Â Â Â Â Types =Â 3*[wg.GRID_VALUE_STRING,]+Types |
---|
1917 | Â Â Â Â Â Â Types[8]Â =Â wg.GRID_VALUE_CHOICE+": ,lines,vdW balls,sticks,balls & sticks,ellipsoids,backbone,ribbons,schematic" |
---|
1918 | Â Â Â Â Â Â styleChoice =Â [' ','lines','vdW balls','sticks','balls & sticks','ellipsoids','backbone','ribbons','schematic'] |
---|
1919 | Â Â Â Â Â Â labelChoice =Â [' ','type','name','number','residue','1-letter','chain'] |
---|
1920 | Â Â Â Â Â Â Types[9]Â =Â wg.GRID_VALUE_CHOICE+": ,type,name,number,residue,1-letter,chain" |
---|
1921 | #Â Â Â Â elif generalData['Type'] == 'modulated': |
---|
1922 | #Â Â Â Â Â Â Types += [] |
---|
1923 | #Â Â Â Â Â Â colLabels += [] |
---|
1924 | Â Â Â Â table =Â [] |
---|
1925 | Â Â Â Â rowLabels =Â [] |
---|
1926 |     for i,atom in enumerate(drawingData['Atoms']): |
---|
1927 | Â Â Â Â Â Â table.append(atom[:colLabels.index('I/A')+1]) |
---|
1928 | Â Â Â Â Â Â rowLabels.append(str(i)) |
---|
1929 | |
---|
1930 | Â Â Â Â atomTable =Â G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) |
---|
1931 |     drawAtoms.SetTable(atomTable, True) |
---|
1932 | Â Â Â Â drawAtoms.SetMargins(0,0) |
---|
1933 | Â Â Â Â drawAtoms.AutoSizeColumns(True) |
---|
1934 | Â Â Â Â drawAtoms.SetColSize(colLabels.index('Style'),80) |
---|
1935 | Â Â Â Â drawAtoms.SetColSize(colLabels.index('Color'),50) |
---|
1936 |     drawAtoms.Bind(wg.EVT_GRID_CELL_CHANGE, RefreshAtomGrid) |
---|
1937 |     drawAtoms.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK, RefreshAtomGrid) |
---|
1938 |     drawAtoms.Bind(wg.EVT_GRID_CELL_LEFT_DCLICK, RefreshAtomGrid) |
---|
1939 |     drawAtoms.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK, RowSelect) |
---|
1940 |     for i,atom in enumerate(drawingData['Atoms']): |
---|
1941 | Â Â Â Â Â Â attr =Â wg.GridCellAttr()Â Â Â Â Â Â Â Â #needs to be here - gets lost if outside loop! |
---|
1942 | Â Â Â Â Â Â attr.SetReadOnly(True) |
---|
1943 | Â Â Â Â Â Â attr.SetBackgroundColour(atom[cs+2]) |
---|
1944 | Â Â Â Â Â Â drawAtoms.SetAttr(i,cs+2,attr) |
---|
1945 | Â Â Â Â Â Â drawAtoms.SetCellValue(i,cs+2,'') |
---|
1946 | Â Â Â Â indx =Â drawingData['selectedAtoms'] |
---|
1947 |     if indx: |
---|
1948 |       for r in range(len(atomData)): |
---|
1949 |         if r in indx: |
---|
1950 | Â Â Â Â Â Â Â Â Â Â drawAtoms.SelectRow(r) |
---|
1951 |     for c in range(len(colLabels)): |
---|
1952 | Â Â Â Â Â Â attr =Â wg.GridCellAttr()Â Â Â Â Â Â Â Â #needs to be here - gets lost if outside loop! |
---|
1953 | Â Â Â Â Â Â attr.SetReadOnly(True) |
---|
1954 | Â Â Â Â Â Â attr.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
1955 |       if colLabels[c] not in ['Style','Label','Color']: |
---|
1956 | Â Â Â Â Â Â Â Â drawAtoms.SetColAttr(c,attr) |
---|
1957 | Â Â Â Â G2frame.dataFrame.setSizePosLeft([600,300]) |
---|
1958 | |
---|
1959 | Â Â Â Â FindBondsDraw() |
---|
1960 | Â Â Â Â drawAtoms.ClearSelection() |
---|
1961 | #Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
1962 | |
---|
1963 |   def DrawAtomStyle(event): |
---|
1964 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
1965 |     if indx: |
---|
1966 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
1967 | Â Â Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
1968 | Â Â Â Â Â Â cx,ct,cs,ci =Â data['Drawing']['atomPtrs'] |
---|
1969 | Â Â Â Â Â Â styleChoice =Â [' ','lines','vdW balls','sticks','balls & sticks','ellipsoids','polyhedra'] |
---|
1970 |       if generalData['Type'] == 'macromolecular': |
---|
1971 | Â Â Â Â Â Â Â Â styleChoice =Â [' ','lines','vdW balls','sticks','balls & sticks','ellipsoids', |
---|
1972 | Â Â Â Â Â Â Â Â 'backbone','ribbons','schematic'] |
---|
1973 | Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select','Atom drawing style',styleChoice) |
---|
1974 |       if dlg.ShowModal() == wx.ID_OK: |
---|
1975 | Â Â Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
1976 | Â Â Â Â Â Â Â Â parms =Â styleChoice[sel] |
---|
1977 |         for r in indx: |
---|
1978 | Â Â Â Â Â Â Â Â Â Â atomData[r][cs]Â =Â parms |
---|
1979 | Â Â Â Â Â Â Â Â Â Â drawAtoms.SetCellValue(r,cs,parms) |
---|
1980 | Â Â Â Â Â Â dlg.Destroy() |
---|
1981 | Â Â Â Â Â Â FindBondsDraw() |
---|
1982 | Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
1983 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
1984 | |
---|
1985 |   def DrawAtomLabel(event): |
---|
1986 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
1987 |     if indx: |
---|
1988 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
1989 | Â Â Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
1990 | Â Â Â Â Â Â cx,ct,cs,ci =Â data['Drawing']['atomPtrs'] |
---|
1991 | Â Â Â Â Â Â styleChoice =Â [' ','type','name','number'] |
---|
1992 |       if generalData['Type'] == 'macromolecular': |
---|
1993 | Â Â Â Â Â Â Â Â styleChoice =Â [' ','type','name','number','residue','1-letter','chain'] |
---|
1994 | Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select','Atom label style',styleChoice) |
---|
1995 |       if dlg.ShowModal() == wx.ID_OK: |
---|
1996 | Â Â Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
1997 | Â Â Â Â Â Â Â Â parms =Â styleChoice[sel] |
---|
1998 |         for r in indx: |
---|
1999 | Â Â Â Â Â Â Â Â Â Â atomData[r][cs+1]Â =Â parms |
---|
2000 | Â Â Â Â Â Â Â Â Â Â drawAtoms.SetCellValue(r,cs+1,parms) |
---|
2001 | Â Â Â Â Â Â dlg.Destroy() |
---|
2002 | Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
2003 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2004 | Â Â Â Â Â Â |
---|
2005 |   def DrawAtomColor(event): |
---|
2006 | |
---|
2007 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
2008 |     if indx: |
---|
2009 |       if len(indx) > 1: |
---|
2010 | Â Â Â Â Â Â Â Â G2frame.dataFrame.SetStatusText('Select Custom Color, change color, Add to Custom Colors, then OK') |
---|
2011 | Â Â Â Â Â Â else: |
---|
2012 | Â Â Â Â Â Â Â Â G2frame.dataFrame.SetStatusText('Change color, Add to Custom Colors, then OK') |
---|
2013 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
2014 | Â Â Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2015 | Â Â Â Â Â Â cx,ct,cs,ci =Â data['Drawing']['atomPtrs'] |
---|
2016 | Â Â Â Â Â Â atmColors =Â [] |
---|
2017 | Â Â Â Â Â Â atmTypes =Â [] |
---|
2018 |       for r in indx: |
---|
2019 |         if atomData[r][cs+2] not in atmColors: |
---|
2020 | Â Â Â Â Â Â Â Â Â Â atmColors.append(atomData[r][cs+2]) |
---|
2021 | Â Â Â Â Â Â Â Â Â Â atmTypes.append(atomData[r][ct]) |
---|
2022 |           if len(atmColors) > 16: |
---|
2023 | Â Â Â Â Â Â Â Â Â Â Â Â break |
---|
2024 | Â Â Â Â Â Â colors =Â wx.ColourData() |
---|
2025 | Â Â Â Â Â Â colors.SetChooseFull(True) |
---|
2026 | Â Â Â Â Â Â dlg =Â wx.ColourDialog(G2frame) |
---|
2027 |       if dlg.ShowModal() == wx.ID_OK: |
---|
2028 |         for i in range(len(atmColors)):          |
---|
2029 | Â Â Â Â Â Â Â Â Â Â atmColors[i]Â =Â dlg.GetColourData().GetColour() |
---|
2030 | Â Â Â Â Â Â Â Â colorDict =Â dict(zip(atmTypes,atmColors)) |
---|
2031 |         for r in indx: |
---|
2032 | Â Â Â Â Â Â Â Â Â Â color =Â colorDict[atomData[r][ct]] |
---|
2033 | Â Â Â Â Â Â Â Â Â Â atomData[r][cs+2]Â =Â color |
---|
2034 | Â Â Â Â Â Â Â Â Â Â attr =Â wg.GridCellAttr()Â Â Â Â Â Â Â Â #needs to be here - gets lost if outside loop! |
---|
2035 | Â Â Â Â Â Â Â Â Â Â attr.SetBackgroundColour(color) |
---|
2036 | Â Â Â Â Â Â Â Â Â Â drawAtoms.SetAttr(r,cs+2,attr) |
---|
2037 | Â Â Â Â Â Â Â Â Â Â data['Drawing']['Atoms'][r][cs+2]Â =Â color |
---|
2038 | Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
2039 | Â Â Â Â Â Â dlg.Destroy() |
---|
2040 | Â Â Â Â Â Â G2frame.dataFrame.SetStatusText('') |
---|
2041 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2042 | Â Â Â Â Â Â |
---|
2043 |   def ResetAtomColors(event): |
---|
2044 | Â Â Â Â generalData =Â data['General'] |
---|
2045 | Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2046 | Â Â Â Â cx,ct,cs,ci =Â data['Drawing']['atomPtrs'] |
---|
2047 |     for atom in atomData:      |
---|
2048 | Â Â Â Â Â Â atNum =Â generalData['AtomTypes'].index(atom[ct]) |
---|
2049 | Â Â Â Â Â Â atom[cs+2]Â =Â list(generalData['Color'][atNum]) |
---|
2050 | Â Â Â Â UpdateDrawAtoms() |
---|
2051 | Â Â Â Â drawAtoms.ClearSelection() |
---|
2052 | Â Â Â Â G2plt.PlotStructure(G2frame,data)Â Â Â Â |
---|
2053 | Â Â Â Â |
---|
2054 |   def SetViewPoint(event): |
---|
2055 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
2056 |     if indx: |
---|
2057 | Â Â Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2058 | Â Â Â Â Â Â cx =Â data['Drawing']['atomPtrs'][0] |
---|
2059 | Â Â Â Â Â Â data['Drawing']['viewPoint']Â =Â [atomData[indx[0]][cx:cx+3],[indx[0],0]] |
---|
2060 | Â Â Â Â Â Â drawAtoms.ClearSelection()Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #do I really want to do this? |
---|
2061 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2062 | Â Â Â Â Â Â |
---|
2063 |   def noDuplicate(xyz,atomData):         #be careful where this is used - it's slow |
---|
2064 | Â Â Â Â cx =Â data['Drawing']['atomPtrs'][0] |
---|
2065 |     if True in [np.allclose(np.array(xyz),np.array(atom[cx:cx+3]),atol=0.0002) for atom in atomData]: |
---|
2066 |       return False |
---|
2067 | Â Â Â Â else: |
---|
2068 |       return True |
---|
2069 | Â Â Â Â Â Â Â Â |
---|
2070 |   def AddSymEquiv(event): |
---|
2071 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
2072 | Â Â Â Â indx.sort() |
---|
2073 |     if indx: |
---|
2074 |       colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())] |
---|
2075 | Â Â Â Â Â Â cx =Â colLabels.index('x') |
---|
2076 | Â Â Â Â Â Â cuia =Â colLabels.index('I/A') |
---|
2077 | Â Â Â Â Â Â cuij =Â cuia+2 |
---|
2078 | Â Â Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2079 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
2080 | Â Â Â Â Â Â SGData =Â generalData['SGData'] |
---|
2081 | Â Â Â Â Â Â dlg =Â G2gd.SymOpDialog(G2frame,SGData,False,True) |
---|
2082 | Â Â Â Â Â Â try: |
---|
2083 |         if dlg.ShowModal() == wx.ID_OK: |
---|
2084 | Â Â Â Â Â Â Â Â Â Â Inv,Cent,Opr,Cell,New,Force =Â dlg.GetSelection() |
---|
2085 | Â Â Â Â Â Â Â Â Â Â Cell =Â np.array(Cell) |
---|
2086 | Â Â Â Â Â Â Â Â Â Â cent =Â SGData['SGCen'][Cent] |
---|
2087 | Â Â Â Â Â Â Â Â Â Â M,T =Â SGData['SGOps'][Opr] |
---|
2088 |           for ind in indx: |
---|
2089 | Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â np.array(atomData[ind][cx:cx+3]) |
---|
2090 | Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â np.inner(M,XYZ)+T |
---|
2091 |             if Inv: |
---|
2092 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â -XYZ |
---|
2093 | Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â XYZ+cent+Cell |
---|
2094 |             if Force: |
---|
2095 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â G2spc.MoveToUnitCell(XYZ) |
---|
2096 |             if noDuplicate(XYZ,atomData): |
---|
2097 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom =Â copy.copy(atomData[ind]) |
---|
2098 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cx:cx+3]Â =Â XYZ |
---|
2099 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomOp =Â atom[cx+3] |
---|
2100 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â newOp =Â str(((Opr+1)+100*Cent)*(1-2*Inv))+'+'+Â \ |
---|
2101 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â str(int(Cell[0]))+','+str(int(Cell[1]))+','+str(int(Cell[2]))Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
2102 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cx+3]Â =Â G2spc.StringOpsProd(atomOp,newOp,SGData) |
---|
2103 |               if atom[cuia] == 'A': |
---|
2104 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Uij =Â atom[cuij:cuij+6] |
---|
2105 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U =Â G2spc.Uij2U(Uij) |
---|
2106 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U =Â np.inner(np.inner(M,U),M) |
---|
2107 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Uij =Â G2spc.U2Uij(U) |
---|
2108 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cuij:cuij+6]Â =Â Uij |
---|
2109 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData.append(atom) |
---|
2110 | Â Â Â Â Â Â finally: |
---|
2111 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
2112 | Â Â Â Â Â Â UpdateDrawAtoms() |
---|
2113 | Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
2114 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2115 | Â Â Â Â Â Â |
---|
2116 |   def TransformSymEquiv(event): |
---|
2117 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
2118 | Â Â Â Â indx.sort() |
---|
2119 |     if indx: |
---|
2120 | Â Â Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2121 |       colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())] |
---|
2122 | Â Â Â Â Â Â cx =Â colLabels.index('x') |
---|
2123 | Â Â Â Â Â Â cuia =Â colLabels.index('I/A') |
---|
2124 | Â Â Â Â Â Â cuij =Â cuia+2 |
---|
2125 | Â Â Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2126 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
2127 | Â Â Â Â Â Â SGData =Â generalData['SGData'] |
---|
2128 | Â Â Â Â Â Â dlg =Â G2gd.SymOpDialog(G2frame,SGData,False,True) |
---|
2129 | Â Â Â Â Â Â try: |
---|
2130 |         if dlg.ShowModal() == wx.ID_OK: |
---|
2131 | Â Â Â Â Â Â Â Â Â Â Inv,Cent,Opr,Cell,New,Force =Â dlg.GetSelection() |
---|
2132 | Â Â Â Â Â Â Â Â Â Â Cell =Â np.array(Cell) |
---|
2133 | Â Â Â Â Â Â Â Â Â Â cent =Â SGData['SGCen'][Cent] |
---|
2134 | Â Â Â Â Â Â Â Â Â Â M,T =Â SGData['SGOps'][Opr] |
---|
2135 |           for ind in indx: |
---|
2136 | Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â np.array(atomData[ind][cx:cx+3]) |
---|
2137 | Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â np.inner(M,XYZ)+T |
---|
2138 |             if Inv: |
---|
2139 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â -XYZ |
---|
2140 | Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â XYZ+cent+Cell |
---|
2141 |             if Force: |
---|
2142 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â XYZ =Â G2spc.MoveToUnitCell(XYZ) |
---|
2143 | Â Â Â Â Â Â Â Â Â Â Â Â atom =Â atomData[ind] |
---|
2144 | Â Â Â Â Â Â Â Â Â Â Â Â atom[cx:cx+3]Â =Â XYZ |
---|
2145 | Â Â Â Â Â Â Â Â Â Â Â Â atomOp =Â atom[cx+3] |
---|
2146 | Â Â Â Â Â Â Â Â Â Â Â Â newOp =Â str(((Opr+1)+100*Cent)*(1-2*Inv))+'+'+Â \ |
---|
2147 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â str(int(Cell[0]))+','+str(int(Cell[1]))+','+str(int(Cell[2])) |
---|
2148 | Â Â Â Â Â Â Â Â Â Â Â Â atom[cx+3]Â =Â G2spc.StringOpsProd(atomOp,newOp,SGData) |
---|
2149 |             if atom[cuia] == 'A': |
---|
2150 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Uij =Â atom[cuij:cuij+6] |
---|
2151 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â U =Â G2spc.Uij2U(Uij) |
---|
2152 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â U =Â np.inner(np.inner(M,U),M) |
---|
2153 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Uij =Â G2spc.U2Uij(U) |
---|
2154 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cuij:cuij+6]Â =Â Uij |
---|
2155 | Â Â Â Â Â Â Â Â Â Â data['Drawing']['Atoms']Â =Â atomData |
---|
2156 | Â Â Â Â Â Â finally: |
---|
2157 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
2158 | Â Â Â Â Â Â UpdateDrawAtoms() |
---|
2159 | Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
2160 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2161 | Â Â Â Â Â Â |
---|
2162 |   def FillCoordSphere(event): |
---|
2163 | Â Â Â Â generalData =Â data['General'] |
---|
2164 | Â Â Â Â Amat,Bmat =Â G2lat.cell2AB(generalData['Cell'][1:7]) |
---|
2165 | Â Â Â Â radii =Â generalData['BondRadii'] |
---|
2166 | Â Â Â Â atomTypes =Â generalData['AtomTypes'] |
---|
2167 | Â Â Â Â try: |
---|
2168 | Â Â Â Â Â Â indH =Â atomTypes.index('H') |
---|
2169 | Â Â Â Â Â Â radii[indH]Â =Â 0.5 |
---|
2170 | Â Â Â Â except: |
---|
2171 |       pass      |
---|
2172 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
2173 |     if indx: |
---|
2174 | Â Â Â Â Â Â indx.sort() |
---|
2175 | Â Â Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2176 | Â Â Â Â Â Â numAtoms =Â len(atomData) |
---|
2177 | Â Â Â Â Â Â cx,ct,cs,ci =Â data['Drawing']['atomPtrs'] |
---|
2178 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
2179 | Â Â Â Â Â Â SGData =Â generalData['SGData'] |
---|
2180 | Â Â Â Â Â Â cellArray =Â G2lat.CellBlock(1) |
---|
2181 | Â Â Â Â Â Â wx.BeginBusyCursor() |
---|
2182 | Â Â Â Â Â Â try: |
---|
2183 |         for ind in indx: |
---|
2184 | Â Â Â Â Â Â Â Â Â Â atomA =Â atomData[ind] |
---|
2185 | Â Â Â Â Â Â Â Â Â Â xyzA =Â np.array(atomA[cx:cx+3]) |
---|
2186 | Â Â Â Â Â Â Â Â Â Â indA =Â atomTypes.index(atomA[ct]) |
---|
2187 |           for atomB in atomData[:numAtoms]: |
---|
2188 | Â Â Â Â Â Â Â Â Â Â Â Â indB =Â atomTypes.index(atomB[ct]) |
---|
2189 | Â Â Â Â Â Â Â Â Â Â Â Â sumR =Â radii[indA]+radii[indB] |
---|
2190 | Â Â Â Â Â Â Â Â Â Â Â Â xyzB =Â np.array(atomB[cx:cx+3]) |
---|
2191 |             for xyz in cellArray+xyzB: |
---|
2192 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â dist =Â np.sqrt(np.sum(np.inner(Amat,xyz-xyzA)**2)) |
---|
2193 |               if 0 < dist <= data['Drawing']['radiusFactor']*sumR: |
---|
2194 |                 if noDuplicate(xyz,atomData): |
---|
2195 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â oprB =Â atomB[cx+3] |
---|
2196 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â C =Â xyz-xyzB |
---|
2197 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newOp =Â '1+'+str(int(round(C[0])))+','+str(int(round(C[1])))+','+str(int(round(C[2]))) |
---|
2198 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newAtom =Â atomB[:] |
---|
2199 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newAtom[cx:cx+3]Â =Â xyz |
---|
2200 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newAtom[cx+3]Â =Â G2spc.StringOpsProd(oprB,newOp,SGData) |
---|
2201 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData.append(newAtom) |
---|
2202 | Â Â Â Â Â Â finally: |
---|
2203 | Â Â Â Â Â Â Â Â wx.EndBusyCursor() |
---|
2204 | Â Â Â Â Â Â data['Drawing']['Atoms']Â =Â atomData |
---|
2205 | Â Â Â Â Â Â UpdateDrawAtoms() |
---|
2206 | Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
2207 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2208 | Â Â Â Â Â Â |
---|
2209 |   def FillUnitCell(event): |
---|
2210 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
2211 | Â Â Â Â indx.sort() |
---|
2212 |     if indx: |
---|
2213 | Â Â Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2214 |       colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())] |
---|
2215 | Â Â Â Â Â Â cx =Â colLabels.index('x') |
---|
2216 | Â Â Â Â Â Â cuia =Â colLabels.index('I/A') |
---|
2217 | Â Â Â Â Â Â cuij =Â cuia+2 |
---|
2218 | Â Â Â Â Â Â generalData =Â data['General'] |
---|
2219 | Â Â Â Â Â Â SGData =Â generalData['SGData'] |
---|
2220 | Â Â Â Â Â Â wx.BeginBusyCursor() |
---|
2221 | Â Â Â Â Â Â try: |
---|
2222 |         for ind in indx: |
---|
2223 | Â Â Â Â Â Â Â Â Â Â atom =Â atomData[ind] |
---|
2224 | Â Â Â Â Â Â Â Â Â Â XYZ =Â np.array(atom[cx:cx+3]) |
---|
2225 |           if atom[cuia] == 'A': |
---|
2226 | Â Â Â Â Â Â Â Â Â Â Â Â Uij =Â atom[cuij:cuij+6] |
---|
2227 | Â Â Â Â Â Â Â Â Â Â Â Â result =Â G2spc.GenAtom(XYZ,SGData,False,Uij,False) |
---|
2228 |             for item in result: |
---|
2229 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom =Â copy.copy(atomData[ind]) |
---|
2230 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cx:cx+3]Â =Â item[0] |
---|
2231 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cx+3]Â =Â str(item[2])+'+'Â \ |
---|
2232 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â +str(item[3][0])+','+str(item[3][1])+','+str(item[3][2]) |
---|
2233 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cuij:cuij+6]Â =Â item[1] |
---|
2234 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Opp =Â G2spc.Opposite(item[0]) |
---|
2235 |               for xyz in Opp: |
---|
2236 |                 if noDuplicate(xyz,atomData): |
---|
2237 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cell =Â np.asarray(np.rint(xyz-atom[cx:cx+3]),dtype=np.int32) |
---|
2238 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cell =Â '1'+'+'+Â \ |
---|
2239 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â str(cell[0])+','+str(cell[1])+','+str(cell[2]) |
---|
2240 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cx:cx+3]Â =Â xyz |
---|
2241 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cx+3]Â =Â G2spc.StringOpsProd(cell,atom[cx+3],SGData) |
---|
2242 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData.append(atom[:]) |
---|
2243 | Â Â Â Â Â Â Â Â Â Â else: |
---|
2244 | Â Â Â Â Â Â Â Â Â Â Â Â result =Â G2spc.GenAtom(XYZ,SGData,False,Move=False) |
---|
2245 |             for item in result: |
---|
2246 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom =Â copy.copy(atomData[ind]) |
---|
2247 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cx:cx+3]Â =Â item[0] |
---|
2248 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cx+3]Â =Â str(item[1])+'+'Â \ |
---|
2249 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â +str(item[2][0])+','+str(item[2][1])+','+str(item[2][2]) |
---|
2250 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Opp =Â G2spc.Opposite(item[0]) |
---|
2251 |               for xyz in Opp: |
---|
2252 |                 if noDuplicate(xyz,atomData): |
---|
2253 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cell =Â np.asarray(np.rint(xyz-atom[cx:cx+3]),dtype=np.int32) |
---|
2254 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cell =Â '1'+'+'+Â \ |
---|
2255 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â str(cell[0])+','+str(cell[1])+','+str(cell[2]) |
---|
2256 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cx:cx+3]Â =Â xyz |
---|
2257 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atom[cx+3]Â =Â G2spc.StringOpsProd(cell,atom[cx+3],SGData) |
---|
2258 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData.append(atom[:])Â Â Â Â Â Â Â Â |
---|
2259 | Â Â Â Â Â Â Â Â Â Â data['Drawing']['Atoms']Â =Â atomData |
---|
2260 | Â Â Â Â Â Â finally: |
---|
2261 | Â Â Â Â Â Â Â Â wx.EndBusyCursor() |
---|
2262 | Â Â Â Â Â Â UpdateDrawAtoms() |
---|
2263 | Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
2264 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2265 | Â Â Â Â Â Â |
---|
2266 |   def FindBondsToo():             #works but slow for large structures - keep as reference |
---|
2267 | Â Â Â Â cx,ct,cs,ci =Â data['Drawing']['atomPtrs'] |
---|
2268 | Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2269 | Â Â Â Â generalData =Â data['General'] |
---|
2270 | Â Â Â Â Amat,Bmat =Â G2lat.cell2AB(generalData['Cell'][1:7]) |
---|
2271 | Â Â Â Â radii =Â generalData['BondRadii'] |
---|
2272 | Â Â Â Â atomTypes =Â generalData['AtomTypes'] |
---|
2273 | Â Â Â Â try: |
---|
2274 | Â Â Â Â Â Â indH =Â atomTypes.index('H') |
---|
2275 | Â Â Â Â Â Â radii[indH]Â =Â 0.5 |
---|
2276 | Â Â Â Â except: |
---|
2277 |       pass      |
---|
2278 |     for atom in atomData: |
---|
2279 | Â Â Â Â Â Â atom[-1]Â =Â [] |
---|
2280 | Â Â Â Â Atoms =Â [] |
---|
2281 |     for i,atom in enumerate(atomData): |
---|
2282 | Â Â Â Â Â Â Atoms.append([i,np.array(atom[cx:cx+3]),atom[cs],radii[atomTypes.index(atom[ct])]]) |
---|
2283 |     for atomA in Atoms: |
---|
2284 |       if atomA[2] in ['lines','sticks','ellipsoids','balls & sticks','polyhedra']: |
---|
2285 |         for atomB in Atoms:          |
---|
2286 | Â Â Â Â Â Â Â Â Â Â Dx =Â atomB[1]-atomA[1] |
---|
2287 | Â Â Â Â Â Â Â Â Â Â DX =Â np.inner(Amat,Dx) |
---|
2288 | Â Â Â Â Â Â Â Â Â Â dist =Â np.sqrt(np.sum(DX**2)) |
---|
2289 | Â Â Â Â Â Â Â Â Â Â sumR =Â atomA[3]+atomB[3] |
---|
2290 |           if 0.5 < dist <= 0.85*sumR: |
---|
2291 | Â Â Â Â Â Â Â Â Â Â Â Â i =Â atomA[0] |
---|
2292 |             if atomA[2] == 'polyhedra': |
---|
2293 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[i][-1].append(DX) |
---|
2294 |             elif atomB[1] != 'polyhedra': |
---|
2295 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â j =Â atomB[0] |
---|
2296 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[i][-1].append(Dx*atomA[3]/sumR) |
---|
2297 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atomData[j][-1].append(-Dx*atomB[3]/sumR) |
---|
2298 | Â Â Â Â Â Â Â Â Â Â |
---|
2299 |   def FindBondsDraw():          #uses numpy & masks - very fast even for proteins! |
---|
2300 |     import numpy.ma as ma |
---|
2301 | Â Â Â Â cx,ct,cs,ci =Â data['Drawing']['atomPtrs'] |
---|
2302 | Â Â Â Â hydro =Â data['Drawing']['showHydrogen'] |
---|
2303 | Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2304 | Â Â Â Â generalData =Â data['General'] |
---|
2305 | Â Â Â Â Amat,Bmat =Â G2lat.cell2AB(generalData['Cell'][1:7]) |
---|
2306 | Â Â Â Â radii =Â generalData['BondRadii'] |
---|
2307 | Â Â Â Â atomTypes =Â generalData['AtomTypes'] |
---|
2308 | Â Â Â Â try: |
---|
2309 | Â Â Â Â Â Â indH =Â atomTypes.index('H') |
---|
2310 | Â Â Â Â Â Â radii[indH]Â =Â 0.5 |
---|
2311 | Â Â Â Â except: |
---|
2312 |       pass      |
---|
2313 |     for atom in atomData: |
---|
2314 | Â Â Â Â Â Â atom[-2]Â =Â []Â Â Â Â Â Â Â Â #clear out old bonds/polyhedra |
---|
2315 | Â Â Â Â Â Â atom[-1]Â =Â [] |
---|
2316 | Â Â Â Â Indx =Â range(len(atomData)) |
---|
2317 | Â Â Â Â Atoms =Â [] |
---|
2318 | Â Â Â Â Styles =Â [] |
---|
2319 | Â Â Â Â Radii =Â [] |
---|
2320 |     for atom in atomData: |
---|
2321 | Â Â Â Â Â Â Atoms.append(np.array(atom[cx:cx+3])) |
---|
2322 | Â Â Â Â Â Â Styles.append(atom[cs]) |
---|
2323 | Â Â Â Â Â Â try: |
---|
2324 |         if not hydro and atom[ct] == 'H': |
---|
2325 | Â Â Â Â Â Â Â Â Â Â Radii.append(0.0) |
---|
2326 | Â Â Â Â Â Â Â Â else: |
---|
2327 | Â Â Â Â Â Â Â Â Â Â Radii.append(radii[atomTypes.index(atom[ct])]) |
---|
2328 |       except ValueError:     #changed atom type! |
---|
2329 | Â Â Â Â Â Â Â Â Radii.append(0.20) |
---|
2330 | Â Â Â Â Atoms =Â np.array(Atoms) |
---|
2331 | Â Â Â Â Radii =Â np.array(Radii) |
---|
2332 | Â Â Â Â IASR =Â zip(Indx,Atoms,Styles,Radii) |
---|
2333 |     for atomA in IASR: |
---|
2334 |       if atomA[2] in ['lines','sticks','ellipsoids','balls & sticks','polyhedra']: |
---|
2335 | Â Â Â Â Â Â Â Â Dx =Â Atoms-atomA[1] |
---|
2336 | Â Â Â Â Â Â Â Â dist =Â ma.masked_less(np.sqrt(np.sum(np.inner(Amat,Dx)**2,axis=0)),0.5)Â #gets rid of G2frame & disorder "bonds" < 0.5A |
---|
2337 | Â Â Â Â Â Â Â Â sumR =Â atomA[3]+Radii |
---|
2338 | Â Â Â Â Â Â Â Â IndB =Â ma.nonzero(ma.masked_greater(dist-data['Drawing']['radiusFactor']*sumR,0.))Â Â Â Â Â Â Â Â Â #get indices of bonded atoms |
---|
2339 | Â Â Â Â Â Â Â Â i =Â atomA[0] |
---|
2340 |         for j in IndB[0]: |
---|
2341 |           if Styles[i] == 'polyhedra': |
---|
2342 | Â Â Â Â Â Â Â Â Â Â Â Â atomData[i][-2].append(np.inner(Amat,Dx[j])) |
---|
2343 |           elif Styles[j] != 'polyhedra' and j > i: |
---|
2344 | Â Â Â Â Â Â Â Â Â Â Â Â atomData[i][-2].append(Dx[j]*Radii[i]/sumR[j]) |
---|
2345 | Â Â Â Â Â Â Â Â Â Â Â Â atomData[j][-2].append(-Dx[j]*Radii[j]/sumR[j]) |
---|
2346 |         if Styles[i] == 'polyhedra': |
---|
2347 | Â Â Â Â Â Â Â Â Â Â Bonds =Â atomData[i][-2] |
---|
2348 | Â Â Â Â Â Â Â Â Â Â Faces =Â [] |
---|
2349 |           if len(Bonds) > 2: |
---|
2350 | Â Â Â Â Â Â Â Â Â Â Â Â FaceGen =Â G2lat.uniqueCombinations(Bonds,3)Â Â Â #N.B. this is a generator |
---|
2351 |             for face in FaceGen: |
---|
2352 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â vol =Â nl.det(face) |
---|
2353 |               if abs(vol) > 1. or len(Bonds) == 3: |
---|
2354 |                 if vol < 0.: |
---|
2355 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â face =Â [face[0],face[2],face[1]] |
---|
2356 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â face =Â np.array(face) |
---|
2357 |                 if not np.array([np.array(nl.det(face-bond))+0.0001 < 0 for bond in Bonds]).any(): |
---|
2358 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â norm =Â np.cross(face[1]-face[0],face[2]-face[0]) |
---|
2359 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â norm /=Â np.sqrt(np.sum(norm**2)) |
---|
2360 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Faces.append([face,norm]) |
---|
2361 | Â Â Â Â Â Â Â Â Â Â Â Â atomData[i][-1]Â =Â Faces |
---|
2362 | Â Â Â Â Â Â Â Â Â Â Â Â |
---|
2363 |   def DrawAtomsDelete(event):  |
---|
2364 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
2365 | Â Â Â Â indx.sort() |
---|
2366 |     if indx: |
---|
2367 | Â Â Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2368 | Â Â Â Â Â Â indx.reverse() |
---|
2369 |       for ind in indx: |
---|
2370 |         del atomData[ind] |
---|
2371 | Â Â Â Â Â Â UpdateDrawAtoms() |
---|
2372 | Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
2373 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2374 | Â Â Â Â event.StopPropagation() |
---|
2375 | Â Â Â Â |
---|
2376 |   def OnReloadDrawAtoms(event): |
---|
2377 | Â Â Â Â data['Drawing']['Atoms']Â =Â [] |
---|
2378 | Â Â Â Â UpdateDrawAtoms() |
---|
2379 | Â Â Â Â drawAtoms.ClearSelection() |
---|
2380 | Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2381 | Â Â Â Â event.StopPropagation() |
---|
2382 | Â Â Â Â |
---|
2383 |   def DrawAtomsDeleteByIDs(IDs): |
---|
2384 | Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2385 | Â Â Â Â indx =Â G2mth.FindAtomIndexByIDs(atomData,IDs) |
---|
2386 | Â Â Â Â indx.reverse() |
---|
2387 |     for ind in indx: |
---|
2388 |       del atomData[ind] |
---|
2389 | Â Â Â Â Â Â |
---|
2390 |   def ChangeDrawAtomsByIDs(colName,IDs,value): |
---|
2391 | Â Â Â Â atomData =Â data['Drawing']['Atoms'] |
---|
2392 | Â Â Â Â cx,ct,cs,ci =Â data['Drawing']['atomPtrs'] |
---|
2393 |     if colName == 'Name': |
---|
2394 | Â Â Â Â Â Â col =Â ct-1 |
---|
2395 |     elif colName == 'Type': |
---|
2396 | Â Â Â Â Â Â col =Â ct |
---|
2397 |     elif colName == 'I/A': |
---|
2398 | Â Â Â Â Â Â col =Â cs |
---|
2399 | Â Â Â Â indx =Â G2mth.FindAtomIndexByIDs(atomData,IDs) |
---|
2400 |     for ind in indx: |
---|
2401 | Â Â Â Â Â Â atomData[ind][col]Â =Â value |
---|
2402 | Â Â Â Â Â Â Â Â |
---|
2403 |   def OnDrawPlane(event): |
---|
2404 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
2405 |     if len(indx) < 4: |
---|
2406 |       print '**** ERROR - need 4+ atoms for plane calculation' |
---|
2407 | Â Â Â Â Â Â return |
---|
2408 | Â Â Â Â PlaneData =Â {} |
---|
2409 | Â Â Â Â drawingData =Â data['Drawing'] |
---|
2410 | Â Â Â Â atomData =Â drawingData['Atoms'] |
---|
2411 |     colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())] |
---|
2412 | Â Â Â Â cx =Â colLabels.index('x') |
---|
2413 | Â Â Â Â cn =Â colLabels.index('Name') |
---|
2414 | Â Â Â Â xyz =Â [] |
---|
2415 |     for i,atom in enumerate(atomData): |
---|
2416 |       if i in indx: |
---|
2417 | Â Â Â Â Â Â Â Â xyz.append([i,]+atom[cn:cn+2]+atom[cx:cx+3]) |
---|
2418 | Â Â Â Â generalData =Â data['General'] |
---|
2419 | Â Â Â Â PlaneData['Name']Â =Â generalData['Name'] |
---|
2420 | Â Â Â Â PlaneData['Atoms']Â =Â xyz |
---|
2421 | Â Â Â Â PlaneData['Cell']Â =Â generalData['Cell'][1:]Â #+ volume |
---|
2422 | Â Â Â Â G2stMn.BestPlane(PlaneData) |
---|
2423 | Â Â Â Â |
---|
2424 |   def OnDrawDistVP(event): |
---|
2425 | Â Â Â Â # distance to view point |
---|
2426 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
2427 |     if not indx: |
---|
2428 |       print '***** ERROR - no atoms selected' |
---|
2429 | Â Â Â Â Â Â return |
---|
2430 | Â Â Â Â generalData =Â data['General'] |
---|
2431 | Â Â Â Â Amat,Bmat =Â G2lat.cell2AB(generalData['Cell'][1:7])Â Â Â Â Â Â |
---|
2432 | Â Â Â Â drawingData =Â data['Drawing'] |
---|
2433 | Â Â Â Â viewPt =Â np.array(drawingData['viewPoint'][0]) |
---|
2434 |     print ' Distance from view point at %.3f %.3f %.3f to:'%(viewPt[0],viewPt[1],viewPt[2]) |
---|
2435 | Â Â Â Â atomDData =Â drawingData['Atoms'] |
---|
2436 |     colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())] |
---|
2437 | Â Â Â Â cx =Â colLabels.index('x') |
---|
2438 | Â Â Â Â cn =Â colLabels.index('Name') |
---|
2439 |     for i in indx: |
---|
2440 | Â Â Â Â Â Â atom =Â atomDData[i] |
---|
2441 | Â Â Â Â Â Â Dx =Â np.array(atom[cx:cx+3])-viewPt |
---|
2442 | Â Â Â Â Â Â dist =Â np.sqrt(np.sum(np.inner(Amat,Dx)**2,axis=0)) |
---|
2443 |       print 'Atom: %8s (%12s) distance = %.3f'%(atom[cn],atom[cx+3],dist) |
---|
2444 | Â Â |
---|
2445 |   def OnDrawDAT(event): |
---|
2446 | Â Â Â Â #distance, angle, torsion |
---|
2447 | Â Â Â Â indx =Â drawAtoms.GetSelectedRows() |
---|
2448 |     if len(indx) not in [2,3,4]: |
---|
2449 |       print '**** ERROR - wrong number of atoms for distance, angle or torsion calculation' |
---|
2450 | Â Â Â Â Â Â return |
---|
2451 | Â Â Â Â DATData =Â {} |
---|
2452 | Â Â Â Â ocx,oct,ocs,cia =Â data['General']['AtomPtrs'] |
---|
2453 | Â Â Â Â drawingData =Â data['Drawing'] |
---|
2454 | Â Â Â Â atomData =Â data['Atoms'] |
---|
2455 | Â Â Â Â atomDData =Â drawingData['Atoms'] |
---|
2456 |     colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())] |
---|
2457 | Â Â Â Â cx =Â colLabels.index('x') |
---|
2458 | Â Â Â Â cn =Â colLabels.index('Name') |
---|
2459 | Â Â Â Â cid =Â colLabels.index('I/A')+8 |
---|
2460 | Â Â Â Â xyz =Â [] |
---|
2461 | Â Â Â Â Oxyz =Â [] |
---|
2462 | Â Â Â Â DATData['Natoms']Â =Â len(indx) |
---|
2463 |     for i in indx: |
---|
2464 | Â Â Â Â Â Â atom =Â atomDData[i] |
---|
2465 | Â Â Â Â Â Â xyz.append([i,]+atom[cn:cn+2]+atom[cx:cx+4])Â #also gets Sym Op |
---|
2466 |       id = G2mth.FindAtomIndexByIDs(atomData,[atom[cid],],False)[0] |
---|
2467 | Â Â Â Â Â Â Oxyz.append([id,]+atomData[id][cx+1:cx+4]) |
---|
2468 | Â Â Â Â DATData['Datoms']Â =Â xyz |
---|
2469 | Â Â Â Â DATData['Oatoms']Â =Â Oxyz |
---|
2470 | Â Â Â Â generalData =Â data['General'] |
---|
2471 | Â Â Â Â DATData['Name']Â =Â generalData['Name'] |
---|
2472 | Â Â Â Â DATData['SGData']Â =Â generalData['SGData'] |
---|
2473 | Â Â Â Â DATData['Cell']Â =Â generalData['Cell'][1:]Â #+ volume |
---|
2474 |     if 'pId' in data: |
---|
2475 | Â Â Â Â Â Â DATData['pId']Â =Â data['pId'] |
---|
2476 |       DATData['covData'] = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Covariance')) |
---|
2477 | Â Â Â Â G2stMn.DisAglTor(DATData) |
---|
2478 | Â Â Â Â Â Â Â Â |
---|
2479 | ################################################################################ |
---|
2480 | #### Draw Options page |
---|
2481 | ################################################################################ |
---|
2482 | |
---|
2483 |   def UpdateDrawOptions(): |
---|
2484 |     import copy |
---|
2485 |     import wx.lib.colourselect as wcs |
---|
2486 |     def SlopSizer():      |
---|
2487 |       def OnCameraPos(event): |
---|
2488 | Â Â Â Â Â Â Â Â drawingData['cameraPos']Â =Â cameraPos.GetValue() |
---|
2489 | Â Â Â Â Â Â Â Â cameraPosTxt.SetLabel(' Camera Distance: '+'%.2f'%(drawingData['cameraPos'])) |
---|
2490 | Â Â Â Â Â Â Â Â ZclipTxt.SetLabel(' Z clipping: '+'%.2fA'%(drawingData['Zclip']*drawingData['cameraPos']/100.)) |
---|
2491 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2492 | |
---|
2493 |       def OnZclip(event): |
---|
2494 | Â Â Â Â Â Â Â Â drawingData['Zclip']Â =Â Zclip.GetValue() |
---|
2495 | Â Â Â Â Â Â Â Â ZclipTxt.SetLabel(' Z clipping: '+'%.2fA'%(drawingData['Zclip']*drawingData['cameraPos']/100.)) |
---|
2496 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2497 | Â Â Â Â Â Â Â Â |
---|
2498 |       def OnZstep(event): |
---|
2499 | Â Â Â Â Â Â Â Â try: |
---|
2500 | Â Â Â Â Â Â Â Â Â Â step =Â float(Zstep.GetValue()) |
---|
2501 |           if not (0.01 <= step <= 1.0): |
---|
2502 |             raise ValueError |
---|
2503 |         except ValueError: |
---|
2504 | Â Â Â Â Â Â Â Â Â Â step =Â drawingData['Zstep'] |
---|
2505 | Â Â Â Â Â Â Â Â drawingData['Zstep']Â =Â step |
---|
2506 | Â Â Â Â Â Â Â Â Zstep.SetValue('%.2fA'%(drawingData['Zstep'])) |
---|
2507 | Â Â Â Â Â Â Â Â |
---|
2508 |       def OnMoveZ(event): |
---|
2509 | Â Â Â Â Â Â Â Â move =Â MoveZ.GetValue()*drawingData['Zstep'] |
---|
2510 | Â Â Â Â Â Â Â Â MoveZ.SetValue(0) |
---|
2511 | Â Â Â Â Â Â Â Â VP =Â np.inner(Amat,np.array(drawingData['viewPoint'][0])) |
---|
2512 | Â Â Â Â Â Â Â Â VD =Â np.inner(Amat,np.array(drawingData['viewDir'])) |
---|
2513 | Â Â Â Â Â Â Â Â VD /=Â np.sqrt(np.sum(VD**2)) |
---|
2514 | Â Â Â Â Â Â Â Â VP +=Â move*VD |
---|
2515 | Â Â Â Â Â Â Â Â VP =Â np.inner(Bmat,VP) |
---|
2516 | Â Â Â Â Â Â Â Â drawingData['viewPoint'][0]Â =Â VP |
---|
2517 | Â Â Â Â Â Â Â Â panel =Â drawOptions.GetChildren() |
---|
2518 |         names = [child.GetName() for child in panel] |
---|
2519 |         panel[names.index('viewPoint')].SetValue('%.3f %.3f %.3f'%(VP[0],VP[1],VP[2]))        |
---|
2520 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2521 | Â Â Â Â Â Â Â Â |
---|
2522 |       def OnVdWScale(event): |
---|
2523 | Â Â Â Â Â Â Â Â drawingData['vdwScale']Â =Â vdwScale.GetValue()/100. |
---|
2524 | Â Â Â Â Â Â Â Â vdwScaleTxt.SetLabel(' van der Waals scale: '+'%.2f'%(drawingData['vdwScale'])) |
---|
2525 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2526 | Â Â |
---|
2527 |       def OnEllipseProb(event): |
---|
2528 | Â Â Â Â Â Â Â Â drawingData['ellipseProb']Â =Â ellipseProb.GetValue() |
---|
2529 | Â Â Â Â Â Â Â Â ellipseProbTxt.SetLabel(' Ellipsoid probability: '+'%d%%'%(drawingData['ellipseProb'])) |
---|
2530 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2531 | Â Â |
---|
2532 |       def OnBallScale(event): |
---|
2533 | Â Â Â Â Â Â Â Â drawingData['ballScale']Â =Â ballScale.GetValue()/100. |
---|
2534 | Â Â Â Â Â Â Â Â ballScaleTxt.SetLabel(' Ball scale: '+'%.2f'%(drawingData['ballScale'])) |
---|
2535 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2536 | |
---|
2537 |       def OnBondRadius(event): |
---|
2538 | Â Â Â Â Â Â Â Â drawingData['bondRadius']Â =Â bondRadius.GetValue()/100. |
---|
2539 | Â Â Â Â Â Â Â Â bondRadiusTxt.SetLabel(' Bond radius, A: '+'%.2f'%(drawingData['bondRadius'])) |
---|
2540 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2541 | Â Â Â Â Â Â Â Â |
---|
2542 |       def OnContourLevel(event): |
---|
2543 | Â Â Â Â Â Â Â Â drawingData['contourLevel']Â =Â contourLevel.GetValue()/100. |
---|
2544 | Â Â Â Â Â Â Â Â contourLevelTxt.SetLabel(' Contour level: '+'%.2f'%(drawingData['contourLevel']*generalData['Map']['rhoMax'])) |
---|
2545 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2546 | |
---|
2547 |       def OnMapSize(event): |
---|
2548 | Â Â Â Â Â Â Â Â drawingData['mapSize']Â =Â mapSize.GetValue()/10. |
---|
2549 | Â Â Â Â Â Â Â Â mapSizeTxt.SetLabel(' Map radius, A: '+'%.1f'%(drawingData['mapSize'])) |
---|
2550 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2551 | |
---|
2552 | Â Â Â Â Â Â |
---|
2553 | Â Â Â Â Â Â slopSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
2554 | Â Â Â Â Â Â slideSizer =Â wx.FlexGridSizer(7,2) |
---|
2555 | Â Â Â Â Â Â slideSizer.AddGrowableCol(1,1) |
---|
2556 | Â Â |
---|
2557 | Â Â Â Â Â Â cameraPosTxt =Â wx.StaticText(drawOptions,-1, |
---|
2558 | Â Â Â Â Â Â Â Â ' Camera Distance: '+'%.2f'%(drawingData['cameraPos']),name='cameraPos') |
---|
2559 | Â Â Â Â Â Â G2frame.dataDisplay.cameraPosTxt =Â cameraPosTxt |
---|
2560 | Â Â Â Â Â Â slideSizer.Add(cameraPosTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2561 | Â Â Â Â Â Â cameraPos =Â wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,value=drawingData['cameraPos'],name='cameraSlider') |
---|
2562 | Â Â Â Â Â Â cameraPos.SetRange(10,500) |
---|
2563 |       cameraPos.Bind(wx.EVT_SLIDER, OnCameraPos) |
---|
2564 | Â Â Â Â Â Â G2frame.dataDisplay.cameraSlider =Â cameraPos |
---|
2565 | Â Â Â Â Â Â slideSizer.Add(cameraPos,1,wx.EXPAND|wx.RIGHT) |
---|
2566 | Â Â Â Â Â Â |
---|
2567 | Â Â Â Â Â Â ZclipTxt =Â wx.StaticText(drawOptions,-1,' Z clipping: '+'%.2fA'%(drawingData['Zclip']*drawingData['cameraPos']/100.)) |
---|
2568 | Â Â Â Â Â Â slideSizer.Add(ZclipTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2569 | Â Â Â Â Â Â Zclip =Â wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,value=drawingData['Zclip']) |
---|
2570 | Â Â Â Â Â Â Zclip.SetRange(1,99) |
---|
2571 |       Zclip.Bind(wx.EVT_SLIDER, OnZclip) |
---|
2572 | Â Â Â Â Â Â slideSizer.Add(Zclip,1,wx.EXPAND|wx.RIGHT) |
---|
2573 | Â Â Â Â Â Â |
---|
2574 | Â Â Â Â Â Â ZstepSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
2575 | Â Â Â Â Â Â ZstepSizer.Add(wx.StaticText(drawOptions,-1,' Z step:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2576 | Â Â Â Â Â Â Zstep =Â wx.TextCtrl(drawOptions,value='%.2f'%(drawingData['Zstep']), |
---|
2577 | Â Â Â Â Â Â Â Â style=wx.TE_PROCESS_ENTER) |
---|
2578 | Â Â Â Â Â Â Zstep.Bind(wx.EVT_TEXT_ENTER,OnZstep) |
---|
2579 | Â Â Â Â Â Â Zstep.Bind(wx.EVT_KILL_FOCUS,OnZstep) |
---|
2580 | Â Â Â Â Â Â ZstepSizer.Add(Zstep,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2581 | Â Â Â Â Â Â slideSizer.Add(ZstepSizer) |
---|
2582 | Â Â Â Â Â Â MoveSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
2583 | Â Â Â Â Â Â MoveSizer.Add(wx.StaticText(drawOptions,-1,'Â Â Press to step:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2584 | Â Â Â Â Â Â MoveZ =Â wx.SpinButton(drawOptions,style=wx.SP_HORIZONTAL,size=wx.Size(100,20)) |
---|
2585 | Â Â Â Â Â Â MoveZ.SetValue(0) |
---|
2586 | Â Â Â Â Â Â MoveZ.SetRange(-1,1) |
---|
2587 |       MoveZ.Bind(wx.EVT_SPIN, OnMoveZ) |
---|
2588 | Â Â Â Â Â Â MoveSizer.Add(MoveZ) |
---|
2589 | Â Â Â Â Â Â slideSizer.Add(MoveSizer,1,wx.EXPAND|wx.RIGHT) |
---|
2590 | Â Â Â Â Â Â |
---|
2591 | Â Â Â Â Â Â vdwScaleTxt =Â wx.StaticText(drawOptions,-1,' van der Waals scale: '+'%.2f'%(drawingData['vdwScale'])) |
---|
2592 | Â Â Â Â Â Â slideSizer.Add(vdwScaleTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2593 | Â Â Â Â Â Â vdwScale =Â wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,value=int(100*drawingData['vdwScale'])) |
---|
2594 |       vdwScale.Bind(wx.EVT_SLIDER, OnVdWScale) |
---|
2595 | Â Â Â Â Â Â slideSizer.Add(vdwScale,1,wx.EXPAND|wx.RIGHT) |
---|
2596 | Â Â |
---|
2597 | Â Â Â Â Â Â ellipseProbTxt =Â wx.StaticText(drawOptions,-1,' Ellipsoid probability: '+'%d%%'%(drawingData['ellipseProb'])) |
---|
2598 | Â Â Â Â Â Â slideSizer.Add(ellipseProbTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2599 | Â Â Â Â Â Â ellipseProb =Â wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,value=drawingData['ellipseProb']) |
---|
2600 | Â Â Â Â Â Â ellipseProb.SetRange(1,99) |
---|
2601 |       ellipseProb.Bind(wx.EVT_SLIDER, OnEllipseProb) |
---|
2602 | Â Â Â Â Â Â slideSizer.Add(ellipseProb,1,wx.EXPAND|wx.RIGHT) |
---|
2603 | Â Â |
---|
2604 | Â Â Â Â Â Â ballScaleTxt =Â wx.StaticText(drawOptions,-1,' Ball scale: '+'%.2f'%(drawingData['ballScale'])) |
---|
2605 | Â Â Â Â Â Â slideSizer.Add(ballScaleTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2606 | Â Â Â Â Â Â ballScale =Â wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,value=int(100*drawingData['ballScale'])) |
---|
2607 |       ballScale.Bind(wx.EVT_SLIDER, OnBallScale) |
---|
2608 | Â Â Â Â Â Â slideSizer.Add(ballScale,1,wx.EXPAND|wx.RIGHT) |
---|
2609 | Â Â |
---|
2610 | Â Â Â Â Â Â bondRadiusTxt =Â wx.StaticText(drawOptions,-1,' Bond radius, A: '+'%.2f'%(drawingData['bondRadius'])) |
---|
2611 | Â Â Â Â Â Â slideSizer.Add(bondRadiusTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2612 | Â Â Â Â Â Â bondRadius =Â wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,value=int(100*drawingData['bondRadius'])) |
---|
2613 | Â Â Â Â Â Â bondRadius.SetRange(1,25) |
---|
2614 |       bondRadius.Bind(wx.EVT_SLIDER, OnBondRadius) |
---|
2615 | Â Â Â Â Â Â slideSizer.Add(bondRadius,1,wx.EXPAND|wx.RIGHT) |
---|
2616 | Â Â Â Â Â Â |
---|
2617 |       if generalData['Map']['rhoMax']: |
---|
2618 | Â Â Â Â Â Â Â Â contourLevelTxt =Â wx.StaticText(drawOptions,-1,' Contour level: '+'%.2f'%(drawingData['contourLevel']*generalData['Map']['rhoMax'])) |
---|
2619 | Â Â Â Â Â Â Â Â slideSizer.Add(contourLevelTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2620 | Â Â Â Â Â Â Â Â contourLevel =Â wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,value=int(100*drawingData['contourLevel'])) |
---|
2621 | Â Â Â Â Â Â Â Â contourLevel.SetRange(1,100) |
---|
2622 |         contourLevel.Bind(wx.EVT_SLIDER, OnContourLevel) |
---|
2623 | Â Â Â Â Â Â Â Â slideSizer.Add(contourLevel,1,wx.EXPAND|wx.RIGHT) |
---|
2624 | Â Â Â Â Â Â Â Â mapSizeTxt =Â wx.StaticText(drawOptions,-1,' Map radius, A: '+'%.1f'%(drawingData['mapSize'])) |
---|
2625 | Â Â Â Â Â Â Â Â slideSizer.Add(mapSizeTxt,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2626 | Â Â Â Â Â Â Â Â mapSize =Â wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,value=int(10*drawingData['mapSize'])) |
---|
2627 | Â Â Â Â Â Â Â Â mapSize.SetRange(1,100) |
---|
2628 |         mapSize.Bind(wx.EVT_SLIDER, OnMapSize) |
---|
2629 | Â Â Â Â Â Â Â Â slideSizer.Add(mapSize,1,wx.EXPAND|wx.RIGHT) |
---|
2630 | Â Â Â Â Â Â |
---|
2631 | Â Â Â Â Â Â slopSizer.Add(slideSizer,1,wx.EXPAND|wx.RIGHT) |
---|
2632 | Â Â Â Â Â Â slopSizer.Add((10,5),0) |
---|
2633 | Â Â Â Â Â Â slopSizer.SetMinSize(wx.Size(350,10)) |
---|
2634 |       return slopSizer |
---|
2635 | Â Â Â Â Â Â |
---|
2636 |     def ShowSizer(): |
---|
2637 | Â Â Â Â Â Â |
---|
2638 |       def OnBackColor(event): |
---|
2639 | Â Â Â Â Â Â Â Â drawingData['backColor']Â =Â event.GetValue() |
---|
2640 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2641 | Â Â |
---|
2642 |       def OnShowABC(event): |
---|
2643 | Â Â Â Â Â Â Â Â drawingData['showABC']Â =Â showABC.GetValue() |
---|
2644 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2645 | Â Â |
---|
2646 |       def OnShowUnitCell(event): |
---|
2647 | Â Â Â Â Â Â Â Â drawingData['unitCellBox']Â =Â unitCellBox.GetValue() |
---|
2648 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2649 | Â Â |
---|
2650 |       def OnShowHyd(event): |
---|
2651 | Â Â Â Â Â Â Â Â drawingData['showHydrogen']Â =Â showHydrogen.GetValue() |
---|
2652 | Â Â Â Â Â Â Â Â FindBondsDraw() |
---|
2653 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2654 | Â Â Â Â Â Â Â Â |
---|
2655 |       def OnShowRB(event): |
---|
2656 | Â Â Â Â Â Â Â Â drawingData['showRigidBodies']Â =Â showRB.GetValue() |
---|
2657 | Â Â Â Â Â Â Â Â FindBondsDraw() |
---|
2658 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2659 | Â Â Â Â Â Â Â Â |
---|
2660 |       def OnViewPoint(event): |
---|
2661 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2662 | Â Â Â Â Â Â Â Â viewPt =Â Obj.GetValue().split() |
---|
2663 | Â Â Â Â Â Â Â Â try: |
---|
2664 |           VP = [float(viewPt[i]) for i in range(3)] |
---|
2665 |         except (ValueError,IndexError): |
---|
2666 | Â Â Â Â Â Â Â Â Â Â VP =Â drawingData['viewPoint'][0] |
---|
2667 |         Obj.SetValue('%.3f %.3f %.3f'%(VP[0],VP[1],VP[2])) |
---|
2668 | Â Â Â Â Â Â Â Â drawingData['viewPoint'][0]Â =Â VP |
---|
2669 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2670 | Â Â Â Â Â Â Â Â |
---|
2671 |       def OnViewDir(event): |
---|
2672 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2673 | Â Â Â Â Â Â Â Â viewDir =Â Obj.GetValue().split() |
---|
2674 | Â Â Â Â Â Â Â Â try: |
---|
2675 | Â Â Â Â Â Â Â Â Â Â Amat,Bmat =Â G2lat.cell2AB(generalData['Cell'][1:7]) |
---|
2676 |           VD = np.array([float(viewDir[i]) for i in range(3)]) |
---|
2677 | Â Â Â Â Â Â Â Â Â Â VC =Â np.inner(Amat,VD) |
---|
2678 | Â Â Â Â Â Â Â Â Â Â VC /=Â np.sqrt(np.sum(VC**2)) |
---|
2679 | Â Â Â Â Â Â Â Â Â Â V =Â np.array(drawingData['viewDir']) |
---|
2680 | Â Â Â Â Â Â Â Â Â Â VB =Â np.inner(Amat,V) |
---|
2681 | Â Â Â Â Â Â Â Â Â Â VB /=Â np.sqrt(np.sum(VB**2)) |
---|
2682 | Â Â Â Â Â Â Â Â Â Â VX =Â np.cross(VC,VB) |
---|
2683 | Â Â Â Â Â Â Â Â Â Â A =Â acosd(max((2.-np.sum((VB-VC)**2))/2.,-1.)) |
---|
2684 | Â Â Â Â Â Â Â Â Â Â QV =Â G2mth.AVdeg2Q(A,VX) |
---|
2685 | Â Â Â Â Â Â Â Â Â Â Q =Â drawingData['Quaternion'] |
---|
2686 | Â Â Â Â Â Â Â Â Â Â drawingData['Quaternion']Â =Â G2mth.prodQQ(Q,QV) |
---|
2687 |         except (ValueError,IndexError): |
---|
2688 | Â Â Â Â Â Â Â Â Â Â VD =Â drawingData['viewDir'] |
---|
2689 |         Obj.SetValue('%.3f %.3f %.3f'%(VD[0],VD[1],VD[2])) |
---|
2690 | Â Â Â Â Â Â Â Â drawingData['viewDir']Â =Â VD |
---|
2691 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2692 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
2693 | Â Â Â Â Â Â showSizer =Â wx.BoxSizer(wx.VERTICAL)Â Â Â Â Â Â |
---|
2694 | Â Â Â Â Â Â lineSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
2695 | Â Â Â Â Â Â lineSizer.Add(wx.StaticText(drawOptions,-1,' Background color:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2696 |       backColor = wcs.ColourSelect(drawOptions, -1,colour=drawingData['backColor'],size=wx.Size(25,25)) |
---|
2697 |       backColor.Bind(wcs.EVT_COLOURSELECT, OnBackColor) |
---|
2698 | Â Â Â Â Â Â lineSizer.Add(backColor,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2699 | Â Â Â Â Â Â lineSizer.Add(wx.StaticText(drawOptions,-1,' View Dir.:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2700 | Â Â Â Â Â Â VD =Â drawingData['viewDir'] |
---|
2701 |       viewDir = wx.TextCtrl(drawOptions,value='%.3f %.3f %.3f'%(VD[0],VD[1],VD[2]), |
---|
2702 | Â Â Â Â Â Â Â Â style=wx.TE_PROCESS_ENTER,size=wx.Size(140,20),name='viewDir') |
---|
2703 | Â Â Â Â Â Â viewDir.Bind(wx.EVT_TEXT_ENTER,OnViewDir) |
---|
2704 | Â Â Â Â Â Â viewDir.Bind(wx.EVT_KILL_FOCUS,OnViewDir) |
---|
2705 | Â Â Â Â Â Â G2frame.dataDisplay.viewDir =Â viewDir |
---|
2706 | Â Â Â Â Â Â lineSizer.Add(viewDir,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2707 | Â Â Â Â Â Â showSizer.Add(lineSizer) |
---|
2708 | Â Â Â Â Â Â showSizer.Add((0,5),0) |
---|
2709 | Â Â Â Â Â Â |
---|
2710 | Â Â Â Â Â Â lineSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
2711 | Â Â Â Â Â Â showABC =Â wx.CheckBox(drawOptions,-1,label=' Show view point?') |
---|
2712 |       showABC.Bind(wx.EVT_CHECKBOX, OnShowABC) |
---|
2713 | Â Â Â Â Â Â showABC.SetValue(drawingData['showABC']) |
---|
2714 | Â Â Â Â Â Â lineSizer.Add(showABC,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2715 | Â Â Â Â Â Â lineSizer.Add(wx.StaticText(drawOptions,-1,' View Point:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2716 | Â Â Â Â Â Â VP =Â drawingData['viewPoint'][0] |
---|
2717 |       viewPoint = wx.TextCtrl(drawOptions,value='%.3f %.3f %.3f'%(VP[0],VP[1],VP[2]), |
---|
2718 | Â Â Â Â Â Â Â Â style=wx.TE_PROCESS_ENTER,size=wx.Size(140,20),name='viewPoint') |
---|
2719 | Â Â Â Â Â Â G2frame.dataDisplay.viewPoint =Â viewPoint |
---|
2720 | Â Â Â Â Â Â viewPoint.Bind(wx.EVT_TEXT_ENTER,OnViewPoint) |
---|
2721 | Â Â Â Â Â Â viewPoint.Bind(wx.EVT_KILL_FOCUS,OnViewPoint) |
---|
2722 | Â Â Â Â Â Â lineSizer.Add(viewPoint,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2723 | Â Â Â Â Â Â showSizer.Add(lineSizer) |
---|
2724 | Â Â Â Â Â Â showSizer.Add((0,5),0) |
---|
2725 | Â Â Â Â Â Â |
---|
2726 | Â Â Â Â Â Â line2Sizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
2727 | Â Â |
---|
2728 | Â Â Â Â Â Â unitCellBox =Â wx.CheckBox(drawOptions,-1,label=' Show unit cell?') |
---|
2729 |       unitCellBox.Bind(wx.EVT_CHECKBOX, OnShowUnitCell) |
---|
2730 | Â Â Â Â Â Â unitCellBox.SetValue(drawingData['unitCellBox']) |
---|
2731 | Â Â Â Â Â Â line2Sizer.Add(unitCellBox,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2732 | Â Â |
---|
2733 | Â Â Â Â Â Â showHydrogen =Â wx.CheckBox(drawOptions,-1,label=' Show hydrogens?') |
---|
2734 |       showHydrogen.Bind(wx.EVT_CHECKBOX, OnShowHyd) |
---|
2735 | Â Â Â Â Â Â showHydrogen.SetValue(drawingData['showHydrogen']) |
---|
2736 | Â Â Â Â Â Â line2Sizer.Add(showHydrogen,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2737 | Â Â Â Â Â Â |
---|
2738 | Â Â Â Â Â Â showRB =Â wx.CheckBox(drawOptions,-1,label=' Show rigid Bodies?') |
---|
2739 |       showRB.Bind(wx.EVT_CHECKBOX, OnShowRB) |
---|
2740 | Â Â Â Â Â Â showRB.SetValue(drawingData['showRigidBodies']) |
---|
2741 | Â Â Â Â Â Â line2Sizer.Add(showRB,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2742 | Â Â Â Â Â Â |
---|
2743 | Â Â Â Â Â Â showSizer.Add(line2Sizer) |
---|
2744 |       return showSizer |
---|
2745 | Â Â Â Â Â Â |
---|
2746 |     def RadSizer(): |
---|
2747 | Â Â Â Â Â Â |
---|
2748 |       def OnSizeHatoms(event): |
---|
2749 | Â Â Â Â Â Â Â Â try: |
---|
2750 | Â Â Â Â Â Â Â Â Â Â value =Â max(0.1,min(1.2,float(sizeH.GetValue()))) |
---|
2751 |         except ValueError: |
---|
2752 | Â Â Â Â Â Â Â Â Â Â value =Â 0.5 |
---|
2753 | Â Â Â Â Â Â Â Â drawingData['sizeH']Â =Â value |
---|
2754 | Â Â Â Â Â Â Â Â sizeH.SetValue("%.2f"%(value)) |
---|
2755 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2756 | Â Â Â Â Â Â Â Â |
---|
2757 |       def OnRadFactor(event): |
---|
2758 | Â Â Â Â Â Â Â Â try: |
---|
2759 | Â Â Â Â Â Â Â Â Â Â value =Â max(0.1,min(1.2,float(radFactor.GetValue()))) |
---|
2760 |         except ValueError: |
---|
2761 | Â Â Â Â Â Â Â Â Â Â value =Â 0.85 |
---|
2762 | Â Â Â Â Â Â Â Â drawingData['radiusFactor']Â =Â value |
---|
2763 | Â Â Â Â Â Â Â Â radFactor.SetValue("%.2f"%(value)) |
---|
2764 | Â Â Â Â Â Â Â Â FindBondsDraw() |
---|
2765 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
2766 | Â Â Â Â Â Â |
---|
2767 | Â Â Â Â Â Â radSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
2768 | Â Â Â Â Â Â radSizer.Add(wx.StaticText(drawOptions,-1,' Hydrogen radius, A:Â '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2769 | Â Â Â Â Â Â sizeH =Â wx.TextCtrl(drawOptions,-1,value='%.2f'%(drawingData['sizeH']),size=wx.Size(60,20),style=wx.TE_PROCESS_ENTER) |
---|
2770 | Â Â Â Â Â Â sizeH.Bind(wx.EVT_TEXT_ENTER,OnSizeHatoms) |
---|
2771 | Â Â Â Â Â Â sizeH.Bind(wx.EVT_KILL_FOCUS,OnSizeHatoms) |
---|
2772 | Â Â Â Â Â Â radSizer.Add(sizeH,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2773 | Â Â |
---|
2774 | Â Â Â Â Â Â radSizer.Add(wx.StaticText(drawOptions,-1,' Bond search factor:Â '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2775 | Â Â Â Â Â Â radFactor =Â wx.TextCtrl(drawOptions,value='%.2f'%(drawingData['radiusFactor']),size=wx.Size(60,20),style=wx.TE_PROCESS_ENTER) |
---|
2776 | Â Â Â Â Â Â radFactor.Bind(wx.EVT_TEXT_ENTER,OnRadFactor) |
---|
2777 | Â Â Â Â Â Â radFactor.Bind(wx.EVT_KILL_FOCUS,OnRadFactor) |
---|
2778 | Â Â Â Â Â Â radSizer.Add(radFactor,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2779 |       return radSizer |
---|
2780 | |
---|
2781 | Â Â Â Â # UpdateDrawOptions exectable code starts here |
---|
2782 | Â Â Â Â generalData =Â data['General'] |
---|
2783 | Â Â Â Â Amat,Bmat =Â G2lat.cell2AB(generalData['Cell'][1:7]) |
---|
2784 | Â Â Â Â SetupDrawingData() |
---|
2785 | Â Â Â Â drawingData =Â data['Drawing'] |
---|
2786 |     if generalData['Type'] == 'nuclear': |
---|
2787 | Â Â Â Â Â Â pickChoice =Â ['Atoms','Bonds','Torsions','Planes'] |
---|
2788 |     elif generalData['Type'] == 'macromolecular': |
---|
2789 | Â Â Â Â Â Â pickChoice =Â ['Atoms','Residues','Chains','Bonds','Torsions','Planes','phi/psi'] |
---|
2790 | |
---|
2791 | Â Â Â Â G2frame.dataFrame.SetStatusText('') |
---|
2792 |     if drawOptions.GetSizer(): |
---|
2793 | Â Â Â Â Â Â drawOptions.GetSizer().Clear(True) |
---|
2794 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
2795 | Â Â Â Â mainSizer.Add((5,5),0) |
---|
2796 | Â Â Â Â mainSizer.Add(wx.StaticText(drawOptions,-1,' Drawing controls:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2797 | Â Â Â Â mainSizer.Add((5,5),0)Â Â Â Â |
---|
2798 | Â Â Â Â mainSizer.Add(SlopSizer(),0) |
---|
2799 | Â Â Â Â mainSizer.Add((5,5),0) |
---|
2800 | Â Â Â Â mainSizer.Add(ShowSizer(),0,) |
---|
2801 | Â Â Â Â mainSizer.Add((5,5),0) |
---|
2802 | Â Â Â Â mainSizer.Add(RadSizer(),0,) |
---|
2803 | Â Â Â Â SetPhaseWindow(G2frame.dataFrame,drawOptions,mainSizer) |
---|
2804 | |
---|
2805 | ################################################################################ |
---|
2806 | ####Â Texture routines |
---|
2807 | ################################################################################ |
---|
2808 | Â Â Â Â |
---|
2809 |   def UpdateTexture():    |
---|
2810 |     def SetSHCoef(): |
---|
2811 | Â Â Â Â Â Â cofNames =Â G2lat.GenSHCoeff(SGData['SGLaue'],SamSym[textureData['Model']],textureData['Order']) |
---|
2812 | Â Â Â Â Â Â newSHCoef =Â dict(zip(cofNames,np.zeros(len(cofNames)))) |
---|
2813 | Â Â Â Â Â Â SHCoeff =Â textureData['SH Coeff'][1] |
---|
2814 |       for cofName in SHCoeff: |
---|
2815 |         if cofName in cofNames: |
---|
2816 | Â Â Â Â Â Â Â Â Â Â newSHCoef[cofName]Â =Â SHCoeff[cofName] |
---|
2817 |       return newSHCoef |
---|
2818 | Â Â Â Â |
---|
2819 |     def OnShOrder(event): |
---|
2820 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2821 | Â Â Â Â Â Â textureData['Order']Â =Â int(Obj.GetValue()) |
---|
2822 | Â Â Â Â Â Â textureData['SH Coeff'][1]Â =Â SetSHCoef() |
---|
2823 | Â Â Â Â Â Â wx.CallAfter(UpdateTexture) |
---|
2824 | Â Â Â Â Â Â G2plt.PlotTexture(G2frame,data) |
---|
2825 | Â Â Â Â Â Â Â Â Â Â Â Â |
---|
2826 |     def OnShModel(event): |
---|
2827 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2828 | Â Â Â Â Â Â textureData['Model']Â =Â Obj.GetValue() |
---|
2829 | Â Â Â Â Â Â textureData['SH Coeff'][1]Â =Â SetSHCoef() |
---|
2830 | Â Â Â Â Â Â wx.CallAfter(UpdateTexture) |
---|
2831 | Â Â Â Â Â Â G2plt.PlotTexture(G2frame,data) |
---|
2832 | Â Â Â Â Â Â |
---|
2833 |     def OnSHRefine(event): |
---|
2834 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2835 | Â Â Â Â Â Â textureData['SH Coeff'][0]Â =Â Obj.GetValue() |
---|
2836 | Â Â Â Â Â Â |
---|
2837 |     def OnSHShow(event): |
---|
2838 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2839 | Â Â Â Â Â Â textureData['SHShow']Â =Â Obj.GetValue() |
---|
2840 | Â Â Â Â Â Â wx.CallAfter(UpdateTexture) |
---|
2841 | Â Â Â Â Â Â |
---|
2842 |     def OnProjSel(event): |
---|
2843 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2844 | Â Â Â Â Â Â G2frame.Projection =Â Obj.GetValue() |
---|
2845 | Â Â Â Â Â Â G2plt.PlotTexture(G2frame,data) |
---|
2846 | Â Â Â Â Â Â |
---|
2847 |     def OnColorSel(event): |
---|
2848 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2849 | Â Â Â Â Â Â G2frame.ContourColor =Â Obj.GetValue() |
---|
2850 | Â Â Â Â Â Â G2plt.PlotTexture(G2frame,data) |
---|
2851 | Â Â Â Â Â Â |
---|
2852 |     def OnAngRef(event): |
---|
2853 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2854 | Â Â Â Â Â Â textureData[angIndx[Obj.GetId()]][0]Â =Â Obj.GetValue() |
---|
2855 | Â Â Â Â Â Â |
---|
2856 |     def OnAngValue(event): |
---|
2857 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2858 | Â Â Â Â Â Â try: |
---|
2859 | Â Â Â Â Â Â Â Â value =Â float(Obj.GetValue()) |
---|
2860 |       except ValueError: |
---|
2861 | Â Â Â Â Â Â Â Â value =Â textureData[valIndx[Obj.GetId()]][1] |
---|
2862 | Â Â Â Â Â Â Obj.SetValue('%8.2f'%(value)) |
---|
2863 | Â Â Â Â Â Â textureData[valIndx[Obj.GetId()]][1]Â =Â value |
---|
2864 | Â Â Â Â Â Â |
---|
2865 |     def OnODFValue(event): |
---|
2866 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2867 | Â Â Â Â Â Â try: |
---|
2868 | Â Â Â Â Â Â Â Â value =Â float(Obj.GetValue()) |
---|
2869 |       except ValueError: |
---|
2870 | Â Â Â Â Â Â Â Â value =Â textureData['SH Coeff'][1][ODFIndx[Obj.GetId()]] |
---|
2871 | Â Â Â Â Â Â Obj.SetValue('%8.3f'%(value)) |
---|
2872 | Â Â Â Â Â Â textureData['SH Coeff'][1][ODFIndx[Obj.GetId()]]Â =Â value |
---|
2873 | Â Â Â Â Â Â G2plt.PlotTexture(G2frame,data) |
---|
2874 | Â Â Â Â Â Â |
---|
2875 |     def OnPfType(event): |
---|
2876 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2877 | Â Â Â Â Â Â textureData['PlotType']Â =Â Obj.GetValue() |
---|
2878 | Â Â Â Â Â Â wx.CallAfter(UpdateTexture) |
---|
2879 | Â Â Â Â Â Â G2plt.PlotTexture(G2frame,data) |
---|
2880 | Â Â Â Â Â Â |
---|
2881 |     def OnPFValue(event): |
---|
2882 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2883 | Â Â Â Â Â Â Saxis =Â Obj.GetValue().split() |
---|
2884 |       if textureData['PlotType'] in ['Pole figure','Axial pole distribution']:        |
---|
2885 | Â Â Â Â Â Â Â Â try: |
---|
2886 |           hkl = [int(Saxis[i]) for i in range(3)] |
---|
2887 |         except (ValueError,IndexError): |
---|
2888 | Â Â Â Â Â Â Â Â Â Â hkl =Â textureData['PFhkl'] |
---|
2889 |         if not np.any(np.array(hkl)):    #can't be all zeros! |
---|
2890 | Â Â Â Â Â Â Â Â Â Â hkl =Â textureData['PFhkl'] |
---|
2891 |         Obj.SetValue('%d %d %d'%(hkl[0],hkl[1],hkl[2])) |
---|
2892 | Â Â Â Â Â Â Â Â textureData['PFhkl']Â =Â hkl |
---|
2893 | Â Â Â Â Â Â else: |
---|
2894 | Â Â Â Â Â Â Â Â try: |
---|
2895 |           xyz = [float(Saxis[i]) for i in range(3)] |
---|
2896 |         except (ValueError,IndexError): |
---|
2897 | Â Â Â Â Â Â Â Â Â Â xyz =Â textureData['PFxyz'] |
---|
2898 |         if not np.any(np.array(xyz)):    #can't be all zeros! |
---|
2899 | Â Â Â Â Â Â Â Â Â Â xyz =Â textureData['PFxyz'] |
---|
2900 |         Obj.SetValue('%3.1f %3.1f %3.1f'%(xyz[0],xyz[1],xyz[2])) |
---|
2901 | Â Â Â Â Â Â Â Â textureData['PFxyz']Â =Â xyz |
---|
2902 | Â Â Â Â Â Â G2plt.PlotTexture(G2frame,data) |
---|
2903 | |
---|
2904 | Â Â Â Â # UpdateTexture executable starts here |
---|
2905 | Â Â Â Â G2frame.dataFrame.SetStatusText('') |
---|
2906 | Â Â Â Â generalData =Â data['General']Â Â Â Â |
---|
2907 | Â Â Â Â SGData =Â generalData['SGData'] |
---|
2908 | Â Â Â Â try: |
---|
2909 | Â Â Â Â Â Â textureData =Â generalData['SH Texture'] |
---|
2910 |     except KeyError:      #fix old files! |
---|
2911 | Â Â Â Â Â Â textureData =Â generalData['SH Texture']Â =Â {'Order':0,'Model':'cylindrical', |
---|
2912 | Â Â Â Â Â Â Â Â 'Sample omega':[False,0.0],'Sample chi':[False,0.0],'Sample phi':[False,0.0], |
---|
2913 | Â Â Â Â Â Â Â Â 'SH Coeff':[False,{}],'SHShow':False,'PFhkl':[0,0,1], |
---|
2914 | Â Â Â Â Â Â Â Â 'PFxyz':[0,0,1.],'PlotType':'Pole figure'} |
---|
2915 |     if 'SHShow' not in textureData:   #another fix |
---|
2916 | Â Â Â Â Â Â textureData.update({'SHShow':False,'PFhkl':[0,0,1],'PFxyz':[0,0,1.],'PlotType':'Pole figure'}) |
---|
2917 | Â Â Â Â try:Â Â Â Â Â Â Â Â Â Â Â Â #another fix! |
---|
2918 | Â Â Â Â Â Â x =Â textureData['PlotType'] |
---|
2919 |     except KeyError: |
---|
2920 | Â Â Â Â Â Â textureData.update({'PFxyz':[0,0,1.],'PlotType':'Pole figure'}) |
---|
2921 | Â Â Â Â shModels =Â ['cylindrical','none','shear - 2/m','rolling - mmm'] |
---|
2922 | Â Â Â Â SamSym =Â dict(zip(shModels,['0','-1','2/m','mmm'])) |
---|
2923 |     if generalData['doPawley'] and G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequental results'): |
---|
2924 | Â Â Â Â Â Â G2frame.dataFrame.RefineTexture.Enable(True) |
---|
2925 | Â Â Â Â shAngles =Â ['omega','chi','phi'] |
---|
2926 |     if Texture.GetSizer(): |
---|
2927 | Â Â Â Â Â Â Texture.GetSizer().Clear(True) |
---|
2928 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
2929 | Â Â Â Â titleSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
2930 | Â Â Â Â titleSizer.Add(wx.StaticText(Texture,-1,'Spherical harmonics texture data for '+PhaseName+':'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2931 | Â Â Â Â titleSizer.Add(wx.StaticText(Texture,-1, |
---|
2932 | Â Â Â Â Â Â ' Texture Index J = %7.3f'%(G2lat.textureIndex(textureData['SH Coeff'][1]))), |
---|
2933 | Â Â Â Â Â Â 0,wx.ALIGN_CENTER_VERTICAL) |
---|
2934 | Â Â Â Â mainSizer.Add(titleSizer,0) |
---|
2935 | Â Â Â Â mainSizer.Add((0,5),0) |
---|
2936 | Â Â Â Â shSizer =Â wx.FlexGridSizer(1,6,5,5) |
---|
2937 | Â Â Â Â shSizer.Add(wx.StaticText(Texture,-1,'Texture model: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2938 | Â Â Â Â shModel =Â wx.ComboBox(Texture,-1,value=textureData['Model'],choices=shModels, |
---|
2939 | Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
2940 | Â Â Â Â shModel.Bind(wx.EVT_COMBOBOX,OnShModel) |
---|
2941 | Â Â Â Â shSizer.Add(shModel,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2942 | Â Â Â Â shSizer.Add(wx.StaticText(Texture,-1,'Â Harmonic order: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2943 |     shOrder = wx.ComboBox(Texture,-1,value=str(textureData['Order']),choices=[str(2*i) for i in range(18)], |
---|
2944 | Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
2945 | Â Â Â Â shOrder.Bind(wx.EVT_COMBOBOX,OnShOrder) |
---|
2946 | Â Â Â Â shSizer.Add(shOrder,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2947 | Â Â Â Â shRef =Â wx.CheckBox(Texture,-1,label=' Refine texture?') |
---|
2948 | Â Â Â Â shRef.SetValue(textureData['SH Coeff'][0]) |
---|
2949 |     shRef.Bind(wx.EVT_CHECKBOX, OnSHRefine) |
---|
2950 | Â Â Â Â shSizer.Add(shRef,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2951 | Â Â Â Â shShow =Â wx.CheckBox(Texture,-1,label=' Show coeff.?') |
---|
2952 | Â Â Â Â shShow.SetValue(textureData['SHShow']) |
---|
2953 |     shShow.Bind(wx.EVT_CHECKBOX, OnSHShow) |
---|
2954 | Â Â Â Â shSizer.Add(shShow,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2955 | Â Â Â Â mainSizer.Add(shSizer,0,0) |
---|
2956 | Â Â Â Â mainSizer.Add((0,5),0) |
---|
2957 | Â Â Â Â PTSizer =Â wx.FlexGridSizer(2,4,5,5) |
---|
2958 | Â Â Â Â PTSizer.Add(wx.StaticText(Texture,-1,' Texture plot type: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2959 | Â Â Â Â choices =Â ['Axial pole distribution','Pole figure','Inverse pole figure']Â Â Â Â Â Â |
---|
2960 | Â Â Â Â pfType =Â wx.ComboBox(Texture,-1,value=str(textureData['PlotType']),choices=choices, |
---|
2961 | Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
2962 | Â Â Â Â pfType.Bind(wx.EVT_COMBOBOX,OnPfType) |
---|
2963 | Â Â Â Â PTSizer.Add(pfType,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2964 |     if 'Axial' not in textureData['PlotType']: |
---|
2965 | Â Â Â Â Â Â PTSizer.Add(wx.StaticText(Texture,-1,' Projection type: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2966 | Â Â Â Â Â Â projSel =Â wx.ComboBox(Texture,-1,value=G2frame.Projection,choices=['equal area','stereographic','3D display'], |
---|
2967 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
2968 | Â Â Â Â Â Â projSel.Bind(wx.EVT_COMBOBOX,OnProjSel) |
---|
2969 | Â Â Â Â Â Â PTSizer.Add(projSel,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2970 |     if textureData['PlotType'] in ['Pole figure','Axial pole distribution']: |
---|
2971 | Â Â Â Â Â Â PTSizer.Add(wx.StaticText(Texture,-1,' Pole figure HKL: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2972 | Â Â Â Â Â Â PH =Â textureData['PFhkl'] |
---|
2973 |       pfVal = wx.TextCtrl(Texture,-1,'%d %d %d'%(PH[0],PH[1],PH[2]),style=wx.TE_PROCESS_ENTER) |
---|
2974 | Â Â Â Â else: |
---|
2975 | Â Â Â Â Â Â PTSizer.Add(wx.StaticText(Texture,-1,' Inverse pole figure XYZ: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2976 | Â Â Â Â Â Â PX =Â textureData['PFxyz'] |
---|
2977 |       pfVal = wx.TextCtrl(Texture,-1,'%3.1f %3.1f %3.1f'%(PX[0],PX[1],PX[2]),style=wx.TE_PROCESS_ENTER) |
---|
2978 | Â Â Â Â pfVal.Bind(wx.EVT_TEXT_ENTER,OnPFValue) |
---|
2979 | Â Â Â Â pfVal.Bind(wx.EVT_KILL_FOCUS,OnPFValue) |
---|
2980 | Â Â Â Â PTSizer.Add(pfVal,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2981 |     if 'Axial' not in textureData['PlotType']: |
---|
2982 | Â Â Â Â Â Â PTSizer.Add(wx.StaticText(Texture,-1,' Color scheme'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2983 |       choice = [m for m in mpl.cm.datad.keys() if not m.endswith("_r")] |
---|
2984 | Â Â Â Â Â Â choice.sort() |
---|
2985 | Â Â Â Â Â Â colorSel =Â wx.ComboBox(Texture,-1,value=G2frame.ContourColor,choices=choice, |
---|
2986 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
2987 | Â Â Â Â Â Â colorSel.Bind(wx.EVT_COMBOBOX,OnColorSel) |
---|
2988 | Â Â Â Â Â Â PTSizer.Add(colorSel,0,wx.ALIGN_CENTER_VERTICAL)Â Â Â Â |
---|
2989 | Â Â Â Â mainSizer.Add(PTSizer,0,wx.ALIGN_CENTER_VERTICAL) |
---|
2990 | Â Â Â Â mainSizer.Add((0,5),0) |
---|
2991 |     if textureData['SHShow']: |
---|
2992 | Â Â Â Â Â Â mainSizer.Add(wx.StaticText(Texture,-1,'Spherical harmonic coefficients: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
2993 | Â Â Â Â Â Â mainSizer.Add((0,5),0) |
---|
2994 | Â Â Â Â Â Â ODFSizer =Â wx.FlexGridSizer(2,8,2,2) |
---|
2995 | Â Â Â Â Â Â ODFIndx =Â {} |
---|
2996 | Â Â Â Â Â Â ODFkeys =Â textureData['SH Coeff'][1].keys() |
---|
2997 | Â Â Â Â Â Â ODFkeys.sort() |
---|
2998 |       for item in ODFkeys: |
---|
2999 | Â Â Â Â Â Â Â Â ODFSizer.Add(wx.StaticText(Texture,-1,item),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3000 | Â Â Â Â Â Â Â Â ODFval =Â wx.TextCtrl(Texture,wx.ID_ANY,'%8.3f'%(textureData['SH Coeff'][1][item]),style=wx.TE_PROCESS_ENTER) |
---|
3001 | Â Â Â Â Â Â Â Â ODFIndx[ODFval.GetId()]Â =Â item |
---|
3002 | Â Â Â Â Â Â Â Â ODFval.Bind(wx.EVT_TEXT_ENTER,OnODFValue) |
---|
3003 | Â Â Â Â Â Â Â Â ODFval.Bind(wx.EVT_KILL_FOCUS,OnODFValue) |
---|
3004 | Â Â Â Â Â Â Â Â ODFSizer.Add(ODFval,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3005 | Â Â Â Â Â Â mainSizer.Add(ODFSizer,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3006 | Â Â Â Â Â Â mainSizer.Add((0,5),0) |
---|
3007 | Â Â Â Â mainSizer.Add((0,5),0) |
---|
3008 | Â Â Â Â mainSizer.Add(wx.StaticText(Texture,-1,'Sample orientation angles: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3009 | Â Â Â Â mainSizer.Add((0,5),0) |
---|
3010 | Â Â Â Â angSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
3011 | Â Â Â Â angIndx =Â {} |
---|
3012 | Â Â Â Â valIndx =Â {} |
---|
3013 |     for item in ['Sample omega','Sample chi','Sample phi']: |
---|
3014 | Â Â Â Â Â Â angRef =Â wx.CheckBox(Texture,-1,label=item+': ') |
---|
3015 | Â Â Â Â Â Â angRef.SetValue(textureData[item][0]) |
---|
3016 | Â Â Â Â Â Â angIndx[angRef.GetId()]Â =Â item |
---|
3017 |       angRef.Bind(wx.EVT_CHECKBOX, OnAngRef) |
---|
3018 | Â Â Â Â Â Â angSizer.Add(angRef,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3019 | Â Â Â Â Â Â angVal =Â wx.TextCtrl(Texture,wx.ID_ANY,'%8.2f'%(textureData[item][1]),style=wx.TE_PROCESS_ENTER) |
---|
3020 | Â Â Â Â Â Â valIndx[angVal.GetId()]Â =Â item |
---|
3021 | Â Â Â Â Â Â angVal.Bind(wx.EVT_TEXT_ENTER,OnAngValue) |
---|
3022 | Â Â Â Â Â Â angVal.Bind(wx.EVT_KILL_FOCUS,OnAngValue) |
---|
3023 | Â Â Â Â Â Â angSizer.Add(angVal,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3024 | Â Â Â Â Â Â angSizer.Add((5,0),0) |
---|
3025 | Â Â Â Â mainSizer.Add(angSizer,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3026 | Â Â Â Â SetPhaseWindow(G2frame.dataFrame,Texture,mainSizer) |
---|
3027 | |
---|
3028 | ################################################################################ |
---|
3029 | ##### DData routines - GUI stuff in GSASIIddataGUI.py |
---|
3030 | ################################################################################ |
---|
3031 | Â Â Â Â |
---|
3032 |   def OnHklfAdd(event): |
---|
3033 | Â Â Â Â UseList =Â data['Histograms'] |
---|
3034 | Â Â Â Â keyList =Â UseList.keys() |
---|
3035 | Â Â Â Â TextList =Â [] |
---|
3036 |     if G2frame.PatternTree.GetCount(): |
---|
3037 |       item, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root) |
---|
3038 |       while item: |
---|
3039 | Â Â Â Â Â Â Â Â name =Â G2frame.PatternTree.GetItemText(item) |
---|
3040 |         if name not in keyList and 'HKLF' in name: |
---|
3041 | Â Â Â Â Â Â Â Â Â Â TextList.append(name) |
---|
3042 |         item, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie)            |
---|
3043 |       dlg = wx.MultiChoiceDialog(G2frame, 'Which new data to use?', 'Use data', TextList, wx.CHOICEDLG_STYLE) |
---|
3044 | Â Â Â Â Â Â try: |
---|
3045 |         if dlg.ShowModal() == wx.ID_OK: |
---|
3046 | Â Â Â Â Â Â Â Â Â Â result =Â dlg.GetSelections() |
---|
3047 |           for i in result: |
---|
3048 | Â Â Â Â Â Â Â Â Â Â Â Â histoName =Â TextList[i] |
---|
3049 | Â Â Â Â Â Â Â Â Â Â Â Â UseList[histoName]Â =Â {'Histogram':histoName,'Show':False,'Scale':[1.0,True], |
---|
3050 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]}, |
---|
3051 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Extinction':['Lorentzian','None', |
---|
3052 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â {'Tbar':0.1,'Cos2TM':0.955,'Eg':[1.e-10,False],'Es':[1.e-10,False],'Ep':[1.e-10,False]},]}Â Â Â Â Â Â Â Â Â Â Â Â |
---|
3053 | Â Â Â Â Â Â Â Â Â Â Â Â wx.BeginBusyCursor() |
---|
3054 | Â Â Â Â Â Â Â Â Â Â Â Â UpdateHKLFdata(histoName) |
---|
3055 | Â Â Â Â Â Â Â Â Â Â Â Â wx.EndBusyCursor() |
---|
3056 | Â Â Â Â Â Â Â Â Â Â data['Histograms']Â =Â UseList |
---|
3057 | Â Â Â Â Â Â Â Â Â Â wx.CallAfter(G2ddG.UpdateDData,G2frame,DData,data) |
---|
3058 | Â Â Â Â Â Â finally: |
---|
3059 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
3060 | Â Â Â Â Â Â Â Â |
---|
3061 |   def UpdateHKLFdata(histoName): |
---|
3062 | Â Â Â Â generalData =Â data['General'] |
---|
3063 | Â Â Â Â Id =Â G2gd.GetPatternTreeItemId(G2frame,G2frame.root,histoName) |
---|
3064 | Â Â Â Â reflData =Â G2frame.PatternTree.GetItemPyData(Id)[1] |
---|
3065 | Â Â Â Â SGData =Â generalData['SGData'] |
---|
3066 | Â Â Â Â Cell =Â generalData['Cell'][1:7] |
---|
3067 | Â Â Â Â G,g =Â G2lat.cell2Gmat(Cell) |
---|
3068 |     for ref in reflData: |
---|
3069 | Â Â Â Â Â Â H =Â ref[:3] |
---|
3070 | Â Â Â Â Â Â ref[4]Â =Â np.sqrt(1./G2lat.calc_rDsq2(H,G)) |
---|
3071 | Â Â Â Â Â Â iabsnt,ref[3],ref[11],ref[12]Â =Â G2spc.GenHKLf(H,SGData) |
---|
3072 | Â Â Â Â G2frame.PatternTree.SetItemPyData(Id,[histoName,reflData]) |
---|
3073 | Â Â Â Â |
---|
3074 |   def OnPwdrAdd(event): |
---|
3075 | Â Â Â Â generalData =Â data['General'] |
---|
3076 | Â Â Â Â SGData =Â generalData['SGData'] |
---|
3077 | Â Â Â Â UseList =Â data['Histograms'] |
---|
3078 | Â Â Â Â newList =Â [] |
---|
3079 | Â Â Â Â NShkl =Â len(G2spc.MustrainNames(SGData)) |
---|
3080 | Â Â Â Â NDij =Â len(G2spc.HStrainNames(SGData)) |
---|
3081 | Â Â Â Â keyList =Â UseList.keys() |
---|
3082 | Â Â Â Â TextList =Â ['All PWDR'] |
---|
3083 |     if G2frame.PatternTree.GetCount(): |
---|
3084 |       item, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root) |
---|
3085 |       while item: |
---|
3086 | Â Â Â Â Â Â Â Â name =Â G2frame.PatternTree.GetItemText(item) |
---|
3087 |         if name not in keyList and 'PWDR' in name: |
---|
3088 | Â Â Â Â Â Â Â Â Â Â TextList.append(name) |
---|
3089 |         item, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie) |
---|
3090 |       dlg = wx.MultiChoiceDialog(G2frame, 'Which new data to use?', 'Use data', TextList, wx.CHOICEDLG_STYLE) |
---|
3091 | Â Â Â Â Â Â try: |
---|
3092 |         if dlg.ShowModal() == wx.ID_OK: |
---|
3093 | Â Â Â Â Â Â Â Â Â Â result =Â dlg.GetSelections() |
---|
3094 |           for i in result: newList.append(TextList[i]) |
---|
3095 |           if 'All PWDR' in newList: |
---|
3096 | Â Â Â Â Â Â Â Â Â Â Â Â newList =Â TextList[1:] |
---|
3097 |           for histoName in newList: |
---|
3098 | Â Â Â Â Â Â Â Â Â Â Â Â pId =Â G2gd.GetPatternTreeItemId(G2frame,G2frame.root,histoName) |
---|
3099 | Â Â Â Â Â Â Â Â Â Â Â Â UseList[histoName]Â =Â {'Histogram':histoName,'Show':False, |
---|
3100 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Scale':[1.0,False],'Pref.Ori.':['MD',1.0,False,[0,0,1],0,{}], |
---|
3101 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Size':['isotropic',[1.,1.,1.],[False,False,False],[0,0,1], |
---|
3102 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â [1.,1.,1.,0.,0.,0.],6*[False,]], |
---|
3103 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Mustrain':['isotropic',[1000.0,1000.0,1.0],[False,False,False],[0,0,1], |
---|
3104 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NShkl*[0.01,],NShkl*[False,]], |
---|
3105 |               'HStrain':[NDij*[0.0,],NDij*[False,]],             |
---|
3106 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Extinction':[0.0,False],'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]}} |
---|
3107 | Â Â Â Â Â Â Â Â Â Â Â Â refList =Â G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,pId,'Reflection Lists')) |
---|
3108 | Â Â Â Â Â Â Â Â Â Â Â Â refList[generalData['Name']]Â =Â []Â Â Â Â Â Â Â Â Â Â Â Â |
---|
3109 | Â Â Â Â Â Â Â Â Â Â data['Histograms']Â =Â UseList |
---|
3110 | Â Â Â Â Â Â Â Â Â Â wx.CallAfter(G2ddG.UpdateDData,G2frame,DData,data) |
---|
3111 | Â Â Â Â Â Â finally: |
---|
3112 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
3113 | Â Â Â Â |
---|
3114 |   def OnDataDelete(event): |
---|
3115 | Â Â Â Â UseList =Â data['Histograms'] |
---|
3116 | Â Â Â Â keyList =Â ['All',]+UseList.keys() |
---|
3117 | Â Â Â Â keyList.sort() |
---|
3118 | Â Â Â Â DelList =Â [] |
---|
3119 |     if UseList: |
---|
3120 | Â Â Â Â Â Â DelList =Â [] |
---|
3121 |       dlg = wx.MultiChoiceDialog(G2frame, |
---|
3122 |         'Which histogram to delete from this phase?', 'Delete histogram', |
---|
3123 |         keyList, wx.CHOICEDLG_STYLE) |
---|
3124 | Â Â Â Â Â Â try: |
---|
3125 |         if dlg.ShowModal() == wx.ID_OK: |
---|
3126 | Â Â Â Â Â Â Â Â Â Â result =Â dlg.GetSelections() |
---|
3127 |           for i in result: |
---|
3128 | Â Â Â Â Â Â Â Â Â Â Â Â DelList.append(keyList[i]) |
---|
3129 |           if 'All' in DelList: |
---|
3130 | Â Â Â Â Â Â Â Â Â Â Â Â DelList =Â keyList[1:] |
---|
3131 |           for i in DelList: |
---|
3132 |             del UseList[i] |
---|
3133 | Â Â Â Â Â Â Â Â Â Â wx.CallAfter(G2ddG.UpdateDData,G2frame,DData,data) |
---|
3134 | Â Â Â Â Â Â finally: |
---|
3135 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
3136 | Â Â Â Â Â Â Â Â |
---|
3137 | ################################################################################ |
---|
3138 | ##### Rigid bodies |
---|
3139 | ################################################################################ |
---|
3140 | |
---|
3141 |   def FillRigidBodyGrid(refresh=True): |
---|
3142 | Â Â Â Â '''Fill the Rigid Body Phase information tab page. |
---|
3143 | Â Â Â Â Note that the page is a ScrolledWindow, not a Grid |
---|
3144 | Â Â Â Â ''' |
---|
3145 |     def OnThermSel(event):    #needs to be seen by VecRbSizer! |
---|
3146 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3147 | Â Â Â Â Â Â RBObj =Â Indx[Obj.GetId()] |
---|
3148 | Â Â Â Â Â Â val =Â Obj.GetValue() |
---|
3149 | Â Â Â Â Â Â Ttype =Â 'A' |
---|
3150 |       if val == 'Uiso': |
---|
3151 | Â Â Â Â Â Â Â Â Ttype =Â 'I' |
---|
3152 | Â Â Â Â Â Â Â Â RBObj['ThermalMotion'][0]Â =Â 'Uiso' |
---|
3153 |       elif val == 'T': |
---|
3154 | Â Â Â Â Â Â Â Â RBObj['ThermalMotion'][0]Â =Â 'T' |
---|
3155 |       elif val == 'TL': |
---|
3156 | Â Â Â Â Â Â Â Â RBObj['ThermalMotion'][0]Â =Â 'TL' |
---|
3157 |       elif val == 'TLS': |
---|
3158 | Â Â Â Â Â Â Â Â RBObj['ThermalMotion'][0]Â =Â 'TLS' |
---|
3159 | Â Â Â Â Â Â wx.CallAfter(FillRigidBodyGrid,True) |
---|
3160 |       if val != 'None': |
---|
3161 | Â Â Â Â Â Â Â Â cia =Â data['General']['AtomPtrs'][3] |
---|
3162 |         for i,id in enumerate(RBObj['Ids']): |
---|
3163 | Â Â Â Â Â Â Â Â Â Â data['Atoms'][AtLookUp[id]][cia]Â =Â Ttype |
---|
3164 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3165 | Â Â Â Â Â Â |
---|
3166 |     def ThermDataSizer(RBObj,rbType): |
---|
3167 | Â Â Â Â Â Â |
---|
3168 |       def OnThermval(event): |
---|
3169 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3170 | Â Â Â Â Â Â Â Â item =Â Indx[Obj.GetId()] |
---|
3171 | Â Â Â Â Â Â Â Â try: |
---|
3172 | Â Â Â Â Â Â Â Â Â Â val =Â float(Obj.GetValue()) |
---|
3173 | Â Â Â Â Â Â Â Â Â Â RBObj['ThermalMotion'][1][item]Â =Â val |
---|
3174 |         except ValueError: |
---|
3175 | Â Â Â Â Â Â Â Â Â Â pass |
---|
3176 | Â Â Â Â Â Â Â Â Obj.SetValue('%8.4f'%(RBObj['ThermalMotion'][1][item])) |
---|
3177 | Â Â Â Â Â Â Â Â Cart =Â G2mth.UpdateRBXYZ(Bmat,RBObj,RBData,rbType)[1] |
---|
3178 | Â Â Â Â Â Â Â Â Uout =Â G2mth.UpdateRBUIJ(Bmat,Cart,RBObj) |
---|
3179 | Â Â Â Â Â Â Â Â cia =Â data['General']['AtomPtrs'][3] |
---|
3180 |         for i,id in enumerate(RBObj['Ids']): |
---|
3181 |           if Uout[i][0] == 'I': |
---|
3182 | Â Â Â Â Â Â Â Â Â Â Â Â data['Atoms'][AtLookUp[id]][cia+1]Â =Â Uout[i][1] |
---|
3183 | Â Â Â Â Â Â Â Â Â Â else: |
---|
3184 | Â Â Â Â Â Â Â Â Â Â Â Â data['Atoms'][AtLookUp[id]][cia+2:cia+8]Â =Â Uout[i][2:8] |
---|
3185 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3186 | Â Â Â Â Â Â Â Â |
---|
3187 |       def OnTLSRef(event): |
---|
3188 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3189 | Â Â Â Â Â Â Â Â item =Â Indx[Obj.GetId()] |
---|
3190 | Â Â Â Â Â Â Â Â RBObj['ThermalMotion'][2][item]Â =Â Obj.GetValue() |
---|
3191 | Â Â Â Â Â Â |
---|
3192 | Â Â Â Â Â Â thermSizer =Â wx.FlexGridSizer(1,9,5,5) |
---|
3193 | Â Â Â Â Â Â model =Â RBObj['ThermalMotion'] |
---|
3194 |       if model[0] == 'Uiso': |
---|
3195 | Â Â Â Â Â Â Â Â names =Â ['Uiso',] |
---|
3196 |       elif 'T' in model[0]: |
---|
3197 | Â Â Â Â Â Â Â Â names =Â ['T11','T22','T33','T12','T13','T23'] |
---|
3198 |       if 'L' in model[0]: |
---|
3199 | Â Â Â Â Â Â Â Â names +=Â ['L11','L22','L33','L12','L13','L23'] |
---|
3200 |       if 'S' in model[0]: |
---|
3201 | Â Â Â Â Â Â Â Â names +=Â ['S12','S13','S21','S23','S31','S32','SAA','SBB'] |
---|
3202 |       for i,name in enumerate(names): |
---|
3203 | Â Â Â Â Â Â Â Â thermSizer.Add(wx.StaticText(RigidBodies,-1,name+': '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3204 | Â Â Â Â Â Â Â Â thermVal =Â wx.TextCtrl(RigidBodies,-1,value='%8.4f'%(model[1][i]), |
---|
3205 | Â Â Â Â Â Â Â Â Â Â style=wx.TE_PROCESS_ENTER) |
---|
3206 | Â Â Â Â Â Â Â Â thermVal.Bind(wx.EVT_TEXT_ENTER,OnThermval) |
---|
3207 | Â Â Â Â Â Â Â Â thermVal.Bind(wx.EVT_KILL_FOCUS,OnThermval) |
---|
3208 | Â Â Â Â Â Â Â Â Indx[thermVal.GetId()]Â =Â i |
---|
3209 | Â Â Â Â Â Â Â Â thermSizer.Add(thermVal) |
---|
3210 | Â Â Â Â Â Â Â Â Tcheck =Â wx.CheckBox(RigidBodies,-1,'Refine?') |
---|
3211 | Â Â Â Â Â Â Â Â Tcheck.Bind(wx.EVT_CHECKBOX,OnTLSRef) |
---|
3212 | Â Â Â Â Â Â Â Â Tcheck.SetValue(model[2][i]) |
---|
3213 | Â Â Â Â Â Â Â Â Indx[Tcheck.GetId()]Â =Â i |
---|
3214 | Â Â Â Â Â Â Â Â thermSizer.Add(Tcheck,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3215 |       return thermSizer |
---|
3216 | Â Â Â Â Â Â |
---|
3217 |     def LocationSizer(RBObj,rbType): |
---|
3218 | Â Â Â Â Â Â |
---|
3219 |       def OnOrigRef(event): |
---|
3220 | Â Â Â Â Â Â Â Â RBObj['Orig'][1]Â =Â Ocheck.GetValue() |
---|
3221 | Â Â Â Â Â Â Â |
---|
3222 |       def OnOrienRef(event): |
---|
3223 | Â Â Â Â Â Â Â Â RBObj['Orient'][1]Â =Â Qcheck.GetValue() |
---|
3224 | Â Â Â Â Â Â Â Â |
---|
3225 |       def OnOrigX(event): |
---|
3226 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3227 | Â Â Â Â Â Â Â Â item =Â Indx[Obj.GetId()] |
---|
3228 | Â Â Â Â Â Â Â Â try: |
---|
3229 | Â Â Â Â Â Â Â Â Â Â val =Â float(Obj.GetValue()) |
---|
3230 | Â Â Â Â Â Â Â Â Â Â RBObj['Orig'][0][item]Â =Â val |
---|
3231 | Â Â Â Â Â Â Â Â Â Â Obj.SetValue('%8.5f'%(val)) |
---|
3232 | Â Â Â Â Â Â Â Â Â Â newXYZ =Â G2mth.UpdateRBXYZ(Bmat,RBObj,RBData,rbType)[0] |
---|
3233 |           for i,id in enumerate(RBObj['Ids']): |
---|
3234 | Â Â Â Â Â Â Â Â Â Â Â Â data['Atoms'][AtLookUp[id]][cx:cx+3]Â =Â newXYZ[i] |
---|
3235 | Â Â Â Â Â Â Â Â Â Â data['Drawing']['Atoms']Â =Â [] |
---|
3236 | Â Â Â Â Â Â Â Â Â Â UpdateDrawAtoms(atomStyle) |
---|
3237 | Â Â Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3238 |         except ValueError: |
---|
3239 | Â Â Â Â Â Â Â Â Â Â pass |
---|
3240 | Â Â Â Â Â Â Â Â |
---|
3241 |       def OnOrien(event): |
---|
3242 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3243 | Â Â Â Â Â Â Â Â item =Â Indx[Obj.GetId()] |
---|
3244 | Â Â Â Â Â Â Â Â A,V =Â G2mth.Q2AVdeg(RBObj['Orient'][0]) |
---|
3245 | Â Â Â Â Â Â Â Â V =Â np.inner(Bmat,V) |
---|
3246 | Â Â Â Â Â Â Â Â try: |
---|
3247 | Â Â Â Â Â Â Â Â Â Â val =Â float(Obj.GetValue()) |
---|
3248 |           if item: |
---|
3249 | Â Â Â Â Â Â Â Â Â Â Â Â V[item-1]Â =Â val |
---|
3250 | Â Â Â Â Â Â Â Â Â Â else: |
---|
3251 | Â Â Â Â Â Â Â Â Â Â Â Â A =Â val |
---|
3252 | Â Â Â Â Â Â Â Â Â Â Obj.SetValue('%8.5f'%(val)) |
---|
3253 | Â Â Â Â Â Â Â Â Â Â V =Â np.inner(Amat,V) |
---|
3254 | Â Â Â Â Â Â Â Â Â Â Q =Â G2mth.AVdeg2Q(A,V) |
---|
3255 |           if not any(Q): |
---|
3256 |             raise ValueError |
---|
3257 | Â Â Â Â Â Â Â Â Â Â RBObj['Orient'][0]Â =Â Q |
---|
3258 | Â Â Â Â Â Â Â Â Â Â newXYZ =Â G2mth.UpdateRBXYZ(Bmat,RBObj,RBData,rbType)[0] |
---|
3259 |           for i,id in enumerate(RBObj['Ids']): |
---|
3260 | Â Â Â Â Â Â Â Â Â Â Â Â data['Atoms'][AtLookUp[id]][cx:cx+3]Â =Â newXYZ[i] |
---|
3261 | Â Â Â Â Â Â Â Â Â Â data['Drawing']['Atoms']Â =Â [] |
---|
3262 | Â Â Â Â Â Â Â Â Â Â UpdateDrawAtoms(atomStyle) |
---|
3263 | Â Â Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3264 |         except ValueError: |
---|
3265 | Â Â Â Â Â Â Â Â Â Â pass |
---|
3266 | Â Â Â Â Â Â Â Â |
---|
3267 | Â Â Â Â Â Â topSizer =Â wx.FlexGridSizer(2,6,5,5) |
---|
3268 | Â Â Â Â Â Â Orig =Â RBObj['Orig'][0] |
---|
3269 | Â Â Â Â Â Â Orien,OrienV =Â G2mth.Q2AVdeg(RBObj['Orient'][0]) |
---|
3270 | Â Â Â Â Â Â Orien =Â [Orien,] |
---|
3271 | Â Â Â Â Â Â Orien.extend(OrienV/nl.norm(OrienV)) |
---|
3272 | Â Â Â Â Â Â topSizer.Add(wx.StaticText(RigidBodies,-1,'Origin x,y,z:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3273 |       for ix,x in enumerate(Orig): |
---|
3274 | Â Â Â Â Â Â Â Â origX =Â wx.TextCtrl(RigidBodies,-1,value='%8.5f'%(x),style=wx.TE_PROCESS_ENTER) |
---|
3275 | Â Â Â Â Â Â Â Â origX.Bind(wx.EVT_TEXT_ENTER,OnOrigX) |
---|
3276 | Â Â Â Â Â Â Â Â origX.Bind(wx.EVT_KILL_FOCUS,OnOrigX) |
---|
3277 | Â Â Â Â Â Â Â Â Indx[origX.GetId()]Â =Â ix |
---|
3278 | Â Â Â Â Â Â Â Â topSizer.Add(origX,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3279 | Â Â Â Â Â Â topSizer.Add((5,0),) |
---|
3280 | Â Â Â Â Â Â Ocheck =Â wx.CheckBox(RigidBodies,-1,'Refine?') |
---|
3281 | Â Â Â Â Â Â Ocheck.Bind(wx.EVT_CHECKBOX,OnOrigRef) |
---|
3282 | Â Â Â Â Â Â Ocheck.SetValue(RBObj['Orig'][1]) |
---|
3283 | Â Â Â Â Â Â topSizer.Add(Ocheck,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3284 | Â Â Â Â Â Â topSizer.Add(wx.StaticText(RigidBodies,-1,'Rotation angle, vector:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3285 |       for ix,x in enumerate(Orien): |
---|
3286 | Â Â Â Â Â Â Â Â orien =Â wx.TextCtrl(RigidBodies,-1,value='%8.4f'%(x),style=wx.TE_PROCESS_ENTER) |
---|
3287 | Â Â Â Â Â Â Â Â orien.Bind(wx.EVT_TEXT_ENTER,OnOrien) |
---|
3288 | Â Â Â Â Â Â Â Â orien.Bind(wx.EVT_KILL_FOCUS,OnOrien) |
---|
3289 | Â Â Â Â Â Â Â Â Indx[orien.GetId()]Â =Â ix |
---|
3290 | Â Â Â Â Â Â Â Â topSizer.Add(orien,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3291 | Â Â Â Â Â Â Qcheck =Â wx.ComboBox(RigidBodies,-1,value='',choices=[' ','A','AV'], |
---|
3292 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
3293 | Â Â Â Â Â Â Qcheck.Bind(wx.EVT_COMBOBOX,OnOrienRef) |
---|
3294 | Â Â Â Â Â Â Qcheck.SetValue(RBObj['Orient'][1]) |
---|
3295 | Â Â Â Â Â Â topSizer.Add(Qcheck) |
---|
3296 |       return topSizer |
---|
3297 | Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
3298 |     def ResrbSizer(RBObj): |
---|
3299 | Â Â Â Â Â Â G2frame.dataFrame.SetStatusText('NB: Rotation vector is in crystallographic space') |
---|
3300 | Â Â Â Â Â Â Â |
---|
3301 |       def OnTorsionRef(event): |
---|
3302 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3303 | Â Â Â Â Â Â Â Â item =Â Indx[Obj.GetId()] |
---|
3304 | Â Â Â Â Â Â Â Â RBObj['Torsions'][item][1]Â =Â Obj.GetValue()Â Â Â Â Â Â Â Â |
---|
3305 | Â Â Â Â Â Â Â Â |
---|
3306 |       def OnTorsion(event): |
---|
3307 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3308 | Â Â Â Â Â Â Â Â item =Â Indx[Obj.GetId()] |
---|
3309 | Â Â Â Â Â Â Â Â try: |
---|
3310 | Â Â Â Â Â Â Â Â Â Â val =Â float(Obj.GetValue()) |
---|
3311 | Â Â Â Â Â Â Â Â Â Â RBObj['Torsions'][item][0]Â =Â val |
---|
3312 | Â Â Â Â Â Â Â Â Â Â newXYZ =Â G2mth.UpdateRBXYZ(Bmat,RBObj,RBData,'Residue')[0] |
---|
3313 |           for i,id in enumerate(RBObj['Ids']): |
---|
3314 | Â Â Â Â Â Â Â Â Â Â Â Â data['Atoms'][AtLookUp[id]][cx:cx+3]Â =Â newXYZ[i] |
---|
3315 |         except ValueError: |
---|
3316 | Â Â Â Â Â Â Â Â Â Â pass |
---|
3317 | Â Â Â Â Â Â Â Â Obj.SetValue("%10.3f"%(RBObj['Torsions'][item][0]))Â Â Â Â Â Â Â Â |
---|
3318 | Â Â Â Â Â Â Â Â data['Drawing']['Atoms']Â =Â [] |
---|
3319 | Â Â Â Â Â Â Â Â UpdateDrawAtoms(atomStyle) |
---|
3320 | Â Â Â Â Â Â Â Â drawAtoms.ClearSelection() |
---|
3321 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3322 | Â Â Â Â Â Â Â Â |
---|
3323 |       def OnDelResRB(event): |
---|
3324 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3325 | Â Â Â Â Â Â Â Â RBId =Â Indx[Obj.GetId()] |
---|
3326 | Â Â Â Â Â Â Â Â RBData['Residue'][RBId]['useCount']Â -=Â 1 |
---|
3327 | Â Â Â Â Â Â Â Â RBObjs =Â data['RBModels']['Residue'] |
---|
3328 |         for rbObj in RBObjs: |
---|
3329 |           if RBId == rbObj['RBId']: |
---|
3330 | Â Â Â Â Â Â Â Â Â Â Â Â data['RBModels']['Residue'].remove(rbObj)Â Â Â Â Â Â Â Â Â |
---|
3331 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3332 | Â Â Â Â Â Â Â Â wx.CallAfter(FillRigidBodyGrid,True) |
---|
3333 | Â Â Â Â Â Â Â Â |
---|
3334 | Â Â Â Â Â Â resrbSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
3335 | Â Â Â Â Â Â resrbSizer.Add(wx.StaticText(RigidBodies,-1,120*'-')) |
---|
3336 | Â Â Â Â Â Â topLine =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
3337 | Â Â Â Â Â Â topLine.Add(wx.StaticText(RigidBodies,-1, |
---|
3338 | Â Â Â Â Â Â Â Â 'Name: '+RBObj['RBname']+RBObj['numChain']+'Â Â '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3339 | Â Â Â Â Â Â rbId =Â RBObj['RBId'] |
---|
3340 | Â Â Â Â Â Â delRB =Â wx.CheckBox(RigidBodies,-1,'Delete?') |
---|
3341 | Â Â Â Â Â Â delRB.Bind(wx.EVT_CHECKBOX,OnDelResRB) |
---|
3342 | Â Â Â Â Â Â Indx[delRB.GetId()]Â =Â rbId |
---|
3343 | Â Â Â Â Â Â topLine.Add(delRB,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3344 | Â Â Â Â Â Â resrbSizer.Add(topLine) |
---|
3345 | Â Â Â Â Â Â resrbSizer.Add(LocationSizer(RBObj,'Residue')) |
---|
3346 | Â Â Â Â Â Â resrbSizer.Add(wx.StaticText(RigidBodies,-1,'Torsions:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3347 | Â Â Â Â Â Â torSizer =Â wx.FlexGridSizer(1,6,5,5) |
---|
3348 |       for itors,tors in enumerate(RBObj['Torsions']): |
---|
3349 | Â Â Â Â Â Â Â Â torSizer.Add(wx.StaticText(RigidBodies,-1,'Torsion '+'%d'%(itors)),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3350 | Â Â Â Â Â Â Â Â torsTxt =Â wx.TextCtrl(RigidBodies,-1,value='%.3f'%(tors[0]),style=wx.TE_PROCESS_ENTER) |
---|
3351 | Â Â Â Â Â Â Â Â torsTxt.Bind(wx.EVT_TEXT_ENTER,OnTorsion) |
---|
3352 | Â Â Â Â Â Â Â Â torsTxt.Bind(wx.EVT_KILL_FOCUS,OnTorsion) |
---|
3353 | Â Â Â Â Â Â Â Â Indx[torsTxt.GetId()]Â =Â itors |
---|
3354 | Â Â Â Â Â Â Â Â torSizer.Add(torsTxt) |
---|
3355 | Â Â Â Â Â Â Â Â torCheck =Â wx.CheckBox(RigidBodies,-1,'Refine?') |
---|
3356 | Â Â Â Â Â Â Â Â torCheck.Bind(wx.EVT_CHECKBOX,OnTorsionRef) |
---|
3357 | Â Â Â Â Â Â Â Â torCheck.SetValue(tors[1]) |
---|
3358 | Â Â Â Â Â Â Â Â Indx[torCheck.GetId()]Â =Â itors |
---|
3359 | Â Â Â Â Â Â Â Â torSizer.Add(torCheck,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3360 | Â Â Â Â Â Â resrbSizer.Add(torSizer) |
---|
3361 | Â Â Â Â Â Â tchoice =Â ['None','Uiso','T','TL','TLS'] |
---|
3362 | Â Â Â Â Â Â thermSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
3363 | Â Â Â Â Â Â thermSizer.Add(wx.StaticText(RigidBodies,-1,'Rigid body thermal motion model: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3364 | Â Â Â Â Â Â thermSel =Â wx.ComboBox(RigidBodies,-1,value=RBObj['ThermalMotion'][0],choices=tchoice, |
---|
3365 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
3366 | Â Â Â Â Â Â Indx[thermSel.GetId()]Â =Â RBObj |
---|
3367 | Â Â Â Â Â Â thermSel.Bind(wx.EVT_COMBOBOX,OnThermSel) |
---|
3368 | Â Â Â Â Â Â thermSizer.Add(thermSel,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3369 | Â Â Â Â Â Â thermSizer.Add(wx.StaticText(RigidBodies,-1,' Units: T A^2, L deg^2, S deg-A'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3370 | Â Â Â Â Â Â resrbSizer.Add(thermSizer) |
---|
3371 |       if RBObj['ThermalMotion'][0] != 'None': |
---|
3372 | Â Â Â Â Â Â Â Â resrbSizer.Add(ThermDataSizer(RBObj,'Residue')) |
---|
3373 |       return resrbSizer |
---|
3374 | Â Â Â Â Â Â |
---|
3375 |     def VecrbSizer(RBObj): |
---|
3376 | Â Â Â Â Â Â G2frame.dataFrame.SetStatusText('NB: Rotation vector is in crystallographic space') |
---|
3377 | Â Â Â Â Â Â Â Â Â Â |
---|
3378 |       def OnDelVecRB(event): |
---|
3379 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3380 | Â Â Â Â Â Â Â Â RBId =Â Indx[Obj.GetId()] |
---|
3381 | Â Â Â Â Â Â Â Â RBData['Vector'][RBId]['useCount']Â -=Â 1Â Â Â Â Â Â Â Â |
---|
3382 | Â Â Â Â Â Â Â Â RBObjs =Â data['RBModels']['Vector'] |
---|
3383 |         for rbObj in RBObjs: |
---|
3384 |           if RBId == rbObj['RBId']: |
---|
3385 | Â Â Â Â Â Â Â Â Â Â Â Â data['RBModels']['Vector'].remove(rbObj)Â Â Â Â Â Â Â Â Â |
---|
3386 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3387 | Â Â Â Â Â Â Â Â wx.CallAfter(FillRigidBodyGrid,True) |
---|
3388 | Â Â Â Â Â Â Â |
---|
3389 | Â Â Â Â Â Â vecrbSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
3390 | Â Â Â Â Â Â vecrbSizer.Add(wx.StaticText(RigidBodies,-1,120*'-')) |
---|
3391 | Â Â Â Â Â Â topLine =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
3392 | Â Â Â Â Â Â topLine.Add(wx.StaticText(RigidBodies,-1, |
---|
3393 | Â Â Â Â Â Â Â Â 'Name: '+RBObj['RBname']+'Â Â '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3394 | Â Â Â Â Â Â rbId =Â RBObj['RBId'] |
---|
3395 | Â Â Â Â Â Â delRB =Â wx.CheckBox(RigidBodies,-1,'Delete?') |
---|
3396 | Â Â Â Â Â Â delRB.Bind(wx.EVT_CHECKBOX,OnDelVecRB) |
---|
3397 | Â Â Â Â Â Â Indx[delRB.GetId()]Â =Â rbId |
---|
3398 | Â Â Â Â Â Â topLine.Add(delRB,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3399 | Â Â Â Â Â Â vecrbSizer.Add(topLine) |
---|
3400 | Â Â Â Â Â Â vecrbSizer.Add(LocationSizer(RBObj,'Vector')) |
---|
3401 | Â Â Â Â Â Â tchoice =Â ['None','Uiso','T','TL','TLS'] |
---|
3402 | Â Â Â Â Â Â thermSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
3403 | Â Â Â Â Â Â thermSizer.Add(wx.StaticText(RigidBodies,-1,'Rigid body thermal motion model: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3404 | Â Â Â Â Â Â thermSel =Â wx.ComboBox(RigidBodies,-1,value=RBObj['ThermalMotion'][0],choices=tchoice, |
---|
3405 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
3406 | Â Â Â Â Â Â Indx[thermSel.GetId()]Â =Â RBObj |
---|
3407 | Â Â Â Â Â Â thermSel.Bind(wx.EVT_COMBOBOX,OnThermSel) |
---|
3408 | Â Â Â Â Â Â thermSizer.Add(thermSel,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3409 | Â Â Â Â Â Â thermSizer.Add(wx.StaticText(RigidBodies,-1,' Units: T A^2, L deg^2, S deg-A'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3410 | Â Â Â Â Â Â vecrbSizer.Add(thermSizer) |
---|
3411 |       if RBObj['ThermalMotion'][0] != 'None': |
---|
3412 | Â Â Â Â Â Â Â Â vecrbSizer.Add(ThermDataSizer(RBObj,'Vector')) |
---|
3413 |       return vecrbSizer        |
---|
3414 | Â Â Â Â |
---|
3415 | Â Â Â Â # FillRigidBodyGrid executable code starts here |
---|
3416 |     if refresh: |
---|
3417 | Â Â Â Â Â Â RigidBodies.DestroyChildren() |
---|
3418 | Â Â Â Â AtLookUp =Â G2mth.FillAtomLookUp(data['Atoms']) |
---|
3419 | Â Â Â Â general =Â data['General'] |
---|
3420 | Â Â Â Â cx =Â general['AtomPtrs'][0] |
---|
3421 | Â Â Â Â Amat,Bmat =Â G2lat.cell2AB(general['Cell'][1:7]) |
---|
3422 | Â Â Â Â RBData =Â G2frame.PatternTree.GetItemPyData(Â Â |
---|
3423 | Â Â Â Â Â Â G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Rigid bodies')) |
---|
3424 | Â Â Â Â Indx =Â {} |
---|
3425 | Â Â Â Â atomStyle =Â 'balls & sticks' |
---|
3426 |     if 'macro' in general['Type']: |
---|
3427 | Â Â Â Â Â Â atomStyle =Â 'sticks' |
---|
3428 | Â Â Â Â G2frame.dataFrame.SetStatusText('') |
---|
3429 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
3430 |     if not data['RBModels']: |
---|
3431 | Â Â Â Â Â Â mainSizer.Add((5,5),0) |
---|
3432 | Â Â Â Â Â Â mainSizer.Add(wx.StaticText(RigidBodies,-1,'No rigid body models:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3433 | Â Â Â Â Â Â mainSizer.Add((5,5),0) |
---|
3434 |     if 'Residue' in data['RBModels']: |
---|
3435 | Â Â Â Â Â Â mainSizer.Add((5,5),0) |
---|
3436 | Â Â Â Â Â Â mainSizer.Add(wx.StaticText(RigidBodies,-1,'Residue rigid bodies:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3437 | Â Â Â Â Â Â mainSizer.Add((5,5),0) |
---|
3438 |       for RBObj in data['RBModels']['Residue']: |
---|
3439 | Â Â Â Â Â Â Â Â mainSizer.Add(ResrbSizer(RBObj)) |
---|
3440 |     if 'Vector' in data['RBModels']: |
---|
3441 | Â Â Â Â Â Â mainSizer.Add((5,5),0) |
---|
3442 | Â Â Â Â Â Â mainSizer.Add(wx.StaticText(RigidBodies,-1,'Vector rigid bodies:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3443 | Â Â Â Â Â Â mainSizer.Add((5,5),0) |
---|
3444 |       for RBObj in data['RBModels']['Vector']: |
---|
3445 | Â Â Â Â Â Â Â Â mainSizer.Add(VecrbSizer(RBObj)) |
---|
3446 | |
---|
3447 | Â Â Â Â SetPhaseWindow(G2frame.dataFrame,RigidBodies,mainSizer) |
---|
3448 | |
---|
3449 |   def OnRBCopyParms(event): |
---|
3450 | Â Â Â Â RBObjs =Â [] |
---|
3451 |     for rbType in ['Vector','Residue']:      |
---|
3452 | Â Â Â Â Â Â RBObjs +=Â data['RBModels'].get(rbType,[]) |
---|
3453 |     if not len(RBObjs): |
---|
3454 |       print '**** ERROR - no rigid bodies defined ****' |
---|
3455 | Â Â Â Â Â Â return |
---|
3456 |     if len(RBObjs) == 1: |
---|
3457 |       print '**** INFO - only one rigid body defined; nothing to copy to ****' |
---|
3458 | Â Â Â Â Â Â return |
---|
3459 | Â Â Â Â Source =Â [] |
---|
3460 | Â Â Â Â sourceRB =Â {} |
---|
3461 |     for RBObj in RBObjs: |
---|
3462 | Â Â Â Â Â Â Source.append(RBObj['RBname']) |
---|
3463 | Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select source','Copy rigid body parameters',Source) |
---|
3464 |     if dlg.ShowModal() == wx.ID_OK: |
---|
3465 | Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
3466 | Â Â Â Â Â Â name =Â Source[sel] |
---|
3467 |       for item in ['Orig','Orient','ThermalMotion']: |
---|
3468 | Â Â Â Â Â Â Â Â sourceRB.update({item:RBObjs[sel][item],}) |
---|
3469 | Â Â Â Â dlg.Destroy() |
---|
3470 |     if not sourceRB: |
---|
3471 | Â Â Â Â Â Â return |
---|
3472 | Â Â Â Â dlg =Â wx.MultiChoiceDialog(G2frame,'Select targets','Copy rigid body parameters',Source) |
---|
3473 |     if dlg.ShowModal() == wx.ID_OK: |
---|
3474 | Â Â Â Â Â Â sel =Â dlg.GetSelections() |
---|
3475 |       for x in sel: |
---|
3476 | Â Â Â Â Â Â Â Â RBObjs[x].update(copy.copy(sourceRB)) |
---|
3477 | Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3478 | Â Â Â Â wx.CallAfter(FillRigidBodyGrid(True)) |
---|
3479 | Â Â Â Â Â Â Â Â |
---|
3480 |   def OnRBAssign(event): |
---|
3481 | Â Â Â Â |
---|
3482 | Â Â Â Â G2frame.dataFrame.SetStatusText('') |
---|
3483 | Â Â Â Â RBData =Â G2frame.PatternTree.GetItemPyData(Â Â |
---|
3484 | Â Â Â Â Â Â G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Rigid bodies')) |
---|
3485 | Â Â Â Â rbNames =Â {} |
---|
3486 |     for rbVec in RBData['Vector']: |
---|
3487 |       if rbVec != 'AtInfo': |
---|
3488 | Â Â Â Â Â Â Â Â rbNames[RBData['Vector'][rbVec]['RBname']]Â =['Vector',rbVec] |
---|
3489 |     for rbRes in RBData['Residue']: |
---|
3490 |       if rbRes != 'AtInfo': |
---|
3491 | Â Â Â Â Â Â Â Â rbNames[RBData['Residue'][rbRes]['RBname']]Â =Â ['Residue',rbRes] |
---|
3492 |     if not rbNames: |
---|
3493 |       print '**** ERROR - no rigid bodies defined ****' |
---|
3494 | Â Â Â Â Â Â return |
---|
3495 | Â Â Â Â general =Â data['General'] |
---|
3496 | Â Â Â Â Amat,Bmat =Â G2lat.cell2AB(general['Cell'][1:7]) |
---|
3497 | Â Â Â Â cx,ct =Â general['AtomPtrs'][:2] |
---|
3498 | Â Â Â Â atomData =Â data['Atoms'] |
---|
3499 | Â Â Â Â Indx =Â {} |
---|
3500 | Â Â Â Â atInd =Â [-1,-1,-1] |
---|
3501 | Â Â Â Â data['testRBObj']Â =Â {} |
---|
3502 | Â Â Â Â Â Â |
---|
3503 |     def Draw(): |
---|
3504 | Â Â Â Â Â Â |
---|
3505 |       def OnOk(event): |
---|
3506 | Â Â Â Â Â Â Â Â rbType =Â data['testRBObj']['rbType'] |
---|
3507 | Â Â Â Â Â Â Â Â RBObjs =Â data['RBModels'].get(rbType,[]) |
---|
3508 | Â Â Â Â Â Â Â Â rbObj =Â data['testRBObj']['rbObj'] |
---|
3509 | Â Â Â Â Â Â Â Â rbId =Â rbObj['RBId'] |
---|
3510 | Â Â Â Â Â Â Â Â newXYZ =Â G2mth.UpdateRBXYZ(Bmat,rbObj,RBData,rbType)[0] |
---|
3511 | Â Â Â Â Â Â Â Â Ids =Â [] |
---|
3512 | Â Â Â Â Â Â Â Â dmax =Â 0.0 |
---|
3513 | Â Â Â Â Â Â Â Â oldXYZ =Â G2mth.getAtomXYZ(atomData,cx) |
---|
3514 |         for xyz in newXYZ: |
---|
3515 | Â Â Â Â Â Â Â Â Â Â dist =Â G2mth.GetXYZDist(xyz,oldXYZ,Amat) |
---|
3516 | Â Â Â Â Â Â Â Â Â Â dmax =Â max(dmax,np.min(dist)) |
---|
3517 |           id = np.argmin(dist) |
---|
3518 | Â Â Â Â Â Â Â Â Â Â Ids.append(atomData[id][-1]) |
---|
3519 | Â Â Â Â Â Â Â Â Â Â atomData[id][cx:cx+3]Â =Â xyz |
---|
3520 |         if dmax > 0.5: |
---|
3521 |           print '**** WARNING - some atoms not found or misidentified ****' |
---|
3522 |           print '****      check torsion angles & try again   ****' |
---|
3523 | Â Â Â Â Â Â Â Â Â Â OkBtn.SetLabel('Not Ready') |
---|
3524 | Â Â Â Â Â Â Â Â Â Â OkBtn.Enable(False) |
---|
3525 | Â Â Â Â Â Â Â Â Â Â return |
---|
3526 | Â Â Â Â Â Â Â Â rbObj['Ids']Â =Â Ids |
---|
3527 |         rbObj['ThermalMotion'] = ['None',[0. for i in range(21)],[False for i in range(21)]] #type,values,flags |
---|
3528 | Â Â Â Â Â Â Â Â rbObj['RBname']Â +=Â ':'+str(RBData[rbType][rbId]['useCount']) |
---|
3529 | Â Â Â Â Â Â Â Â RBObjs.append(rbObj) |
---|
3530 | Â Â Â Â Â Â Â Â data['RBModels'][rbType]Â =Â RBObjs |
---|
3531 | Â Â Â Â Â Â Â Â RBData[rbType][rbId]['useCount']Â +=Â 1 |
---|
3532 |         del data['testRBObj'] |
---|
3533 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3534 | Â Â Â Â Â Â Â Â FillRigidBodyGrid(True) |
---|
3535 | Â Â Â Â Â Â Â Â |
---|
3536 |       def OnCancel(event): |
---|
3537 |         del data['testRBObj'] |
---|
3538 | Â Â Â Â Â Â Â Â FillRigidBodyGrid(True) |
---|
3539 | Â Â Â Â Â Â Â Â |
---|
3540 |       def OnRBSel(event): |
---|
3541 | Â Â Â Â Â Â Â Â selection =Â rbSel.GetValue() |
---|
3542 | Â Â Â Â Â Â Â Â rbType,rbId =Â rbNames[selection] |
---|
3543 | Â Â Â Â Â Â Â Â data['testRBObj']['rbAtTypes']Â =Â RBData[rbType][rbId]['rbTypes'] |
---|
3544 | Â Â Â Â Â Â Â Â data['testRBObj']['AtInfo']Â =Â RBData[rbType]['AtInfo'] |
---|
3545 | Â Â Â Â Â Â Â Â data['testRBObj']['rbType']Â =Â rbType |
---|
3546 | Â Â Â Â Â Â Â Â data['testRBObj']['rbData']Â =Â RBData |
---|
3547 | Â Â Â Â Â Â Â Â data['testRBObj']['Sizers']Â =Â {} |
---|
3548 | Â Â Â Â Â Â Â Â rbRef =Â RBData[rbType][rbId]['rbRef'] |
---|
3549 | Â Â Â Â Â Â Â Â data['testRBObj']['rbRef']Â =Â rbRef |
---|
3550 | Â Â Â Â Â Â Â Â refType =Â [] |
---|
3551 | Â Â Â Â Â Â Â Â refName =Â [] |
---|
3552 |         for ref in rbRef[:3]: |
---|
3553 | Â Â Â Â Â Â Â Â Â Â reftype =Â data['testRBObj']['rbAtTypes'][ref] |
---|
3554 | Â Â Â Â Â Â Â Â Â Â refType.append(reftype) |
---|
3555 | Â Â Â Â Â Â Â Â Â Â refName.append(reftype+' '+str(rbRef[0])) |
---|
3556 | Â Â Â Â Â Â Â Â atNames,AtNames =Â fillAtNames(refType,atomData,ct) |
---|
3557 | Â Â Â Â Â Â Â Â data['testRBObj']['atNames']Â =Â atNames |
---|
3558 | Â Â Â Â Â Â Â Â data['testRBObj']['AtNames']Â =Â AtNames |
---|
3559 | Â Â Â Â Â Â Â Â data['testRBObj']['rbObj']Â =Â {'Orig':[[0,0,0],False], |
---|
3560 | Â Â Â Â Â Â Â Â Â Â 'Orient':[[0.,0.,0.,1.],' '],'Ids':[],'RBId':rbId,'Torsions':[], |
---|
3561 | Â Â Â Â Â Â Â Â Â Â 'numChain':'','RBname':RBData[rbType][rbId]['RBname']} |
---|
3562 | Â Â Â Â Â Â Â Â data['testRBObj']['torAtms']Â =Â []Â Â Â Â Â Â Â Â |
---|
3563 |         for item in RBData[rbType][rbId].get('rbSeq',[]): |
---|
3564 | Â Â Â Â Â Â Â Â Â Â data['testRBObj']['rbObj']['Torsions'].append([item[2],False]) |
---|
3565 | Â Â Â Â Â Â Â Â Â Â data['testRBObj']['torAtms'].append([-1,-1,-1]) |
---|
3566 | Â Â Â Â Â Â Â Â Draw() |
---|
3567 | Â Â Â Â Â Â Â Â |
---|
3568 |       def fillAtNames(refType,atomData,ct): |
---|
3569 | Â Â Â Â Â Â Â Â atNames =Â [{},{},{}] |
---|
3570 | Â Â Â Â Â Â Â Â AtNames =Â {} |
---|
3571 |         for iatm,atom in enumerate(atomData): |
---|
3572 | Â Â Â Â Â Â Â Â Â Â AtNames[atom[ct-1]]Â =Â iatm |
---|
3573 |           for i,reftype in enumerate(refType): |
---|
3574 |             if atom[ct] == reftype: |
---|
3575 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â atNames[i][atom[ct-1]]Â =Â iatm |
---|
3576 |         return atNames,AtNames |
---|
3577 | Â Â Â Â Â Â Â Â |
---|
3578 |       def OnAtOrigPick(event): |
---|
3579 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3580 | Â Â Â Â Â Â Â Â item =Â Indx[Obj.GetId()] |
---|
3581 | Â Â Â Â Â Â Â Â atName =Â Obj.GetValue() |
---|
3582 | Â Â Â Â Â Â Â Â rbType =Â data['testRBObj']['rbType'] |
---|
3583 | Â Â Â Â Â Â Â Â atInd[0]Â =Â atNames[item][atName] |
---|
3584 |         if 'Vector' in rbType: |
---|
3585 | Â Â Â Â Â Â Â Â Â Â rbObj =Â data['testRBObj']['rbObj'] |
---|
3586 | Â Â Â Â Â Â Â Â Â Â rbId =Â rbObj['RBId'] |
---|
3587 | Â Â Â Â Â Â Â Â Â Â rbRef =Â data['testRBObj']['rbRef'] |
---|
3588 | Â Â Â Â Â Â Â Â Â Â rbXYZ =Â -RBData[rbType][rbId]['rbXYZ'] |
---|
3589 | Â Â Â Â Â Â Â Â Â Â nref =Â atNames[item][atName] |
---|
3590 | Â Â Â Â Â Â Â Â Â Â Oxyz =Â np.inner(Bmat,np.array(rbXYZ[rbRef[0]])) |
---|
3591 | Â Â Â Â Â Â Â Â Â Â Nxyz =Â np.array(atomData[nref][cx:cx+3]) |
---|
3592 | Â Â Â Â Â Â Â Â Â Â Orig =Â Nxyz-Oxyz |
---|
3593 |           data['testRBObj']['rbObj']['Orig'][0] = Orig  |
---|
3594 | Â Â Â Â Â Â Â Â else: |
---|
3595 | Â Â Â Â Â Â Â Â Â Â Orig =Â atomData[atNames[item][atName]][cx:cx+3] |
---|
3596 | Â Â Â Â Â Â Â Â Â Â data['testRBObj']['rbObj']['Orig'][0]Â =Â Orig |
---|
3597 |         for x,item in zip(Orig,Xsizers): |
---|
3598 | Â Â Â Â Â Â Â Â Â Â item.SetLabel('%10.5f'%(x)) |
---|
3599 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3600 | Â Â Â Â Â Â Â Â |
---|
3601 |       def OnAtQPick(event): |
---|
3602 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3603 | Â Â Â Â Â Â Â Â item =Â Indx[Obj.GetId()] |
---|
3604 | Â Â Â Â Â Â Â Â atName =Â Obj.GetValue() |
---|
3605 | Â Â Â Â Â Â Â Â atInd[item]Â =Â atNames[item][atName] |
---|
3606 |         if any([x<0 for x in atInd]): |
---|
3607 | Â Â Â Â Â Â Â Â Â Â return |
---|
3608 | Â Â Â Â Â Â Â Â OkBtn.SetLabel('OK') |
---|
3609 | Â Â Â Â Â Â Â Â OkBtn.Enable(True) |
---|
3610 | Â Â Â Â Â Â Â Â rbType =Â data['testRBObj']['rbType'] |
---|
3611 | Â Â Â Â Â Â Â Â rbObj =Â data['testRBObj']['rbObj'] |
---|
3612 | Â Â Â Â Â Â Â Â rbId =Â rbObj['RBId'] |
---|
3613 | Â Â Â Â Â Â Â Â rbRef =Â data['testRBObj']['rbRef'] |
---|
3614 | Â Â Â Â Â Â Â Â rbXYZ =Â RBData[rbType][rbId]['rbXYZ'] |
---|
3615 | Â Â Â Â Â Â Â Â rbOrig =Â rbXYZ[rbRef[0]] |
---|
3616 | Â Â Â Â Â Â Â Â VAR =Â rbXYZ[rbRef[1]]-rbOrig |
---|
3617 | Â Â Â Â Â Â Â Â VBR =Â rbXYZ[rbRef[2]]-rbOrig |
---|
3618 |         if rbType == 'Vector': |
---|
3619 | Â Â Â Â Â Â Â Â Â Â Orig =Â np.array(atomData[atInd[0]][cx:cx+3]) |
---|
3620 | Â Â Â Â Â Â Â Â else: |
---|
3621 | Â Â Â Â Â Â Â Â Â Â Orig =Â np.array(data['testRBObj']['rbObj']['Orig'][0])Â Â Â Â Â Â Â Â |
---|
3622 | Â Â Â Â Â Â Â Â VAC =Â np.inner(Amat,np.array(atomData[atInd[1]][cx:cx+3])-Orig) |
---|
3623 | Â Â Â Â Â Â Â Â VBC =Â np.inner(Amat,np.array(atomData[atInd[2]][cx:cx+3])-Orig) |
---|
3624 | Â Â Â Â Â Â Â Â VCC =Â np.cross(VAR,VAC) |
---|
3625 | Â Â Â Â Â Â Â Â QuatA =Â G2mth.makeQuat(VAR,VAC,VCC)[0] |
---|
3626 | Â Â Â Â Â Â Â Â VAR =Â G2mth.prodQVQ(QuatA,VAR) |
---|
3627 | Â Â Â Â Â Â Â Â VBR =Â G2mth.prodQVQ(QuatA,VBR) |
---|
3628 | Â Â Â Â Â Â Â Â QuatB =Â G2mth.makeQuat(VBR,VBC,VAR)[0] |
---|
3629 | Â Â Â Â Â Â Â Â QuatC =Â G2mth.prodQQ(QuatB,QuatA) |
---|
3630 | Â Â Â Â Â Â Â Â data['testRBObj']['rbObj']['Orient']Â =Â [QuatC,' '] |
---|
3631 |         for x,item in zip(QuatC,Osizers): |
---|
3632 | Â Â Â Â Â Â Â Â Â Â item.SetLabel('%10.4f'%(x))Â Â Â Â Â Â Â Â |
---|
3633 |         if rbType == 'Vector': |
---|
3634 | Â Â Â Â Â Â Â Â Â Â Oxyz =Â np.inner(Bmat,G2mth.prodQVQ(QuatC,rbOrig)) |
---|
3635 | Â Â Â Â Â Â Â Â Â Â Nxyz =Â np.array(atomData[atInd[0]][cx:cx+3]) |
---|
3636 | Â Â Â Â Â Â Â Â Â Â Orig =Â Nxyz-Oxyz |
---|
3637 | Â Â Â Â Â Â Â Â Â Â data['testRBObj']['rbObj']['Orig'][0]Â =Â Orig |
---|
3638 |           for x,item in zip(Orig,Xsizers): |
---|
3639 | Â Â Â Â Â Â Â Â Â Â Â Â item.SetLabel('%10.5f'%(x)) |
---|
3640 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3641 | Â Â Â Â Â Â Â Â |
---|
3642 |       def OnTorAngle(event): |
---|
3643 | Â Â Â Â Â Â Â Â OkBtn.SetLabel('OK') |
---|
3644 | Â Â Â Â Â Â Â Â OkBtn.Enable(True) |
---|
3645 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3646 | Â Â Â Â Â Â Â Â [tor,torSlide]Â =Â Indx[Obj.GetId()] |
---|
3647 | Â Â Â Â Â Â Â Â Tors =Â data['testRBObj']['rbObj']['Torsions'][tor] |
---|
3648 | Â Â Â Â Â Â Â Â try: |
---|
3649 | Â Â Â Â Â Â Â Â Â Â value =Â float(Obj.GetValue()) |
---|
3650 |         except ValueError: |
---|
3651 | Â Â Â Â Â Â Â Â Â Â value =Â Tors[0] |
---|
3652 | Â Â Â Â Â Â Â Â Tors[0]Â =Â value |
---|
3653 | Â Â Â Â Â Â Â Â Obj.SetValue('%8.3f'%(value)) |
---|
3654 | Â Â Â Â Â Â Â Â torSlide.SetValue(int(value*10)) |
---|
3655 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3656 | Â Â Â Â Â Â Â Â |
---|
3657 |       def OnTorSlide(event): |
---|
3658 | Â Â Â Â Â Â Â Â OkBtn.SetLabel('OK') |
---|
3659 | Â Â Â Â Â Â Â Â OkBtn.Enable(True) |
---|
3660 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3661 | Â Â Â Â Â Â Â Â tor,ang =Â Indx[Obj.GetId()] |
---|
3662 | Â Â Â Â Â Â Â Â Tors =Â data['testRBObj']['rbObj']['Torsions'][tor] |
---|
3663 | Â Â Â Â Â Â Â Â val =Â float(Obj.GetValue())/10. |
---|
3664 | Â Â Â Â Â Â Â Â Tors[0]Â =Â val |
---|
3665 | Â Â Â Â Â Â Â Â ang.SetValue('%8.3f'%(val)) |
---|
3666 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3667 | |
---|
3668 |       if len(data['testRBObj']): |
---|
3669 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3670 | Â Â Â Â Â Â Â Â Â Â |
---|
3671 | Â Â Â Â Â Â RigidBodies.DestroyChildren() |
---|
3672 | Â Â Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
3673 | Â Â Â Â Â Â mainSizer.Add((5,5),0) |
---|
3674 |       if data['testRBObj']: |
---|
3675 | Â Â Â Â Â Â Â Â Xsizers =Â [] |
---|
3676 | Â Â Â Â Â Â Â Â Osizers =Â [] |
---|
3677 | Â Â Â Â Â Â Â Â rbObj =Â data['testRBObj']['rbObj'] |
---|
3678 | Â Â Â Â Â Â Â Â rbName =Â rbObj['RBname'] |
---|
3679 | Â Â Â Â Â Â Â Â rbId =Â rbObj['RBId'] |
---|
3680 | Â Â Â Â Â Â Â Â Orig =Â rbObj['Orig'][0] |
---|
3681 | Â Â Â Â Â Â Â Â Orien =Â rbObj['Orient'][0] |
---|
3682 | Â Â Â Â Â Â Â Â rbRef =Â data['testRBObj']['rbRef'] |
---|
3683 | Â Â Â Â Â Â Â Â Torsions =Â rbObj['Torsions'] |
---|
3684 | Â Â Â Â Â Â Â Â refName =Â [] |
---|
3685 |         for ref in rbRef: |
---|
3686 | Â Â Â Â Â Â Â Â Â Â refName.append(data['testRBObj']['rbAtTypes'][ref]+str(ref)) |
---|
3687 | Â Â Â Â Â Â Â Â atNames =Â data['testRBObj']['atNames'] |
---|
3688 | Â Â Â Â Â Â Â Â mainSizer.Add(wx.StaticText(RigidBodies,-1,'Locate rigid body : '+rbName), |
---|
3689 | Â Â Â Â Â Â Â Â Â Â 0,wx.ALIGN_CENTER_VERTICAL) |
---|
3690 | Â Â Â Â Â Â Â Â mainSizer.Add((5,5),0) |
---|
3691 | Â Â Â Â Â Â Â Â OriSizer =Â wx.FlexGridSizer(1,5,5,5) |
---|
3692 | Â Â Â Â Â Â Â Â OriSizer.Add(wx.StaticText(RigidBodies,-1,'Origin x,y,z: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3693 |         for ix,x in enumerate(Orig): |
---|
3694 | Â Â Â Â Â Â Â Â Â Â origX =Â wx.StaticText(RigidBodies,-1,'%10.5f'%(x)) |
---|
3695 | Â Â Â Â Â Â Â Â Â Â OriSizer.Add(origX,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3696 | Â Â Â Â Â Â Â Â Â Â Xsizers.append(origX) |
---|
3697 | Â Â Â Â Â Â Â Â OriSizer.Add((5,0),) |
---|
3698 |         if len(atomData): |
---|
3699 | Â Â Â Â Â Â Â Â Â Â choice =Â atNames[0].keys() |
---|
3700 | Â Â Â Â Â Â Â Â Â Â choice.sort() |
---|
3701 | Â Â Â Â Â Â Â Â Â Â data['testRBObj']['Sizers']['Xsizers']Â =Â Xsizers |
---|
3702 | Â Â Â Â Â Â Â Â OriSizer.Add(wx.StaticText(RigidBodies,-1,'Orientation quaternion: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3703 |         for ix,x in enumerate(Orien): |
---|
3704 | Â Â Â Â Â Â Â Â Â Â orien =Â wx.StaticText(RigidBodies,-1,'%10.4f'%(x)) |
---|
3705 | Â Â Â Â Â Â Â Â Â Â OriSizer.Add(orien,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3706 | Â Â Â Â Â Â Â Â Â Â Osizers.append(orien) |
---|
3707 | Â Â Â Â Â Â Â Â data['testRBObj']['Sizers']['Osizers']Â =Â Osizers |
---|
3708 | Â Â Â Â Â Â Â Â mainSizer.Add(OriSizer) |
---|
3709 | Â Â Â Â Â Â Â Â mainSizer.Add((5,5),0) |
---|
3710 | Â Â Â Â Â Â Â Â RefSizer =Â wx.FlexGridSizer(1,7,5,5) |
---|
3711 |         if len(atomData): |
---|
3712 | Â Â Â Â Â Â Â Â Â Â RefSizer.Add(wx.StaticText(RigidBodies,-1,'Location setting: Select match to'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3713 |           for i in [0,1,2]: |
---|
3714 | Â Â Â Â Â Â Â Â Â Â Â Â choice =Â ['',]+atNames[i].keys() |
---|
3715 | Â Â Â Â Â Â Â Â Â Â Â Â choice.sort() |
---|
3716 | Â Â Â Â Â Â Â Â Â Â Â Â RefSizer.Add(wx.StaticText(RigidBodies,-1,' '+refName[i]+': '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3717 | Â Â Â Â Â Â Â Â Â Â Â Â atPick =Â wx.ComboBox(RigidBodies,-1,value='', |
---|
3718 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â choices=choice[1:],style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
3719 |             if i: |
---|
3720 |               atPick.Bind(wx.EVT_COMBOBOX, OnAtQPick) |
---|
3721 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
3722 |               atPick.Bind(wx.EVT_COMBOBOX, OnAtOrigPick)              |
---|
3723 | Â Â Â Â Â Â Â Â Â Â Â Â Indx[atPick.GetId()]Â =Â i |
---|
3724 | Â Â Â Â Â Â Â Â Â Â Â Â RefSizer.Add(atPick,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3725 | Â Â Â Â Â Â Â Â mainSizer.Add(RefSizer) |
---|
3726 | Â Â Â Â Â Â Â Â mainSizer.Add((5,5),0) |
---|
3727 |         if Torsions:          |
---|
3728 | Â Â Â Â Â Â Â Â Â Â AtNames =Â data['testRBObj']['AtNames'] |
---|
3729 | Â Â Â Â Â Â Â Â Â Â rbAtTypes =Â data['testRBObj']['rbAtTypes'] |
---|
3730 | Â Â Â Â Â Â Â Â Â Â rbSeq =Â RBData['Residue'][rbId]['rbSeq'] |
---|
3731 | Â Â Â Â Â Â Â Â Â Â TorSizer =Â wx.FlexGridSizer(1,4) |
---|
3732 | Â Â Â Â Â Â Â Â Â Â TorSizer.AddGrowableCol(1,1) |
---|
3733 |           for t,[torsion,seq] in enumerate(zip(Torsions,rbSeq)): |
---|
3734 | Â Â Â Â Â Â Â Â Â Â Â Â torName =Â '' |
---|
3735 |             for item in [seq[0],seq[1],seq[3][0]]: |
---|
3736 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â torName +=Â data['testRBObj']['rbAtTypes'][item]+str(item)+' ' |
---|
3737 | Â Â Â Â Â Â Â Â Â Â Â Â TorSizer.Add(wx.StaticText(RigidBodies,-1,'Side chain torsion for rb seq: '+torName),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3738 | Â Â Â Â Â Â Â Â Â Â Â Â torSlide =Â wx.Slider(RigidBodies,style=wx.SL_HORIZONTAL) |
---|
3739 | Â Â Â Â Â Â Â Â Â Â Â Â torSlide.SetRange(0,3600) |
---|
3740 | Â Â Â Â Â Â Â Â Â Â Â Â torSlide.SetValue(int(torsion[0]*10.)) |
---|
3741 |             torSlide.Bind(wx.EVT_SLIDER, OnTorSlide) |
---|
3742 | Â Â Â Â Â Â Â Â Â Â Â Â TorSizer.Add(torSlide,1,wx.EXPAND|wx.RIGHT) |
---|
3743 | Â Â Â Â Â Â Â Â Â Â Â Â TorSizer.Add(wx.StaticText(RigidBodies,-1,' Angle: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3744 | Â Â Â Â Â Â Â Â Â Â Â Â ang =Â wx.TextCtrl(RigidBodies,-1,value='%8.3f'%(torsion[0]),style=wx.TE_PROCESS_ENTER) |
---|
3745 | Â Â Â Â Â Â Â Â Â Â Â Â ang.Bind(wx.EVT_TEXT_ENTER,OnTorAngle) |
---|
3746 | Â Â Â Â Â Â Â Â Â Â Â Â ang.Bind(wx.EVT_KILL_FOCUS,OnTorAngle) |
---|
3747 | Â Â Â Â Â Â Â Â Â Â Â Â Indx[torSlide.GetId()]Â =Â [t,ang] |
---|
3748 | Â Â Â Â Â Â Â Â Â Â Â Â Indx[ang.GetId()]Â =Â [t,torSlide] |
---|
3749 | Â Â Â Â Â Â Â Â Â Â Â Â TorSizer.Add(ang,0,wx.ALIGN_CENTER_VERTICAL)Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
3750 | Â Â Â Â Â Â Â Â Â Â mainSizer.Add(TorSizer,1,wx.EXPAND|wx.RIGHT) |
---|
3751 | Â Â Â Â Â Â Â Â else: |
---|
3752 | Â Â Â Â Â Â Â Â Â Â mainSizer.Add(wx.StaticText(RigidBodies,-1,'No side chain torsions'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3753 | Â Â Â Â Â Â else: |
---|
3754 | Â Â Â Â Â Â Â Â mainSizer.Add(wx.StaticText(RigidBodies,-1,'Assign rigid body:'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3755 | Â Â Â Â Â Â Â Â mainSizer.Add((5,5),0) |
---|
3756 | Â Â Â Â Â Â Â Â topSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
3757 | Â Â Â Â Â Â Â Â topSizer.Add(wx.StaticText(RigidBodies,-1,'Select rigid body model'),0,wx.ALIGN_CENTER_VERTICAL) |
---|
3758 | Â Â Â Â Â Â Â Â rbSel =Â wx.ComboBox(RigidBodies,-1,value='',choices=rbNames.keys(), |
---|
3759 | Â Â Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
3760 |         rbSel.Bind(wx.EVT_COMBOBOX, OnRBSel) |
---|
3761 | Â Â Â Â Â Â Â Â topSizer.Add((5,5),0) |
---|
3762 | Â Â Â Â Â Â Â Â topSizer.Add(rbSel,0,wx.ALIGN_CENTER_VERTICAL) |
---|
3763 | Â Â Â Â Â Â Â Â mainSizer.Add(topSizer)Â Â Â Â Â Â Â Â |
---|
3764 | Â Â Â Â Â Â Â Â |
---|
3765 | Â Â Â Â Â Â OkBtn =Â wx.Button(RigidBodies,-1,"Not ready") |
---|
3766 |       OkBtn.Bind(wx.EVT_BUTTON, OnOk) |
---|
3767 | Â Â Â Â Â Â OkBtn.Enable(False) |
---|
3768 | Â Â Â Â Â Â CancelBtn =Â wx.Button(RigidBodies,-1,'Cancel') |
---|
3769 |       CancelBtn.Bind(wx.EVT_BUTTON, OnCancel) |
---|
3770 | Â Â Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
3771 | Â Â Â Â Â Â btnSizer.Add((20,20),1) |
---|
3772 | Â Â Â Â Â Â btnSizer.Add(OkBtn) |
---|
3773 | Â Â Â Â Â Â btnSizer.Add(CancelBtn) |
---|
3774 | Â Â Â Â Â Â btnSizer.Add((20,20),1) |
---|
3775 |       mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
3776 | Â Â Â Â Â Â SetPhaseWindow(G2frame.dataFrame,RigidBodies,mainSizer) |
---|
3777 | Â Â Â Â Draw() |
---|
3778 | Â Â Â Â |
---|
3779 |   def OnAutoFindResRB(event): |
---|
3780 | Â Â Â Â RBData =Â G2frame.PatternTree.GetItemPyData(Â Â |
---|
3781 | Â Â Â Â Â Â G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Rigid bodies')) |
---|
3782 | Â Â Â Â rbKeys =Â RBData['Residue'].keys() |
---|
3783 | Â Â Â Â rbKeys.remove('AtInfo') |
---|
3784 |     if not len(rbKeys): |
---|
3785 |       print '**** ERROR - no residue rigid bodies are defined ****' |
---|
3786 | Â Â Â Â Â Â return |
---|
3787 |     RBNames = [RBData['Residue'][k]['RBname'] for k in rbKeys] |
---|
3788 | Â Â Â Â RBIds =Â dict(zip(RBNames,rbKeys)) |
---|
3789 | Â Â Â Â general =Â data['General'] |
---|
3790 | Â Â Â Â Amat,Bmat =Â G2lat.cell2AB(general['Cell'][1:7]) |
---|
3791 | Â Â Â Â Atoms =Â data['Atoms'] |
---|
3792 | Â Â Â Â AtLookUp =Â G2mth.FillAtomLookUp(Atoms) |
---|
3793 |     if 'macro' not in general['Type']: |
---|
3794 |       print '**** ERROR - this phase is not a macromolecule ****' |
---|
3795 | Â Â Â Â Â Â return |
---|
3796 |     if not len(Atoms): |
---|
3797 |       print '**** ERROR - this phase has no atoms ****' |
---|
3798 | Â Â Â Â Â Â return |
---|
3799 | Â Â Â Â RBObjs =Â [] |
---|
3800 | Â Â Â Â cx,ct =Â general['AtomPtrs'][:2] |
---|
3801 | Â Â Â Â iatm =Â 0 |
---|
3802 | Â Â Â Â wx.BeginBusyCursor() |
---|
3803 | Â Â Â Â try: |
---|
3804 |       while iatm < len(Atoms): |
---|
3805 | Â Â Â Â Â Â Â Â atom =Â Atoms[iatm] |
---|
3806 | Â Â Â Â Â Â Â Â res =Â atom[1].strip() |
---|
3807 |         numChain = ' %s %s'%(atom[0],atom[2]) |
---|
3808 |         if res not in RBIds or atom[ct-1] == 'OXT': |
---|
3809 | Â Â Â Â Â Â Â Â Â Â iatm +=Â 1 |
---|
3810 |           continue    #skip for OXT, water molecules, etc. |
---|
3811 | Â Â Â Â Â Â Â Â rbRes =Â RBData['Residue'][RBIds[res]] |
---|
3812 | Â Â Â Â Â Â Â Â rbRef =Â rbRes['rbRef'] |
---|
3813 | Â Â Â Â Â Â Â Â VAR =Â rbRes['rbXYZ'][rbRef[1]]-rbRes['rbXYZ'][rbRef[0]] |
---|
3814 | Â Â Â Â Â Â Â Â VBR =Â rbRes['rbXYZ'][rbRef[2]]-rbRes['rbXYZ'][rbRef[0]] |
---|
3815 | Â Â Â Â Â Â Â Â rbObj =Â {'RBname':rbRes['RBname']+':'+str(rbRes['useCount']),'numChain':numChain} |
---|
3816 | Â Â Â Â Â Â Â Â rbAtoms =Â [] |
---|
3817 | Â Â Â Â Â Â Â Â rbIds =Â [] |
---|
3818 |         for iratm in range(len(rbRes['atNames'])): |
---|
3819 | Â Â Â Â Â Â Â Â Â Â rbAtoms.append(np.array(Atoms[iatm][cx:cx+3])) |
---|
3820 | Â Â Â Â Â Â Â Â Â Â rbIds.append(Atoms[iatm][20]) |
---|
3821 | Â Â Â Â Â Â Â Â Â Â iatm +=Â 1Â Â #puts this at beginning of next residue? |
---|
3822 | Â Â Â Â Â Â Â Â Orig =Â rbAtoms[rbRef[0]] |
---|
3823 | Â Â Â Â Â Â Â Â rbObj['RBId']Â =Â RBIds[res] |
---|
3824 | Â Â Â Â Â Â Â Â rbObj['Ids']Â =Â rbIds |
---|
3825 | Â Â Â Â Â Â Â Â rbObj['Orig']Â =Â [Orig,False] |
---|
3826 | #Â Â Â Â Â Â Â Â print ' residue '+rbRes['RBname']+str(atom[0]).strip()+ \ |
---|
3827 | #Â Â Â Â Â Â Â Â Â Â ' origin at: ','%.5f %.5f %.5f'%(Orig[0],Orig[1],Orig[2]) |
---|
3828 | Â Â Â Â Â Â Â Â VAC =Â np.inner(Amat,rbAtoms[rbRef[1]]-Orig) |
---|
3829 | Â Â Â Â Â Â Â Â VBC =Â np.inner(Amat,rbAtoms[rbRef[2]]-Orig) |
---|
3830 | Â Â Â Â Â Â Â Â VCC =Â np.cross(VAR,VAC) |
---|
3831 | Â Â Â Â Â Â Â Â QuatA =Â G2mth.makeQuat(VAR,VAC,VCC)[0] |
---|
3832 | Â Â Â Â Â Â Â Â VAR =Â G2mth.prodQVQ(QuatA,VAR) |
---|
3833 | Â Â Â Â Â Â Â Â VBR =Â G2mth.prodQVQ(QuatA,VBR) |
---|
3834 | Â Â Â Â Â Â Â Â QuatB =Â G2mth.makeQuat(VBR,VBC,VAR)[0] |
---|
3835 | Â Â Â Â Â Â Â Â QuatC =Â G2mth.prodQQ(QuatB,QuatA) |
---|
3836 | Â Â Â Â Â Â Â Â rbObj['Orient']Â =Â [QuatC,' '] |
---|
3837 |         rbObj['ThermalMotion'] = ['None',[0. for i in range(21)],[False for i in range(21)]] #type,values,flags |
---|
3838 | Â Â Â Â Â Â Â Â SXYZ =Â [] |
---|
3839 | Â Â Â Â Â Â Â Â TXYZ =Â [] |
---|
3840 | Â Â Â Â Â Â Â Â rbObj['Torsions']Â =Â [] |
---|
3841 |         for i,xyz in enumerate(rbRes['rbXYZ']): |
---|
3842 | Â Â Â Â Â Â Â Â Â Â SXYZ.append(G2mth.prodQVQ(QuatC,xyz))Â Â Â Â Â Â Â Â |
---|
3843 | Â Â Â Â Â Â Â Â Â Â TXYZ.append(np.inner(Amat,rbAtoms[i]-Orig)) |
---|
3844 |         for Oatm,Patm,x,Riders in rbRes['rbSeq']: |
---|
3845 | Â Â Â Â Â Â Â Â Â Â VBR =Â SXYZ[Oatm]-SXYZ[Patm] |
---|
3846 | Â Â Â Â Â Â Â Â Â Â VAR =Â SXYZ[Riders[0]]-SXYZ[Patm] |
---|
3847 | Â Â Â Â Â Â Â Â Â Â VAC =Â TXYZ[Riders[0]]-TXYZ[Patm] |
---|
3848 | Â Â Â Â Â Â Â Â Â Â QuatA,D =Â G2mth.makeQuat(VAR,VAC,VBR) |
---|
3849 | Â Â Â Â Â Â Â Â Â Â ang =Â 180.*D/np.pi |
---|
3850 | Â Â Â Â Â Â Â Â Â Â rbObj['Torsions'].append([ang,False]) |
---|
3851 |           for ride in Riders: |
---|
3852 | Â Â Â Â Â Â Â Â Â Â Â Â SXYZ[ride]Â =Â G2mth.prodQVQ(QuatA,SXYZ[ride]-SXYZ[Patm])+SXYZ[Patm] |
---|
3853 | Â Â Â Â Â Â Â Â rbRes['useCount']Â +=Â 1 |
---|
3854 | Â Â Â Â Â Â Â Â RBObjs.append(rbObj) |
---|
3855 | Â Â Â Â Â Â data['RBModels']['Residue']Â =Â RBObjs |
---|
3856 |       for RBObj in RBObjs: |
---|
3857 | Â Â Â Â Â Â Â Â newXYZ =Â G2mth.UpdateRBXYZ(Bmat,RBObj,RBData,'Residue')[0] |
---|
3858 |         for i,id in enumerate(RBObj['Ids']): |
---|
3859 | Â Â Â Â Â Â Â Â Â Â data['Atoms'][AtLookUp[id]][cx:cx+3]Â =Â newXYZ[i] |
---|
3860 | Â Â Â Â finally: |
---|
3861 | Â Â Â Â Â Â wx.EndBusyCursor() |
---|
3862 | Â Â Â Â wx.CallAfter(FillRigidBodyGrid,True) |
---|
3863 | Â Â Â Â |
---|
3864 |   def OnRBRemoveAll(event): |
---|
3865 | Â Â Â Â data['RBModels']['Residue']Â =Â [] |
---|
3866 | Â Â Â Â data['RBModels']['Vector']Â =Â [] |
---|
3867 | Â Â Â Â RBData =Â G2frame.PatternTree.GetItemPyData(Â Â |
---|
3868 | Â Â Â Â Â Â G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Rigid bodies')) |
---|
3869 |     for RBType in ['Vector','Residue']: |
---|
3870 |       for rbId in RBData[RBType]: |
---|
3871 | Â Â Â Â Â Â Â Â RBData[RBType][rbId]['useCount']Â =Â 0Â Â Â Â |
---|
3872 | Â Â Â Â FillRigidBodyGrid(True) |
---|
3873 | Â Â Â Â |
---|
3874 |   def OnGlobalResRBTherm(event): |
---|
3875 | Â Â Â Â AtLookUp =Â G2mth.FillAtomLookUp(data['Atoms']) |
---|
3876 | Â Â Â Â RBObjs =Â data['RBModels']['Residue'] |
---|
3877 | Â Â Â Â names =Â ['None','Uiso','T','TL','TLS'] |
---|
3878 | Â Â Â Â cia =Â data['General']['AtomPtrs'][3] |
---|
3879 | Â Â Â Â dlg =Â wx.SingleChoiceDialog(G2frame,'Select','Residue thermal motion model',names) |
---|
3880 |     if dlg.ShowModal() == wx.ID_OK: |
---|
3881 | Â Â Â Â Â Â sel =Â dlg.GetSelection() |
---|
3882 | Â Â Â Â Â Â parm =Â names[sel] |
---|
3883 | Â Â Â Â Â Â Ttype =Â 'A' |
---|
3884 |       if parm == 'Uiso': |
---|
3885 | Â Â Â Â Â Â Â Â Ttype =Â 'I'Â Â Â Â |
---|
3886 |       for rbObj in RBObjs: |
---|
3887 | Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][0]Â =Â parm |
---|
3888 |         if parm != 'None': |
---|
3889 |           for i,id in enumerate(rbObj['Ids']): |
---|
3890 | Â Â Â Â Â Â Â Â Â Â Â Â data['Atoms'][AtLookUp[id]][cia]Â =Â Ttype |
---|
3891 | Â Â Â Â dlg.Destroy() |
---|
3892 | Â Â Â Â wx.CallAfter(FillRigidBodyGrid,True) |
---|
3893 | |
---|
3894 |   def OnGlobalResRBRef(event): |
---|
3895 | Â Â Â Â RBObjs =Â data['RBModels']['Residue'] |
---|
3896 | Â Â Â Â names =Â ['Origin','Orient. angle','Full Orient.'] |
---|
3897 | Â Â Â Â nTor =Â 0 |
---|
3898 |     for rbObj in RBObjs: |
---|
3899 | Â Â Â Â Â Â nTor =Â max(nTor,len(rbObj['Torsions'])) |
---|
3900 |     names += ['Torsion '+str(i) for i in range(nTor)] |
---|
3901 |     if np.any([rbObj['ThermalMotion'][0] == 'Uiso' for rbObj in RBObjs]): |
---|
3902 | Â Â Â Â Â Â names +=Â ['Uiso',] |
---|
3903 |     if np.any([rbObj['ThermalMotion'][0] == 'TLS' for rbObj in RBObjs]): |
---|
3904 | Â Â Â Â Â Â names +=Â ['Tii','Tij','Lii','Lij','Sij'] |
---|
3905 |     elif np.any([rbObj['ThermalMotion'][0] == 'TL' for rbObj in RBObjs]): |
---|
3906 | Â Â Â Â Â Â names +=Â ['Tii','Tij','Lii','Lij'] |
---|
3907 |     elif np.any([rbObj['ThermalMotion'][0] == 'T' for rbObj in RBObjs]): |
---|
3908 | Â Â Â Â Â Â names +=Â ['Tii','Tij'] |
---|
3909 | |
---|
3910 | Â Â Â Â dlg =Â wx.MultiChoiceDialog(G2frame,'Select','Refinement controls',names) |
---|
3911 |     if dlg.ShowModal() == wx.ID_OK: |
---|
3912 | Â Â Â Â Â Â sel =Â dlg.GetSelections() |
---|
3913 | Â Â Â Â Â Â parms =Â [] |
---|
3914 |       for x in sel: |
---|
3915 | Â Â Â Â Â Â Â Â parms.append(names[x]) |
---|
3916 | Â Â Â Â Â Â wx.BeginBusyCursor() |
---|
3917 | Â Â Â Â Â Â try: |
---|
3918 |         for rbObj in RBObjs: |
---|
3919 |           if 'Origin' in parms: |
---|
3920 | Â Â Â Â Â Â Â Â Â Â Â Â rbObj['Orig'][1]Â =Â True |
---|
3921 | Â Â Â Â Â Â Â Â Â Â else: |
---|
3922 | Â Â Â Â Â Â Â Â Â Â Â Â rbObj['Orig'][1]Â =Â False |
---|
3923 |           if 'Full Orient.' in parms: |
---|
3924 | Â Â Â Â Â Â Â Â Â Â Â Â rbObj['Orient'][1]Â =Â 'AV' |
---|
3925 |           elif 'Orient. angle' in parms: |
---|
3926 | Â Â Â Â Â Â Â Â Â Â Â Â rbObj['Orient'][1]Â =Â 'A' |
---|
3927 | Â Â Â Â Â Â Â Â Â Â else: |
---|
3928 | Â Â Â Â Â Â Â Â Â Â Â Â rbObj['Orient'][1]Â =Â ' ' |
---|
3929 |           for i in range(len(rbObj['Torsions'])): |
---|
3930 |             if 'Torsion '+str(i) in parms: |
---|
3931 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['Torsions'][i][1]Â =Â True |
---|
3932 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
3933 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['Torsions'][i][1]Â =Â False |
---|
3934 |           if rbObj['ThermalMotion'][0] == 'Uiso': |
---|
3935 |             if 'Uiso' in parms: |
---|
3936 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][2][0]Â =Â True |
---|
3937 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
3938 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][2][0]Â =Â False |
---|
3939 |           elif 'T' in rbObj['ThermalMotion'][0]: |
---|
3940 |             if 'Tii' in parms: |
---|
3941 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][2][0:2]Â =Â [True,True,True] |
---|
3942 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
3943 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][2][0:2]Â =Â [False,False,False] |
---|
3944 |             if 'Tij' in parms: |
---|
3945 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][2][3:6]Â =Â [True,True,True] |
---|
3946 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
3947 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][2][3:6]Â =Â [False,False,False] |
---|
3948 |           elif 'L' in rbObj['ThermalMotion'][0]: |
---|
3949 |             if 'Lii' in parms: |
---|
3950 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][2][6:9]Â =Â [True,True,True] |
---|
3951 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
3952 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][2][6:9]Â =Â [False,False,False] |
---|
3953 |             if 'Lij' in parms: |
---|
3954 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][2][9:12]Â =Â [True,True,True] |
---|
3955 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
3956 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][2][9:12]Â =Â [False,False,False] |
---|
3957 |           elif 'S' in rbObj['ThermalMotion'][0]: |
---|
3958 |             if 'Sij' in parms: |
---|
3959 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][2][12:20]Â =Â [True,True,True,True,True,True,True,True] |
---|
3960 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
---|
3961 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â rbObj['ThermalMotion'][2][12:20]Â =Â [False,False,False,False,False,False,False,False] |
---|
3962 | Â Â Â Â Â Â finally: |
---|
3963 | Â Â Â Â Â Â Â Â wx.EndBusyCursor() |
---|
3964 | Â Â Â Â Â Â FillRigidBodyGrid() |
---|
3965 | Â Â Â Â Â Â |
---|
3966 | ################################################################################ |
---|
3967 | ##### MC/SA routines |
---|
3968 | ################################################################################ |
---|
3969 | |
---|
3970 |   def UpdateMCSA(refresh=True): |
---|
3971 | Â Â Â Â Indx =Â {} |
---|
3972 | Â Â Â Â |
---|
3973 |     def OnPosRef(event): |
---|
3974 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3975 | Â Â Â Â Â Â model,item,ix =Â Indx[Obj.GetId()] |
---|
3976 | Â Â Â Â Â Â model[item][1][ix]Â =Â Obj.GetValue() |
---|
3977 | Â Â Â Â Â Â |
---|
3978 |     def OnPosVal(event): |
---|
3979 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3980 | Â Â Â Â Â Â model,item,ix =Â Indx[Obj.GetId()] |
---|
3981 | Â Â Â Â Â Â try: |
---|
3982 | Â Â Â Â Â Â Â Â model[item][0][ix]Â =Â float(Obj.GetValue()) |
---|
3983 |       except ValueError: |
---|
3984 | Â Â Â Â Â Â Â Â pass |
---|
3985 | Â Â Â Â Â Â Obj.SetValue("%.4f"%(model[item][0][ix])) |
---|
3986 | Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
3987 | Â Â Â Â Â Â |
---|
3988 |     def OnPosRange(event): |
---|
3989 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
3990 | Â Â Â Â Â Â model,item,ix =Â Indx[Obj.GetId()] |
---|
3991 | Â Â Â Â Â Â Range =Â Obj.GetValue().split() |
---|
3992 | Â Â Â Â Â Â try: |
---|
3993 |         rmin,rmax = [float(Range[i]) for i in range(2)] |
---|
3994 |         if rmin >= rmax: |
---|
3995 |           raise ValueError |
---|
3996 |       except (ValueError,IndexError): |
---|
3997 | Â Â Â Â Â Â Â Â rmin,rmax =Â model[item][2][ix] |
---|
3998 | Â Â Â Â Â Â model[item][2][ix]Â =Â [rmin,rmax] |
---|
3999 |       Obj.SetValue('%.3f %.3f'%(rmin,rmax))         |
---|
4000 | Â Â Â Â Â Â Â Â |
---|
4001 |     def atomSizer(model): |
---|
4002 | Â Â Â Â Â Â |
---|
4003 | Â Â Â Â Â Â atomsizer =Â wx.FlexGridSizer(1,7,5,5) |
---|
4004 | Â Â Â Â Â Â atomsizer.Add(wx.StaticText(MCSA,-1,' Atom: '+model['name']+': '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
4005 |       for ix,item in enumerate(['x','y','z']): |
---|
4006 | Â Â Â Â Â Â Â Â posRef =Â wx.CheckBox(MCSA,-1,label=item+': ') |
---|
4007 | Â Â Â Â Â Â Â Â posRef.SetValue(model['Pos'][1][ix]) |
---|
4008 | Â Â Â Â Â Â Â Â posRef.Bind(wx.EVT_CHECKBOX,OnPosRef) |
---|
4009 | Â Â Â Â Â Â Â Â Indx[posRef.GetId()]Â =Â [model,'Pos',ix] |
---|
4010 | Â Â Â Â Â Â Â Â atomsizer.Add(posRef,0,wx.ALIGN_CENTER_VERTICAL) |
---|
4011 | Â Â Â Â Â Â Â Â posVal =Â wx.TextCtrl(MCSA,-1,'%.4f'%(model['Pos'][0][ix]),style=wx.TE_PROCESS_ENTER) |
---|
4012 | Â Â Â Â Â Â Â Â posVal.Bind(wx.EVT_TEXT_ENTER,OnPosVal) |
---|
4013 | Â Â Â Â Â Â Â Â posVal.Bind(wx.EVT_KILL_FOCUS,OnPosVal) |
---|
4014 | Â Â Â Â Â Â Â Â Indx[posVal.GetId()]Â =Â [model,'Pos',ix] |
---|
4015 | Â Â Â Â Â Â Â Â atomsizer.Add(posVal,0,wx.ALIGN_CENTER_VERTICAL) |
---|
4016 | Â Â Â Â Â Â atomsizer.Add((5,5),0) |
---|
4017 |       for ix,item in enumerate(['x','y','z']): |
---|
4018 | Â Â Â Â Â Â Â Â atomsizer.Add(wx.StaticText(MCSA,-1,' Range: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
4019 | Â Â Â Â Â Â Â Â rmin,rmax =Â model['Pos'][2][ix] |
---|
4020 |         posRange = wx.TextCtrl(MCSA,-1,'%.3f %.3f'%(rmin,rmax),style=wx.TE_PROCESS_ENTER) |
---|
4021 | Â Â Â Â Â Â Â Â Indx[posRange.GetId()]Â =Â [model,'Pos',ix] |
---|
4022 | Â Â Â Â Â Â Â Â posRange.Bind(wx.EVT_TEXT_ENTER,OnPosRange) |
---|
4023 | Â Â Â Â Â Â Â Â posRange.Bind(wx.EVT_KILL_FOCUS,OnPosRange) |
---|
4024 | Â Â Â Â Â Â Â Â atomsizer.Add(posRange,0,wx.ALIGN_CENTER_VERTICAL) |
---|
4025 |       return atomsizer |
---|
4026 | Â Â Â Â Â Â |
---|
4027 |     def rbSizer(model): |
---|
4028 | Â Â Â Â Â Â |
---|
4029 |       def OnOrVar(event): |
---|
4030 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
4031 | Â Â Â Â Â Â Â Â model =Â Indx[Obj.GetId()] |
---|
4032 | Â Â Â Â Â Â Â Â model['Ovar']Â =Â Obj.GetValue() |
---|
4033 | Â Â Â Â Â Â |
---|
4034 |       def OnOriVal(event): |
---|
4035 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
4036 | Â Â Â Â Â Â Â Â model,ix =Â Indx[Obj.GetId()] |
---|
4037 | Â Â Â Â Â Â Â Â A,V =Â G2mth.Q2AVdeg(model['Ori'][0]) |
---|
4038 |         if ix: |
---|
4039 | Â Â Â Â Â Â Â Â Â Â Anew =Â A |
---|
4040 | Â Â Â Â Â Â Â Â Â Â Vec =Â Obj.GetValue().split() |
---|
4041 | Â Â Â Â Â Â Â Â Â Â try: |
---|
4042 |             Vnew = [float(Vec[i]) for i in range(3)] |
---|
4043 |           except ValueError: |
---|
4044 | Â Â Â Â Â Â Â Â Â Â Â Â Vnew =Â V |
---|
4045 | Â Â Â Â Â Â Â Â else: |
---|
4046 | Â Â Â Â Â Â Â Â Â Â Vnew =Â V |
---|
4047 | Â Â Â Â Â Â Â Â Â Â try: |
---|
4048 | Â Â Â Â Â Â Â Â Â Â Â Â Anew =Â float(Obj.GetValue()) |
---|
4049 |           except ValueError: |
---|
4050 | Â Â Â Â Â Â Â Â Â Â Â Â Anew =Â A |
---|
4051 | Â Â Â Â Â Â Â Â model['Ori'][0]Â =Â G2mth.AVdeg2Q(Anew,Vnew) |
---|
4052 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
4053 | Â Â Â Â Â Â Â Â UpdateMCSA() |
---|
4054 | |
---|
4055 |       def OnMolCent(event): |
---|
4056 | Â Â Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
4057 | Â Â Â Â Â Â Â Â model =Â Indx[Obj.GetId()] |
---|
4058 | Â Â Â Â Â Â Â Â model['MolCent'][1]Â =Â Obj.GetValue() |
---|
4059 |         if model['MolCent'][1]: |
---|
4060 | Â Â Â Â Â Â Â Â Â Â G2mth.SetMolCent(model,RBData)Â Â Â Â Â Â Â Â |
---|
4061 | Â Â Â Â Â Â Â Â G2plt.PlotStructure(G2frame,data) |
---|
4062 | Â Â Â Â Â Â |
---|
4063 | Â Â Â Â Â Â rbsizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
4064 | Â Â Â Â Â Â rbsizer1 =Â wx.FlexGridSizer(1,7,5,5) |
---|
4065 | Â Â Â Â Â Â rbsizer1.Add(wx.StaticText(MCSA,-1,model['Type']+': '+model['name']+': '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
4066 |       for ix,item in enumerate(['x','y','z']): |
---|
4067 | Â Â Â Â Â Â Â Â posRef =Â wx.CheckBox(MCSA,-1,label=item+': ') |
---|
4068 | Â Â Â Â Â Â Â Â posRef.SetValue(model['Pos'][1][ix]) |
---|
4069 | Â Â Â Â Â Â Â Â posRef.Bind(wx.EVT_CHECKBOX,OnPosRef) |
---|
4070 | Â Â Â Â Â Â Â Â Indx[posRef.GetId()]Â =Â [model,'Pos',ix] |
---|
4071 | Â Â Â Â Â Â Â Â rbsizer1.Add(posRef,0,wx.ALIGN_CENTER_VERTICAL) |
---|
4072 | Â Â Â Â Â Â Â Â posVal =Â wx.TextCtrl(MCSA,-1,'%.4f'%(model['Pos'][0][ix]),style=wx.TE_PROCESS_ENTER) |
---|
4073 | Â Â Â Â Â Â Â Â posVal.Bind(wx.EVT_TEXT_ENTER,OnPosVal) |
---|
4074 | Â Â Â Â Â Â Â Â posVal.Bind(wx.EVT_KILL_FOCUS,OnPosVal) |
---|
4075 | Â Â Â Â Â Â Â Â Indx[posVal.GetId()]Â =Â [model,'Pos',ix] |
---|
4076 | Â Â Â Â Â Â Â Â rbsizer1.Add(posVal,0,wx.ALIGN_CENTER_VERTICAL) |
---|
4077 | Â Â Â Â Â Â molcent =Â wx.CheckBox(MCSA,-1,label=' Use mol. center? ') |
---|
4078 | Â Â Â Â Â Â molcent.SetValue(model['MolCent'][1]) |
---|
4079 | Â Â Â Â Â Â molcent.Bind(wx.EVT_CHECKBOX,OnMolCent) |
---|
4080 | Â Â Â Â Â Â Indx[molcent.GetId()]Â =Â model |
---|
4081 | Â Â Â Â Â Â rbsizer1.Add(molcent,0,wx.ALIGN_CENTER_VERTICAL) |
---|
4082 |       for ix,item in enumerate(['x','y','z']): |
---|
4083 | Â Â Â Â Â Â Â Â rbsizer1.Add(wx.StaticText(MCSA,-1,' Range: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
4084 | Â Â Â Â Â Â Â Â rmin,rmax =Â model['Pos'][2][ix] |
---|
4085 |         posRange = wx.TextCtrl(MCSA,-1,'%.3f %.3f'%(rmin,rmax),style=wx.TE_PROCESS_ENTER) |
---|
4086 | Â Â Â Â Â Â Â Â Indx[posRange.GetId()]Â =Â [model,'Pos',ix] |
---|
4087 | Â Â Â Â Â Â Â Â posRange.Bind(wx.EVT_TEXT_ENTER,OnPosRange) |
---|
4088 | Â Â Â Â Â Â Â Â posRange.Bind(wx.EVT_KILL_FOCUS,OnPosRange) |
---|
4089 | Â Â Â Â Â Â Â Â rbsizer1.Add(posRange,0,wx.ALIGN_CENTER_VERTICAL) |
---|
4090 | Â Â Â Â Â Â Â Â |
---|
4091 | Â Â Â Â Â Â rbsizer2 =Â wx.FlexGridSizer(1,6,5,5) |
---|
4092 | Â Â Â Â Â Â Orien,OrienV =Â G2mth.Q2AVdeg(model['Ori'][0]) |
---|
4093 | Â Â Â Â Â Â Ori =Â [Orien,]+list(OrienV) |
---|
4094 | Â Â Â Â Â Â rbsizer2.Add(wx.StaticText(MCSA,-1,'Oa: '),0,wx.ALIGN_CENTER_VERTICAL) |
---|
4095 | Â Â Â Â Â Â angVal =Â wx.TextCtrl(MCSA,-1,'%.5f'%(Ori[0]),style=wx.TE_PROCESS_ENTER) |
---|
4096 | Â Â Â Â Â Â angVal.Bind(wx.EVT_TEXT_ENTER,OnOriVal) |
---|
4097 | Â Â Â Â Â Â angVal.Bind(wx.EVT_KILL_FOCUS,OnOriVal) |
---|
4098 | Â Â Â Â Â Â Indx[angVal.GetId()]Â =Â [model,0] |
---|
4099 | Â Â Â Â |
---|