Changeset 1673


Ignore:
Timestamp:
Feb 27, 2015 10:17:11 AM (7 years ago)
Author:
vondreele
Message:

add a Copy plot controls to the PWDR/SASD data window. It copies the new plot controls (Offset, etc.) from one plot to the others that are compatible.
Fix problem when Assemble molecule is used on an extended structure.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r1669 r1673  
    6666] = [wx.NewId() for item in range(17)]
    6767
    68 [ wxID_PWDRADD, wxID_HKLFADD, wxID_PWDANALYSIS, wxID_PWDCOPY, wxID_DATADELETE, wxID_SHOWALL,
    69 ] = [wx.NewId() for item in range(6)]
     68[ wxID_PWDRADD, wxID_HKLFADD, wxID_PWDANALYSIS, wxID_PWDCOPY, wxID_PLOTCTRLCOPY,
     69    wxID_DATADELETE, wxID_SHOWALL,
     70] = [wx.NewId() for item in range(7)]
    7071
    7172[ wxID_ATOMSEDITADD, wxID_ATOMSEDITINSERT, wxID_ATOMSEDITDELETE, wxID_ATOMSREFINE,
     
    16211622        self.ErrorAnal.Append(id=wxID_PWDCOPY,kind=wx.ITEM_NORMAL,text='Copy params',
    16221623            help='Copy of PWDR parameters')
     1624        self.ErrorAnal.Append(id=wxID_PLOTCTRLCOPY,kind=wx.ITEM_NORMAL,text='Copy plot controls',
     1625            help='Copy of PWDR plot controls')
     1626           
    16231627        self.PostfillDataMenu()
    16241628           
     
    38243828        data[0]['wtFactor'] = val
    38253829        wtval.SetValue('%.3f'%(val))
     3830       
     3831    def onCopyPlotCtrls(event):
     3832        '''Respond to menu item to copy multiple sections from a histogram.
     3833        Need this here to pass on the G2frame object.
     3834        '''
     3835        G2pdG.CopyPlotCtrls(G2frame)
    38263836
    38273837    def onCopySelectedItems(event):
     
    38503860        G2frame.dataFrame.Bind(wx.EVT_MENU, OnErrorAnalysis, id=wxID_PWDANALYSIS)
    38513861        G2frame.dataFrame.Bind(wx.EVT_MENU, onCopySelectedItems, id=wxID_PWDCOPY)
     3862        G2frame.dataFrame.Bind(wx.EVT_MENU, onCopyPlotCtrls, id=wxID_PLOTCTRLCOPY)
    38523863    elif kind in ['HKLF',]:
    38533864        SetDataMenuBar(G2frame,G2frame.dataFrame.HKLFMenu)
  • trunk/GSASIImath.py

    r1669 r1673  
    288288        atomData[Indx[indb]] = None
    289289        IndB = set(list(IndB)+list(getNeighbors(newAtoms[-1],radius)))
     290        if len(IndB) > nAtom:
     291            print 'Assemble molecule cannot be used on extended structures'
     292            return atomData
    290293    for atom in atomData:
    291294        if atom != None:
  • trunk/GSASIIpwdGUI.py

    r1643 r1673  
    207207        copyNames += addNames
    208208    return histType,copyNames
    209 
    210 def CopySelectedHistItems(G2frame):
    211     '''Global copy: Copy items from current histogram to others.
    212     This is called from the menubar and is available only when the top histogram tree entry
    213     is selected.
     209   
     210def CopyPlotCtrls(G2frame):
     211    '''Global copy: Copy plot controls from current histogram to others.
    214212    '''
    215213    hst = G2frame.PatternTree.GetItemText(G2frame.PatternId)
    216214    histList = GetHistsLikeSelected(G2frame)
    217215    if not histList:
    218         G2frame.ErrorDialog('No match','No histograms match '+hst,G2frame.dataFrame)
     216        G2frame.ErrorDialog('No match','No other histograms match '+hst,G2frame.dataFrame)
     217        return
     218    sourceData = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)
     219   
     220    if 'Offset' not in sourceData[0]:    #patch for old data
     221        sourceData[0].update({'Offset':[0.0,0.0],'delOffset':0.02,'refOffset':-1.0,
     222            'refDelt':0.01,'qPlot':False,'dPlot':False,'sqrtPlot':False})
     223        G2frame.PatternTree.SetItemPyData(G2frame.PatternId,sourceData)
     224       
     225    dlg = G2gd.G2MultiChoiceDialog(
     226        G2frame.dataFrame,
     227        'Copy plot controls from\n'+str(hst[5:])+' to...',
     228        'Copy plot controls', histList)
     229    results = []
     230    try:
     231        if dlg.ShowModal() == wx.ID_OK:
     232            results = dlg.GetSelections()
     233    finally:
     234        dlg.Destroy()
     235    copyList = []
     236    for i in results:
     237        copyList.append(histList[i])
     238
     239    keys = ['Offset','delOffset','refOffset','refDelt','qPlot','dPlot','sqrtPlot']
     240    source = dict(zip(keys,[sourceData[0][item] for item in keys]))
     241    for hist in copyList:
     242        Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,hist)
     243        data = G2frame.PatternTree.GetItemPyData(Id)
     244        data[0].update(source)
     245        G2frame.PatternTree.SetItemPyData(Id,data)
     246    print 'Copy of plot controls successful'
     247
     248def CopySelectedHistItems(G2frame):
     249    '''Global copy: Copy items from current histogram to others.
     250    '''
     251    hst = G2frame.PatternTree.GetItemText(G2frame.PatternId)
     252    histList = GetHistsLikeSelected(G2frame)
     253    if not histList:
     254        G2frame.ErrorDialog('No match','No other histograms match '+hst,G2frame.dataFrame)
    219255        return
    220256    choices = ['Limits','Background','Instrument Parameters','Sample Parameters']
Note: See TracChangeset for help on using the changeset viewer.