1 | #GSASII - data display routines |
---|
2 | import wx |
---|
3 | import wx.grid as wg |
---|
4 | import math |
---|
5 | import time |
---|
6 | import cPickle |
---|
7 | import GSASIIpath |
---|
8 | import GSASIIpeak as G2pk |
---|
9 | import GSASIIlattice as G2lat |
---|
10 | import GSASIIindex as G2indx |
---|
11 | import GSASIIplot as G2plt |
---|
12 | import GSASIIgrid as G2gd |
---|
13 | |
---|
14 | # trig functions in degrees |
---|
15 | sind = lambda x: math.sin(x*math.pi/180.) |
---|
16 | tand = lambda x: math.tan(x*math.pi/180.) |
---|
17 | cosd = lambda x: math.cos(x*math.pi/180.) |
---|
18 | asind = lambda x: 180.*math.asin(x)/math.pi |
---|
19 | |
---|
20 | def UpdatePeakGrid(self, data): |
---|
21 | if self.dataDisplay: |
---|
22 | self.dataDisplay.Destroy() |
---|
23 | |
---|
24 | def OnUnDo(event): |
---|
25 | DoUnDo() |
---|
26 | self.dataFrame.UnDo.Enable(False) |
---|
27 | |
---|
28 | def DoUnDo(): |
---|
29 | print 'Undo last refinement' |
---|
30 | file = open('GSASII.save','rb') |
---|
31 | PatternId = self.PatternId |
---|
32 | for item in ['Background','Instrument Parameters','Peak List']: |
---|
33 | self.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, item),cPickle.load(file)) |
---|
34 | if self.dataDisplay.GetName() == item: |
---|
35 | if item == 'Background': |
---|
36 | UpdateBackgroundGrid(self,self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, item))) |
---|
37 | elif item == 'Instrument Parameters': |
---|
38 | UpdateInstrumentGrid(self,self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, item))) |
---|
39 | elif item == 'Peak List': |
---|
40 | UpdatePeakGrid(self,self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, item))) |
---|
41 | print item,' recovered' |
---|
42 | file.close() |
---|
43 | |
---|
44 | def OnPeakFit(event): |
---|
45 | self.SaveState() |
---|
46 | print 'Peak Fitting - Do one cycle of peak fitting' |
---|
47 | PatternId = self.PatternId |
---|
48 | PickId = self.PickId |
---|
49 | peaks = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Peak List')) |
---|
50 | if not peaks: |
---|
51 | self.ErrorDialog('No peaks!','Nothing to fit!') |
---|
52 | return |
---|
53 | background = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Background'))[0] |
---|
54 | limits = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Limits'))[1] |
---|
55 | inst = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Instrument Parameters')) |
---|
56 | data = self.PatternTree.GetItemPyData(PatternId)[1] |
---|
57 | OK,smin,Rwp,runtime,GoOn = G2pk.DoPeakFit(peaks,background,limits,inst,data) |
---|
58 | UpdatePeakGrid(self,peaks) |
---|
59 | G2plt.PlotPatterns(self) |
---|
60 | if not OK: |
---|
61 | print 'Refinement failed' |
---|
62 | dlg = wx.MessageDialog(self, 'Do you want to reload now?', 'Refinement failed', wx.YES_NO) |
---|
63 | try: |
---|
64 | if dlg.ShowModal() == wx.ID_YES: |
---|
65 | DoUnDo() |
---|
66 | self.dataFrame.UnDo.Enable(False) |
---|
67 | finally: |
---|
68 | dlg.Destroy() |
---|
69 | else: |
---|
70 | self.dataFrame.UnDo.Enable(True) |
---|
71 | print "%s%7.2f%s%12.6g" % ('Rwp = ',Rwp,'%, Smin = ',smin) |
---|
72 | print "%s%8.3f%s " % ('fitpeak time =',runtime,'s') |
---|
73 | print 'finished' |
---|
74 | return |
---|
75 | |
---|
76 | def OnAutoPeakFit(event): |
---|
77 | self.SaveState() |
---|
78 | print 'AutoPeak Fitting - run until minimized' |
---|
79 | PatternId = self.PatternId |
---|
80 | PickId = self.PickId |
---|
81 | peaks = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Peak List')) |
---|
82 | if not peaks: |
---|
83 | self.ErrorDialog('No peaks!','Nothing to fit!') |
---|
84 | return |
---|
85 | background = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Background'))[0] |
---|
86 | limits = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Limits'))[1] |
---|
87 | inst = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Instrument Parameters')) |
---|
88 | data = self.PatternTree.GetItemPyData(PatternId)[1] |
---|
89 | smin = 1.0e15 |
---|
90 | GoOn = True |
---|
91 | while GoOn: |
---|
92 | osmin = smin |
---|
93 | OK,smin,Rwp,runtime,GoOn = G2pk.DoPeakFit(peaks,background,limits,inst,data) |
---|
94 | UpdatePeakGrid(self,peaks) |
---|
95 | if not OK: |
---|
96 | break |
---|
97 | G2plt.PlotPatterns(self) |
---|
98 | print "%s%7.2f%s%12.6g" % ('Rwp = ',Rwp,'%, Smin = ',smin) |
---|
99 | rat = (osmin-smin)/smin |
---|
100 | if rat < 1.0e-4: GoOn = False |
---|
101 | if not OK: |
---|
102 | print 'Refinement failed' |
---|
103 | dlg = wx.MessageDialog(self, 'Do you want to reload now?', 'Refinement failed', wx.YES_NO) |
---|
104 | try: |
---|
105 | if dlg.ShowModal() == wx.ID_YES: |
---|
106 | DoUnDo() |
---|
107 | self.dataFrame.UnDo.Enable(False) |
---|
108 | finally: |
---|
109 | dlg.Destroy() |
---|
110 | else: |
---|
111 | self.dataFrame.UnDo.Enable(True) |
---|
112 | print "%s%8.3f%s " % ('fitpeak time =',runtime,'s per cycle') |
---|
113 | print 'finished' |
---|
114 | return |
---|
115 | |
---|
116 | def RefreshPeakGrid(event): |
---|
117 | event.StopPropagation() |
---|
118 | data = self.PeakTable.GetData() |
---|
119 | T = [] |
---|
120 | for peak in data:T.append(peak[0]) |
---|
121 | D = dict(zip(T,data)) |
---|
122 | T.sort() |
---|
123 | X = [] |
---|
124 | for key in T: X.append(D[key]) |
---|
125 | data = X |
---|
126 | G2plt.PlotPatterns(self) |
---|
127 | |
---|
128 | def setBackgroundColors(): |
---|
129 | for r in range(self.dataDisplay.GetNumberRows()): |
---|
130 | for c in range(self.dataDisplay.GetNumberCols()): |
---|
131 | if self.dataDisplay.GetColLabelValue(c) in ['position','intensity','sigma','gamma']: |
---|
132 | if float(self.dataDisplay.GetCellValue(r,c)) < 0.: |
---|
133 | self.dataDisplay.SetCellBackgroundColour(r,c,wx.RED) |
---|
134 | else: |
---|
135 | self.dataDisplay.SetCellBackgroundColour(r,c,wx.WHITE) |
---|
136 | |
---|
137 | def KeyEditPeakGrid(event): |
---|
138 | rowList = self.dataDisplay.GetSelectedRows() |
---|
139 | colList = self.dataDisplay.GetSelectedCols() |
---|
140 | selectList = self.dataDisplay.GetSelectedCells() |
---|
141 | data = self.PatternTree.GetItemPyData(self.PickId) |
---|
142 | if event.GetKeyCode() == wx.WXK_RETURN: |
---|
143 | event.Skip(True) |
---|
144 | elif event.GetKeyCode() == wx.WXK_CONTROL: |
---|
145 | event.Skip(True) |
---|
146 | elif event.GetKeyCode() == wx.WXK_SHIFT: |
---|
147 | event.Skip(True) |
---|
148 | elif rowList: |
---|
149 | self.dataDisplay.ClearSelection() |
---|
150 | if event.GetKeyCode() == wx.WXK_DELETE: |
---|
151 | self.dataDisplay.ClearGrid() |
---|
152 | rowList.reverse() |
---|
153 | nDel = 0 |
---|
154 | for row in rowList: |
---|
155 | self.PeakTable.DeleteRow(row) |
---|
156 | nDel += 1 |
---|
157 | if nDel: |
---|
158 | msg = wg.GridTableMessage(self.PeakTable, |
---|
159 | wg.GRIDTABLE_NOTIFY_ROWS_DELETED,0,nDel) |
---|
160 | self.dataDisplay.ProcessTableMessage(msg) |
---|
161 | data = self.PeakTable.GetData() |
---|
162 | self.PatternTree.SetItemPyData(self.PickId,data[:-nDel]) |
---|
163 | self.dataDisplay.ForceRefresh() |
---|
164 | setBackgroundColors() |
---|
165 | if not len(self.PatternTree.GetItemPyData(self.PickId)): |
---|
166 | self.dataFrame.PeakFit.Enable(False) |
---|
167 | self.dataFrame.AutoPeakFit.Enable(False) |
---|
168 | |
---|
169 | elif colList: |
---|
170 | self.dataDisplay.ClearSelection() |
---|
171 | key = event.GetKeyCode() |
---|
172 | for col in colList: |
---|
173 | if self.PeakTable.GetTypeName(0,col) == wg.GRID_VALUE_BOOL: |
---|
174 | if key == 89: #'Y' |
---|
175 | for row in range(self.PeakTable.GetNumberRows()): data[row][col]=True |
---|
176 | elif key == 78: #'N' |
---|
177 | for row in range(self.PeakTable.GetNumberRows()): data[row][col]=False |
---|
178 | elif selectList: |
---|
179 | self.dataDisplay.ClearSelection() |
---|
180 | key = event.GetKeyCode() |
---|
181 | for row,col in selectList: |
---|
182 | if self.PeakTable.GetTypeName(row,col) == wg.GRID_VALUE_BOOL: |
---|
183 | if key == 89: #'Y' |
---|
184 | data[row][col]=True |
---|
185 | elif key == 78: #'N' |
---|
186 | data[row][col]=False |
---|
187 | G2plt.PlotPatterns(self) |
---|
188 | |
---|
189 | self.dataFrame.SetMenuBar(self.dataFrame.PeakMenu) |
---|
190 | if not self.dataFrame.GetStatusBar(): |
---|
191 | Status = self.dataFrame.CreateStatusBar() |
---|
192 | self.Bind(wx.EVT_MENU, OnUnDo, id=G2gd.wxID_UNDO) |
---|
193 | self.Bind(wx.EVT_MENU, OnPeakFit, id=G2gd.wxID_PEAKFIT) |
---|
194 | self.Bind(wx.EVT_MENU, OnAutoPeakFit, id=G2gd.wxID_AUTOPEAKFIT) |
---|
195 | self.dataFrame.PeakFit.Enable(False) |
---|
196 | self.dataFrame.AutoPeakFit.Enable(False) |
---|
197 | if data: |
---|
198 | self.dataFrame.PeakFit.Enable(True) |
---|
199 | self.dataFrame.AutoPeakFit.Enable(True) |
---|
200 | self.PickTable = [] |
---|
201 | rowLabels = [] |
---|
202 | for i in range(len(data)): rowLabels.append(str(i+1)) |
---|
203 | colLabels = ['position','refine','intensity','refine','sigma','refine','gamma','refine'] |
---|
204 | Types = [wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL, |
---|
205 | wg.GRID_VALUE_FLOAT+':10,1',wg.GRID_VALUE_BOOL, |
---|
206 | wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL, |
---|
207 | wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL] |
---|
208 | T = [] |
---|
209 | for peak in data: |
---|
210 | T.append(peak[0]) |
---|
211 | D = dict(zip(T,data)) |
---|
212 | T.sort() |
---|
213 | X = [] |
---|
214 | for key in T: X.append(D[key]) |
---|
215 | data = X |
---|
216 | self.PatternTree.SetItemPyData(self.PickId,data) |
---|
217 | self.PeakTable = G2gd.Table(data,rowLabels=rowLabels,colLabels=colLabels,types=Types) |
---|
218 | self.dataFrame.SetLabel('Peak List') |
---|
219 | self.dataDisplay = G2gd.GSGrid(parent=self.dataFrame) |
---|
220 | self.dataDisplay.SetTable(self.PeakTable, True) |
---|
221 | setBackgroundColors() |
---|
222 | self.dataDisplay.Bind(wg.EVT_GRID_CELL_CHANGE, RefreshPeakGrid) |
---|
223 | self.dataDisplay.Bind(wx.EVT_KEY_DOWN, KeyEditPeakGrid) |
---|
224 | self.dataDisplay.SetMargins(0,0) |
---|
225 | self.dataDisplay.AutoSizeColumns(False) |
---|
226 | self.dataFrame.setSizePosLeft([550,350]) |
---|
227 | |
---|
228 | def UpdateBackgroundGrid(self,data): |
---|
229 | BackId = G2gd.GetPatternTreeItemId(self,self.PatternId, 'Background') |
---|
230 | |
---|
231 | def RefreshBackgroundGrid(event): |
---|
232 | data = self.BackTable.GetData() |
---|
233 | M = len(data[0]) |
---|
234 | N = data[0][2]+3 |
---|
235 | item = data[0] |
---|
236 | if N > M: #add terms |
---|
237 | for i in range(M,N): |
---|
238 | item.append(0.0) |
---|
239 | self.BackTable.SetColLabelValue(i,str(i-2)) |
---|
240 | data = [item] |
---|
241 | msg = wg.GridTableMessage(self.BackTable, |
---|
242 | wg.GRIDTABLE_NOTIFY_COLS_APPENDED,0,N-M) |
---|
243 | self.dataDisplay.ProcessTableMessage(msg) |
---|
244 | elif N < M: #delete terms |
---|
245 | new = [] |
---|
246 | for i in range(N): |
---|
247 | new.append(item[i]) |
---|
248 | data = [new] |
---|
249 | msg = wg.GridTableMessage(self.BackTable, |
---|
250 | wg.GRIDTABLE_NOTIFY_COLS_DELETED,0,M-N) |
---|
251 | self.dataDisplay.ProcessTableMessage(msg) |
---|
252 | self.PatternTree.SetItemPyData(BackId,data) |
---|
253 | |
---|
254 | self.dataFrame.setSizePosLeft([700,150]) |
---|
255 | maxTerm = 7 |
---|
256 | self.BackTable = [] |
---|
257 | N = len(data[0]) |
---|
258 | M = data[0][2] |
---|
259 | colLabels = ['function','refine','Nterms'] |
---|
260 | rowLabels=['background'] |
---|
261 | for i in range(M): colLabels.append(str(i+1)) |
---|
262 | Types = [wg.GRID_VALUE_CHOICE+':chebyschev,another,more', |
---|
263 | wg.GRID_VALUE_BOOL, |
---|
264 | wg.GRID_VALUE_NUMBER+':1,'+str(maxTerm)] |
---|
265 | for i in range(maxTerm): |
---|
266 | Types.append(wg.GRID_VALUE_FLOAT+':10,3') |
---|
267 | self.BackTable = G2gd.Table(data,rowLabels=rowLabels,colLabels=colLabels,types=Types) |
---|
268 | self.dataFrame.SetLabel('Background') |
---|
269 | self.dataFrame.SetMenuBar(self.dataFrame.BlankMenu) |
---|
270 | self.dataDisplay = G2gd.GSGrid(parent=self.dataFrame) |
---|
271 | self.dataDisplay.Bind(wg.EVT_GRID_CELL_CHANGE, RefreshBackgroundGrid) |
---|
272 | self.dataDisplay.SetTable(self.BackTable, True) |
---|
273 | self.dataDisplay.SetMargins(0,0) |
---|
274 | self.dataDisplay.AutoSizeColumns(False) |
---|
275 | |
---|
276 | def UpdateLimitsGrid(self, data): |
---|
277 | if self.dataDisplay: |
---|
278 | self.dataDisplay.Destroy() |
---|
279 | self.dataFrame.setSizePosLeft([250,150]) |
---|
280 | LimitId = G2gd.GetPatternTreeItemId(self,self.PatternId, 'Limits') |
---|
281 | def RefreshLimitsGrid(event): |
---|
282 | data = self.LimitsTable.GetData() |
---|
283 | old = data[0] |
---|
284 | new = data[1] |
---|
285 | new[0] = max(old[0],new[0]) |
---|
286 | new[1] = max(new[0],min(old[1],new[1])) |
---|
287 | data = [old,new] |
---|
288 | G2plt.PlotPatterns(self) |
---|
289 | |
---|
290 | self.LimitsTable = [] |
---|
291 | colLabels = ['Tmin','Tmax'] |
---|
292 | rowLabels = ['original','changed'] |
---|
293 | Types = [wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3'] |
---|
294 | self.LimitsTable = G2gd.Table(data,rowLabels=rowLabels,colLabels=colLabels,types=Types) |
---|
295 | self.dataFrame.SetLabel('Limits') |
---|
296 | self.dataFrame.SetMenuBar(self.dataFrame.BlankMenu) |
---|
297 | self.dataDisplay = G2gd.GSGrid(parent=self.dataFrame) |
---|
298 | self.dataDisplay.SetTable(self.LimitsTable, True) |
---|
299 | self.dataDisplay.Bind(wg.EVT_GRID_CELL_CHANGE, RefreshLimitsGrid) |
---|
300 | self.dataDisplay.SetMargins(0,0) |
---|
301 | self.dataDisplay.AutoSizeColumns(False) |
---|
302 | |
---|
303 | def UpdateInstrumentGrid(self, data): |
---|
304 | if self.dataDisplay: |
---|
305 | self.dataDisplay.Destroy() |
---|
306 | Ka2 = False |
---|
307 | Xwid = 700 |
---|
308 | if len(data[0]) == 13: |
---|
309 | Ka2 = True |
---|
310 | Xwid = 840 |
---|
311 | self.dataFrame.setSizePosLeft([Xwid,170]) |
---|
312 | self.dataFrame.SetMenuBar(self.dataFrame.BlankMenu) |
---|
313 | InstId = G2gd.GetPatternTreeItemId(self,self.PatternId, 'Instrument Parameters') |
---|
314 | |
---|
315 | def RefreshInstrumentGrid(event,doAnyway=False): |
---|
316 | if doAnyway or event.GetRow() == 1: |
---|
317 | peaks = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,self.PatternId, 'Peak List')) |
---|
318 | ins = data[1] |
---|
319 | if 'P' in ins[0]: #update powder peak parameters |
---|
320 | for peak in peaks: |
---|
321 | if Ka2: |
---|
322 | peak[4] = ins[6]*tand(peak[0]/2.0)**2+ins[7]*tand(peak[0]/2.0)+ins[8] |
---|
323 | peak[6] = ins[9]/cosd(peak[0]/2.0)+ins[10]*tand(peak[0]/2.0) |
---|
324 | else: |
---|
325 | peak[4] = ins[4]*tand(peak[0]/2.0)**2+ins[5]*tand(peak[0]/2.0)+ins[6] |
---|
326 | peak[6] = ins[7]/cosd(peak[0]/2.0)+ins[8]*tand(peak[0]/2.0) |
---|
327 | |
---|
328 | def OnReset(event): |
---|
329 | if Ka2: |
---|
330 | data[1][6:12] = data[0][6:12] |
---|
331 | else: |
---|
332 | data[1][4:10] = data[0][4:10] |
---|
333 | RefreshInstrumentGrid(event,doAnyway=True) #to get peaks updated |
---|
334 | UpdateInstrumentGrid(self, data) |
---|
335 | |
---|
336 | self.InstrumentTable = [] |
---|
337 | if 'P' in data[1][0]: #powder data |
---|
338 | self.dataFrame.SetMenuBar(self.dataFrame.InstMenu) |
---|
339 | if not self.dataFrame.GetStatusBar(): |
---|
340 | Status = self.dataFrame.CreateStatusBar() |
---|
341 | self.Bind(wx.EVT_MENU, OnReset, id=G2gd.wxID_INSTPRMRESET) |
---|
342 | if Ka2: |
---|
343 | Types = [wg.GRID_VALUE_CHOICE+":PXC,PNC,PNT",wg.GRID_VALUE_FLOAT+':10,6',wg.GRID_VALUE_FLOAT+':10,6', #type, lam-1 & lam-2 |
---|
344 | wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3', #zero, ratio, pola |
---|
345 | wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3', #u,v,w |
---|
346 | wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_FLOAT+':10,2'] |
---|
347 | else: |
---|
348 | Types = [wg.GRID_VALUE_CHOICE+":PXC,PNC,PNT",wg.GRID_VALUE_FLOAT+':10,6', #type & lam-1 |
---|
349 | wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3', #zero, pola |
---|
350 | wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3', #u,v,w |
---|
351 | wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_FLOAT+':10,2'] |
---|
352 | colLabels = data[3] |
---|
353 | rowLabels = ['default','changed','refine'] |
---|
354 | self.InstrumentTable = G2gd.Table(data[:-1],rowLabels=rowLabels,colLabels=colLabels,types=Types) |
---|
355 | self.dataFrame.SetLabel('Instrument Parameters') |
---|
356 | self.dataDisplay = G2gd.GSGrid(parent=self.dataFrame) |
---|
357 | self.dataDisplay.SetTable(self.InstrumentTable, True) |
---|
358 | self.dataDisplay.Bind(wg.EVT_GRID_CELL_CHANGE, RefreshInstrumentGrid) |
---|
359 | self.dataDisplay.SetMargins(0,0) |
---|
360 | self.dataDisplay.AutoSizeColumns(False) |
---|
361 | beg = 4 |
---|
362 | if Ka2: beg = 6 |
---|
363 | for i in range(len(data[2])): |
---|
364 | if i < beg or i == beg+6: |
---|
365 | self.dataDisplay.SetCellRenderer(2,i,wg.GridCellStringRenderer()) |
---|
366 | self.dataDisplay.SetCellValue(2,i,'') |
---|
367 | self.dataDisplay.SetReadOnly(2,i,isReadOnly=True) |
---|
368 | else: |
---|
369 | self.dataDisplay.SetCellRenderer(2,i,wg.GridCellBoolRenderer()) |
---|
370 | self.dataDisplay.SetCellEditor(2,i,wg.GridCellBoolEditor()) |
---|
371 | else: #single crystal data |
---|
372 | Types = [wg.GRID_VALUE_CHOICE+":SXC,SNC,SNT",wg.GRID_VALUE_FLOAT+':10,6'] |
---|
373 | colLabels = data[2] |
---|
374 | rowLabels = ['original','changed'] |
---|
375 | self.InstrumentTable = Table(data[:-1],rowLabels=rowLabels,colLabels=colLabels,types=Types) |
---|
376 | self.dataFrame.SetLabel('Instrument Parameters') |
---|
377 | self.dataDisplay = G2gd.GSGrid(parent=self.dataFrame) |
---|
378 | self.dataDisplay.SetTable(self.InstrumentTable, True) |
---|
379 | self.dataDisplay.Bind(wg.EVT_GRID_CELL_CHANGE, RefreshInstrumentGrid) |
---|
380 | self.dataDisplay.SetMargins(0,0) |
---|
381 | self.dataDisplay.AutoSizeColumns(False) |
---|
382 | |
---|
383 | def UpdateIndexPeaksGrid(self, data): |
---|
384 | IndexId = G2gd.GetPatternTreeItemId(self,self.PatternId, 'Index Peak List') |
---|
385 | |
---|
386 | def RefreshIndexPeaksGrid(event): |
---|
387 | data = self.IndexPeaksTable.GetData() |
---|
388 | self.PatternTree.SetItemPyData(IndexId,data) |
---|
389 | |
---|
390 | def KeyEditPickGrid(event): |
---|
391 | colList = self.dataDisplay.GetSelectedCols() |
---|
392 | rowList = self.dataDisplay.GetSelectedRows() |
---|
393 | data = self.PatternTree.GetItemPyData(IndexId) |
---|
394 | if event.GetKeyCode() == wx.WXK_RETURN: |
---|
395 | event.Skip(True) |
---|
396 | elif event.GetKeyCode() == wx.WXK_CONTROL: |
---|
397 | event.Skip(True) |
---|
398 | elif event.GetKeyCode() == wx.WXK_SHIFT: |
---|
399 | event.Skip(True) |
---|
400 | elif event.GetKeyCode() == wx.WXK_DELETE: |
---|
401 | dlg = wx.MessageDialog(self, 'Delete Index Peak List?', ' ', wx.YES | wx.NO) |
---|
402 | try: |
---|
403 | result = dlg.ShowModal() |
---|
404 | if result == wx.ID_YES: |
---|
405 | oldlen = len(data) |
---|
406 | data = [] |
---|
407 | self.PatternTree.SetItemPyData(IndexId,data) |
---|
408 | self.dataDisplay.Clear() |
---|
409 | self.dataDisplay.Destroy() |
---|
410 | self.IndexPeaksTable = [] |
---|
411 | finally: |
---|
412 | dlg.Destroy() |
---|
413 | elif colList: |
---|
414 | self.dataDisplay.ClearSelection() |
---|
415 | key = event.GetKeyCode() |
---|
416 | for col in colList: |
---|
417 | if self.IndexPeaksTable.GetTypeName(0,col) == wg.GRID_VALUE_BOOL: |
---|
418 | if key == 89: #'Y' |
---|
419 | for row in range(self.IndexPeaksTable.GetNumberRows()): data[row][col]=True |
---|
420 | elif key == 78: #'N' |
---|
421 | for row in range(self.IndexPeaksTable.GetNumberRows()): data[row][col]=False |
---|
422 | |
---|
423 | if self.dataDisplay: |
---|
424 | self.dataDisplay.Destroy() |
---|
425 | self.dataFrame.setSizePosLeft([500,300]) |
---|
426 | self.dataFrame.SetMenuBar(self.dataFrame.BlankMenu) |
---|
427 | inst = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,self.PatternId, 'Instrument Parameters'))[1] |
---|
428 | self.IndexPeaksTable = [] |
---|
429 | if not data: |
---|
430 | peaks = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,self.PatternId, 'Peak List')) |
---|
431 | for peak in peaks: |
---|
432 | dsp = inst[1]/(2.0*sind(peak[0]/2.0)) |
---|
433 | data.append([peak[0],peak[2],True,False,0,0,0,dsp,0.0]) |
---|
434 | else: |
---|
435 | cells = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,self.PatternId, 'Unit Cells List')) |
---|
436 | if cells: |
---|
437 | cellist = cells[2] |
---|
438 | dmin = cells[3] |
---|
439 | self.HKL = [] |
---|
440 | for i,cell in enumerate(cellist): |
---|
441 | if cell[-1]: |
---|
442 | ibrav = cell[2] |
---|
443 | A = G2lat.cell2A(cell[3:9]) |
---|
444 | self.HKL = G2lat.GenHBravais(dmin,ibrav,A) |
---|
445 | G2indx.IndexPeaks(data,self.HKL) |
---|
446 | for hkl in self.HKL: |
---|
447 | hkl.append(2.0*asind(inst[1]/(2.*hkl[3]))) |
---|
448 | rowLabels = [] |
---|
449 | for i in range(len(data)): rowLabels.append(str(i+1)) |
---|
450 | colLabels = ['position','intensity','use','indexed','h','k','l','d-obs','d-calc'] |
---|
451 | Types = [wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_FLOAT+':10,1',wg.GRID_VALUE_BOOL, |
---|
452 | wg.GRID_VALUE_BOOL,wg.GRID_VALUE_LONG,wg.GRID_VALUE_LONG,wg.GRID_VALUE_LONG, |
---|
453 | wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_FLOAT+':10,5'] |
---|
454 | self.PatternTree.SetItemPyData(IndexId,data) |
---|
455 | self.IndexPeaksTable = G2gd.Table(data,rowLabels=rowLabels,colLabels=colLabels,types=Types) |
---|
456 | self.dataFrame.SetLabel('Index Peak List') |
---|
457 | self.dataDisplay = G2gd.GSGrid(parent=self.dataFrame) |
---|
458 | self.dataDisplay.SetTable(self.IndexPeaksTable, True) |
---|
459 | self.dataDisplay.Bind(wg.EVT_GRID_CELL_CHANGE, RefreshIndexPeaksGrid) |
---|
460 | self.dataDisplay.Bind(wx.EVT_KEY_DOWN, KeyEditPickGrid) |
---|
461 | self.dataDisplay.SetMargins(0,0) |
---|
462 | self.dataDisplay.AutoSizeColumns(False) |
---|
463 | |
---|
464 | def UpdateUnitCellsGrid(self, data): |
---|
465 | UnitCellsId = G2gd.GetPatternTreeItemId(self,self.PatternId, 'Unit Cells List') |
---|
466 | bravaisSymb = ['Fm3m','Im3m','Pm3m','R3-H','P6/mmm','I4/mmm', |
---|
467 | 'P4/mmm','Fmmm','Immm','Cmmm','Pmmm','C2/m','P2/m','P1'] |
---|
468 | |
---|
469 | def OnRefineCell(event): |
---|
470 | def cellPrint(ibrav,A): |
---|
471 | cell = G2lat.A2cell(A) |
---|
472 | Vol = G2lat.calc_V(A) |
---|
473 | if ibrav in [0,1,2]: |
---|
474 | print "%s%10.6f" % ('a =',cell[0]) |
---|
475 | elif ibrav in [3,4,5,6]: |
---|
476 | print "%s%10.6f %s%10.6f %s%12.3f" % ('a =',cell[0],' c =',cell[2],' volume =',Vol) |
---|
477 | elif ibrav in [7,8,9,10]: |
---|
478 | print "%s%10.6f %s%10.6f %s%10.6f %s%12.3f" % ('a =',cell[0],'b =',cell[1],'c =',cell[2],' volume =',Vol) |
---|
479 | elif ibrav in [11,12]: |
---|
480 | print "%s%10.6f %s%10.6f %s%10.6f %s%8.3f %s%12.3f" % ('a =',cell[0],'b =',cell[1],'c =',cell[2],'beta =',cell[4],' volume =',Vol) |
---|
481 | else: |
---|
482 | print "%s%10.6f %s%10.6f %s%10.6f" % ('a =',cell[0],'b =',cell[1],'c =',cell[2]) |
---|
483 | print "%s%8.3f %s%8.3f %s%8.3f %s%12.3f" % ('alpha =',cell[3],'beta =',cell[4],'gamma =',cell[5],' volume =',Vol) |
---|
484 | |
---|
485 | bravaisSymb = ['Fm3m','Im3m','Pm3m','R3-H','P6/mmm','I4/mmm', |
---|
486 | 'P4/mmm','Fmmm','Immm','Cmmm','Pmmm','C2/m','P2/m','P1'] |
---|
487 | PatternId = self.PatternId |
---|
488 | PickId = self.PickId |
---|
489 | peaks = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Index Peak List')) |
---|
490 | if not peaks: |
---|
491 | self.ErrorDialog('No peaks!', 'Nothing to refine!') |
---|
492 | return |
---|
493 | print 'Refine cell' |
---|
494 | inst = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Instrument Parameters'))[1] |
---|
495 | controls,bravais,cells,dmin = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Unit Cells List')) |
---|
496 | cell = controls[6:12] |
---|
497 | A = G2lat.cell2A(cell) |
---|
498 | print controls[5] |
---|
499 | ibrav = bravaisSymb.index(controls[5]) |
---|
500 | dmin = G2indx.getDmin(peaks)-0.005 |
---|
501 | Lhkl,M20,X20 = G2indx.refinePeaks(peaks,ibrav,A) |
---|
502 | controls[6:12] = G2lat.A2cell(A) |
---|
503 | controls[12] = G2lat.calc_V(A) |
---|
504 | data = [controls,bravais,cells,dmin] |
---|
505 | self.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Unit Cells List'),data) |
---|
506 | self.HKL = G2lat.GenHBravais(dmin,ibrav,A) |
---|
507 | UpdateUnitCellsGrid(self,data) |
---|
508 | print "%s%10.3f" % ('refinement M20 = ',M20) |
---|
509 | print 'unindexed lines = ',X20 |
---|
510 | cellPrint(ibrav,A) |
---|
511 | for hkl in self.HKL: |
---|
512 | hkl.append(2.0*asind(inst[1]/(2.*hkl[3]))) |
---|
513 | if 'PKS' in self.PatternTree.GetItemText(self.PatternId): |
---|
514 | G2plt.PlotPowderLines(self) |
---|
515 | else: |
---|
516 | G2plt.PlotPatterns(self) |
---|
517 | |
---|
518 | def OnIndexPeaks(event): |
---|
519 | PatternId = self.PatternId |
---|
520 | peaks = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Index Peak List')) |
---|
521 | if not peaks: |
---|
522 | self.ErrorDialog('No peaks!', 'Nothing to index!') |
---|
523 | return |
---|
524 | inst = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Instrument Parameters'))[1] |
---|
525 | print 'Peak Indexing' |
---|
526 | try: |
---|
527 | controls,bravais,cells,dmin = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Unit Cells List')) |
---|
528 | cells = [] |
---|
529 | except ValueError: |
---|
530 | self.ErrorDialog('Error','Need to set controls in Unit Cell List first') |
---|
531 | return |
---|
532 | if True not in bravais: |
---|
533 | self.ErrorDialog('Error','No Bravais lattices selected') |
---|
534 | return |
---|
535 | self.dataFrame.IndexPeaks.Enable(False) |
---|
536 | self.dataFrame.CopyCell.Enable(False) |
---|
537 | OK,dmin,cells = G2indx.DoIndexPeaks(peaks,inst,controls,bravais) |
---|
538 | if OK: |
---|
539 | data = [controls,bravais,cells,dmin] |
---|
540 | self.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Unit Cells List'),data) |
---|
541 | UpdateUnitCellsGrid(self,data) |
---|
542 | bestCell = cells[0] |
---|
543 | if bestCell[0] > 10.: |
---|
544 | self.HKL = G2lat.GenHBravais(dmin,bestCell[2],G2lat.cell2A(bestCell[3:9])) |
---|
545 | for hkl in self.HKL: |
---|
546 | hkl.append(2.0*asind(inst[1]/(2.*hkl[3]))) |
---|
547 | if 'PKS' in self.PatternTree.GetItemText(self.PatternId): |
---|
548 | G2plt.PlotPowderLines(self) |
---|
549 | else: |
---|
550 | G2plt.PlotPatterns(self) |
---|
551 | self.dataFrame.CopyCell.Enable(True) |
---|
552 | self.dataFrame.IndexPeaks.Enable(True) |
---|
553 | |
---|
554 | def CopyUnitCell(event): |
---|
555 | controls,bravais,cells,dmin = self.PatternTree.GetItemPyData(UnitCellsId) |
---|
556 | for Cell in cells: |
---|
557 | if Cell[-1]: |
---|
558 | break |
---|
559 | cell = Cell[2:9] |
---|
560 | controls[4] = 1 |
---|
561 | controls[5] = bravaisSymb[cell[0]] |
---|
562 | controls[6:12] = cell[1:8] |
---|
563 | controls[12] = G2lat.calc_V(G2lat.cell2A(controls[6:12])) |
---|
564 | for i in range(4,13): |
---|
565 | self.UnitCellsTable.SetValue(i,1,controls[i]) |
---|
566 | self.PatternTree.SetItemPyData(UnitCellsId,[controls,bravais,cells,dmin]) |
---|
567 | self.dataDisplay.ForceRefresh() |
---|
568 | self.dataFrame.RefineCell.Enable(True) |
---|
569 | |
---|
570 | def RefreshUnitCellsGrid(event): |
---|
571 | cells,dmin = self.PatternTree.GetItemPyData(UnitCellsId)[2:] |
---|
572 | r,c = event.GetRow(),event.GetCol() |
---|
573 | if cells: |
---|
574 | if c == 6: |
---|
575 | for i in range(min(self.UnitCellsTable.GetNumberRows(),len(cells))): |
---|
576 | cells[i][-1] = False |
---|
577 | self.UnitCellsTable.SetValue(i,c,0) |
---|
578 | self.UnitCellsTable.SetValue(r,c,1) |
---|
579 | cells[r][-1] = True |
---|
580 | ibrav = cells[r][2] |
---|
581 | A = G2lat.cell2A(cells[r][3:9]) |
---|
582 | self.HKL = G2lat.GenHBravais(dmin,ibrav,A) |
---|
583 | for hkl in self.HKL: |
---|
584 | hkl.append(2.0*asind(inst[1]/(2.*hkl[3]))) |
---|
585 | if 'PKS' in self.PatternTree.GetItemText(self.PatternId): |
---|
586 | G2plt.PlotPowderLines(self) |
---|
587 | else: |
---|
588 | G2plt.PlotPatterns(self) |
---|
589 | controls = [] |
---|
590 | bravais = [0,0,0,0,0,0,0, 0,0,0,0,0,0,0] |
---|
591 | table = self.UnitCellsTable.GetData() |
---|
592 | for i,row in enumerate(table): |
---|
593 | if i in [0,4]: |
---|
594 | if row[1]: |
---|
595 | controls.append(1) |
---|
596 | else: |
---|
597 | controls.append(0) |
---|
598 | elif i in [1,3]: |
---|
599 | controls.append(float(row[1])) |
---|
600 | elif i in [2]: |
---|
601 | controls.append(int(row[1])) |
---|
602 | elif i in [5]: |
---|
603 | controls.append(row[1]) |
---|
604 | elif i in [6,7,8,9,10,11]: |
---|
605 | if controls[5] in bravaisSymb[:3]: #cubic |
---|
606 | if i in [6]: |
---|
607 | controls.append(float(row[1])) |
---|
608 | controls.append(float(row[1])) |
---|
609 | controls.append(float(row[1])) |
---|
610 | controls.append(90.) |
---|
611 | controls.append(90.) |
---|
612 | controls.append(90.) |
---|
613 | elif controls[5] in bravaisSymb[3:7]: #hexagonal & tetragonal |
---|
614 | if i in [6]: |
---|
615 | controls.append(float(row[1])) |
---|
616 | controls.append(float(row[1])) |
---|
617 | elif i in [8]: |
---|
618 | controls.append(float(row[1])) |
---|
619 | controls.append(90.) |
---|
620 | controls.append(90.) |
---|
621 | if controls[5] in bravaisSymb[3:5]: #hexagonal |
---|
622 | controls.append(120.) |
---|
623 | else: #tetragonal |
---|
624 | controls.append(90.) |
---|
625 | elif controls[5] in bravaisSymb[7:13]: #orthorhombic & monoclinic |
---|
626 | if i in [6,7,8]: |
---|
627 | controls.append(float(row[1])) |
---|
628 | if i in [9,10,11]: |
---|
629 | if controls[5] in bravaisSymb[7:11]: |
---|
630 | controls.append(90.) |
---|
631 | controls.append(90.) |
---|
632 | controls.append(90.) |
---|
633 | break |
---|
634 | else: |
---|
635 | if i in [9,11]: |
---|
636 | controls.append(90.) |
---|
637 | else: |
---|
638 | controls.append(float(row[1])) |
---|
639 | else: #triclinic |
---|
640 | controls.append(float(row[1])) |
---|
641 | controls.append(G2lat.calc_V(G2lat.cell2A(controls[6:12]))) #volume |
---|
642 | for i,row in enumerate(table): |
---|
643 | if i < 14: |
---|
644 | bravais[i] = int(row[2]) |
---|
645 | else: |
---|
646 | break |
---|
647 | if controls[4]: |
---|
648 | for i in range(6,13): |
---|
649 | self.UnitCellsTable.SetValue(i,1,controls[i]) |
---|
650 | self.dataDisplay.ForceRefresh() |
---|
651 | if controls[4] and not False in controls[6:12]: |
---|
652 | self.dataFrame.RefineCell.Enable(True) |
---|
653 | else: |
---|
654 | self.dataFrame.RefineCell.Enable(False) |
---|
655 | data = [controls,bravais,cells,dmin] |
---|
656 | self.PatternTree.SetItemPyData(UnitCellsId,data) |
---|
657 | |
---|
658 | if self.dataDisplay: |
---|
659 | self.dataDisplay.Destroy() |
---|
660 | self.dataFrame.SetMenuBar(self.dataFrame.IndexMenu) |
---|
661 | if not self.dataFrame.GetStatusBar(): |
---|
662 | Status = self.dataFrame.CreateStatusBar() |
---|
663 | self.Bind(wx.EVT_MENU, OnIndexPeaks, id=G2gd.wxID_INDEXPEAKS) |
---|
664 | self.Bind(wx.EVT_MENU, CopyUnitCell, id=G2gd.wxID_COPYCELL) |
---|
665 | self.Bind(wx.EVT_MENU, OnRefineCell, id=G2gd.wxID_REFINECELL) |
---|
666 | self.UnitCellsTable = [] |
---|
667 | controls,bravais,cells,dmin = data |
---|
668 | if cells: |
---|
669 | self.dataFrame.setSizePosLeft([900,320]) |
---|
670 | else: |
---|
671 | self.dataFrame.setSizePosLeft([280,320]) |
---|
672 | if len(controls) < 13: |
---|
673 | controls.append(G2lat.calc_V(G2lat.cell2A(controls[6:12]))) |
---|
674 | self.PatternTree.SetItemPyData(UnitCellsId,data) |
---|
675 | inst = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,self.PatternId, 'Instrument Parameters'))[1] |
---|
676 | if cells: |
---|
677 | colLabels = ['controls','value','try','Bravais cells', |
---|
678 | 'M20','X20','use','Bravais','a','b','c','alpha','beta','gamma','Volume'] |
---|
679 | Types = [wg.GRID_VALUE_STRING,wg.GRID_VALUE_FLOAT+":10,1", |
---|
680 | wg.GRID_VALUE_BOOL,wg.GRID_VALUE_STRING,wg.GRID_VALUE_FLOAT+':10,2', |
---|
681 | wg.GRID_VALUE_NUMBER,wg.GRID_VALUE_BOOL,wg.GRID_VALUE_STRING, |
---|
682 | wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_FLOAT+':10,5', |
---|
683 | wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3', |
---|
684 | wg.GRID_VALUE_FLOAT+':10,2'] |
---|
685 | else: |
---|
686 | colLabels = ['controls','value','try','Bravais cells'] |
---|
687 | Types = [wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING, |
---|
688 | wg.GRID_VALUE_BOOL,wg.GRID_VALUE_STRING] |
---|
689 | controlNames = ['Vary zero?','Max zero error','Max Nc/Nobs','Start volume','refine cell?', |
---|
690 | 'bravais','a=','b=','c=','alpha=','beta=','gamma=','Volume='] |
---|
691 | bravaisNames = ['Cubic-F','Cubic-I','Cubic-P','Trigonal-R','Trigonal/Hexagonal-P', |
---|
692 | 'Tetragonal-I','Tetragonal-P','Orthorhombic-F','Orthorhombic-I','Orthorhombic-C', |
---|
693 | 'Orthorhombic-P','Monoclinic-C','Monoclinic-P','Triclinic'] |
---|
694 | rowLabels = [] |
---|
695 | table = [] |
---|
696 | numRows = max(len(bravais),len(cells)) |
---|
697 | for i in range(numRows): |
---|
698 | rowLabels.append('') |
---|
699 | if i < 13: |
---|
700 | row = [controlNames[i],controls[i],bravais[i],bravaisSymb[i]] |
---|
701 | elif i < 14: |
---|
702 | row = ['','',bravais[i],bravaisSymb[i]] |
---|
703 | else: |
---|
704 | row = ['','','',''] |
---|
705 | if cells: |
---|
706 | if i < len(cells): |
---|
707 | cell = cells[i] |
---|
708 | row += cell[0:2]+[cell[-1]]+[bravaisSymb[cell[2]]]+cell[3:10] |
---|
709 | if cell[-1]: |
---|
710 | A = G2lat.cell2A(cell[3:9]) |
---|
711 | self.HKL = G2lat.GenHBravais(dmin,cell[2],A) |
---|
712 | for hkl in self.HKL: |
---|
713 | hkl.append(2.0*asind(inst[1]/(2.*hkl[3]))) |
---|
714 | else: |
---|
715 | row += 14*['',] |
---|
716 | table.append(row) |
---|
717 | self.UnitCellsTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) |
---|
718 | self.dataFrame.SetLabel('Unit Cells List') |
---|
719 | self.dataDisplay = G2gd.GSGrid(parent=self.dataFrame) |
---|
720 | self.dataDisplay.SetTable(self.UnitCellsTable, True) |
---|
721 | self.dataDisplay.Bind(wg.EVT_GRID_CELL_CHANGE, RefreshUnitCellsGrid) |
---|
722 | self.dataDisplay.SetMargins(0,0) |
---|
723 | self.dataDisplay.SetRowLabelSize(0) |
---|
724 | self.dataDisplay.SetCellRenderer(0,1,wg.GridCellBoolRenderer()) |
---|
725 | self.dataDisplay.SetCellEditor(0,1,wg.GridCellBoolEditor()) |
---|
726 | self.dataDisplay.SetCellRenderer(1,1,wg.GridCellFloatRenderer(5,2)) |
---|
727 | self.dataDisplay.SetCellEditor(1,1,wg.GridCellFloatEditor(5,0)) |
---|
728 | self.dataDisplay.SetCellRenderer(2,1,wg.GridCellNumberRenderer()) |
---|
729 | self.dataDisplay.SetCellEditor(2,1,wg.GridCellNumberEditor(1,10)) |
---|
730 | self.dataDisplay.SetCellRenderer(3,1,wg.GridCellFloatRenderer(5,0)) |
---|
731 | self.dataDisplay.SetCellEditor(3,1,wg.GridCellFloatEditor(5,2)) |
---|
732 | self.dataDisplay.SetCellRenderer(4,1,wg.GridCellBoolRenderer()) |
---|
733 | self.dataDisplay.SetCellEditor(4,1,wg.GridCellBoolEditor()) |
---|
734 | self.dataDisplay.SetCellRenderer(5,1,wg.GridCellStringRenderer()) |
---|
735 | self.dataDisplay.SetCellEditor(5,1,wg.GridCellChoiceEditor(bravaisSymb,False)) |
---|
736 | for i in range(6,9): |
---|
737 | self.dataDisplay.SetCellRenderer(i,1,wg.GridCellFloatRenderer(10,5)) |
---|
738 | self.dataDisplay.SetCellEditor(i,1,wg.GridCellFloatEditor(10,5)) |
---|
739 | for i in range(9,13): |
---|
740 | self.dataDisplay.SetCellRenderer(i,1,wg.GridCellFloatRenderer(10,3)) |
---|
741 | self.dataDisplay.SetCellEditor(i,1,wg.GridCellFloatEditor(10,3)) |
---|
742 | for i in range(14): |
---|
743 | self.dataDisplay.SetReadOnly(i,0,isReadOnly=True) |
---|
744 | self.dataDisplay.SetReadOnly(i,3,isReadOnly=True) |
---|
745 | if cells: |
---|
746 | self.dataFrame.CopyCell.Enable(True) |
---|
747 | for r in range(max(len(cells),14)): |
---|
748 | if r > 12: |
---|
749 | self.dataDisplay.SetCellRenderer(r,0,wg.GridCellStringRenderer()) |
---|
750 | self.dataDisplay.SetCellRenderer(r,1,wg.GridCellStringRenderer()) |
---|
751 | if r > 13: |
---|
752 | self.dataDisplay.SetCellRenderer(r,2,wg.GridCellStringRenderer()) |
---|
753 | for c in range(4,15): |
---|
754 | if r >= len(cells): |
---|
755 | self.dataDisplay.SetCellRenderer(r,c,wg.GridCellStringRenderer()) |
---|
756 | if c != 6: |
---|
757 | self.dataDisplay.SetReadOnly(r,c,isReadOnly=True) |
---|
758 | self.dataDisplay.AutoSizeColumns(False) |
---|
759 | if controls[4] and not False in controls[6:12]: |
---|
760 | self.dataFrame.RefineCell.Enable(True) |
---|
761 | else: |
---|
762 | self.dataFrame.RefineCell.Enable(False) |
---|
763 | |
---|