Changeset 2593 for trunk/GSASIIphsGUI.py


Ignore:
Timestamp:
Dec 17, 2016 9:24:00 PM (7 years ago)
Author:
toby
Message:

Add Pawley settings menu item; open Phases and selected data tree item on GPX open

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r2588 r2593  
    2626import wx.lib.scrolledpanel as wxscroll
    2727import matplotlib as mpl
     28import math
    2829import copy
    2930import time
     
    72117212            G2frame.dataFrame.setSizePosLeft([450,300])
    72127213                   
     7214    def OnPawleySet(event):
     7215        '''Set Pawley parameters and optionally recompute
     7216        '''
     7217        #GSASIIpath.IPyBreak()
     7218       
     7219        def DisablePawleyOpts(*args):
     7220            pawlVal.Enable(generalData['doPawley'])
     7221            pawlNegWt.Enable(generalData['doPawley'])
     7222        generalData = data['General']
     7223        startDmin = generalData['Pawley dmin']
     7224        General = wx.Dialog(G2frame.dataFrame,wx.ID_ANY,'Set Pawley Parameters',
     7225                        style=wx.DEFAULT_DIALOG_STYLE)
     7226        mainSizer = wx.BoxSizer(wx.VERTICAL)
     7227        mainSizer.Add(wx.StaticText(General,wx.ID_ANY,
     7228                                    'Set Pawley Extraction Parameters for phase '+
     7229                                    generalData.get('Name','?')))
     7230        mainSizer.Add([5,10])
     7231        pawleySizer = wx.BoxSizer(wx.HORIZONTAL)
     7232        pawleySizer.Add(wx.StaticText(General,label=' Do Pawley refinement?: '),0,WACV)
     7233        pawlRef = G2G.G2CheckBox(General,'',generalData,'doPawley',
     7234                             DisablePawleyOpts)
     7235        pawleySizer.Add(pawlRef,0,WACV)
     7236        mainSizer.Add(pawleySizer)
     7237        pawleySizer = wx.BoxSizer(wx.HORIZONTAL)
     7238        pawleySizer.Add(wx.StaticText(General,label=' Pawley dmin: '),0,WACV)
     7239        def d2Q(*a,**kw):
     7240            temp['Qmax'] = 2 * math.pi / generalData['Pawley dmin']
     7241            pawlQVal.SetValue(temp['Qmax'])
     7242        pawlVal = G2G.ValidatedTxtCtrl(General,generalData,'Pawley dmin',
     7243               min=0.25,max=20.,nDig=(10,5),typeHint=float,OnLeave=d2Q)
     7244        pawleySizer.Add(pawlVal,0,WACV)
     7245        pawleySizer.Add(wx.StaticText(General,label='   Qmax: '),0,WACV)
     7246        temp = {'Qmax':2 * math.pi / generalData['Pawley dmin']}
     7247        def Q2D(*args,**kw):
     7248            generalData['Pawley dmin'] = 2 * math.pi / temp['Qmax']
     7249            pawlVal.SetValue(generalData['Pawley dmin'])       
     7250        pawlQVal = G2G.ValidatedTxtCtrl(General,temp,'Qmax',
     7251               min=0.314,max=25.,nDig=(10,5),typeHint=float,OnLeave=Q2D)
     7252        pawleySizer.Add(pawlQVal,0,WACV)
     7253        mainSizer.Add(pawleySizer)
     7254        pawleySizer = wx.BoxSizer(wx.HORIZONTAL)
     7255        pawleySizer.Add(wx.StaticText(General,label=' Pawley neg. wt.: '),0,WACV)
     7256        pawlNegWt = G2G.ValidatedTxtCtrl(General,generalData,'Pawley neg wt',
     7257                    min=0.,max=1.,nDig=(10,4),typeHint=float)
     7258        pawleySizer.Add(pawlNegWt,0,WACV)
     7259        mainSizer.Add(pawleySizer)
     7260
     7261        # make OK button
     7262        def OnOK(event): General.EndModal(wx.ID_OK)
     7263        mainSizer.Add([5,5])
     7264        btnsizer = wx.StdDialogButtonSizer()
     7265        btn = wx.Button(General, wx.ID_OK)
     7266        btn.Bind(wx.EVT_BUTTON, OnOK)
     7267        btn.SetDefault()
     7268        btnsizer.AddButton(btn)
     7269        btn = wx.Button(General, wx.ID_CANCEL)
     7270        btnsizer.AddButton(btn)
     7271        btnsizer.Realize()
     7272        mainSizer.Add(btnsizer, 0, wx.ALIGN_CENTER|wx.ALL, 5)
     7273
     7274        General.SetSizer(mainSizer)
     7275        mainSizer.Fit(General)
     7276        res = General.ShowModal()
     7277        General.Destroy()
     7278
     7279        if generalData['doPawley'] and res == wx.ID_OK and startDmin != generalData['Pawley dmin']:
     7280            dlg = wx.MessageDialog(G2frame,'Do you want to initialize the Pawley reflections with the new Dmin value?','Initialize Pawley?',
     7281                wx.YES_NO | wx.ICON_QUESTION)
     7282            try:
     7283                result = dlg.ShowModal()
     7284                if result == wx.ID_NO:
     7285                    return
     7286            finally:
     7287                dlg.Destroy()
     7288            OnPawleyLoad(event)
     7289           
    72137290    def OnPawleyLoad(event):
    72147291        generalData = data['General']
     
    79798056        # Pawley reflections
    79808057        FillSelectPageMenu(TabSelectionIdDict, G2frame.dataFrame.PawleyMenu)
     8058        G2frame.dataFrame.Bind(wx.EVT_MENU, OnPawleySet, id=G2gd.wxID_PAWLEYSET)
    79818059        G2frame.dataFrame.Bind(wx.EVT_MENU, OnPawleyLoad, id=G2gd.wxID_PAWLEYLOAD)
    79828060        G2frame.dataFrame.Bind(wx.EVT_MENU, OnPawleyEstimate, id=G2gd.wxID_PAWLEYESTIMATE)
Note: See TracChangeset for help on using the changeset viewer.