Changeset 1086 for trunk/GSASIIgrid.py


Ignore:
Timestamp:
Oct 5, 2013 5:51:48 PM (8 years ago)
Author:
toby
Message:

finish dummy (simulated) histogram

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r1080 r1086  
    758758      value for the current row to all fields below (default is False)
    759759     
     760    :param list minvals: optional list of minimum values for validation
     761      of float or int values. Ignored if value is None.
     762    :param list maxvals: optional list of maximum values for validation
     763      of float or int values. Ignored if value is None.
     764    :param list sizevals: optional list of wx.Size values for each input
     765      widget. Ignored if value is None.
    760766    :returns: the wx.Dialog created here. Use method .ShowModal() to display it.
    761767   
     
    786792    def __init__(self,parent,dictlst,elemlst,prelbl=[],postlbl=[],
    787793                 title='Edit items',header='',size=(300,250),
    788                  CopyButton=False):
     794                 CopyButton=False,
     795                 minvals=[],maxvals=[],sizevals=[]):
    789796        if len(dictlst) != len(elemlst):
    790797            raise Exception,"ScrolledMultiEditor error: len(dictlst) != len(elemlst) "+str(len(dictlst))+" != "+str(len(elemlst))
     
    823830            else:
    824831                subSizer.Add(wx.StaticText(panel,wx.ID_ANY,str(prelbl[i])))
     832            kargs = {}
     833            if i < len(minvals):
     834                if minvals[i] is not None: kargs['min']=minvals[i]
     835            if i < len(maxvals):
     836                if maxvals[i] is not None: kargs['max']=maxvals[i]
     837            if i < len(sizevals):
     838                if sizevals[i]: kargs['size']=sizevals[i]
    825839            if CopyButton:
    826840                import wx.lib.colourselect as wscs
     
    836850                subSizer.Add(but)
    837851            # create the validated TextCrtl, store it and add it to the sizer
    838             ctrl = ValidatedTxtCtrl(panel,d,k,OKcontrol=self.ControlOKButton)
     852            ctrl = ValidatedTxtCtrl(panel,d,k,OKcontrol=self.ControlOKButton,
     853                                    **kargs)
    839854            self.ValidatedControlsList.append(ctrl)
    840855            subSizer.Add(ctrl)
     
    30193034       
    30203035def UpdatePWHKPlot(G2frame,kind,item):
    3021     '''Needs a doc string
     3036    '''Called when the histogram main tree entry is called. Displays the
     3037    histogram weight factor, refinement statistics for the histogram
     3038    and the range of data for a simulation.
     3039
     3040    Also invokes a plot of the histogram.
    30223041    '''
     3042    def onEditSimRange(event):
     3043        'Edit simulation range'
     3044        inp = [
     3045            min(data[1][0]),
     3046            max(data[1][0]),
     3047            None
     3048            ]
     3049        inp[2] = (inp[1] - inp[0])/(len(data[1][0])-1.)
     3050        names = ('start angle', 'end angle', 'step size')
     3051        dictlst = [inp] * len(inp)
     3052        elemlst = range(len(inp))
     3053        dlg = ScrolledMultiEditor(
     3054            G2frame,[inp] * len(inp), range(len(inp)), names,
     3055            header='Edit simulation range',
     3056            minvals=(0.001,0.001,0.0001),
     3057            maxvals=(180.,180.,.1),
     3058            )
     3059        dlg.CenterOnParent()
     3060        val = dlg.ShowModal()
     3061        dlg.Destroy()
     3062        if val != wx.ID_OK: return
     3063        if inp[0] > inp[1]:
     3064            end,start,step = inp
     3065        else:               
     3066            start,end,step = inp
     3067        step = abs(step)
     3068        newdata = np.arange(start,end+step,step)
     3069        if len(newdata) < 2: return # too small a range - reject
     3070        data[1][0] = newdata
     3071        data[1][1] = data[1][2] = None
     3072        UpdatePWHKPlot(G2frame,kind,item) # redisplay data screen
    30233073
    30243074    def OnErrorAnalysis(event):
     
    30513101    wtSizer.Add(wtval,0,wx.ALIGN_CENTER_VERTICAL)
    30523102    mainSizer.Add(wtSizer)
     3103    if data[0].get('Dummy'):
     3104        simSizer = wx.BoxSizer(wx.HORIZONTAL)
     3105        Tmin = min(data[1][0])
     3106        Tmax = max(data[1][0])
     3107        num = len(data[1][0])
     3108        step = (Tmax - Tmin)/(num-1)
     3109        t = u'2\u03b8' # 2theta
     3110        lbl =  u'Simulation range: {:.2f} to {:.2f} {:s}\nwith {:.4f} steps ({:d} points)'
     3111        lbl += u'\n(Edit range resets observed intensities).'
     3112        lbl = lbl.format(Tmin,Tmax,t,step,num)
     3113        simSizer.Add(wx.StaticText(G2frame.dataDisplay,wx.ID_ANY,lbl),
     3114                    0,wx.ALIGN_CENTER_VERTICAL)
     3115        but = wx.Button(G2frame.dataDisplay,wx.ID_ANY,"Edit range")
     3116        but.Bind(wx.EVT_BUTTON,onEditSimRange)
     3117        simSizer.Add(but,0,wx.ALIGN_CENTER_VERTICAL)
     3118        mainSizer.Add(simSizer)
    30533119    if 'Nobs' in data[0]:
    30543120        mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,
Note: See TracChangeset for help on using the changeset viewer.