source: trunk/GSASIIddataGUI.py @ 2826

Last change on this file since 2826 was 2752, checked in by vondreele, 8 years ago

fix (again) a LeBail? bug on loading a new phase

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 46.4 KB
Line 
1# -*- coding: utf-8 -*-
2#GSASII - phase data display routines
3########### SVN repository information ###################
4# $Date: 2017-03-09 14:54:25 +0000 (Thu, 09 Mar 2017) $
5# $Author: vondreele $
6# $Revision: 2752 $
7# $URL: trunk/GSASIIddataGUI.py $
8# $Id: GSASIIddataGUI.py 2752 2017-03-09 14:54:25Z vondreele $
9########### SVN repository information ###################
10'''
11*GSASIIddataGUI: Phase Diffraction Data GUI*
12--------------------------------------------
13
14Module to create the GUI for display of diffraction data * phase
15information that is shown in the data display window
16(when a phase is selected.)
17
18'''
19import wx
20import GSASIIpath
21GSASIIpath.SetVersionNumber("$Revision: 2752 $")
22import GSASIIlattice as G2lat
23import GSASIIspc as G2spc
24import GSASIIplot as G2plt
25import GSASIIgrid as G2gd
26import GSASIIpwd as G2pwd
27import GSASIIphsGUI as G2phsGUI
28import GSASIIctrls as G2G
29import numpy as np
30
31WACV = wx.ALIGN_CENTER_VERTICAL
32VERY_LIGHT_GREY = wx.Colour(235,235,235)
33WHITE = wx.Colour(255,255,255)
34BLACK = wx.Colour(0,0,0)
35mapDefault = {'MapType':'','RefList':'','Resolution':0.5,'Show bonds':True,
36                'rho':[],'rhoMax':0.,'mapSize':10.0,'cutOff':50.,'Flip':False}
37
38################################################################################
39##### DData routines
40################################################################################       
41def UpdateDData(G2frame,DData,data,hist='',Scroll=0):
42    '''Display the Diffraction Data associated with a phase
43    (items where there is a value for each histogram and phase)
44
45    :param wx.frame G2frame: the main GSAS-II frame object
46    :param wx.ScrolledWindow DData: notebook page to be used for the display
47    :param dict data: all the information on the phase in a dictionary
48    :param str hist: histogram name
49    :param int Scroll: previous scroll position
50
51    '''
52    G2frame.dataFrame.SetStatusText('')
53    keyList = G2frame.GetHistogramNames(['PWDR','HKLF'])
54    UseList = data['Histograms']
55    if UseList:
56        G2frame.dataFrame.DataMenu.Enable(G2gd.wxID_DATADELETE,True)
57        for item in G2frame.Refine: item.Enable(True)
58    else:
59        G2frame.dataFrame.DataMenu.Enable(G2gd.wxID_DATADELETE,False)
60        for item in G2frame.Refine: item.Enable(False)
61    generalData = data['General']
62    PhaseName = generalData['Name']       
63    SGData = generalData['SGData']
64    if len(UseList) == 0: # no associated, don't display anything
65        G2frame.hist = '' 
66    elif hist: # something was input as a selection
67        G2frame.hist = hist
68    elif not G2frame.hist or G2frame.hist not in UseList: # no or bad selection but have data, take the first
69        for key in keyList:
70            if key in UseList:
71                    G2frame.hist = key
72                    break
73    PWDR = any(['PWDR' in item for item in keyList])
74    Indx = {}
75   
76    def PlotSizer():
77
78        def OnPlotSel(event):
79            Obj = event.GetEventObject()
80            generalData['Data plot type'] = Obj.GetStringSelection()
81            G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
82            wx.CallLater(100,UpdateDData,G2frame,DData,data,G2frame.hist)
83           
84        def OnPOhkl(event):
85            event.Skip()
86            Obj = event.GetEventObject()
87            Saxis = Obj.GetValue().split()
88            try:
89                hkl = [int(Saxis[i]) for i in range(3)]
90            except (ValueError,IndexError):
91                hkl = generalData['POhkl']
92            if not np.any(np.array(hkl)):
93                hkl = generalData['POhkl']
94            generalData['POhkl'] = hkl
95            h,k,l = hkl
96            Obj.SetValue('%3d %3d %3d'%(h,k,l)) 
97            G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
98       
99        plotSizer = wx.BoxSizer(wx.VERTICAL)
100        choice = ['None','Mustrain','Size','Preferred orientation','Inv. pole figure']
101        plotSel = wx.RadioBox(DData,wx.ID_ANY,'Select plot type:',choices=choice,
102            majorDimension=1,style=wx.RA_SPECIFY_COLS)
103        plotSel.SetStringSelection(generalData['Data plot type'])
104        plotSel.Bind(wx.EVT_RADIOBOX,OnPlotSel)   
105        plotSizer.Add(plotSel)
106        if generalData['Data plot type'] == 'Preferred orientation':
107            POhklSizer = wx.BoxSizer(wx.HORIZONTAL)
108            POhklSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Plot preferred orientation for H K L: '),0,WACV)
109            h,k,l = generalData['POhkl']
110            poAxis = wx.TextCtrl(DData,wx.ID_ANY,'%3d %3d %3d'%(h,k,l),style=wx.TE_PROCESS_ENTER)
111            poAxis.Bind(wx.EVT_TEXT_ENTER,OnPOhkl)
112            poAxis.Bind(wx.EVT_KILL_FOCUS,OnPOhkl)
113            POhklSizer.Add(poAxis,0,WACV)
114            plotSizer.Add(POhklSizer)
115        elif generalData['Data plot type'] == 'Inv. pole figure':
116            pass    #might need something here?     
117        return plotSizer
118       
119    def ScaleSizer():
120       
121        def OnScaleRef(event):
122            Obj = event.GetEventObject()
123            UseList[G2frame.hist]['Scale'][1] = Obj.GetValue()
124           
125        scaleSizer = wx.BoxSizer(wx.HORIZONTAL)
126        if 'PWDR' in G2frame.hist:
127            scaleRef = wx.CheckBox(DData,wx.ID_ANY,label=' Phase fraction: ')
128        elif 'HKLF' in G2frame.hist:
129            scaleRef = wx.CheckBox(DData,wx.ID_ANY,label=' Scale factor: ')               
130        scaleRef.SetValue(UseList[G2frame.hist]['Scale'][1])
131        scaleRef.Bind(wx.EVT_CHECKBOX, OnScaleRef)
132        scaleSizer.Add(scaleRef,0,WACV|wx.LEFT,5)
133        scaleVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Scale'],0,
134            min=0.,nDig=(10,4),typeHint=float)
135        scaleSizer.Add(scaleVal,0,WACV)
136        if 'PWDR' in G2frame.hist and generalData['Type'] != 'magnetic':
137            wtSum = G2pwd.PhaseWtSum(G2frame,G2frame.hist)
138            weightFr = UseList[G2frame.hist]['Scale'][0]*generalData['Mass']/wtSum
139            scaleSizer.Add(wx.StaticText(DData,label=' Wt. fraction: %.3f'%(weightFr)),0,WACV)
140        return scaleSizer
141       
142    def OnLGmixRef(event):
143        Obj = event.GetEventObject()
144        hist,name = Indx[Obj.GetId()]
145        UseList[G2frame.hist][name][2][2] = Obj.GetValue()
146       
147    def OnLGmixVal(event):
148        event.Skip()
149        Obj = event.GetEventObject()
150        hist,name = Indx[Obj.GetId()]
151        try:
152            value = float(Obj.GetValue())
153            UseList[G2frame.hist][name][1][2] = value
154#            if 0 <= value <= 1:
155#                UseList[G2frame.hist][name][1][2] = value
156#            else:
157#                raise ValueError
158        except ValueError:
159            pass
160        Obj.SetValue("%.4f"%(UseList[G2frame.hist][name][1][2]))          #reset in case of error
161
162    def OnSizeType(event):
163        Obj = event.GetEventObject()
164        UseList[G2frame.hist]['Size'][0] = Obj.GetValue()
165        G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
166        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
167       
168    def OnSizeRef(event):
169        Obj = event.GetEventObject()
170        hist,pid = Indx[Obj.GetId()]
171        if UseList[G2frame.hist]['Size'][0] == 'ellipsoidal':
172            UseList[G2frame.hist]['Size'][5][pid] = Obj.GetValue()               
173        else:
174            UseList[G2frame.hist]['Size'][2][pid] = Obj.GetValue()
175       
176    def OnSizeVal(event):
177        event.Skip()
178        Obj = event.GetEventObject()
179        hist,pid = Indx[Obj.GetId()]
180        if UseList[G2frame.hist]['Size'][0] == 'ellipsoidal':
181            try:
182                size = float(Obj.GetValue())
183                if pid < 3 and size <= 0.001:            #10A lower limit!
184                    raise ValueError
185                UseList[G2frame.hist]['Size'][4][pid] = size                   
186            except ValueError:
187                pass
188            Obj.SetValue("%.5f"%(UseList[G2frame.hist]['Size'][4][pid]))          #reset in case of error
189        else:
190            try:
191                size = float(Obj.GetValue())
192                if size <= 0.001:            #10A lower limit!
193                    raise ValueError
194                UseList[G2frame.hist]['Size'][1][pid] = size
195            except ValueError:
196                pass
197            Obj.SetValue("%.5f"%(UseList[G2frame.hist]['Size'][1][pid]))          #reset in case of error
198        wx.CallAfter(G2plt.PlotSizeStrainPO,G2frame,data,hist)
199       
200    def OnStrainType(event):
201        Obj = event.GetEventObject()
202        UseList[G2frame.hist]['Mustrain'][0] = Obj.GetValue()
203        G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
204        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
205       
206    def OnStrainRef(event):
207        Obj = event.GetEventObject()
208        hist,pid = Indx[Obj.GetId()]
209        if UseList[G2frame.hist]['Mustrain'][0] == 'generalized':
210            UseList[G2frame.hist]['Mustrain'][5][pid] = Obj.GetValue()
211        else:
212            UseList[G2frame.hist]['Mustrain'][2][pid] = Obj.GetValue()
213       
214    def OnStrainVal(event):
215        event.Skip()
216        Snames = G2spc.MustrainNames(SGData)
217        Obj = event.GetEventObject()
218        hist,pid = Indx[Obj.GetId()]
219        try:
220            strain = float(Obj.GetValue())
221            if UseList[G2frame.hist]['Mustrain'][0] == 'generalized':
222                if '4' in Snames[pid] and strain < 0:
223                    raise ValueError
224                UseList[G2frame.hist]['Mustrain'][4][pid] = strain
225            else:
226                if strain <= 0:
227                    raise ValueError
228                UseList[G2frame.hist]['Mustrain'][1][pid] = strain
229        except ValueError:
230            pass
231        if UseList[G2frame.hist]['Mustrain'][0] == 'generalized':
232            Obj.SetValue("%.1f"%(UseList[G2frame.hist]['Mustrain'][4][pid]))          #reset in case of error
233        else:
234            Obj.SetValue("%.1f"%(UseList[G2frame.hist]['Mustrain'][1][pid]))          #reset in case of error
235        wx.CallAfter(G2plt.PlotSizeStrainPO,G2frame,data,hist)
236       
237    def OnStrainAxis(event):
238        event.Skip()
239        Obj = event.GetEventObject()
240        Saxis = Obj.GetValue().split()
241        try:
242            hkl = [int(Saxis[i]) for i in range(3)]
243        except (ValueError,IndexError):
244            hkl = UseList[G2frame.hist]['Mustrain'][3]
245        if not np.any(np.array(hkl)):
246            hkl = UseList[G2frame.hist]['Mustrain'][3]
247        UseList[G2frame.hist]['Mustrain'][3] = hkl
248        h,k,l = hkl
249        Obj.SetValue('%3d %3d %3d'%(h,k,l)) 
250        G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
251       
252    def OnResetStrain(event):
253        Obj = event.GetEventObject()
254        Obj.SetValue(False)
255        item,name = Indx[Obj.GetId()]
256        if name == 'isotropic':
257            UseList[item]['Mustrain'][1][0] = 1000.0
258        elif name == 'uniaxial':
259            UseList[item]['Mustrain'][1][0] = 1000.0
260            UseList[item]['Mustrain'][1][1] = 1000.0
261        elif name == 'generalized':
262            muiso = 1000.
263            cell = generalData['Cell'][1:7]
264            vals = G2spc.Muiso2Shkl(muiso,SGData,cell)
265            nTerm = len(UseList[item]['Mustrain'][4])
266            for i in range(nTerm):
267                UseList[item]['Mustrain'][4][i] = vals[i]
268        G2plt.PlotSizeStrainPO(G2frame,data,item)
269        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
270           
271    def OnHstrainRef(event):
272        Obj = event.GetEventObject()
273        hist,pid = Indx[Obj.GetId()]
274        UseList[G2frame.hist]['HStrain'][1][pid] = Obj.GetValue()
275       
276    def OnHstrainVal(event):
277        event.Skip()
278        Obj = event.GetEventObject()
279        hist,pid = Indx[Obj.GetId()]
280        try:
281            strain = float(Obj.GetValue())
282            UseList[G2frame.hist]['HStrain'][0][pid] = strain
283        except ValueError:
284            pass
285        Obj.SetValue("%.3g"%(UseList[G2frame.hist]['HStrain'][0][pid]))          #reset in case of error
286
287    def OnPOAxis(event):
288        event.Skip()
289        Obj = event.GetEventObject()
290        Saxis = Obj.GetValue().split()
291        try:
292            hkl = [int(Saxis[i]) for i in range(3)]
293        except (ValueError,IndexError):
294            hkl = UseList[G2frame.hist]['Pref.Ori.'][3]
295        if not np.any(np.array(hkl)):
296            hkl = UseList[G2frame.hist]['Pref.Ori.'][3]
297        UseList[G2frame.hist]['Pref.Ori.'][3] = hkl
298        h,k,l = hkl
299        Obj.SetValue('%3d %3d %3d'%(h,k,l)) 
300       
301    def OnPOOrder(event):
302        Obj = event.GetEventObject()
303        Order = int(Obj.GetValue())
304        UseList[G2frame.hist]['Pref.Ori.'][4] = Order
305        UseList[G2frame.hist]['Pref.Ori.'][5] = SetPOCoef(Order,G2frame.hist)
306        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
307
308    def OnPOType(event):
309        Obj = event.GetEventObject()
310        if 'March' in Obj.GetValue():
311            UseList[G2frame.hist]['Pref.Ori.'][0] = 'MD'
312        else:
313            UseList[G2frame.hist]['Pref.Ori.'][0] = 'SH'
314        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
315
316    def OnPORef(event):
317        Obj = event.GetEventObject()
318        UseList[G2frame.hist]['Pref.Ori.'][2] = Obj.GetValue()
319           
320    def SetPOCoef(Order,hist):
321        cofNames = G2lat.GenSHCoeff(SGData['SGLaue'],'0',Order,False)     #cylindrical & no M
322        newPOCoef = dict(zip(cofNames,np.zeros(len(cofNames))))
323        POCoeff = UseList[G2frame.hist]['Pref.Ori.'][5]
324        for cofName in POCoeff:
325            if cofName in  cofNames:
326                newPOCoef[cofName] = POCoeff[cofName]
327        return newPOCoef
328       
329    def checkAxis(axis):
330        if not np.any(np.array(axis)):
331            return False
332        return axis
333       
334    def TopSizer(name,choices,parm,OnType):
335        topSizer = wx.BoxSizer(wx.HORIZONTAL)
336        topSizer.Add(wx.StaticText(DData,wx.ID_ANY,name),0,WACV)
337        sizeType = wx.ComboBox(DData,wx.ID_ANY,value=UseList[G2frame.hist][parm][0],choices=choices,
338            style=wx.CB_READONLY|wx.CB_DROPDOWN)
339        sizeType.Bind(wx.EVT_COMBOBOX, OnType)
340        topSizer.Add(sizeType,0,WACV|wx.BOTTOM,5)
341        return topSizer
342       
343    def LGmixSizer(name,OnVal,OnRef):
344        lgmixSizer = wx.BoxSizer(wx.HORIZONTAL)
345        lgmixRef = wx.CheckBox(DData,wx.ID_ANY,label='LGmix')
346        lgmixRef.thisown = False
347        lgmixRef.SetValue(UseList[G2frame.hist][name][2][2])
348        Indx[lgmixRef.GetId()] = [G2frame.hist,name]
349        lgmixRef.Bind(wx.EVT_CHECKBOX, OnRef)
350        lgmixSizer.Add(lgmixRef,0,WACV|wx.LEFT,5)
351#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
352        lgmixVal = wx.TextCtrl(DData,wx.ID_ANY,
353            '%.4f'%(UseList[G2frame.hist][name][1][2]),style=wx.TE_PROCESS_ENTER)
354        Indx[lgmixVal.GetId()] = [G2frame.hist,name]
355        lgmixVal.Bind(wx.EVT_TEXT_ENTER,OnVal)
356        lgmixVal.Bind(wx.EVT_KILL_FOCUS,OnVal)
357        lgmixSizer.Add(lgmixVal,0,WACV|wx.LEFT,5)
358        return lgmixSizer
359                   
360    def ResetSizer(name,OnReset):
361        resetSizer = wx.BoxSizer(wx.HORIZONTAL)
362        reset = wx.CheckBox(DData,wx.ID_ANY,label='Reset?')
363        reset.thisown = False
364        reset.SetValue(False)
365        Indx[reset.GetId()] = [G2frame.hist,name]
366        reset.Bind(wx.EVT_CHECKBOX,OnReset)
367        resetSizer.Add(reset,0,WACV|wx.TOP|wx.LEFT,5)
368        return resetSizer
369       
370    def IsoSizer(name,parm,fmt,OnVal,OnRef):
371        isoSizer = wx.BoxSizer(wx.HORIZONTAL)
372        sizeRef = wx.CheckBox(DData,wx.ID_ANY,label=name)
373        sizeRef.thisown = False
374        sizeRef.SetValue(UseList[G2frame.hist][parm][2][0])
375        Indx[sizeRef.GetId()] = [G2frame.hist,0]
376        sizeRef.Bind(wx.EVT_CHECKBOX, OnRef)
377        isoSizer.Add(sizeRef,0,WACV|wx.LEFT,5)
378#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
379        sizeVal = wx.TextCtrl(DData,wx.ID_ANY,
380            fmt%(UseList[G2frame.hist][parm][1][0]),style=wx.TE_PROCESS_ENTER)
381        Indx[sizeVal.GetId()] = [G2frame.hist,0]
382        sizeVal.Bind(wx.EVT_TEXT_ENTER,OnVal)
383        sizeVal.Bind(wx.EVT_KILL_FOCUS,OnVal)
384        isoSizer.Add(sizeVal,0,WACV)
385        return isoSizer
386       
387    def UniSizer(parm,OnAxis):
388        uniSizer = wx.BoxSizer(wx.HORIZONTAL)
389        uniSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Unique axis, H K L: '),0,WACV)
390        h,k,l = UseList[G2frame.hist][parm][3]
391        Axis = wx.TextCtrl(DData,wx.ID_ANY,'%3d %3d %3d'%(h,k,l),style=wx.TE_PROCESS_ENTER)
392        Axis.Bind(wx.EVT_TEXT_ENTER,OnAxis)
393        Axis.Bind(wx.EVT_KILL_FOCUS,OnAxis)
394        uniSizer.Add(Axis,0,WACV|wx.LEFT,5)
395        return uniSizer
396       
397    def UniDataSizer(parmName,parm,fmt,OnVal,OnRef):
398        dataSizer = wx.BoxSizer(wx.HORIZONTAL)
399        parms = zip([' Equatorial '+parmName,' Axial '+parmName],
400            UseList[G2frame.hist][parm][1],UseList[G2frame.hist][parm][2],range(2))
401        for Pa,val,ref,id in parms:
402            sizeRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa)
403            sizeRef.thisown = False
404            sizeRef.SetValue(ref)
405            Indx[sizeRef.GetId()] = [G2frame.hist,id]
406            sizeRef.Bind(wx.EVT_CHECKBOX, OnRef)
407            dataSizer.Add(sizeRef,0,WACV|wx.LEFT,5)
408#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
409            sizeVal = wx.TextCtrl(DData,wx.ID_ANY,fmt%(val),style=wx.TE_PROCESS_ENTER)
410            Indx[sizeVal.GetId()] = [G2frame.hist,id]
411            sizeVal.Bind(wx.EVT_TEXT_ENTER,OnVal)
412            sizeVal.Bind(wx.EVT_KILL_FOCUS,OnVal)
413            dataSizer.Add(sizeVal,0,WACV|wx.BOTTOM,5)
414        return dataSizer
415       
416    def EllSizeDataSizer():
417        parms = zip(['S11','S22','S33','S12','S13','S23'],UseList[G2frame.hist]['Size'][4],
418            UseList[G2frame.hist]['Size'][5],range(6))
419        dataSizer = wx.FlexGridSizer(0,6,5,5)
420        for Pa,val,ref,id in parms:
421            sizeRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa)
422            sizeRef.thisown = False
423            sizeRef.SetValue(ref)
424            Indx[sizeRef.GetId()] = [G2frame.hist,id]
425            sizeRef.Bind(wx.EVT_CHECKBOX, OnSizeRef)
426            dataSizer.Add(sizeRef,0,WACV)
427#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
428            sizeVal = wx.TextCtrl(DData,wx.ID_ANY,'%.3f'%(val),style=wx.TE_PROCESS_ENTER)
429            Indx[sizeVal.GetId()] = [G2frame.hist,id]
430            sizeVal.Bind(wx.EVT_TEXT_ENTER,OnSizeVal)
431            sizeVal.Bind(wx.EVT_KILL_FOCUS,OnSizeVal)
432            dataSizer.Add(sizeVal,0,WACV)
433        return dataSizer
434       
435    def GenStrainDataSizer():
436        Snames = G2spc.MustrainNames(SGData)
437        numb = len(Snames)
438        if len(UseList[G2frame.hist]['Mustrain'][4]) < numb:
439            UseList[G2frame.hist]['Mustrain'][4] = numb*[0.0,]
440            UseList[G2frame.hist]['Mustrain'][5] = numb*[False,]
441        parms = zip(Snames,UseList[G2frame.hist]['Mustrain'][4],UseList[G2frame.hist]['Mustrain'][5],range(numb))
442        dataSizer = wx.FlexGridSizer(0,6,5,5)
443        for Pa,val,ref,id in parms:
444            strainRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa)
445            strainRef.thisown = False
446            strainRef.SetValue(ref)
447            Indx[strainRef.GetId()] = [G2frame.hist,id]
448            strainRef.Bind(wx.EVT_CHECKBOX, OnStrainRef)
449            dataSizer.Add(strainRef,0,WACV)
450#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
451            strainVal = wx.TextCtrl(DData,wx.ID_ANY,'%.1f'%(val),style=wx.TE_PROCESS_ENTER)
452            Indx[strainVal.GetId()] = [G2frame.hist,id]
453            strainVal.Bind(wx.EVT_TEXT_ENTER,OnStrainVal)
454            strainVal.Bind(wx.EVT_KILL_FOCUS,OnStrainVal)
455            dataSizer.Add(strainVal,0,WACV)
456        return dataSizer
457
458    def HstrainSizer():
459        hstrainSizer = wx.FlexGridSizer(0,6,5,5)
460        Hsnames = G2spc.HStrainNames(SGData)
461        parms = zip(Hsnames,UseList[G2frame.hist]['HStrain'][0],UseList[G2frame.hist]['HStrain'][1],range(len(Hsnames)))
462        for Pa,val,ref,id in parms:
463            hstrainRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa)
464            hstrainRef.thisown = False
465            hstrainRef.SetValue(ref)
466            Indx[hstrainRef.GetId()] = [G2frame.hist,id]
467            hstrainRef.Bind(wx.EVT_CHECKBOX, OnHstrainRef)
468            hstrainSizer.Add(hstrainRef,0,WACV|wx.LEFT,5)
469#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
470            hstrainVal = wx.TextCtrl(DData,wx.ID_ANY,'%.3g'%(val),style=wx.TE_PROCESS_ENTER)
471            Indx[hstrainVal.GetId()] = [G2frame.hist,id]
472            hstrainVal.Bind(wx.EVT_TEXT_ENTER,OnHstrainVal)
473            hstrainVal.Bind(wx.EVT_KILL_FOCUS,OnHstrainVal)
474            hstrainSizer.Add(hstrainVal,0,WACV)
475        return hstrainSizer
476       
477    def PoTopSizer(POData):
478        poSizer = wx.FlexGridSizer(0,6,5,5)
479        choice = ['March-Dollase','Spherical harmonics']
480        POtype = choice[['MD','SH'].index(POData[0])]
481        poSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Preferred orientation model '),0,WACV)
482        POType = wx.ComboBox(DData,wx.ID_ANY,value=POtype,choices=choice,
483            style=wx.CB_READONLY|wx.CB_DROPDOWN)
484        POType.Bind(wx.EVT_COMBOBOX, OnPOType)
485        poSizer.Add(POType)
486        if POData[0] == 'SH':
487            poSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Harmonic order: '),0,WACV)
488            poOrder = wx.ComboBox(DData,wx.ID_ANY,value=str(POData[4]),choices=[str(2*i) for i in range(18)],
489                style=wx.CB_READONLY|wx.CB_DROPDOWN)
490            poOrder.Bind(wx.EVT_COMBOBOX,OnPOOrder)
491            poSizer.Add(poOrder,0,WACV)
492            poRef = wx.CheckBox(DData,wx.ID_ANY,label=' Refine? ')
493            poRef.SetValue(POData[2])
494            poRef.Bind(wx.EVT_CHECKBOX,OnPORef)
495            poSizer.Add(poRef,0,WACV)
496        return poSizer
497       
498    def MDDataSizer(POData):
499        poSizer = wx.BoxSizer(wx.HORIZONTAL)
500        poRef = wx.CheckBox(DData,wx.ID_ANY,label=' March-Dollase ratio: ')
501        poRef.SetValue(POData[2])
502        poRef.Bind(wx.EVT_CHECKBOX,OnPORef)
503        poSizer.Add(poRef,0,WACV|wx.LEFT,5)
504        poVal = G2G.ValidatedTxtCtrl(DData,POData,1,nDig=(10,3),typeHint=float,min=0.)
505        poSizer.Add(poVal,0,WACV)
506        poSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Unique axis, H K L: '),0,WACV)
507        h,k,l =POData[3]
508        poAxis = wx.TextCtrl(DData,wx.ID_ANY,'%3d %3d %3d'%(h,k,l),style=wx.TE_PROCESS_ENTER)
509        poAxis.Bind(wx.EVT_TEXT_ENTER,OnPOAxis)
510        poAxis.Bind(wx.EVT_KILL_FOCUS,OnPOAxis)
511        poSizer.Add(poAxis,0,WACV)
512        return poSizer
513       
514    def SHDataSizer(POData):
515       
516        def OnODFValue(invalid,value,tc):
517            G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
518   
519        ODFSizer = wx.FlexGridSizer(0,8,2,2)
520        ODFkeys = POData[5].keys()
521        ODFkeys.sort()
522        for odf in ODFkeys:
523            ODFSizer.Add(wx.StaticText(DData,wx.ID_ANY,odf),0,WACV)
524            ODFval = G2G.ValidatedTxtCtrl(DData,POData[5],odf,nDig=(8,3),typeHint=float,OnLeave=OnODFValue)
525            ODFSizer.Add(ODFval,0,WACV|wx.LEFT,5)
526        return ODFSizer
527       
528    def SHPenalty(POData):
529       
530        def OnHKLList(event):
531            dlg = G2G.G2MultiChoiceDialog(G2frame, 'Select penalty hkls',
532                'Penalty hkls',hkls,filterBox=False)
533            try:
534                if dlg.ShowModal() == wx.ID_OK:
535                    POData[6] = [hkls[i] for i in dlg.GetSelections()]
536                    if not POData[6]:
537                        POData[6] = ['',]
538                else:
539                    return
540            finally:
541                dlg.Destroy()
542            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
543           
544        A = G2lat.cell2A(generalData['Cell'][1:7])
545        hkls = G2lat.GenPfHKLs(10,SGData,A)   
546        shPenalty = wx.BoxSizer(wx.HORIZONTAL)
547        shPenalty.Add(wx.StaticText(DData,wx.ID_ANY,' Negative MRD penalty list: '),0,WACV)
548        shPenalty.Add(wx.ComboBox(DData,value=POData[6][0],choices=POData[6],
549            style=wx.CB_DROPDOWN),0,WACV|wx.LEFT,5)
550        hklList = wx.Button(DData,label='Select penalty hkls')
551        hklList.Bind(wx.EVT_BUTTON,OnHKLList)
552        shPenalty.Add(hklList,0,WACV)
553        shPenalty.Add(wx.StaticText(DData,wx.ID_ANY,' Zero MRD tolerance: '),0,WACV)
554        shToler = G2G.ValidatedTxtCtrl(DData,POData,7,nDig=(10,2),typeHint=float)
555        shPenalty.Add(shToler,0,WACV)
556        return shPenalty   
557       
558    def ExtSizer(Type):
559       
560        def OnSCExtType(event):
561            Obj = event.GetEventObject()
562            item = Indx[Obj.GetId()]
563            UseList[item[0]]['Extinction'][item[1]] = Obj.GetValue()
564            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
565               
566        def OnEref(event):
567            Obj = event.GetEventObject()
568            item = Indx[Obj.GetId()]
569            UseList[item[0]]['Extinction'][2][item[1]][1] = Obj.GetValue()
570   
571        def OnExtRef(event):
572            Obj = event.GetEventObject()
573            UseList[G2frame.hist]['Extinction'][1] = Obj.GetValue()
574           
575        if Type == 'HKLF':
576            extSizer = wx.BoxSizer(wx.VERTICAL)
577            typeSizer = wx.BoxSizer(wx.HORIZONTAL)           
578            typeSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Extinction type: '),0,WACV)
579            Choices = ['None','Primary','Secondary Type I','Secondary Type II',]    # remove 'Secondary Type I & II'
580            typeTxt = wx.ComboBox(DData,wx.ID_ANY,choices=Choices,value=UseList[G2frame.hist]['Extinction'][1],
581                style=wx.CB_READONLY|wx.CB_DROPDOWN)
582            Indx[typeTxt.GetId()] = [G2frame.hist,1]
583            typeTxt.Bind(wx.EVT_COMBOBOX,OnSCExtType)
584            typeSizer.Add(typeTxt)
585            typeSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Approx: '),0,WACV)
586            Choices=['Lorentzian','Gaussian']
587            approxTxT = wx.ComboBox(DData,wx.ID_ANY,choices=Choices,value=UseList[G2frame.hist]['Extinction'][0],
588                style=wx.CB_READONLY|wx.CB_DROPDOWN)
589            Indx[approxTxT.GetId()] = [G2frame.hist,0]
590            approxTxT.Bind(wx.EVT_COMBOBOX,OnSCExtType)
591            typeSizer.Add(approxTxT)
592            if UseList[G2frame.hist]['Extinction'][1] == 'None':
593                extSizer.Add(typeSizer,0,WACV)
594            else:
595                extSizer.Add(typeSizer,0,WACV|wx.BOTTOM,5)       
596                if 'Tbar' in UseList[G2frame.hist]['Extinction'][2]:       #skipped for TOF   
597                    valSizer =wx.BoxSizer(wx.HORIZONTAL)
598                    valSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Tbar(mm):'),0,WACV)
599                    tbarVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Extinction'][2],'Tbar',
600                        min=0.,nDig=(10,3),typeHint=float)
601                    valSizer.Add(tbarVal,0,WACV)
602                    valSizer.Add(wx.StaticText(DData,wx.ID_ANY,' cos(2ThM):'),0,WACV)
603                    cos2tm = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Extinction'][2],'Cos2TM',
604                        min=0.,max=1.,nDig=(10,3),typeHint=float)
605                    valSizer.Add(cos2tm,0,WACV)
606                    extSizer.Add(valSizer,0,WACV)
607                val2Sizer =wx.BoxSizer(wx.HORIZONTAL)
608                if 'Primary' in UseList[G2frame.hist]['Extinction'][1]:
609                    Ekey = ['Ep',]
610                elif 'Secondary Type II' == UseList[G2frame.hist]['Extinction'][1]:
611                    Ekey = ['Es',]
612                elif 'Secondary Type I' == UseList[G2frame.hist]['Extinction'][1]:
613                    Ekey = ['Eg',]
614                else:
615                    Ekey = ['Eg','Es']
616                for ekey in Ekey:
617                    Eref = wx.CheckBox(DData,wx.ID_ANY,label=ekey+' : ')
618                    Eref.SetValue(UseList[G2frame.hist]['Extinction'][2][ekey][1])
619                    Indx[Eref.GetId()] = [G2frame.hist,ekey]
620                    Eref.Bind(wx.EVT_CHECKBOX, OnEref)
621                    val2Sizer.Add(Eref,0,WACV|wx.LEFT,5)
622                    Eval = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Extinction'][2][ekey],0,
623                        min=0.,nDig=(10,3,'g'),typeHint=float)
624                    val2Sizer.Add(Eval,0,WACV)
625                extSizer.Add(val2Sizer,0,WACV)
626        else:   #PWDR
627            extSizer = wx.BoxSizer(wx.HORIZONTAL)
628            extRef = wx.CheckBox(DData,wx.ID_ANY,label=' Extinction: ')
629            extRef.SetValue(UseList[G2frame.hist]['Extinction'][1])
630            extRef.Bind(wx.EVT_CHECKBOX, OnExtRef)
631            extSizer.Add(extRef,0,WACV|wx.LEFT,5)
632            extVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Extinction'],0,
633                min=0.,nDig=(10,2),typeHint=float)
634            extSizer.Add(extVal,0,WACV)
635
636        return extSizer
637       
638    def BabSizer():
639       
640        def OnBabRef(event):
641            Obj = event.GetEventObject()
642            item,bab = Indx[Obj.GetId()]
643            UseList[item]['Babinet']['Bab'+bab][1] = Obj.GetValue()
644       
645        babSizer = wx.BoxSizer(wx.HORIZONTAL)
646        for bab in ['A','U']:
647            babRef = wx.CheckBox(DData,wx.ID_ANY,label=' Babinet '+bab+': ')
648            babRef.SetValue(UseList[G2frame.hist]['Babinet']['Bab'+bab][1])
649            Indx[babRef.GetId()] = [G2frame.hist,bab]
650            babRef.Bind(wx.EVT_CHECKBOX, OnBabRef)
651            babSizer.Add(babRef,0,WACV|wx.LEFT,5)
652            babVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Babinet']['Bab'+bab],0,
653                nDig=(10,3),min=0.,typeHint=float)
654            babSizer.Add(babVal,0,WACV)
655        return babSizer
656       
657    def FlackSizer():
658       
659        def OnFlackRef(event):
660            Obj = event.GetEventObject()
661            UseList[G2frame.hist]['Flack'][1] = Obj.GetValue()
662               
663        flackSizer = wx.BoxSizer(wx.HORIZONTAL)
664        flackRef = wx.CheckBox(DData,wx.ID_ANY,label=' Flack parameter: ')
665        flackRef.SetValue(UseList[G2frame.hist]['Flack'][1])
666        flackRef.Bind(wx.EVT_CHECKBOX, OnFlackRef)
667        flackSizer.Add(flackRef,0,WACV|wx.LEFT,5)
668        flackVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Flack'],0,nDig=(10,3),typeHint=float)
669        flackSizer.Add(flackVal,0,WACV)
670        return flackSizer
671       
672    def twinSizer():
673       
674        def OnAddTwin(event):
675            twinMat = np.array([[-1,0,0],[0,-1,0],[0,0,-1]])    #inversion by default
676            twinVal = 0.0
677            UseList[G2frame.hist]['Twins'].append([twinMat,twinVal])
678            nNonM = UseList[G2frame.hist]['Twins'][0][1][2]
679            for i in range(nNonM):
680                UseList[G2frame.hist]['Twins'].append([False,0.0])
681            addtwin.SetValue(False)
682            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
683           
684        def OnMat(event):
685            event.Skip()
686            Obj = event.GetEventObject()
687            it,im = Indx[Obj.GetId()]
688            newMat = Obj.GetValue().split()
689            try:
690                uvw = [int(newMat[i]) for i in range(3)]
691            except ValueError:
692                uvw = UseList[G2frame.hist]['Twins'][it][0][im]
693            UseList[G2frame.hist]['Twins'][it][0][im] = uvw
694            Obj.SetValue('%3d %3d %3d'%(uvw[0],uvw[1],uvw[2]))
695           
696        def OnTwinVal(invalid,value,tc):
697            it = Indx[tc.GetId()]
698            sumTw = 0.
699            for it,twin in enumerate(UseList[G2frame.hist]['Twins']):
700                if it:
701                    sumTw += twin[1]
702            UseList[G2frame.hist]['Twins'][0][1][0] = 1.-sumTw
703            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
704           
705        def OnTwinRef(event):
706            Obj = event.GetEventObject()
707            UseList[G2frame.hist]['Twins'][0][1][1] = Obj.GetValue()
708           
709        def OnTwinInv(event):
710            Obj = event.GetEventObject()
711            it = Indx[Obj.GetId()]
712            UseList[G2frame.hist]['Twins'][it][0] = Obj.GetValue()
713                       
714        def OnTwinDel(event):
715            Obj = event.GetEventObject()
716            it = Indx[Obj.GetId()]
717            nNonM = UseList[G2frame.hist]['Twins'][0][1][2]
718            for i in range(nNonM):
719                del UseList[G2frame.hist]['Twins'][1+i+it]
720            del UseList[G2frame.hist]['Twins'][it]
721            sumTw = 0.
722            for it,twin in enumerate(UseList[G2frame.hist]['Twins']):
723                if it:
724                    sumTw += twin[1]
725            UseList[G2frame.hist]['Twins'][0][1][0] = 1.-sumTw
726            if len(UseList[G2frame.hist]['Twins']) == 1:
727                UseList[G2frame.hist]['Twins'][0][1][1] = False
728            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))           
729           
730        nTwin = len(UseList[G2frame.hist]['Twins'])
731        twinsizer = wx.BoxSizer(wx.VERTICAL)
732        topsizer = wx.BoxSizer(wx.HORIZONTAL)         
733        topsizer.Add(wx.StaticText(DData,wx.ID_ANY,' Merohedral twins: '),0,WACV)
734        #temporary - add twin not allowed if nonmerohedral twins present
735#        if nTwin == 1 or 'bool' not in str(type(UseList[G2frame.hist]['Twins'][1][0])):
736        addtwin = wx.CheckBox(DData,wx.ID_ANY,label=' Add Twin Law')
737        addtwin.Bind(wx.EVT_CHECKBOX, OnAddTwin)
738        topsizer.Add(addtwin,0,WACV|wx.LEFT,5)
739        twinsizer.Add(topsizer)
740        Indx = {}
741        if nTwin > 1:
742            for it,Twin in enumerate(UseList[G2frame.hist]['Twins']):
743                twinMat,twinVal = Twin
744                matSizer = wx.BoxSizer(wx.HORIZONTAL)
745                if it:
746                    Style = wx.TE_PROCESS_ENTER
747                    TwVal = Twin[1]
748                else:
749                    Style = wx.TE_READONLY
750                    TwVal = Twin[1][0]
751                if 'bool' not in str(type(Twin[0])):
752                    matSizer.Add(wx.StaticText(DData,-1,' Twin Law: '),0,WACV|wx.LEFT,5)
753                    for im,Mat in enumerate(twinMat):
754                        mat = wx.TextCtrl(DData,wx.ID_ANY,'%3d %3d %3d'%(Mat[0],Mat[1],Mat[2]),
755                            style=Style)
756                        if it:
757                            Indx[mat.GetId()] = [it,im]
758                            mat.Bind(wx.EVT_TEXT_ENTER,OnMat)
759                            mat.Bind(wx.EVT_KILL_FOCUS,OnMat)
760                        else:
761                            mat.SetBackgroundColour(VERY_LIGHT_GREY)
762                        matSizer.Add(mat,0,WACV|wx.LEFT,5)
763                else:
764                    matSizer.Add(wx.StaticText(DData,-1,' Nonmerohedral twin component %d: '%(it)),0,WACV|wx.LEFT,5)
765                    if not SGData['SGInv']:
766                        twinv = wx.CheckBox(DData,wx.ID_ANY,label=' Use enantiomorph?')
767                        twinv.SetValue(Twin[0])
768                        Indx[twinv.GetId()] = it
769                        twinv.Bind(wx.EVT_CHECKBOX, OnTwinInv)
770                        matSizer.Add(twinv,0,WACV)
771                twinsizer.Add(matSizer,0,WACV|wx.LEFT,5)
772                valSizer = wx.BoxSizer(wx.HORIZONTAL)
773                valSizer.Add(wx.StaticText(DData,-1,label=' Twin element fraction:'),0,WACV)
774                if it:
775                    twinval = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Twins'][it],1,nDig=(10,3),
776                        min=0.,max=1.,typeHint=float,OnLeave=OnTwinVal)
777                    Indx[twinval.GetId()] = it
778                else:
779                    twinval = wx.TextCtrl(DData,-1,'%.3f'%(TwVal),style=Style)
780                    twinval.SetBackgroundColour(VERY_LIGHT_GREY)
781                valSizer.Add(twinval,0,WACV)
782                if it and 'bool' not in str(type(Twin[0])):
783                    twindel = wx.CheckBox(DData,wx.ID_ANY,label=' Delete?')
784                    Indx[twindel.GetId()] = it
785                    twindel.Bind(wx.EVT_CHECKBOX, OnTwinDel)
786                    valSizer.Add(twindel,0,WACV)
787                elif not it:
788                    twinref = wx.CheckBox(DData,wx.ID_ANY,label=' Refine?')
789                    twinref.SetValue(Twin[1][1])
790                    twinref.Bind(wx.EVT_CHECKBOX, OnTwinRef)
791                    valSizer.Add(twinref,0,WACV)
792                twinsizer.Add(valSizer,0,WACV|wx.LEFT,5)
793        return twinsizer
794       
795    def OnSelect(event):
796        G2frame.hist = keyList[select.GetSelection()]
797        oldFocus = wx.Window.FindFocus()
798        G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
799        oldFocus.SetFocus()
800        wx.CallLater(100,RepaintHistogramInfo)
801       
802    def RepaintHistogramInfo(Scroll=0):
803        G2frame.bottomSizer.DeleteWindows()
804        Indx.clear()
805        G2frame.bottomSizer = ShowHistogramInfo()
806        mainSizer.Add(G2frame.bottomSizer)
807        mainSizer.Layout()
808        G2frame.dataFrame.Refresh()
809        DData.SetVirtualSize(mainSizer.GetMinSize())
810        DData.Scroll(0,Scroll)
811        G2frame.dataFrame.SendSizeEvent()
812       
813    def ShowHistogramInfo():
814       
815        def OnUseData(event):
816            Obj = event.GetEventObject()
817            UseList[G2frame.hist]['Use'] = Obj.GetValue()
818
819        def OnLeBail(event):
820            Obj = event.GetEventObject()
821            if not UseList[G2frame.hist]['LeBail']:
822                UseList[G2frame.hist]['newLeBail'] = True
823            UseList[G2frame.hist]['LeBail'] = Obj.GetValue()
824
825        def OnResetSize(event):
826            Obj = event.GetEventObject()
827            Obj.SetValue(False)
828            item,name = Indx[Obj.GetId()]
829            if name == 'isotropic':
830                UseList[item]['Size'][1][0] = 1.0
831            elif name == 'uniaxial':
832                UseList[item]['Size'][1][0] = 1.0
833                UseList[item]['Size'][1][1] = 1.0
834            elif name == 'ellipsoidal':
835                for i in range(3):
836                    UseList[item]['Size'][4][i] = 1.0
837                    UseList[item]['Size'][4][i+3] = 0.0
838            G2plt.PlotSizeStrainPO(G2frame,data,item)
839            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
840           
841        def OnSizeAxis(event):           
842            event.Skip()
843            Obj = event.GetEventObject()
844            Saxis = Obj.GetValue().split()
845            try:
846                hkl = [int(Saxis[i]) for i in range(3)]
847            except (ValueError,IndexError):
848                hkl = UseList[G2frame.hist]['Size'][3]
849            if not np.any(np.array(hkl)):
850                hkl = UseList[G2frame.hist]['Size'][3]
851            UseList[G2frame.hist]['Size'][3] = hkl
852            h,k,l = hkl
853            Obj.SetValue('%3d %3d %3d'%(h,k,l)) 
854
855        if G2frame.hist not in UseList:               
856            G2frame.ErrorDialog('Missing data error',
857                    G2frame.hist+' not in GSAS-II data tree')
858            return
859        if 'Use' not in UseList[G2frame.hist]:      #patch
860            UseList[G2frame.hist]['Use'] = True
861        if 'LeBail' not in UseList[G2frame.hist]:
862            UseList[G2frame.hist]['LeBail'] = False
863        if 'newLeBail' not in UseList[G2frame.hist]:
864            UseList[G2frame.hist]['newLeBail'] = True
865        if 'Babinet' not in UseList[G2frame.hist]:
866            UseList[G2frame.hist]['Babinet'] = {'BabA':[0.0,False],'BabU':[0.0,False]}
867        bottomSizer = wx.BoxSizer(wx.VERTICAL)
868        useBox = wx.BoxSizer(wx.HORIZONTAL)
869        useData = wx.CheckBox(DData,wx.ID_ANY,label='Use Histogram: '+G2frame.hist+' ?')
870        useData.Bind(wx.EVT_CHECKBOX, OnUseData)
871        useData.SetValue(UseList[G2frame.hist]['Use'])
872        useBox.Add(useData,0,WACV)
873        if not generalData['doPawley']:
874            lebail = wx.CheckBox(DData,wx.ID_ANY,label='Do LeBail extraction?')
875            lebail.Bind(wx.EVT_CHECKBOX, OnLeBail)
876            lebail.SetValue(UseList[G2frame.hist]['LeBail'])
877            useBox.Add(lebail,0,WACV)
878            if UseList[G2frame.hist]['LeBail']:
879                G2frame.dataFrame.SetStatusText('To reset LeBail, cycle LeBail check box.')
880        bottomSizer.Add(useBox,0,WACV|wx.TOP|wx.BOTTOM|wx.LEFT,5)
881       
882        bottomSizer.Add(ScaleSizer(),0,WACV|wx.BOTTOM,5)
883           
884        if G2frame.hist[:4] == 'PWDR':
885            if UseList[G2frame.hist]['Size'][0] == 'isotropic':
886                isoSizer = wx.BoxSizer(wx.HORIZONTAL)
887                isoSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'],
888                    'Size',OnSizeType),0,WACV)
889                isoSizer.Add(LGmixSizer('Size',OnLGmixVal,OnLGmixRef))
890                isoSizer.Add(ResetSizer('isotropic',OnResetSize),0,WACV)
891                bottomSizer.Add(isoSizer)
892                bottomSizer.Add(IsoSizer(u'size(\xb5m): ','Size','%.3f',
893                    OnSizeVal,OnSizeRef),0,WACV|wx.BOTTOM,5)
894            elif UseList[G2frame.hist]['Size'][0] == 'uniaxial':
895                uniSizer = wx.BoxSizer(wx.HORIZONTAL)
896                uniSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'],
897                    'Size',OnSizeType),0,WACV)
898                uniSizer.Add(LGmixSizer('Size',OnLGmixVal,OnLGmixRef))
899                uniSizer.Add(ResetSizer('uniaxial',OnResetSize),0,WACV)
900                bottomSizer.Add(UniSizer('Size',OnSizeAxis),0,WACV)
901                bottomSizer.Add(uniSizer)
902                bottomSizer.Add(UniDataSizer(u'size(\xb5m): ','Size','%.3f',OnSizeVal,OnSizeRef)
903                    ,0,WACV|wx.BOTTOM,5)
904            elif UseList[G2frame.hist]['Size'][0] == 'ellipsoidal':
905                ellSizer = wx.BoxSizer(wx.HORIZONTAL)
906                ellSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'],
907                    'Size',OnSizeType),0,WACV)
908                ellSizer.Add(LGmixSizer('Size',OnLGmixVal,OnLGmixRef))
909                ellSizer.Add(ResetSizer('ellipsoidal',OnResetSize),0,WACV)
910                bottomSizer.Add(ellSizer)
911                bottomSizer.Add(EllSizeDataSizer(),0,WACV|wx.BOTTOM,5)
912           
913            if UseList[G2frame.hist]['Mustrain'][0] == 'isotropic':
914                isoSizer = wx.BoxSizer(wx.HORIZONTAL)
915                isoSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',],
916                    'Mustrain',OnStrainType),0,WACV)
917                isoSizer.Add(LGmixSizer('Mustrain',OnLGmixVal,OnLGmixRef))
918                isoSizer.Add(ResetSizer('isotropic',OnResetStrain),0,WACV)
919                bottomSizer.Add(isoSizer)
920                bottomSizer.Add(IsoSizer(' microstrain: ','Mustrain','%.1f',
921                    OnStrainVal,OnStrainRef),0,WACV|wx.BOTTOM,5)
922            elif UseList[G2frame.hist]['Mustrain'][0] == 'uniaxial':
923                uniSizer = wx.BoxSizer(wx.HORIZONTAL)
924                uniSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',],
925                    'Mustrain',OnStrainType),0,WACV)
926                uniSizer.Add(LGmixSizer('Mustrain',OnLGmixVal,OnLGmixRef))
927                uniSizer.Add(ResetSizer('uniaxial',OnResetStrain),0,WACV)
928                bottomSizer.Add(uniSizer)
929                bottomSizer.Add(UniSizer('Mustrain',OnStrainAxis),0,WACV)
930                bottomSizer.Add(UniDataSizer('mustrain: ','Mustrain','%.1f',OnStrainVal,OnStrainRef)
931                                ,0,WACV|wx.BOTTOM,5)
932            elif UseList[G2frame.hist]['Mustrain'][0] == 'generalized':
933                genSizer = wx.BoxSizer(wx.HORIZONTAL)
934                genSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',],
935                    'Mustrain',OnStrainType),0,WACV)
936                genSizer.Add(LGmixSizer('Mustrain',OnLGmixVal,OnLGmixRef))
937                genSizer.Add(ResetSizer('generalized',OnResetStrain),0,WACV)
938                bottomSizer.Add(genSizer)
939                bottomSizer.Add(GenStrainDataSizer(),0,WACV|wx.BOTTOM,5)
940           
941            bottomSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Hydrostatic/elastic strain:'))
942            bottomSizer.Add(HstrainSizer())
943               
944            poSizer = wx.BoxSizer(wx.VERTICAL)
945            POData = UseList[G2frame.hist]['Pref.Ori.']
946# patch - add penalty items
947            if len(POData) < 7:
948                POData.append(['',])
949                POData.append(0.1)
950            if not POData[6]:
951                POData[6] = ['',]
952# end patch
953            poSizer.Add(PoTopSizer(POData))
954            if POData[0] == 'MD':
955                poSizer.Add(MDDataSizer(POData))
956            else:           #'SH'
957                if POData[4]:       #SH order > 0
958                    textJ = G2lat.textureIndex(POData[5])
959                    poSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Spherical harmonic coefficients: '+'Texture index: %.3f'%(textJ))
960                        ,0,WACV|wx.TOP|wx.BOTTOM,5)
961                    poSizer.Add(SHDataSizer(POData),0,WACV|wx.TOP|wx.BOTTOM,5)
962                    poSizer.Add(SHPenalty(POData),0,WACV|wx.TOP|wx.BOTTOM,5)
963                   
964            bottomSizer.Add(poSizer,0,WACV|wx.TOP|wx.BOTTOM,5)
965            bottomSizer.Add(ExtSizer('PWDR'),0,WACV|wx.TOP|wx.BOTTOM,5)
966            if generalData['Type'] != 'magnetic': 
967                bottomSizer.Add(BabSizer(),0,WACV|wx.BOTTOM,5)
968        elif G2frame.hist[:4] == 'HKLF':
969#patch
970            if 'Flack' not in UseList[G2frame.hist]:
971                UseList[G2frame.hist]['Flack'] = [0.0,False]
972            if 'Twins' not in UseList[G2frame.hist]:
973                UseList[G2frame.hist]['Twins'] = [[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]
974#end patch
975            bottomSizer.Add(ExtSizer('HKLF'),0,WACV|wx.BOTTOM,5)
976            bottomSizer.Add(BabSizer(),0,WACV|wx.BOTTOM,5)
977            if not SGData['SGInv'] and len(UseList[G2frame.hist]['Twins']) < 2:
978                bottomSizer.Add(FlackSizer(),0,WACV|wx.BOTTOM,5)
979            bottomSizer.Add(twinSizer(),0,WACV|wx.BOTTOM,5)
980        return bottomSizer
981               
982    if DData.GetSizer():
983        DData.GetSizer().Clear(True)
984    useList = []
985    for name in keyList:
986        if name in UseList:
987            useList.append(name)
988    if not G2frame.dataFrame.GetStatusBar():
989        G2frame.dataFrame.CreateStatusBar()
990    mainSizer = wx.BoxSizer(wx.VERTICAL)
991    mainSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Histogram data for '+PhaseName+':'),0,WACV|wx.LEFT,5)
992    if G2frame.hist != '':
993        topSizer = wx.FlexGridSizer(1,2,5,5)
994        select = wx.ListBox(DData,choices=useList,style=wx.LB_SINGLE,size=(-1,120))
995        select.SetSelection(useList.index(G2frame.hist))
996        select.SetFirstItem(useList.index(G2frame.hist))
997        select.Bind(wx.EVT_LISTBOX,OnSelect)
998        topSizer.Add(select,0,WACV|wx.LEFT,5)
999        if PWDR:
1000            topSizer.Add(PlotSizer())
1001        mainSizer.Add(topSizer)       
1002        G2frame.bottomSizer = ShowHistogramInfo()
1003        mainSizer.Add(G2frame.bottomSizer)
1004    elif not keyList:
1005        mainSizer.Add(wx.StaticText(DData,wx.ID_ANY,'  (This project has no data; use Import to read it)'),
1006                      0,WACV|wx.TOP,10)
1007    elif not UseList:
1008        mainSizer.Add(wx.StaticText(DData,wx.ID_ANY,'  (This phase has no associated data; use appropriate Edit/Add... menu item)'),
1009                      0,WACV|wx.TOP,10)
1010    else:
1011        mainSizer.Add(wx.StaticText(DData,wx.ID_ANY,'  (Strange, how did we get here?)'),
1012                      0,WACV|wx.TOP,10)
1013       
1014    G2phsGUI.SetPhaseWindow(G2frame.dataFrame,DData,mainSizer,Scroll=Scroll)
Note: See TracBrowser for help on using the repository browser.