- Timestamp:
- May 26, 2020 2:38:22 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIphsGUI.py
r4434 r4442 1096 1096 #### Phase editing routines 1097 1097 ################################################################################ 1098 def getAtomSelections(AtmTbl,action='action'): 1099 '''get selected atoms from table or ask user if none are selected''' 1100 indx = AtmTbl.GetSelectedRows() 1101 indx += [row for row,col in AtmTbl.GetSelectedCells()] 1102 for top,bottom in zip([r for r,c in AtmTbl.GetSelectionBlockTopLeft()], 1103 [r for r,c in AtmTbl.GetSelectionBlockBottomRight()]): 1104 indx += list(range(top,bottom+1)) 1105 indx = list(set(indx)) 1106 if indx: return indx 1107 choices = [] 1108 for i in range(AtmTbl.GetNumberRows()): 1109 val = AtmTbl.GetCellValue(i,0) 1110 if val in choices: 1111 val += '_' + str(i) 1112 choices.append(val) 1113 if not choices: return 1114 dlg = G2G.G2MultiChoiceDialog(AtmTbl.GetTopLevelParent(), 1115 'Select atoms','Select atoms for '+action,choices) 1116 if dlg.ShowModal() == wx.ID_OK: 1117 indx = dlg.GetSelections() 1118 dlg.Destroy() 1119 return indx 1120 1098 1121 def SetPhaseWindow(phasePage,mainSizer=None,Scroll=0): 1099 1122 if mainSizer is not None: … … 3444 3467 '''Inserts a new atom into list immediately before every selected atom 3445 3468 ''' 3446 indx = GetSelectedAtoms()3469 indx = getAtomSelections(Atoms) 3447 3470 for a in reversed(sorted(indx)): 3448 3471 AtomInsert(a,0.,0.,0.) … … 3464 3487 '''Adds H atoms to fill out coordination sphere for selected atoms 3465 3488 ''' 3466 indx = GetSelectedAtoms()3489 indx = getAtomSelections(Atoms) 3467 3490 if not indx: return 3468 3491 DisAglCtls = {} … … 3593 3616 cx = colLabels.index('x') 3594 3617 ci = colLabels.index('I/A') 3595 indx = GetSelectedAtoms()3618 indx = getAtomSelections(Atoms) 3596 3619 if len(indx) != 1: 3597 3620 G2frame.ErrorDialog('Atom move error','Only one atom can be moved') … … 3692 3715 HydIds = data['General']['HydIds'] 3693 3716 ci = colLabels.index('I/A') 3694 indx = GetSelectedAtoms()3717 indx = getAtomSelections(Atoms) 3695 3718 IDs = [] 3696 3719 if not indx: return … … 3718 3741 G2frame.dataWindow.AtomEdit.Enable(G2G.wxID_UPDATEHATOM,False) 3719 3742 event.StopPropagation() 3720 3721 def GetSelectedAtoms(action='action'):3722 '''Get all atoms that are selected by row or by having any cell3723 selected. If no atoms are selected ask user.3724 '''3725 indx = list(set([row for row,col in Atoms.GetSelectedCells()]+Atoms.GetSelectedRows()))3726 # if indx:3727 # return indx3728 # else:3729 # G2G.G2MessageBox(G2frame,'Warning: no atoms were selected','Nothing selected')3730 if indx: return indx3731 choices = []3732 for i in range(Atoms.GetNumberRows()):3733 val = Atoms.GetCellValue(i,0)3734 if val in choices:3735 val += '_' + Atoms.GetCellValue(i,5)3736 choices.append(val)3737 if not choices: return3738 dlg = G2G.G2MultiChoiceDialog(Atoms.GetTopLevelParent(),3739 'Select atoms','Select atoms for '+action,choices)3740 if dlg.ShowModal() == wx.ID_OK:3741 indx = dlg.GetSelections()3742 dlg.Destroy()3743 return indx3744 3743 3745 3744 def AtomRefine(event): 3746 3745 colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())] 3747 3746 c = colLabels.index('refine') 3748 indx = GetSelectedAtoms()3747 indx = getAtomSelections(Atoms) 3749 3748 if not indx: return 3750 3749 atomData = data['Atoms'] … … 3768 3767 3769 3768 def AtomModify(event): 3770 indx = GetSelectedAtoms()3769 indx = getAtomSelections(Atoms) 3771 3770 if not indx: return 3772 3771 atomData = data['Atoms'] … … 3878 3877 3879 3878 def AtomTransform(event): 3880 indx = GetSelectedAtoms()3879 indx = getAtomSelections(Atoms) 3881 3880 if not indx: return 3882 3881 generalData = data['General'] … … 3947 3946 # 'yz':np.array([[0,i,j] for i in range(3) for j in range(3)])-np.array([1,1,0]), 3948 3947 # 'xyz':np.array([[i,j,k] for i in range(3) for j in range(3) for k in range(3)])-np.array([1,1,1])} 3949 # indx = GetSelectedAtoms()3948 # indx = getAtomSelections(Atoms) 3950 3949 # if indx: 3951 3950 # generalData = data['General'] … … 3991 3990 3992 3991 def MakeMolecule(event): 3993 indx = GetSelectedAtoms()3992 indx = getAtomSelections(Atoms) 3994 3993 DisAglCtls = {} 3995 3994 if indx is not None and len(indx) == 1: … … 4040 4039 def OnDistAngle(event,fp=None): 4041 4040 'Compute distances and angles' 4042 indx = GetSelectedAtoms()4041 indx = getAtomSelections(Atoms) 4043 4042 Oxyz = [] 4044 4043 xyz = [] … … 7070 7069 #### Structure drawing GUI stuff 7071 7070 ################################################################################ 7072 def getAtomSelections(drawAtoms,action='action'):7073 '''get selected atoms from table or ask user if none selected'''7074 #indx = drawAtoms.GetSelectedRows()7075 indx = list(set([row for row,col in drawAtoms.GetSelectedCells()]+7076 drawAtoms.GetSelectedRows()))7077 if indx: return indx7078 choices = []7079 for i in range(drawAtoms.GetNumberRows()):7080 val = drawAtoms.GetCellValue(i,0)7081 if val in choices:7082 val += '_' + drawAtoms.GetCellValue(i,5)7083 choices.append(val)7084 if not choices: return7085 dlg = G2G.G2MultiChoiceDialog(drawAtoms.GetTopLevelParent(),7086 'Select atoms','Select atoms for '+action,choices)7087 if dlg.ShowModal() == wx.ID_OK:7088 indx = dlg.GetSelections()7089 dlg.Destroy()7090 return indx7091 7092 7071 def SetupDrawingData(): 7093 7072 generalData = data['General']
Note: See TracChangeset
for help on using the changeset viewer.