Changeset 1143 for trunk/GSASIIgrid.py


Ignore:
Timestamp:
Nov 10, 2013 8:32:26 PM (9 years ago)
Author:
toby
Message:

rework constraints to handle names and refine flag for new var (input linear constraints); redo powder 'Sample Parameters'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r1138 r1143  
    141141
    142142VERY_LIGHT_GREY = wx.Colour(235,235,235)
    143 
     143DefaultControls = {
     144    'deriv type':'analytic Hessian',    #default controls
     145    'min dM/M':0.0001,'shift factor':1.,'max cyc':3,'F**2':True,
     146    'minF/sig':0,
     147    'Author':'no name',
     148    'FreeVar1':'Sample humidity (%)',
     149    'FreeVar2':'Sample voltage (V)',
     150    'FreeVar3':'Applied load (MN)',
     151    }
    144152################################################################################
    145153#### GSAS-II class definitions
     
    314322                else:
    315323                    self.invalid = True
    316             wx.TextCtrl.SetValue(self,str(val))
     324            wx.TextCtrl.SetValue(self,str(G2py3.FormatValue(val)))
    317325        else:
    318326            wx.TextCtrl.SetValue(self,str(val))
     
    397405        if not self.evaluated: return # true when an expression is evaluated
    398406        if self.result is not None: # retrieve the stored result
    399             val = self.result[self.key]
    400             self.SetValue(G2py3.FormatValue(val))
     407            self.SetValue(self.result[self.key])
    401408        self.evaluated = False # expression has been recast as value, reset flag
    402409       
     
    716723            self.dct[self.item] = self.values[0] # unknown
    717724
     725################################################################################
     726class G2CheckBox(wx.CheckBox):
     727    '''A customized version of a CheckBox that automatically initializes
     728    the control to match a supplied
     729
     730    :param wx.Panel parent: name of panel or frame that will be
     731      the parent to the TextCtrl. Can be None.
     732    :param str label: text to put on check button
     733    :param dict/list loc: the dict or list with the initial value to be
     734      placed in the CheckBox.
     735    :param int/str key: the dict key or the list index for the value to be
     736      edited by the CheckBox. The ``loc[key]`` element must exist.
     737      The CheckBox will be initialized from this value.
     738      If the value is anything other that True (or 1), it will be taken as
     739      False.
     740    '''
     741    def __init__(self,parent,label,loc,key):
     742        wx.CheckBox.__init__(self,parent,id=wx.ID_ANY,label=label)
     743        self.loc = loc
     744        self.key = key
     745        self.SetValue(self.loc[self.key]==True)
     746        self.Bind(wx.EVT_CHECKBOX, self._OnCheckBox)
     747    def _OnCheckBox(self,event):
     748        self.loc[self.key] = self.GetValue()
    718749################################################################################   
    719750def CallScrolledMultiEditor(parent,dictlst,elemlst,prelbl=[],postlbl=[],
     
    28812912    if 'Author' not in data:
    28822913        data['Author'] = 'no name'
     2914    if 'FreePrm1' not in data:
     2915        data['FreePrm1'] = 'Sample humidity (%)'
     2916    if 'FreePrm2' not in data:
     2917        data['FreePrm2'] = 'Sample voltage (V)'
     2918    if 'FreePrm3' not in data:
     2919        data['FreePrm3'] = 'Applied load (MN)'
    28832920    #end patch
    28842921
     
    30853122       
    30863123    def GetSampleParms():
    3087         sampleParmDict = {'Temperature':[],'Pressure':[],'Humidity':[],'Voltage':[],'Force':[],}
     3124        sampleParmDict = {'Temperature':300.,'Pressure':1.,
     3125                          'FreePrm1':0.,'FreePrm2':0.,'FreePrm3':0.,}
    30883126        sampleParm = {}
    30893127        for name in histNames:
     
    35133551            data = G2frame.PatternTree.GetItemPyData(item)
    35143552            if not data:           #fill in defaults
    3515                 data = {
    3516                     #least squares controls
    3517                     'deriv type':'analytic Hessian','min dM/M':0.0001,'shift factor':1.0,'max cyc':3}
     3553                data = copy.copy(DefaultControls)    #least squares controls
    35183554                G2frame.PatternTree.SetItemPyData(item,data)                             
    35193555            for i in G2frame.Refine: i.Enable(True)
     
    36683704        if 'Temperature' not in data:           #temp fix for old gpx files
    36693705            data = {'Scale':[1.0,True],'Type':'Debye-Scherrer','Absorption':[0.0,False],'DisplaceX':[0.0,False],
    3670                 'DisplaceY':[0.0,False],'Diffuse':[],'Temperature':300.,'Pressure':1.0,'Humidity':0.0,'Voltage':0.0,
    3671                 'Force':0.0,'Gonio. radius':200.0}
     3706                'DisplaceY':[0.0,False],'Diffuse':[],'Temperature':300.,'Pressure':1.0,
     3707                    'FreePrm1':0.,'FreePrm2':0.,'FreePrm3':0.,
     3708                    'Gonio. radius':200.0}
    36723709            G2frame.PatternTree.SetItemPyData(item,data)
    36733710   
Note: See TracChangeset for help on using the changeset viewer.