Changeset 1267
- Timestamp:
- Mar 28, 2014 2:56:26 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIgrid.py
r1265 r1267 105 105 ] = [wx.NewId() for item in range(7)] 106 106 107 [ wxID_BACKCOPY,wxID_LIMITCOPY, wxID_SAMPLECOPY, wxID_BACKFLAGCOPY, wxID_SAMPLEFLAGCOPY,107 [ wxID_BACKCOPY,wxID_LIMITCOPY, wxID_SAMPLECOPY, wxID_SAMPLECOPYSOME, wxID_BACKFLAGCOPY, wxID_SAMPLEFLAGCOPY, 108 108 wxID_SAMPLESAVE, wxID_SAMPLELOAD,wxID_ADDEXCLREGION,wxID_SETSCALE, 109 ] = [wx.NewId() for item in range( 9)]109 ] = [wx.NewId() for item in range(10)] 110 110 111 111 [ wxID_INSTPRMRESET,wxID_CHANGEWAVETYPE,wxID_INSTCOPY, wxID_INSTFLAGCOPY, wxID_INSTLOAD, … … 1433 1433 Sizer = wx.BoxSizer(wx.VERTICAL) 1434 1434 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) 1436 1436 if filterBox: 1437 1437 self.timer = wx.Timer() 1438 1438 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) 1440 1440 self.filterBox = wx.TextCtrl(self, wx.ID_ANY, size=(80,-1),style=wx.TE_PROCESS_ENTER) 1441 1441 self.filterBox.Bind(wx.EVT_CHAR,self.onChar) 1442 1442 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) 1444 1444 Sizer.Add(topSizer,0,wx.ALL|wx.EXPAND,8) 1445 1445 self.clb = wx.CheckListBox(self, wx.ID_ANY, (30,30), wx.DefaultSize, ChoiceList) … … 2517 2517 help='Save sample parameters to file') 2518 2518 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') 2520 2522 self.SampleEdit.Append(id=wxID_SAMPLEFLAGCOPY, kind=wx.ITEM_NORMAL,text='Copy flags', 2521 2523 help='Copy sample parameter refinement flags to other histograms') -
trunk/GSASIIpwdGUI.py
r1265 r1267 85 85 'Trans':1.0, #measured transmission 86 86 } 87 87 def 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 88 116 def SetDefaultSASDModel(): 89 117 'Fills in default items for the SASD Models dictionary' … … 190 218 'Select copy sections', choices, filterBox=False) 191 219 dlg.SetSelections(range(len(choices))) 220 choiceList = [] 192 221 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 197 224 198 225 dlg = G2gd.G2MultiChoiceDialog( … … 210 237 copyList.append(histList[i]) 211 238 212 if 0 in sections: # Limits239 if 'Limits' in choiceList: # Limits 213 240 data = G2frame.PatternTree.GetItemPyData( 214 241 G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId,'Limits')) … … 218 245 G2gd.GetPatternTreeItemId(G2frame,Id,'Limits'), 219 246 copy.deepcopy(data)) 220 if 1 in sections: # Background247 if 'Background' in choiceList: # Background 221 248 data = G2frame.PatternTree.GetItemPyData( 222 249 G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId,'Background')) … … 226 253 G2gd.GetPatternTreeItemId(G2frame,Id,'Background'), 227 254 copy.deepcopy(data)) 228 if 2 in sections: # Instrument Parameters255 if 'Instrument Parameters' in choiceList: # Instrument Parameters 229 256 # for now all items in Inst. parms are copied 230 257 data,data1 = G2frame.PatternTree.GetItemPyData( … … 239 266 G2gd.GetPatternTreeItemId(G2frame,Id,'Instrument Parameters') 240 267 )[1].update(copy.deepcopy(data1)) 241 if 3 in sections: # Sample Parameters268 if 'Sample Parameters' in choiceList: # Sample Parameters 242 269 data = G2frame.PatternTree.GetItemPyData( 243 270 G2gd.GetPatternTreeItemId( … … 547 574 G2frame.dataFrame, 548 575 'Copy bkg ref. flags from\n'+str(hst[5:])+' to...', 549 'Copy flags', histList)576 'Copy bkg flags', histList) 550 577 copyList = [] 551 578 try: … … 1402 1429 dlg.Destroy() 1403 1430 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 1404 1487 def OnSampleFlagCopy(event): 1405 1488 histType,copyNames = SetCopyNames(histName,data['Type']) … … 1478 1561 G2frame.Bind(wx.EVT_MENU, OnSetScale, id=G2gd.wxID_SETSCALE) 1479 1562 G2frame.Bind(wx.EVT_MENU, OnSampleCopy, id=G2gd.wxID_SAMPLECOPY) 1563 G2frame.Bind(wx.EVT_MENU, OnSampleCopySelected, id=G2gd.wxID_SAMPLECOPYSOME) 1480 1564 G2frame.Bind(wx.EVT_MENU, OnSampleFlagCopy, id=G2gd.wxID_SAMPLEFLAGCOPY) 1481 1565 G2frame.Bind(wx.EVT_MENU, OnSampleSave, id=G2gd.wxID_SAMPLESAVE) … … 1516 1600 #patch end 1517 1601 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')) 1540 1603 mainSizer = wx.BoxSizer(wx.VERTICAL) 1541 1604 topSizer = wx.BoxSizer(wx.HORIZONTAL)
Note: See TracChangeset
for help on using the changeset viewer.