Changeset 1267


Ignore:
Timestamp:
Mar 28, 2014 2:56:26 PM (8 years ago)
Author:
toby
Message:

add selected copy for sample param

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r1265 r1267  
    105105] = [wx.NewId() for item in range(7)]
    106106
    107 [ wxID_BACKCOPY,wxID_LIMITCOPY,wxID_SAMPLECOPY, wxID_BACKFLAGCOPY, wxID_SAMPLEFLAGCOPY,
     107[ wxID_BACKCOPY,wxID_LIMITCOPY, wxID_SAMPLECOPY, wxID_SAMPLECOPYSOME, wxID_BACKFLAGCOPY, wxID_SAMPLEFLAGCOPY,
    108108    wxID_SAMPLESAVE, wxID_SAMPLELOAD,wxID_ADDEXCLREGION,wxID_SETSCALE,
    109 ] = [wx.NewId() for item in range(9)]
     109] = [wx.NewId() for item in range(10)]
    110110
    111111[ wxID_INSTPRMRESET,wxID_CHANGEWAVETYPE,wxID_INSTCOPY, wxID_INSTFLAGCOPY, wxID_INSTLOAD,
     
    14331433        Sizer = wx.BoxSizer(wx.VERTICAL)
    14341434        topSizer = wx.BoxSizer(wx.HORIZONTAL)
    1435         topSizer.Add(wx.StaticText(self,wx.ID_ANY,title,size=(-1,35)),1,wx.ALL|wx.EXPAND,1)
     1435        topSizer.Add(wx.StaticText(self,wx.ID_ANY,title,size=(-1,35)),1,wx.ALL|wx.EXPAND|WACV,1)
    14361436        if filterBox:
    14371437            self.timer = wx.Timer()
    14381438            self.timer.Bind(wx.EVT_TIMER,self.Filter)
    1439             topSizer.Add(wx.StaticText(self,wx.ID_ANY,'Filter: '),0,wx.ALL,1)
     1439            topSizer.Add(wx.StaticText(self,wx.ID_ANY,'Name \nFilter: '),0,wx.ALL|WACV,1)
    14401440            self.filterBox = wx.TextCtrl(self, wx.ID_ANY, size=(80,-1),style=wx.TE_PROCESS_ENTER)
    14411441            self.filterBox.Bind(wx.EVT_CHAR,self.onChar)
    14421442            self.filterBox.Bind(wx.EVT_TEXT_ENTER,self.Filter)
    1443             topSizer.Add(self.filterBox,0,wx.ALL,0)
     1443            topSizer.Add(self.filterBox,0,wx.ALL|WACV,0)
    14441444        Sizer.Add(topSizer,0,wx.ALL|wx.EXPAND,8)
    14451445        self.clb = wx.CheckListBox(self, wx.ID_ANY, (30,30), wx.DefaultSize, ChoiceList)
     
    25172517            help='Save sample parameters to file')
    25182518        self.SampleEdit.Append(id=wxID_SAMPLECOPY, kind=wx.ITEM_NORMAL,text='Copy',
    2519             help='Copy refinable sample parameters to other histograms')
     2519            help='Copy refinable and most other sample parameters to other histograms')
     2520        self.SampleEdit.Append(id=wxID_SAMPLECOPYSOME, kind=wx.ITEM_NORMAL,text='Copy selected...',
     2521            help='Copy selected sample parameters to other histograms')
    25202522        self.SampleEdit.Append(id=wxID_SAMPLEFLAGCOPY, kind=wx.ITEM_NORMAL,text='Copy flags',
    25212523            help='Copy sample parameter refinement flags to other histograms')
  • trunk/GSASIIpwdGUI.py

    r1265 r1267  
    8585        'Trans':1.0,                            #measured transmission
    8686        }
    87        
     87def SetupSampleLabels(histName,dataType):
     88    '''Setup a list of labels and number formatting for use in
     89    labeling sample parameters.
     90    :param str histName: Name of histogram, ("PWDR ...")
     91    :param str dataType:
     92    '''
     93    parms = []
     94    parms.append(['Scale','Histogram scale factor: ',[10,4]])
     95    parms.append(['Gonio. radius','Goniometer radius (mm): ',[10,3]])
     96    if 'PWDR' in histName:
     97        if dataType == 'Debye-Scherrer':
     98            parms += [['DisplaceX',u'Sample X displ. perp. to beam (\xb5m): ',[10,3]],
     99                ['DisplaceY',u'Sample Y displ. || to beam (\xb5m): ',[10,3]],
     100                ['Absorption',u'Sample absorption (\xb5\xb7r): ',[10,4]],]
     101        elif dataType == 'Bragg-Brentano':
     102            parms += [['Shift',u'Sample displacement(\xb5m): ',[10,4]],
     103                ['Transparency',u'Sample transparency(1/\xb5eff, cm): ',[10,3]],
     104                ['SurfRoughA','Surface roughness A: ',[10,4]],
     105                ['SurfRoughB','Surface roughness B: ',[10,4]]]
     106    elif 'SASD' in histName:
     107        parms.append(['Thick','Sample thickness (mm)',[10,3]])
     108        parms.append(['Trans','Transmission (meas)',[10,3]])
     109    parms.append(['Omega','Goniometer omega:',[10,3]])
     110    parms.append(['Chi','Goniometer chi:',[10,3]])
     111    parms.append(['Phi','Goniometer phi:',[10,3]])
     112    parms.append(['Temperature','Sample temperature (K): ',[10,3]])
     113    parms.append(['Pressure','Sample pressure (MPa): ',[10,3]])
     114    return parms
     115
    88116def SetDefaultSASDModel():
    89117    'Fills in default items for the SASD Models dictionary'   
     
    190218        'Select copy sections', choices, filterBox=False)
    191219    dlg.SetSelections(range(len(choices)))
     220    choiceList = []
    192221    if dlg.ShowModal() == wx.ID_OK:
    193         sections = dlg.GetSelections()
    194     else:
    195         sections = []
    196     if not sections: return
     222        choiceList = [choices[i] for i in dlg.GetSelections()]
     223    if not choiceList: return
    197224   
    198225    dlg = G2gd.G2MultiChoiceDialog(
     
    210237        copyList.append(histList[i])
    211238
    212     if 0 in sections: # Limits
     239    if 'Limits' in choiceList: # Limits
    213240        data = G2frame.PatternTree.GetItemPyData(
    214241            G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId,'Limits'))
     
    218245                G2gd.GetPatternTreeItemId(G2frame,Id,'Limits'),
    219246                copy.deepcopy(data))
    220     if 1 in sections:  # Background
     247    if 'Background' in choiceList:  # Background
    221248        data = G2frame.PatternTree.GetItemPyData(
    222249            G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId,'Background'))
     
    226253                G2gd.GetPatternTreeItemId(G2frame,Id,'Background'),
    227254                copy.deepcopy(data))
    228     if 2 in sections:  # Instrument Parameters
     255    if 'Instrument Parameters' in choiceList:  # Instrument Parameters
    229256        # for now all items in Inst. parms are copied
    230257        data,data1 = G2frame.PatternTree.GetItemPyData(
     
    239266                G2gd.GetPatternTreeItemId(G2frame,Id,'Instrument Parameters')
    240267                )[1].update(copy.deepcopy(data1))
    241     if 3 in sections:  # Sample Parameters
     268    if 'Sample Parameters' in choiceList:  # Sample Parameters
    242269        data = G2frame.PatternTree.GetItemPyData(
    243270            G2gd.GetPatternTreeItemId(
     
    547574            G2frame.dataFrame,
    548575            'Copy bkg ref. flags from\n'+str(hst[5:])+' to...',
    549             'Copy flags', histList)
     576            'Copy bkg flags', histList)
    550577        copyList = []
    551578        try:
     
    14021429            dlg.Destroy()
    14031430
     1431    def OnSampleCopySelected(event):
     1432        hst = G2frame.PatternTree.GetItemText(G2frame.PatternId)
     1433        Controls = G2frame.PatternTree.GetItemPyData(
     1434            G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Controls'))
     1435        histList = GetHistsLikeSelected(G2frame)
     1436        if not histList:
     1437            G2frame.ErrorDialog('No match','No histograms match '+hst,G2frame.dataFrame)
     1438            return
     1439        # Assemble a list of item labels
     1440        TextTable = {key:label for key,label,dig in
     1441                     SetupSampleLabels(hst,data.get('Type'))
     1442                     }
     1443        # get flexible labels
     1444        TextTable.update({
     1445            key:Controls[key] for key in Controls if key.startswith('FreePrm')
     1446            })
     1447        # add a few extra
     1448        TextTable.update({
     1449            'Type':'Diffractometer type',
     1450            'InstrName':'Instrument Name',
     1451            })
     1452        # Assemble a list of dict entries that would be labeled in the Sample
     1453        # params data window (drop ranId and items not used).
     1454        keyList = [i for i in data.keys() if i in TextTable]
     1455        keyText = [TextTable[i] for i in keyList]
     1456        # sort both lists together, ordered by keyText
     1457        keyText, keyList = zip(*sorted(zip(keyText,keyList))) # sort lists
     1458        selectedKeys = []
     1459        dlg = G2gd.G2MultiChoiceDialog(
     1460            G2frame.dataFrame,
     1461            'Select which sample parameters\nto copy',
     1462            'Select sample parameters', keyText)
     1463        try:
     1464            if dlg.ShowModal() == wx.ID_OK:
     1465                selectedKeys = [keyList[i] for i in dlg.GetSelections()]
     1466        finally:
     1467            dlg.Destroy()
     1468        if not selectedKeys: return # nothing to copy
     1469        copyDict = {}
     1470        for parm in selectedKeys:
     1471            copyDict[parm] = data[parm]
     1472        dlg = G2gd.G2MultiChoiceDialog(
     1473            G2frame.dataFrame,
     1474            'Copy sample params from\n'+str(hst[5:])+' to...',
     1475            'Copy sample parameters', histList)
     1476        try:
     1477            if dlg.ShowModal() == wx.ID_OK:
     1478                result = dlg.GetSelections()
     1479                for i in result:
     1480                    item = histList[i]
     1481                    Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,item)
     1482                    sampleData = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Sample Parameters'))
     1483                    sampleData.update(copy.deepcopy(copyDict))
     1484        finally:
     1485            dlg.Destroy()
     1486
    14041487    def OnSampleFlagCopy(event):
    14051488        histType,copyNames = SetCopyNames(histName,data['Type'])
     
    14781561    G2frame.Bind(wx.EVT_MENU, OnSetScale, id=G2gd.wxID_SETSCALE)
    14791562    G2frame.Bind(wx.EVT_MENU, OnSampleCopy, id=G2gd.wxID_SAMPLECOPY)
     1563    G2frame.Bind(wx.EVT_MENU, OnSampleCopySelected, id=G2gd.wxID_SAMPLECOPYSOME)
    14801564    G2frame.Bind(wx.EVT_MENU, OnSampleFlagCopy, id=G2gd.wxID_SAMPLEFLAGCOPY)
    14811565    G2frame.Bind(wx.EVT_MENU, OnSampleSave, id=G2gd.wxID_SAMPLESAVE)
     
    15161600#patch end
    15171601   
    1518     parms = []
    1519     parms.append(['Scale','Histogram scale factor: ',[10,4]])
    1520     parms.append(['Gonio. radius','Goniometer radius (mm): ',[10,3]])
    1521     if 'PWDR' in histName:
    1522         if data['Type'] == 'Debye-Scherrer':
    1523             parms += [['DisplaceX',u'Sample X displ. perp. to beam (\xb5m): ',[10,3]],
    1524                 ['DisplaceY',u'Sample Y displ. || to beam (\xb5m): ',[10,3]],
    1525                 ['Absorption',u'Sample absorption (\xb5\xb7r): ',[10,4]],]
    1526         elif data['Type'] == 'Bragg-Brentano':
    1527             parms += [['Shift',u'Sample displacement(\xb5m): ',[10,4]],
    1528                 ['Transparency',u'Sample transparency(1/\xb5eff, cm): ',[10,3]],
    1529                 ['SurfRoughA','Surface roughness A: ',[10,4]],
    1530                 ['SurfRoughB','Surface roughness B: ',[10,4]]]
    1531     elif 'SASD' in histName:
    1532         parms.append(['Thick','Sample thickness (mm)',[10,3]])
    1533         parms.append(['Trans','Transmission (meas)',[10,3]])
    1534     parms.append(['Omega','Goniometer omega:',[10,3]])
    1535     parms.append(['Chi','Goniometer chi:',[10,3]])
    1536     parms.append(['Phi','Goniometer phi:',[10,3]])
    1537     parms.append(['Temperature','Sample temperature (K): ',[10,3]])
    1538     parms.append(['Pressure','Sample pressure (MPa): ',[10,3]])
    1539                
     1602    parms = SetupSampleLabels(histName,data.get('Type'))
    15401603    mainSizer = wx.BoxSizer(wx.VERTICAL)
    15411604    topSizer = wx.BoxSizer(wx.HORIZONTAL)
Note: See TracChangeset for help on using the changeset viewer.