1 | #GSASII - image data display routines |
---|
2 | ########### SVN repository information ################### |
---|
3 | # $Date: 2011-04-28 18:11:32 +0000 (Thu, 28 Apr 2011) $ |
---|
4 | # $Author: vondreele $ |
---|
5 | # $Revision: 271 $ |
---|
6 | # $URL: trunk/GSASIIimgGUI.py $ |
---|
7 | # $Id: GSASIIimgGUI.py 271 2011-04-28 18:11:32Z vondreele $ |
---|
8 | ########### SVN repository information ################### |
---|
9 | import wx |
---|
10 | import wx.grid as wg |
---|
11 | import matplotlib as mpl |
---|
12 | import math |
---|
13 | import time |
---|
14 | import cPickle |
---|
15 | import GSASIIpath |
---|
16 | import GSASIIimage as G2img |
---|
17 | import GSASIIplot as G2plt |
---|
18 | import GSASIIIO as G2IO |
---|
19 | import GSASIIgrid as G2gd |
---|
20 | |
---|
21 | VERY_LIGHT_GREY = wx.Colour(235,235,235) |
---|
22 | |
---|
23 | # trig functions in degrees |
---|
24 | sind = lambda x: math.sin(x*math.pi/180.) |
---|
25 | tand = lambda x: math.tan(x*math.pi/180.) |
---|
26 | cosd = lambda x: math.cos(x*math.pi/180.) |
---|
27 | asind = lambda x: 180.*math.asin(x)/math.pi |
---|
28 | |
---|
29 | |
---|
30 | def UpdateImageControls(self,data,masks): |
---|
31 | import ImageCalibrants as calFile |
---|
32 | |
---|
33 | def OnDataType(event): |
---|
34 | data['type'] = typeSel.GetValue()[:4] |
---|
35 | |
---|
36 | def OnNewColorBar(event): |
---|
37 | data['color'] = colSel.GetValue() |
---|
38 | G2plt.PlotExposedImage(self,event=event) |
---|
39 | |
---|
40 | def OnNewCalibrant(event): |
---|
41 | data['calibrant'] = calSel.GetValue() |
---|
42 | data['calibskip'] = calFile.Calibrants[data['calibrant']][2] |
---|
43 | limits = calFile.Calibrants[data['calibrant']][3] |
---|
44 | data['calibdmin'],data['pixLimit'],data['cutoff'] = limits |
---|
45 | pixLimit.SetValue(str(limits[1])) |
---|
46 | cutOff.SetValue('%.1f'%(limits[2])) |
---|
47 | calibSkip.SetValue(str(data['calibskip'])) |
---|
48 | calibDmin.SetValue('%.1f'%(limits[0])) |
---|
49 | |
---|
50 | def OnPixLimit(event): |
---|
51 | data['pixLimit'] = int(pixLimit.GetValue()) |
---|
52 | |
---|
53 | def OnCalibSkip(event): |
---|
54 | data['calibskip'] = int(calibSkip.GetValue()) |
---|
55 | |
---|
56 | def OnSetRings(event): |
---|
57 | if data['setRings']: |
---|
58 | data['setRings'] = False |
---|
59 | else: |
---|
60 | data['setRings'] = True |
---|
61 | G2plt.PlotExposedImage(self,event=event) |
---|
62 | |
---|
63 | def OnCalibDmin(event): |
---|
64 | try: |
---|
65 | dmin = float(calibDmin.GetValue()) |
---|
66 | if dmin < 0.5: |
---|
67 | raise ValueError |
---|
68 | data['calibdmin'] = dmin |
---|
69 | except ValueError: |
---|
70 | pass |
---|
71 | calibDmin.SetValue("%.2f"%(data['calibdmin'])) #reset in case of error |
---|
72 | |
---|
73 | def OnAzmthOff(event): |
---|
74 | try: |
---|
75 | azmthoff = float(azmthOff.GetValue()) |
---|
76 | data['azmthOff'] = azmthoff |
---|
77 | except ValueError: |
---|
78 | pass |
---|
79 | azmthOff.SetValue("%.2f"%(data['azmthOff'])) #reset in case of error |
---|
80 | |
---|
81 | def OnCutOff(event): |
---|
82 | try: |
---|
83 | cutoff = float(cutOff.GetValue()) |
---|
84 | if cutoff < 0.1: |
---|
85 | raise ValueError |
---|
86 | data['cutoff'] = cutoff |
---|
87 | except ValueError: |
---|
88 | pass |
---|
89 | cutOff.SetValue("%.1f"%(data['cutoff'])) #reset in case of error |
---|
90 | |
---|
91 | def OnMaxVal(event): |
---|
92 | try: |
---|
93 | value = min(data['range'][0][1],int(maxVal.GetValue())) |
---|
94 | if value < data['range'][1][0]+1: |
---|
95 | raise ValueError |
---|
96 | data['range'][1][1] = value |
---|
97 | except ValueError: |
---|
98 | pass |
---|
99 | maxVal.SetValue('%.0f'%(data['range'][1][1])) |
---|
100 | DeltOne = data['range'][1][1]-max(0.0,data['range'][0][0]) |
---|
101 | sqrtDeltOne = math.sqrt(DeltOne) |
---|
102 | maxSel.SetValue(int(100*sqrtDeltOne/sqrtDeltZero)) |
---|
103 | minSel.SetValue(int(100*(data['range'][1][0]/DeltOne))) |
---|
104 | G2plt.PlotExposedImage(self,event=event) |
---|
105 | |
---|
106 | def OnMinVal(event): |
---|
107 | try: |
---|
108 | value = int(minVal.GetValue()) |
---|
109 | if value > data['range'][1][1]-1: |
---|
110 | raise ValueError |
---|
111 | data['range'][1][0] = value |
---|
112 | except ValueError: |
---|
113 | pass |
---|
114 | minVal.SetValue('%.0f'%(data['range'][1][0])) |
---|
115 | minSel.SetValue(int(100*(data['range'][1][0]-max(0.0,data['range'][0][0]))/DeltOne)) |
---|
116 | G2plt.PlotExposedImage(self,event=event) |
---|
117 | |
---|
118 | def OnMaxSlider(event): |
---|
119 | sqrtDeltZero = math.sqrt(data['range'][0][1]) |
---|
120 | imax = int(maxSel.GetValue())*sqrtDeltZero/100. |
---|
121 | data['range'][1][1] = imax**2 |
---|
122 | data['range'][1][0] = max(0.0,min(data['range'][1][1]-1,data['range'][1][0])) |
---|
123 | DeltOne = max(1.0,data['range'][1][1]-data['range'][1][0]) |
---|
124 | minSel.SetValue(int(100*(data['range'][1][0]/DeltOne))) |
---|
125 | maxVal.SetValue('%.0f'%(data['range'][1][1])) |
---|
126 | G2plt.PlotExposedImage(self,event=event) |
---|
127 | |
---|
128 | def OnMinSlider(event): |
---|
129 | DeltOne = data['range'][1][1]-data['range'][1][0] |
---|
130 | imin = int(minSel.GetValue())*DeltOne/100. |
---|
131 | data['range'][1][0] = max(0.0,min(data['range'][1][1]-1,imin)) |
---|
132 | minVal.SetValue('%.0f'%(data['range'][1][0])) |
---|
133 | G2plt.PlotExposedImage(self,event=event) |
---|
134 | |
---|
135 | def OnNumOutChans(event): |
---|
136 | try: |
---|
137 | numChans = int(outChan.GetValue()) |
---|
138 | if numChans < 1: |
---|
139 | raise ValueError |
---|
140 | data['outChannels'] = numChans |
---|
141 | except ValueError: |
---|
142 | pass |
---|
143 | outChan.SetValue(str(data['outChannels'])) #reset in case of error |
---|
144 | |
---|
145 | def OnNumOutAzms(event): |
---|
146 | try: |
---|
147 | numAzms = int(outAzim.GetValue()) |
---|
148 | if numAzms < 1: |
---|
149 | raise ValueError |
---|
150 | data['outAzimuths'] = numAzms |
---|
151 | except ValueError: |
---|
152 | pass |
---|
153 | outAzim.SetValue(str(data['outAzimuths'])) #reset in case of error |
---|
154 | G2plt.PlotExposedImage(self,event=event) |
---|
155 | |
---|
156 | def OnWavelength(event): |
---|
157 | try: |
---|
158 | wave = float(waveSel.GetValue()) |
---|
159 | if wave < .01: |
---|
160 | raise ValueError |
---|
161 | data['wavelength'] = wave |
---|
162 | except ValueError: |
---|
163 | pass |
---|
164 | waveSel.SetValue("%6.5f" % (data['wavelength'])) #reset in case of error |
---|
165 | |
---|
166 | def OnShowLines(event): |
---|
167 | if data['showLines']: |
---|
168 | data['showLines'] = False |
---|
169 | else: |
---|
170 | data['showLines'] = True |
---|
171 | G2plt.PlotExposedImage(self,event=event) |
---|
172 | |
---|
173 | def OnSetDefault(event): |
---|
174 | import copy |
---|
175 | if data['setDefault']: |
---|
176 | self.imageDefault = {} |
---|
177 | data['setDefault'] = False |
---|
178 | else: |
---|
179 | self.imageDefault = copy.copy(data) |
---|
180 | data['setDefault'] = True |
---|
181 | |
---|
182 | def OnIOtth(event): |
---|
183 | Ltth = max(float(self.InnerTth.GetValue()),0.001) |
---|
184 | Utth = float(self.OuterTth.GetValue()) |
---|
185 | if Ltth > Utth: |
---|
186 | Ltth,Utth = Utth,Ltth |
---|
187 | data['IOtth'] = [Ltth,Utth] |
---|
188 | self.InnerTth.SetValue("%8.3f" % (Ltth)) |
---|
189 | self.OuterTth.SetValue("%8.2f" % (Utth)) |
---|
190 | G2plt.PlotExposedImage(self,event=event) |
---|
191 | |
---|
192 | def OnFullIntegrate(event): |
---|
193 | Lazm =int(self.Lazim.GetValue()) |
---|
194 | if data['fullIntegrate']: |
---|
195 | data['fullIntegrate'] = False |
---|
196 | data['LRazimuth'] = [Lazm,Lazm+20] |
---|
197 | else: |
---|
198 | data['fullIntegrate'] = True |
---|
199 | data['LRazimuth'] = [Lazm,Lazm+360] |
---|
200 | UpdateImageControls(self,data,masks) |
---|
201 | G2plt.PlotExposedImage(self,event=event) |
---|
202 | |
---|
203 | def OnLRazim(event): |
---|
204 | Lazm =int(self.Lazim.GetValue()) |
---|
205 | if data['fullIntegrate']: |
---|
206 | self.Razim.SetValue("%6d" % (Lazm+360)) |
---|
207 | Razm = int(self.Razim.GetValue()) |
---|
208 | if Lazm > Razm: |
---|
209 | Lazm -= 360 |
---|
210 | data['LRazimuth'] = [Lazm,Razm] |
---|
211 | G2plt.PlotExposedImage(self,event=event) |
---|
212 | |
---|
213 | def OnClearCalib(event): |
---|
214 | data['ring'] = [] |
---|
215 | data['rings'] = [] |
---|
216 | data['ellipses'] = [] |
---|
217 | self.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMCLEARCALIB,enable=False) |
---|
218 | G2plt.PlotExposedImage(self,event=event) |
---|
219 | |
---|
220 | def OnCalibrate(event): |
---|
221 | self.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMCLEARCALIB,enable=True) |
---|
222 | self.dataFrame.GetStatusBar().SetStatusText('Select > 4 points on 1st used ring; LB to pick, RB on point to delete else RB to finish') |
---|
223 | self.ifGetRing = True |
---|
224 | |
---|
225 | def OnIntegrate(event): |
---|
226 | self.Integrate = G2img.ImageIntegrate(self.ImageZ,data,masks) |
---|
227 | G2plt.PlotIntegration(self,newPlot=True) |
---|
228 | G2IO.SaveIntegration(self,self.PickId,data) |
---|
229 | self.MakePDF.Enable(True) |
---|
230 | |
---|
231 | def OnIntegrateAll(event): |
---|
232 | print 'integrate all' |
---|
233 | TextList = [[False,'All IMG',0]] |
---|
234 | Names = [] |
---|
235 | if self.PatternTree.GetCount(): |
---|
236 | id, cookie = self.PatternTree.GetFirstChild(self.root) |
---|
237 | while id: |
---|
238 | name = self.PatternTree.GetItemText(id) |
---|
239 | Names.append(name) |
---|
240 | if 'IMG' in name: |
---|
241 | TextList.append([False,name,id]) |
---|
242 | id, cookie = self.PatternTree.GetNextChild(self.root, cookie) |
---|
243 | if len(TextList) == 1: |
---|
244 | self.ErrorDialog('Nothing to integrate','There must some "IMG" patterns') |
---|
245 | return |
---|
246 | dlg = self.CopyDialog(self,'Image integration controls','Select images to integrate:',TextList) |
---|
247 | try: |
---|
248 | if dlg.ShowModal() == wx.ID_OK: |
---|
249 | result = dlg.GetData() |
---|
250 | if result[0][0]: #the 'All IMG' is True |
---|
251 | result = TextList[1:] |
---|
252 | for item in result: item[0] = True |
---|
253 | for item in result: |
---|
254 | ifintegrate,name,id = item |
---|
255 | if ifintegrate: |
---|
256 | id = G2gd.GetPatternTreeItemId(self, self.root, name) |
---|
257 | Npix,imagefile = self.PatternTree.GetItemPyData(id) |
---|
258 | image = G2IO.GetImageData(self,imagefile,True) |
---|
259 | Id = G2gd.GetPatternTreeItemId(self,id, 'Image Controls') |
---|
260 | Data = self.PatternTree.GetItemPyData(Id) |
---|
261 | try: |
---|
262 | Masks = self.PatternTree.GetItemPyData( |
---|
263 | G2gd.GetPatternTreeItemId(self,self.Image, 'Masks')) |
---|
264 | except TypeError: #missing Masks |
---|
265 | Imin,Imax = Data['Range'] |
---|
266 | Masks = {'Points':[],'Rings':[],'Arcs':[],'Polygons':[],'Thresholds':[(Imin,Imax),[Imin,Imax]]} |
---|
267 | self.PatternTree.SetItemPyData( |
---|
268 | G2gd.GetPatternTreeItemId(self,self.Image, 'Masks'),Masks) |
---|
269 | self.Integrate = G2img.ImageIntegrate(image,Data,Masks) |
---|
270 | # G2plt.PlotIntegration(self,newPlot=True,event=event) |
---|
271 | G2IO.SaveIntegration(self,Id,Data) |
---|
272 | finally: |
---|
273 | dlg.Destroy() |
---|
274 | |
---|
275 | def OnCopyControls(event): |
---|
276 | import copy |
---|
277 | TextList = [[False,'All IMG',0]] |
---|
278 | Names = [] |
---|
279 | if self.PatternTree.GetCount(): |
---|
280 | id, cookie = self.PatternTree.GetFirstChild(self.root) |
---|
281 | while id: |
---|
282 | name = self.PatternTree.GetItemText(id) |
---|
283 | Names.append(name) |
---|
284 | if 'IMG' in name: |
---|
285 | if id == self.Image: |
---|
286 | Source = name |
---|
287 | Data = copy.deepcopy(self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,id, 'Image Controls'))) |
---|
288 | Data['showLines'] = True |
---|
289 | Data['ring'] = [] |
---|
290 | Data['rings'] = [] |
---|
291 | Data['ellipses'] = [] |
---|
292 | Data['setDefault'] = False |
---|
293 | else: |
---|
294 | TextList.append([False,name,id]) |
---|
295 | id, cookie = self.PatternTree.GetNextChild(self.root, cookie) |
---|
296 | if len(TextList) == 1: |
---|
297 | self.ErrorDialog('Nothing to copy controls to','There must be more than one "IMG" pattern') |
---|
298 | return |
---|
299 | dlg = self.CopyDialog(self,'Copy image controls','Copy controls from '+Source+' to:',TextList) |
---|
300 | try: |
---|
301 | if dlg.ShowModal() == wx.ID_OK: |
---|
302 | result = dlg.GetData() |
---|
303 | if result[0][0]: |
---|
304 | result = TextList[1:] |
---|
305 | for item in result: item[0] = True |
---|
306 | for i,item in enumerate(result): |
---|
307 | ifcopy,name,id = item |
---|
308 | if ifcopy: |
---|
309 | oldData = copy.deepcopy(self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,id, 'Image Controls'))) |
---|
310 | Data['range'] = oldData['range'] |
---|
311 | Data['size'] = oldData['size'] |
---|
312 | Data['ring'] = [] |
---|
313 | Data['rings'] = [] |
---|
314 | Data['ellipses'] = [] |
---|
315 | self.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(self,id, 'Image Controls'),copy.deepcopy(Data)) |
---|
316 | finally: |
---|
317 | dlg.Destroy() |
---|
318 | |
---|
319 | def OnSaveControls(event): |
---|
320 | dlg = wx.FileDialog(self, 'Choose image controls file', '.', '', |
---|
321 | 'image control files (*.imctrl)|*.imctrl',wx.OPEN) |
---|
322 | if self.dirname: |
---|
323 | dlg.SetDirectory(self.dirname) |
---|
324 | try: |
---|
325 | if dlg.ShowModal() == wx.ID_OK: |
---|
326 | filename = dlg.GetPath() |
---|
327 | File = open(filename,'w') |
---|
328 | save = {} |
---|
329 | keys = ['type','wavelength','calibrant','distance','center', |
---|
330 | 'tilt','rotation','azmthOff','fullIntegrate','LRazimuth', |
---|
331 | 'IOtth','outAzimuths'] |
---|
332 | for key in keys: |
---|
333 | File.write(key+':'+str(data[key])+'\n') |
---|
334 | File.close() |
---|
335 | finally: |
---|
336 | dlg.Destroy() |
---|
337 | |
---|
338 | def OnLoadControls(event): |
---|
339 | dlg = wx.FileDialog(self, 'Choose image controls file', '.', '', |
---|
340 | 'image control files (*.imctrl)|*.imctrl',wx.OPEN) |
---|
341 | if self.dirname: |
---|
342 | dlg.SetDirectory(self.dirname) |
---|
343 | try: |
---|
344 | if dlg.ShowModal() == wx.ID_OK: |
---|
345 | filename = dlg.GetPath() |
---|
346 | File = open(filename,'r') |
---|
347 | save = {} |
---|
348 | S = File.readline() |
---|
349 | while S: |
---|
350 | if S[0] == '#': |
---|
351 | S = File.readline() |
---|
352 | continue |
---|
353 | [key,val] = S[:-1].split(':') |
---|
354 | if key in ['type','calibrant']: |
---|
355 | save[key] = val |
---|
356 | elif key in ['wavelength','distance','tilt','rotation']: |
---|
357 | save[key] = float(val) |
---|
358 | elif key in ['fullIntegrate',]: |
---|
359 | save[key] = bool(val) |
---|
360 | elif key in ['outAzimuths',]: |
---|
361 | save[key] = int(val) |
---|
362 | elif key in ['LRazimuth',]: |
---|
363 | if ',' in val: |
---|
364 | vals = val.strip('[] ').split(',') |
---|
365 | else: |
---|
366 | vals = val.strip('[] ').split() |
---|
367 | save[key] = [int(vals[0]),int(vals[1])] |
---|
368 | elif key in ['center','IOtth']: |
---|
369 | if ',' in val: |
---|
370 | vals = val.strip('[] ').split(',') |
---|
371 | else: |
---|
372 | vals = val.strip('[] ').split() |
---|
373 | save[key] = [float(vals[0]),float(vals[1])] |
---|
374 | S = File.readline() |
---|
375 | data.update(save) |
---|
376 | UpdateImageControls(self,data,masks) |
---|
377 | G2plt.PlotExposedImage(self,event=event) |
---|
378 | |
---|
379 | File.close() |
---|
380 | finally: |
---|
381 | dlg.Destroy() |
---|
382 | |
---|
383 | #fix for old files: |
---|
384 | if 'azmthOff' not in data: |
---|
385 | data['azmthOff'] = 0.0 |
---|
386 | #end fix |
---|
387 | |
---|
388 | colorList = [m for m in mpl.cm.datad.keys() if not m.endswith("_r")] |
---|
389 | calList = [m for m in calFile.Calibrants.keys()] |
---|
390 | typeList = ['PWDR - powder diffraction data','SASD - small angle scattering data', |
---|
391 | 'REFL - reflectometry data'] |
---|
392 | if not data.get('type'): #patch for old project files |
---|
393 | data['type'] = 'PWDR' |
---|
394 | typeDict = {'PWDR':typeList[0],'SASD':typeList[1],'REFL':typeList[2]} |
---|
395 | if self.dataDisplay: |
---|
396 | self.dataDisplay.Destroy() |
---|
397 | self.dataFrame.SetMenuBar(self.dataFrame.ImageMenu) |
---|
398 | if not self.dataFrame.GetStatusBar(): |
---|
399 | self.dataFrame.CreateStatusBar() |
---|
400 | self.dataFrame.Bind(wx.EVT_MENU, OnCalibrate, id=G2gd.wxID_IMCALIBRATE) |
---|
401 | self.dataFrame.Bind(wx.EVT_MENU, OnClearCalib, id=G2gd.wxID_IMCLEARCALIB) |
---|
402 | if not data['rings']: |
---|
403 | self.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMCLEARCALIB,enable=False) |
---|
404 | self.dataFrame.Bind(wx.EVT_MENU, OnIntegrate, id=G2gd.wxID_IMINTEGRATE) |
---|
405 | self.dataFrame.Bind(wx.EVT_MENU, OnIntegrateAll, id=G2gd.wxID_INTEGRATEALL) |
---|
406 | self.dataFrame.Bind(wx.EVT_MENU, OnCopyControls, id=G2gd.wxID_IMCOPYCONTROLS) |
---|
407 | self.dataFrame.Bind(wx.EVT_MENU, OnSaveControls, id=G2gd.wxID_IMSAVECONTROLS) |
---|
408 | self.dataFrame.Bind(wx.EVT_MENU, OnLoadControls, id=G2gd.wxID_IMLOADCONTROLS) |
---|
409 | self.dataDisplay = wx.Panel(self.dataFrame) |
---|
410 | mainSizer = wx.BoxSizer(wx.VERTICAL) |
---|
411 | mainSizer.Add((5,10),0) |
---|
412 | |
---|
413 | comboSizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
414 | comboSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Type of image data: '),0, |
---|
415 | wx.ALIGN_CENTER_VERTICAL) |
---|
416 | typeSel = wx.ComboBox(parent=self.dataDisplay,value=typeDict[data['type']],choices=typeList, |
---|
417 | style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
418 | typeSel.SetValue(data['type']) |
---|
419 | typeSel.Bind(wx.EVT_COMBOBOX, OnDataType) |
---|
420 | comboSizer.Add(typeSel,0,wx.ALIGN_CENTER_VERTICAL) |
---|
421 | comboSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Color bar '),0, |
---|
422 | wx.ALIGN_CENTER_VERTICAL) |
---|
423 | colSel = wx.ComboBox(parent=self.dataDisplay,value=data['color'],choices=colorList, |
---|
424 | style=wx.CB_READONLY|wx.CB_DROPDOWN|wx.CB_SORT) |
---|
425 | colSel.Bind(wx.EVT_COMBOBOX, OnNewColorBar) |
---|
426 | comboSizer.Add(colSel,0,wx.ALIGN_CENTER_VERTICAL) |
---|
427 | comboSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Azimuth offset '),0, |
---|
428 | wx.ALIGN_CENTER_VERTICAL) |
---|
429 | azmthOff = wx.TextCtrl(parent=self.dataDisplay,value=("%.2f" % (data['azmthOff'])), |
---|
430 | style=wx.TE_PROCESS_ENTER) |
---|
431 | azmthOff.Bind(wx.EVT_TEXT_ENTER,OnAzmthOff) |
---|
432 | azmthOff.Bind(wx.EVT_KILL_FOCUS,OnAzmthOff) |
---|
433 | comboSizer.Add(azmthOff,0,wx.ALIGN_CENTER_VERTICAL) |
---|
434 | mainSizer.Add(comboSizer,0,wx.ALIGN_LEFT) |
---|
435 | mainSizer.Add((5,5),0) |
---|
436 | |
---|
437 | maxSizer = wx.FlexGridSizer(2,3,0,5) |
---|
438 | maxSizer.AddGrowableCol(1,1) |
---|
439 | maxSizer.SetFlexibleDirection(wx.HORIZONTAL) |
---|
440 | sqrtDeltZero = math.sqrt(data['range'][0][1]-max(0.0,data['range'][0][0])) |
---|
441 | DeltOne = data['range'][1][1]-max(0.0,data['range'][0][0]) |
---|
442 | sqrtDeltOne = math.sqrt(DeltOne) |
---|
443 | maxSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Max intensity'),0, |
---|
444 | wx.ALIGN_CENTER_VERTICAL) |
---|
445 | maxSel = wx.Slider(parent=self.dataDisplay,style=wx.SL_HORIZONTAL, |
---|
446 | value=int(100*sqrtDeltOne/sqrtDeltZero)) |
---|
447 | maxSizer.Add(maxSel,1,wx.EXPAND) |
---|
448 | maxSel.Bind(wx.EVT_SLIDER, OnMaxSlider) |
---|
449 | maxVal = wx.TextCtrl(parent=self.dataDisplay,value='%.0f'%(data['range'][1][1])) |
---|
450 | maxVal.Bind(wx.EVT_TEXT_ENTER,OnMaxVal) |
---|
451 | maxVal.Bind(wx.EVT_KILL_FOCUS,OnMaxVal) |
---|
452 | maxSizer.Add(maxVal,0,wx.ALIGN_CENTER_VERTICAL) |
---|
453 | maxSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Min intensity'),0, |
---|
454 | wx.ALIGN_CENTER_VERTICAL) |
---|
455 | minSel = wx.Slider(parent=self.dataDisplay,style=wx.SL_HORIZONTAL, |
---|
456 | value=int(100*(data['range'][1][0]-max(0.0,data['range'][0][0]))/DeltOne)) |
---|
457 | maxSizer.Add(minSel,1,wx.EXPAND) |
---|
458 | minSel.Bind(wx.EVT_SLIDER, OnMinSlider) |
---|
459 | minVal = wx.TextCtrl(parent=self.dataDisplay,value='%.0f'%(data['range'][1][0])) |
---|
460 | minVal.Bind(wx.EVT_TEXT_ENTER,OnMinVal) |
---|
461 | minVal.Bind(wx.EVT_KILL_FOCUS,OnMinVal) |
---|
462 | maxSizer.Add(minVal,0,wx.ALIGN_CENTER_VERTICAL) |
---|
463 | mainSizer.Add(maxSizer,0,wx.ALIGN_LEFT|wx.EXPAND) |
---|
464 | |
---|
465 | dataSizer = wx.FlexGridSizer(6,4,5,5) |
---|
466 | dataSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Calibration coefficients'),0, |
---|
467 | wx.ALIGN_CENTER_VERTICAL) |
---|
468 | dataSizer.Add((5,0),0) |
---|
469 | dataSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Integration coefficients'),0, |
---|
470 | wx.ALIGN_CENTER_VERTICAL) |
---|
471 | dataSizer.Add((5,0),0) |
---|
472 | |
---|
473 | dataSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Beam center X,Y'),0, |
---|
474 | wx.ALIGN_CENTER_VERTICAL) |
---|
475 | cent = data['center'] |
---|
476 | centText = wx.TextCtrl(parent=self.dataDisplay,value=("%8.3f,%8.3f" % (cent[0],cent[1])),style=wx.TE_READONLY) |
---|
477 | centText.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
478 | dataSizer.Add(centText,0,wx.ALIGN_CENTER_VERTICAL) |
---|
479 | |
---|
480 | dataSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Inner/Outer 2-theta'),0, |
---|
481 | wx.ALIGN_CENTER_VERTICAL) |
---|
482 | |
---|
483 | IOtth = data['IOtth'] |
---|
484 | littleSizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
485 | self.InnerTth = wx.TextCtrl(parent=self.dataDisplay, |
---|
486 | value=("%8.3f" % (IOtth[0])),style=wx.TE_PROCESS_ENTER) |
---|
487 | self.InnerTth.Bind(wx.EVT_TEXT_ENTER,OnIOtth) |
---|
488 | self.InnerTth.Bind(wx.EVT_KILL_FOCUS,OnIOtth) |
---|
489 | littleSizer.Add(self.InnerTth,0,wx.ALIGN_CENTER_VERTICAL) |
---|
490 | self.OuterTth = wx.TextCtrl(parent=self.dataDisplay, |
---|
491 | value=("%8.2f" % (IOtth[1])),style=wx.TE_PROCESS_ENTER) |
---|
492 | self.OuterTth.Bind(wx.EVT_TEXT_ENTER,OnIOtth) |
---|
493 | self.OuterTth.Bind(wx.EVT_KILL_FOCUS,OnIOtth) |
---|
494 | littleSizer.Add(self.OuterTth,0,wx.ALIGN_CENTER_VERTICAL) |
---|
495 | dataSizer.Add(littleSizer,0,) |
---|
496 | |
---|
497 | dataSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Wavelength'),0, |
---|
498 | wx.ALIGN_CENTER_VERTICAL) |
---|
499 | waveSel = wx.TextCtrl(parent=self.dataDisplay,value=("%6.5f" % (data['wavelength'])), |
---|
500 | style=wx.TE_PROCESS_ENTER) |
---|
501 | waveSel.Bind(wx.EVT_TEXT_ENTER,OnWavelength) |
---|
502 | waveSel.Bind(wx.EVT_KILL_FOCUS,OnWavelength) |
---|
503 | dataSizer.Add(waveSel,0,wx.ALIGN_CENTER_VERTICAL) |
---|
504 | |
---|
505 | dataSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Start/End azimuth'),0, |
---|
506 | wx.ALIGN_CENTER_VERTICAL) |
---|
507 | LRazim = data['LRazimuth'] |
---|
508 | littleSizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
509 | self.Lazim = wx.TextCtrl(parent=self.dataDisplay, |
---|
510 | value=("%6d" % (LRazim[0])),style=wx.TE_PROCESS_ENTER) |
---|
511 | self.Lazim.Bind(wx.EVT_TEXT_ENTER,OnLRazim) |
---|
512 | self.Lazim.Bind(wx.EVT_KILL_FOCUS,OnLRazim) |
---|
513 | littleSizer.Add(self.Lazim,0,wx.ALIGN_CENTER_VERTICAL) |
---|
514 | self.Razim = wx.TextCtrl(parent=self.dataDisplay, |
---|
515 | value=("%6d" % (LRazim[1])),style=wx.TE_PROCESS_ENTER) |
---|
516 | self.Razim.Bind(wx.EVT_TEXT_ENTER,OnLRazim) |
---|
517 | self.Razim.Bind(wx.EVT_KILL_FOCUS,OnLRazim) |
---|
518 | if data['fullIntegrate']: |
---|
519 | self.Razim.Enable(False) |
---|
520 | self.Razim.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
521 | self.Razim.SetValue("%6d" % (LRazim[0]+360)) |
---|
522 | littleSizer.Add(self.Razim,0,wx.ALIGN_CENTER_VERTICAL) |
---|
523 | dataSizer.Add(littleSizer,0,) |
---|
524 | |
---|
525 | dataSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Distance'),0, |
---|
526 | wx.ALIGN_CENTER_VERTICAL) |
---|
527 | distSel = wx.TextCtrl(parent=self.dataDisplay,value=("%8.3f"%(data['distance'])),style=wx.TE_READONLY) |
---|
528 | distSel.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
529 | dataSizer.Add(distSel,0,wx.ALIGN_CENTER_VERTICAL) |
---|
530 | |
---|
531 | dataSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' No. 2-theta/azimuth bins'),0, |
---|
532 | wx.ALIGN_CENTER_VERTICAL) |
---|
533 | littleSizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
534 | outChan = wx.TextCtrl(parent=self.dataDisplay,value=str(data['outChannels']),style=wx.TE_PROCESS_ENTER) |
---|
535 | outChan.Bind(wx.EVT_TEXT_ENTER,OnNumOutChans) |
---|
536 | outChan.Bind(wx.EVT_KILL_FOCUS,OnNumOutChans) |
---|
537 | littleSizer.Add(outChan,0,wx.ALIGN_CENTER_VERTICAL) |
---|
538 | outAzim = wx.TextCtrl(parent=self.dataDisplay,value=str(data['outAzimuths']),style=wx.TE_PROCESS_ENTER) |
---|
539 | outAzim.Bind(wx.EVT_TEXT_ENTER,OnNumOutAzms) |
---|
540 | outAzim.Bind(wx.EVT_KILL_FOCUS,OnNumOutAzms) |
---|
541 | littleSizer.Add(outAzim,0,wx.ALIGN_CENTER_VERTICAL) |
---|
542 | dataSizer.Add(littleSizer,0,) |
---|
543 | |
---|
544 | dataSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Tilt angle'),0, |
---|
545 | wx.ALIGN_CENTER_VERTICAL) |
---|
546 | tiltSel = wx.TextCtrl(parent=self.dataDisplay,value=("%9.3f"%(data['tilt'])),style=wx.TE_READONLY) |
---|
547 | tiltSel.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
548 | dataSizer.Add(tiltSel,0,wx.ALIGN_CENTER_VERTICAL) |
---|
549 | showLines = wx.CheckBox(parent=self.dataDisplay,label='Show integration limits?') |
---|
550 | dataSizer.Add(showLines,0,wx.ALIGN_CENTER_VERTICAL) |
---|
551 | showLines.Bind(wx.EVT_CHECKBOX, OnShowLines) |
---|
552 | showLines.SetValue(data['showLines']) |
---|
553 | fullIntegrate = wx.CheckBox(parent=self.dataDisplay,label='Do full integration?') |
---|
554 | dataSizer.Add(fullIntegrate,0,wx.ALIGN_CENTER_VERTICAL) |
---|
555 | fullIntegrate.Bind(wx.EVT_CHECKBOX, OnFullIntegrate) |
---|
556 | fullIntegrate.SetValue(data['fullIntegrate']) |
---|
557 | |
---|
558 | dataSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Tilt rotation'),0, |
---|
559 | wx.ALIGN_CENTER_VERTICAL) |
---|
560 | rotSel = wx.TextCtrl(parent=self.dataDisplay,value=("%9.3f"%(data['rotation']-90.)),style=wx.TE_READONLY) |
---|
561 | rotSel.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
562 | dataSizer.Add(rotSel,0,wx.ALIGN_CENTER_VERTICAL) |
---|
563 | setDefault = wx.CheckBox(parent=self.dataDisplay,label='Use as default for all images?') |
---|
564 | dataSizer.Add(setDefault,0,wx.ALIGN_CENTER_VERTICAL) |
---|
565 | setDefault.Bind(wx.EVT_CHECKBOX, OnSetDefault) |
---|
566 | setDefault.SetValue(data['setDefault']) |
---|
567 | |
---|
568 | mainSizer.Add((5,5),0) |
---|
569 | mainSizer.Add(dataSizer,0) |
---|
570 | mainSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Calibration controls:'),0, |
---|
571 | wx.ALIGN_CENTER_VERTICAL) |
---|
572 | mainSizer.Add((5,5),0) |
---|
573 | calibSizer = wx.FlexGridSizer(2,3,5,5) |
---|
574 | comboSizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
575 | comboSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Calibrant '),0, |
---|
576 | wx.ALIGN_CENTER_VERTICAL) |
---|
577 | calSel = wx.ComboBox(parent=self.dataDisplay,value=data['calibrant'],choices=calList, |
---|
578 | style=wx.CB_READONLY|wx.CB_DROPDOWN|wx.CB_SORT) |
---|
579 | calSel.Bind(wx.EVT_COMBOBOX, OnNewCalibrant) |
---|
580 | comboSizer.Add(calSel,0,wx.ALIGN_CENTER_VERTICAL) |
---|
581 | calibSizer.Add(comboSizer,0) |
---|
582 | |
---|
583 | comboSizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
584 | comboSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Calib lines to skip '),0, |
---|
585 | wx.ALIGN_CENTER_VERTICAL) |
---|
586 | calibSkip = wx.ComboBox(parent=self.dataDisplay,value=str(data['calibskip']),choices=['0','1','2','3','4','5','6','7','8','9','10'], |
---|
587 | style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
588 | calibSkip.Bind(wx.EVT_COMBOBOX, OnCalibSkip) |
---|
589 | comboSizer.Add(calibSkip,0,wx.ALIGN_CENTER_VERTICAL) |
---|
590 | calibSizer.Add(comboSizer,0) |
---|
591 | |
---|
592 | comboSizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
593 | comboSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Min calib d-spacing '),0, |
---|
594 | wx.ALIGN_CENTER_VERTICAL) |
---|
595 | calibDmin = wx.TextCtrl(parent=self.dataDisplay,value=("%.2f" % (data['calibdmin'])), |
---|
596 | style=wx.TE_PROCESS_ENTER) |
---|
597 | calibDmin.Bind(wx.EVT_TEXT_ENTER,OnCalibDmin) |
---|
598 | calibDmin.Bind(wx.EVT_KILL_FOCUS,OnCalibDmin) |
---|
599 | comboSizer.Add(calibDmin,0,wx.ALIGN_CENTER_VERTICAL) |
---|
600 | calibSizer.Add(comboSizer,0) |
---|
601 | |
---|
602 | comboSizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
603 | comboSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Min ring I/Ib '),0, |
---|
604 | wx.ALIGN_CENTER_VERTICAL) |
---|
605 | cutOff = wx.TextCtrl(parent=self.dataDisplay,value=("%.1f" % (data['cutoff'])), |
---|
606 | style=wx.TE_PROCESS_ENTER) |
---|
607 | cutOff.Bind(wx.EVT_TEXT_ENTER,OnCutOff) |
---|
608 | cutOff.Bind(wx.EVT_KILL_FOCUS,OnCutOff) |
---|
609 | comboSizer.Add(cutOff,0,wx.ALIGN_CENTER_VERTICAL) |
---|
610 | calibSizer.Add(comboSizer,0) |
---|
611 | |
---|
612 | comboSizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
613 | comboSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Pixel search range '),0, |
---|
614 | wx.ALIGN_CENTER_VERTICAL) |
---|
615 | pixLimit = wx.ComboBox(parent=self.dataDisplay,value=str(data['pixLimit']),choices=['1','2','5','10','15','20'], |
---|
616 | style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
617 | pixLimit.Bind(wx.EVT_COMBOBOX, OnPixLimit) |
---|
618 | comboSizer.Add(pixLimit,0,wx.ALIGN_CENTER_VERTICAL) |
---|
619 | calibSizer.Add(comboSizer,0) |
---|
620 | |
---|
621 | comboSizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
622 | setRings = wx.CheckBox(parent=self.dataDisplay,label='Show ring picks?') |
---|
623 | comboSizer.Add(setRings,0) |
---|
624 | setRings.Bind(wx.EVT_CHECKBOX, OnSetRings) |
---|
625 | setRings.SetValue(data['setRings']) |
---|
626 | calibSizer.Add(comboSizer,0) |
---|
627 | |
---|
628 | mainSizer.Add(calibSizer,0,wx.ALIGN_CENTER_VERTICAL) |
---|
629 | |
---|
630 | mainSizer.Layout() |
---|
631 | self.dataDisplay.SetSizer(mainSizer) |
---|
632 | fitSize = mainSizer.Fit(self.dataFrame) |
---|
633 | self.dataFrame.setSizePosLeft(fitSize) |
---|
634 | self.dataDisplay.SetSize(fitSize) |
---|
635 | |
---|
636 | def UpdateMasks(self,data): |
---|
637 | |
---|
638 | def OnTextMsg(event): |
---|
639 | Obj = event.GetEventObject() |
---|
640 | Obj.SetToolTipString('Drag this mask on 2D Powder Image with mouse to change ') |
---|
641 | |
---|
642 | def OnThreshold(event): |
---|
643 | try: |
---|
644 | lower = max(int(lowerThreshold.GetValue()),thresh[0][0]) |
---|
645 | except ValueError: |
---|
646 | lower = thresh[0][0] |
---|
647 | try: |
---|
648 | upper = min(int(upperThreshold.GetValue()),thresh[0][1]) |
---|
649 | except ValueError: |
---|
650 | upper = thresh[0][1] |
---|
651 | data['Thresholds'][1] = [lower,upper] |
---|
652 | lowerThreshold.SetValue("%8d" % (lower)) |
---|
653 | upperThreshold.SetValue("%8d" % (upper)) |
---|
654 | G2plt.PlotExposedImage(self,event=event) |
---|
655 | |
---|
656 | def OnSpotDiameter(event): |
---|
657 | Obj = event.GetEventObject() |
---|
658 | try: |
---|
659 | diameter = min(100.,max(0.1,float(Obj.GetValue()))) |
---|
660 | except ValueError: |
---|
661 | diameter = 1.0 |
---|
662 | Obj.SetValue("%.2f"%(diameter)) |
---|
663 | data['Points'][spotIds.index(Obj.GetId())][2] = diameter |
---|
664 | G2plt.PlotExposedImage(self,event=event) |
---|
665 | |
---|
666 | def OnDeleteSpot(event): |
---|
667 | Obj = event.GetEventObject() |
---|
668 | del(data['Points'][delSpotId.index(Obj)]) |
---|
669 | UpdateMasks(self,data) |
---|
670 | G2plt.PlotExposedImage(self,event=event) |
---|
671 | |
---|
672 | def OnRingThickness(event): |
---|
673 | Obj = event.GetEventObject() |
---|
674 | try: |
---|
675 | thick = min(1.0,max(0.001,float(Obj.GetValue()))) |
---|
676 | except ValueError: |
---|
677 | thick = 0.1 |
---|
678 | Obj.SetValue("%.3f"%(thick)) |
---|
679 | data['Rings'][ringIds.index(Obj.GetId())][1] = thick |
---|
680 | G2plt.PlotExposedImage(self,event=event) |
---|
681 | |
---|
682 | def OnDeleteRing(event): |
---|
683 | Obj = event.GetEventObject() |
---|
684 | del(data['Rings'][delRingId.index(Obj)]) |
---|
685 | UpdateMasks(self,data) |
---|
686 | G2plt.PlotExposedImage(self,event=event) |
---|
687 | |
---|
688 | def OnArcThickness(event): |
---|
689 | Obj = event.GetEventObject() |
---|
690 | try: |
---|
691 | thick = min(20.0,max(0.001,float(Obj.GetValue()))) |
---|
692 | except ValueError: |
---|
693 | thick = 0.1 |
---|
694 | Obj.SetValue("%.3f"%(thick)) |
---|
695 | data['Arcs'][arcIds.index(Obj.GetId())][2] = thick |
---|
696 | G2plt.PlotExposedImage(self,event=event) |
---|
697 | |
---|
698 | def OnDeleteArc(event): |
---|
699 | Obj = event.GetEventObject() |
---|
700 | del(data['Arcs'][delArcId.index(Obj)]) |
---|
701 | UpdateMasks(self,data) |
---|
702 | G2plt.PlotExposedImage(self,event=event) |
---|
703 | |
---|
704 | def OnDeletePoly(event): |
---|
705 | Obj = event.GetEventObject() |
---|
706 | del(data['Polygons'][delPolyId.index(Obj)]) |
---|
707 | UpdateMasks(self,data) |
---|
708 | G2plt.PlotExposedImage(self,event=event) |
---|
709 | |
---|
710 | def OnCopyMask(event): |
---|
711 | import copy |
---|
712 | TextList = [] |
---|
713 | Names = [] |
---|
714 | if self.PatternTree.GetCount(): |
---|
715 | id, cookie = self.PatternTree.GetFirstChild(self.root) |
---|
716 | while id: |
---|
717 | name = self.PatternTree.GetItemText(id) |
---|
718 | Names.append(name) |
---|
719 | if 'IMG' in name: |
---|
720 | if id == self.Image: |
---|
721 | Source = name |
---|
722 | Mask = copy.copy(self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,id, 'Masks'))) |
---|
723 | del Mask['Thresholds'] |
---|
724 | else: |
---|
725 | TextList.append([False,name,id]) |
---|
726 | id, cookie = self.PatternTree.GetNextChild(self.root, cookie) |
---|
727 | if not len(TextList): |
---|
728 | self.ErrorDialog('Nothing to copy mask to','There must be more than one "IMG" pattern') |
---|
729 | return |
---|
730 | dlg = self.CopyDialog(self,'Copy mask information','Copy mask from '+Source+' to:',TextList) |
---|
731 | try: |
---|
732 | if dlg.ShowModal() == wx.ID_OK: |
---|
733 | result = dlg.GetData() |
---|
734 | for i,item in enumerate(result): |
---|
735 | ifcopy,name,id = item |
---|
736 | if ifcopy: |
---|
737 | mask = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,id, 'Masks')) |
---|
738 | mask.update(Mask) |
---|
739 | self.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(self,id, 'Masks'),mask) |
---|
740 | finally: |
---|
741 | dlg.Destroy() |
---|
742 | |
---|
743 | if self.dataDisplay: |
---|
744 | self.dataDisplay.Destroy() |
---|
745 | self.dataFrame.SetMenuBar(self.dataFrame.MaskMenu) |
---|
746 | self.dataFrame.Bind(wx.EVT_MENU, OnCopyMask, id=G2gd.wxID_MASKCOPY) |
---|
747 | if not self.dataFrame.GetStatusBar(): |
---|
748 | Status = self.dataFrame.CreateStatusBar() |
---|
749 | Status.SetStatusText("To add mask: On 2D Powder Image, key a:arc, r:ring, s:spot, p:polygon") |
---|
750 | self.dataDisplay = wx.Panel(self.dataFrame) |
---|
751 | mainSizer = wx.BoxSizer(wx.VERTICAL) |
---|
752 | mainSizer.Add((5,10),0) |
---|
753 | |
---|
754 | thresh = data['Thresholds'] #min/max intensity range |
---|
755 | spots = data['Points'] #x,y,radius in mm |
---|
756 | rings = data['Rings'] #radius, thickness |
---|
757 | polygons = data['Polygons'] #3+ x,y pairs |
---|
758 | arcs = data['Arcs'] #radius, start/end azimuth, thickness |
---|
759 | |
---|
760 | littleSizer = wx.FlexGridSizer(2,3,0,5) |
---|
761 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Lower/Upper limits '),0, |
---|
762 | wx.ALIGN_CENTER_VERTICAL) |
---|
763 | Text = wx.TextCtrl(self.dataDisplay,value=("%8d" % (thresh[0][0])),style=wx.TE_READONLY) |
---|
764 | littleSizer.Add(Text,0,wx.ALIGN_CENTER_VERTICAL) |
---|
765 | Text.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
766 | Text = wx.TextCtrl(self.dataDisplay,value=("%8d" % (thresh[0][1])),style=wx.TE_READONLY) |
---|
767 | littleSizer.Add(Text,0,wx.ALIGN_CENTER_VERTICAL) |
---|
768 | Text.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
769 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Lower/Upper thresholds '), |
---|
770 | 0,wx.ALIGN_CENTER_VERTICAL) |
---|
771 | lowerThreshold = wx.TextCtrl(parent=self.dataDisplay, |
---|
772 | value=("%8d" % (thresh[1][0])),style=wx.TE_PROCESS_ENTER) |
---|
773 | lowerThreshold.Bind(wx.EVT_TEXT_ENTER,OnThreshold) |
---|
774 | lowerThreshold.Bind(wx.EVT_KILL_FOCUS,OnThreshold) |
---|
775 | littleSizer.Add(lowerThreshold,0,wx.ALIGN_CENTER_VERTICAL) |
---|
776 | upperThreshold = wx.TextCtrl(parent=self.dataDisplay, |
---|
777 | value=("%8d" % (thresh[1][1])),style=wx.TE_PROCESS_ENTER) |
---|
778 | upperThreshold.Bind(wx.EVT_TEXT_ENTER,OnThreshold) |
---|
779 | upperThreshold.Bind(wx.EVT_KILL_FOCUS,OnThreshold) |
---|
780 | littleSizer.Add(upperThreshold,0,wx.ALIGN_CENTER_VERTICAL) |
---|
781 | mainSizer.Add(littleSizer,0,) |
---|
782 | spotIds = [] |
---|
783 | delSpotId = [] |
---|
784 | if spots: |
---|
785 | littleSizer = wx.FlexGridSizer(len(spots)+2,3,0,5) |
---|
786 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Spot masks:'),0, |
---|
787 | wx.ALIGN_CENTER_VERTICAL) |
---|
788 | littleSizer.Add((5,0),0) |
---|
789 | littleSizer.Add((5,0),0) |
---|
790 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' position, mm'),0, |
---|
791 | wx.ALIGN_CENTER_VERTICAL) |
---|
792 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' diameter, mm'),0, |
---|
793 | wx.ALIGN_CENTER_VERTICAL) |
---|
794 | littleSizer.Add((5,0),0) |
---|
795 | for x,y,d in spots: |
---|
796 | spotText = wx.TextCtrl(parent=self.dataDisplay,value=("%.2f,%.2f" % (x,y)), |
---|
797 | style=wx.TE_READONLY) |
---|
798 | spotText.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
799 | littleSizer.Add(spotText,0,wx.ALIGN_CENTER_VERTICAL) |
---|
800 | spotText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) |
---|
801 | spotDiameter = wx.TextCtrl(parent=self.dataDisplay,value=("%.2f" % (d)), |
---|
802 | style=wx.TE_PROCESS_ENTER) |
---|
803 | littleSizer.Add(spotDiameter,0,wx.ALIGN_CENTER_VERTICAL) |
---|
804 | spotDiameter.Bind(wx.EVT_TEXT_ENTER,OnSpotDiameter) |
---|
805 | spotDiameter.Bind(wx.EVT_KILL_FOCUS,OnSpotDiameter) |
---|
806 | spotIds.append(spotDiameter.GetId()) |
---|
807 | spotDelete = wx.CheckBox(parent=self.dataDisplay,label='delete?') |
---|
808 | spotDelete.Bind(wx.EVT_CHECKBOX,OnDeleteSpot) |
---|
809 | delSpotId.append(spotDelete) |
---|
810 | littleSizer.Add(spotDelete,0,wx.ALIGN_CENTER_VERTICAL) |
---|
811 | mainSizer.Add(littleSizer,0,) |
---|
812 | ringIds = [] |
---|
813 | delRingId = [] |
---|
814 | if rings: |
---|
815 | littleSizer = wx.FlexGridSizer(len(rings)+2,3,0,5) |
---|
816 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Ring masks:'),0, |
---|
817 | wx.ALIGN_CENTER_VERTICAL) |
---|
818 | littleSizer.Add((5,0),0) |
---|
819 | littleSizer.Add((5,0),0) |
---|
820 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' 2-theta,deg'),0, |
---|
821 | wx.ALIGN_CENTER_VERTICAL) |
---|
822 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' thickness, deg'),0, |
---|
823 | wx.ALIGN_CENTER_VERTICAL) |
---|
824 | littleSizer.Add((5,0),0) |
---|
825 | for tth,thick in rings: |
---|
826 | ringText = wx.TextCtrl(parent=self.dataDisplay,value=("%.3f" % (tth)), |
---|
827 | style=wx.TE_READONLY) |
---|
828 | ringText.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
829 | ringText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) |
---|
830 | littleSizer.Add(ringText,0,wx.ALIGN_CENTER_VERTICAL) |
---|
831 | ringThick = wx.TextCtrl(parent=self.dataDisplay,value=("%.3f" % (thick)), |
---|
832 | style=wx.TE_PROCESS_ENTER) |
---|
833 | littleSizer.Add(ringThick,0,wx.ALIGN_CENTER_VERTICAL) |
---|
834 | ringThick.Bind(wx.EVT_TEXT_ENTER,OnRingThickness) |
---|
835 | ringThick.Bind(wx.EVT_KILL_FOCUS,OnRingThickness) |
---|
836 | ringIds.append(ringThick.GetId()) |
---|
837 | ringDelete = wx.CheckBox(parent=self.dataDisplay,label='delete?') |
---|
838 | ringDelete.Bind(wx.EVT_CHECKBOX,OnDeleteRing) |
---|
839 | delRingId.append(ringDelete) |
---|
840 | littleSizer.Add(ringDelete,0,wx.ALIGN_CENTER_VERTICAL) |
---|
841 | mainSizer.Add(littleSizer,0,) |
---|
842 | arcIds = [] |
---|
843 | delArcId = [] |
---|
844 | if arcs: |
---|
845 | littleSizer = wx.FlexGridSizer(len(rings)+2,4,0,5) |
---|
846 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Arc masks:'),0, |
---|
847 | wx.ALIGN_CENTER_VERTICAL) |
---|
848 | littleSizer.Add((5,0),0) |
---|
849 | littleSizer.Add((5,0),0) |
---|
850 | littleSizer.Add((5,0),0) |
---|
851 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' 2-theta,deg'),0, |
---|
852 | wx.ALIGN_CENTER_VERTICAL) |
---|
853 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' azimuth, deg'),0, |
---|
854 | wx.ALIGN_CENTER_VERTICAL) |
---|
855 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' thickness, deg'),0, |
---|
856 | wx.ALIGN_CENTER_VERTICAL) |
---|
857 | littleSizer.Add((5,0),0) |
---|
858 | for tth,azimuth,thick in arcs: |
---|
859 | arcText = wx.TextCtrl(parent=self.dataDisplay,value=("%.3f" % (tth)), |
---|
860 | style=wx.TE_READONLY) |
---|
861 | arcText.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
862 | arcText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) |
---|
863 | littleSizer.Add(arcText,0,wx.ALIGN_CENTER_VERTICAL) |
---|
864 | azmText = wx.TextCtrl(parent=self.dataDisplay,value=("%d,%d" % (azimuth[0],azimuth[1])), |
---|
865 | style=wx.TE_READONLY) |
---|
866 | azmText.SetBackgroundColour(VERY_LIGHT_GREY) |
---|
867 | azmText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) |
---|
868 | littleSizer.Add(azmText,0,wx.ALIGN_CENTER_VERTICAL) |
---|
869 | arcThick = wx.TextCtrl(parent=self.dataDisplay,value=("%.3f" % (thick)), |
---|
870 | style=wx.TE_PROCESS_ENTER) |
---|
871 | littleSizer.Add(arcThick,0,wx.ALIGN_CENTER_VERTICAL) |
---|
872 | arcThick.Bind(wx.EVT_TEXT_ENTER,OnArcThickness) |
---|
873 | arcThick.Bind(wx.EVT_KILL_FOCUS,OnArcThickness) |
---|
874 | arcIds.append(arcThick.GetId()) |
---|
875 | arcDelete = wx.CheckBox(parent=self.dataDisplay,label='delete?') |
---|
876 | arcDelete.Bind(wx.EVT_CHECKBOX,OnDeleteArc) |
---|
877 | delArcId.append(arcDelete) |
---|
878 | littleSizer.Add(arcDelete,0,wx.ALIGN_CENTER_VERTICAL) |
---|
879 | mainSizer.Add(littleSizer,0,) |
---|
880 | polyIds = [] |
---|
881 | delPolyId = [] |
---|
882 | if polygons: |
---|
883 | littleSizer = wx.FlexGridSizer(len(polygons)+2,2,0,5) |
---|
884 | littleSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Polygon masks:'),0, |
---|
885 | wx.ALIGN_CENTER_VERTICAL) |
---|
886 | littleSizer.Add((5,0),0) |
---|
887 | for polygon in polygons: |
---|
888 | if polygon: |
---|
889 | polyList = [] |
---|
890 | for x,y in polygon: |
---|
891 | polyList.append("%.2f, %.2f"%(x,y)) |
---|
892 | polyText = wx.ComboBox(self.dataDisplay,value=polyList[0],choices=polyList,style=wx.CB_READONLY) |
---|
893 | littleSizer.Add(polyText,0,wx.ALIGN_CENTER_VERTICAL) |
---|
894 | polyDelete = wx.CheckBox(parent=self.dataDisplay,label='delete?') |
---|
895 | polyDelete.Bind(wx.EVT_CHECKBOX,OnDeletePoly) |
---|
896 | delPolyId.append(polyDelete) |
---|
897 | littleSizer.Add(polyDelete,0,wx.ALIGN_CENTER_VERTICAL) |
---|
898 | mainSizer.Add(littleSizer,0,) |
---|
899 | mainSizer.Layout() |
---|
900 | self.dataDisplay.SetSizer(mainSizer) |
---|
901 | self.dataDisplay.SetSize(mainSizer.Fit(self.dataFrame)) |
---|
902 | self.dataFrame.setSizePosLeft(mainSizer.Fit(self.dataFrame)) |
---|