Changeset 1017 for trunk/GSASIIpwdGUI.py


Ignore:
Timestamp:
Aug 6, 2013 9:10:46 PM (9 years ago)
Author:
vondreele
Message:

implement excluded regions - 1st attempt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwdGUI.py

    r1008 r1017  
    611611    '''respond to selection of PWDR Limits data tree item.
    612612    '''
    613     #Add excluded regions here
    614613    if G2frame.dataDisplay:
    615614        G2frame.dataFrame.Clear()
    616615       
     616    def KeyEditPeakGrid(event):
     617        row = G2frame.dataDisplay.GetSelectedRows()[0]
     618        if row > 1: #can't delete limits!
     619            G2frame.dataDisplay.ClearSelection()
     620            if event.GetKeyCode() == wx.WXK_DELETE:
     621                G2frame.dataDisplay.ClearGrid()
     622                del(data[row])
     623                wx.CallAfter(UpdateLimitsGrid,G2frame,data)
     624                G2plt.PlotPatterns(G2frame)
     625                       
    617626    def RefreshLimitsGrid(event):
    618627        event.StopPropagation()
     
    622631        new[0] = max(old[0],new[0])
    623632        new[1] = max(new[0],min(old[1],new[1]))
    624         data = [old,new]
     633        if len(data) > 2:
     634            excl = data[2:]
     635            for item in excl:
     636                item[0] = max(old[0],item[0])
     637                item[1] = max(item[0],min(old[1],item[1]))
     638        data = [old,new]+excl
     639        G2frame.LimitsTable.SetData(data)
    625640        G2plt.PlotPatterns(G2frame)
    626641       
     
    644659        finally:
    645660            dlg.Destroy()
     661           
     662    def OnAddExcl(event):
     663        G2frame.ifGetExclude = True
     664        print 'Add excluded region'
    646665       
    647666    G2frame.LimitsTable = []
    648667    colLabels = ['Tmin','Tmax']
    649668    rowLabels = ['original','changed']
     669    for i in range(len(data)-2):
     670        rowLabels.append('exclude')
    650671    Types = 2*[wg.GRID_VALUE_FLOAT+':10,3',]
    651672    G2frame.LimitsTable = G2gd.Table(data,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     
    655676        Status = G2frame.dataFrame.CreateStatusBar()
    656677    G2frame.Bind(wx.EVT_MENU,OnLimitCopy,id=G2gd.wxID_LIMITCOPY)
     678    G2frame.Bind(wx.EVT_MENU,OnAddExcl,id=G2gd.wxID_ADDEXCLREGION)   
    657679    G2frame.dataDisplay = G2gd.GSGrid(parent=G2frame.dataFrame)
    658680    G2frame.dataDisplay.SetTable(G2frame.LimitsTable, True)
    659681    G2frame.dataDisplay.Bind(wg.EVT_GRID_CELL_CHANGE, RefreshLimitsGrid)               
     682    G2frame.dataDisplay.Bind(wx.EVT_KEY_DOWN, KeyEditPeakGrid)
    660683    G2frame.dataDisplay.SetMargins(0,0)
    661684    G2frame.dataDisplay.AutoSizeColumns(False)
    662     G2frame.dataFrame.setSizePosLeft([230,160])
     685    G2frame.dataFrame.setSizePosLeft([230,260])
    663686   
    664687################################################################################
     
    20392062    powName = 'PWDR'+dataFile[4:]
    20402063    powId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, powName)
    2041     fullLimits,limits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,powId, 'Limits'))
     2064    fullLimits,limits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,powId, 'Limits'))[:2]
    20422065    inst = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,powId, 'Instrument Parameters'))[0]
    20432066    if 'Lam' in inst:
Note: See TracChangeset for help on using the changeset viewer.