Changeset 4503
- Timestamp:
- Jun 20, 2020 7:39:59 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIconstrGUI.py
r4492 r4503 3163 3163 if El not in AtInfo: 3164 3164 Info = G2elem.GetAtomInfo(El) 3165 AtInfo[El] = [Info['Drad'] ['Color']]3165 AtInfo[El] = [Info['Drad'],Info['Color']] 3166 3166 rbData['rbTypes'][r] = El 3167 3167 resGrid.SetCellValue(r,c,El) … … 3177 3177 pass 3178 3178 3179 def RowSelect(event):3180 r,c = event.GetRow(),event.GetCol()3181 if c < 0: #only row clicks3182 for iGrid in resList:3183 iGrid.ClearSelection()3184 resGrid.SelectRow(r,True)3185 3186 3179 def OnRefSel(event): 3187 3180 Obj = event.GetEventObject() … … 3233 3226 resGrid.Bind(wg.EVT_GRID_CELL_CHANGE, ChangeCell) 3234 3227 resGrid.Bind(wg.EVT_GRID_CELL_LEFT_DCLICK, TypeSelect) 3235 resGrid.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK, RowSelect) 3236 attr = wx.grid.GridCellAttr() 3237 attr.IncRef() 3238 attr.SetEditor(G2G.GridFractionEditor(resGrid)) 3239 for c in range(3): 3228 for c in range(2,5): 3229 attr = wx.grid.GridCellAttr() 3240 3230 attr.IncRef() 3231 attr.SetEditor(G2G.GridFractionEditor(resGrid)) 3241 3232 resGrid.SetColAttr(c, attr) 3242 3233 for row in range(vecTable.GetNumberRows()): 3243 for col in range(5): 3244 resGrid.SetCellStyle(row,col,VERY_LIGHT_GREY,True) 3234 resGrid.SetReadOnly(row,1,True) 3245 3235 resGrid.AutoSizeColumns(False) 3246 3236 vecSizer = wx.BoxSizer() -
trunk/GSASIIdataGUI.py
r4492 r4503 4338 4338 self.SetTitleByGPX() 4339 4339 os.chdir(dlg.GetDirectory()) # to get Mac/Linux to change directory! 4340 config = G2G.GetConfigValsDocs() 4341 GSASIIpath.addPrevGPX(self.GSASprojectfile,config) 4340 4342 return True 4341 4343 else: -
trunk/GSASIIphsGUI.py
r4502 r4503 1402 1402 atomData[i][-1] = Faces 1403 1403 1404 def VoidMap(data,aMax=1,bMax=1,cMax=1,gridspacing=.25,probeRadius=.5): 1404 def VoidMap(data,aMax=1,bMax=1,cMax=1,gridspacing=.25,probeRadius=.5, 1405 aMin=0,bMin=0,cMin=0): 1405 1406 '''Compute points where there are no atoms within probeRadius A. 1406 1407 All atoms in the Atoms list are considered, provided their … … 1417 1418 Defaults to 1. 1418 1419 :param float ,probeRadius=.5: 1419 1420 :param float aMin: Minimum along the *a* direction (fractional units). 1421 Defaults to 0. 1422 :param float bMin: Minimum along the *b* direction (fractional units). 1423 Defaults to 0. 1424 :param float cMin: Minimum along the *c* direction (fractional units). 1425 Defaults to 0. 1426 : 1420 1427 ''' 1421 1428 … … 1427 1434 1428 1435 xx,yy,zz = np.meshgrid( 1429 np.linspace( 0,aMax,int(0.5+cell[0]*aMax/gridspacing),endpoint=False),1430 np.linspace( 0,cMax,int(0.5+cell[1]*bMax/gridspacing),endpoint=False),1431 np.linspace( 0,cMax,int(0.5+cell[2]*cMax/gridspacing),endpoint=False))1436 np.linspace(aMin,aMax,int(0.5+cell[0]*(aMax-aMin)/gridspacing),endpoint=False), 1437 np.linspace(bMin,bMax,int(0.5+cell[1]*(bMax-bMin)/gridspacing),endpoint=False), 1438 np.linspace(cMin,cMax,int(0.5+cell[2]*(cMax-cMin)/gridspacing),endpoint=False)) 1432 1439 coordGrd = np.array([xyz for xyz in zip(xx.ravel(),yy.ravel(),zz.ravel())]) 1433 1440 … … 9984 9991 RBnames = [] 9985 9992 for RBObj in data['RBModels']['Residue']: 9986 RBnames.append(RBObj['RBname'].split(':')[0]+RBObj['numChain']) 9993 # RBnames.append(RBObj['RBname'].split(':')[0]+RBObj['numChain']) 9994 RBnames.append(RBObj['RBname']+RBObj['numChain']) 9987 9995 rbName = RBnames[0] 9988 9996 rbObj = data['RBModels']['Residue'][0] … … 10047 10055 atoms that should be matched. 10048 10056 ''' 10057 UsedIds = [] 10058 for i in data['RBModels']: 10059 for j in data['RBModels'][i]: 10060 UsedIds += j['Ids'] 10049 10061 rbType = data['testRBObj']['rbType'] 10050 10062 rbObj = data['testRBObj']['rbObj'] … … 10058 10070 10059 10071 newXYZ = G2mth.UpdateRBXYZ(Bmat,rbObj,RBData,rbType)[0] 10060 atmTypes = [atomData[i][ct] for i in range(len(atomData))] 10072 # categorize atoms by type, omitting any that are already assigned 10073 # in a rigid body 10074 atmTypes = [None if atomData[i][-1] in UsedIds 10075 else atomData[i][ct] 10076 for i in range(len(atomData))] 10061 10077 # remove assigned atoms from search groups 10062 10078 for i in selDict: 10079 if selDict[i] is None: continue 10063 10080 atmTypes[selDict[i]] = None 10064 10081 atmXYZ = G2mth.getAtomXYZ(atomData,cx) … … 10080 10097 else: 10081 10098 lbl = '' 10082 if i in selDict: 10099 if i in selDict and selDict[i] is None: 10100 matchTable.append([t , lbl] + list(xyz)) 10101 continue 10102 elif i in selDict: 10083 10103 searchXYZ = [atmXYZ[selDict[i]]] #assigned 10084 10104 numLookup = [selDict[i]] … … 10086 10106 if t not in oXYZbyT: 10087 10107 unmatched.append(i) 10108 matchTable.append([t , lbl] + list(xyz)) 10088 10109 continue 10089 10110 searchXYZ = oXYZbyT[t] 10090 10111 numLookup = atmNumByT[t] 10091 10112 dist = G2mth.GetXYZDist(xyz,searchXYZ,Amat) 10092 repeat = True 10093 while repeat: 10094 repeat = False 10113 while True: 10095 10114 pidIndx = np.argmin(dist) 10096 10115 d = dist[pidIndx] 10097 10116 pid = numLookup[pidIndx] 10098 10117 if atomData[pid][-1] in Ids: #duplicate - 2 atoms on same site; invalidate & look again 10099 repeat = True10100 10118 dist[pidIndx] = 100. 10101 10119 if min(dist) == 100: 10102 unmatched.append(i) 10103 repeat = False 10104 continue 10105 Ids.append(atomData[pid][-1]) 10106 matchTable.append([t , lbl] + list(xyz) + [pid, atomData[pid][0]] 10120 pid = None 10121 break 10122 else: 10123 break 10124 if pid is not None: 10125 Ids.append(atomData[pid][-1]) 10126 matchTable.append([t , lbl] + list(xyz) + [pid, atomData[pid][0]] 10107 10127 + atomData[pid][cx:cx+3] + [d, Ids[-1]]) 10108 if unmatched: 10109 if unmatchedRBatoms is not None: 10110 unmatchedRBatoms[:] = unmatched 10111 return [] 10128 else: 10129 unmatched.append(i) 10130 matchTable.append([t , lbl] + list(xyz)) 10131 if unmatched and unmatchedRBatoms is not None: 10132 unmatchedRBatoms[:] = unmatched 10112 10133 return matchTable 10113 10134 10114 10135 def Draw(): 10115 10136 '''Create the window for assigning RB to atoms''' 10116 def On Ok(event):10137 def OnAddRB(event): 10117 10138 'respond to OK button, set info into phase' 10139 cx,ct,cs,cia = data['General']['AtomPtrs'] 10118 10140 matchTable = UpdateTable() 10119 10141 dmax = 0. 10120 Ids = []10121 10142 for line in matchTable: 10122 xyz = line[2:5] 10123 pid = line[5] 10124 dmax = max(dmax,line[10]) 10125 atomData[pid][cx:cx+3] = xyz 10126 Ids.append(line[11]) 10143 if len(line) >= 11: 10144 dmax = max(dmax,line[10]) 10127 10145 if dmax > 1.0: 10128 10146 msg = "Atoms may not be properly located. Are you sure you want to do this?" … … 10132 10150 return 10133 10151 dlg.Destroy() 10152 Ids = [] 10153 for line in matchTable: 10154 if len(line) < 11: 10155 elem = line[0] 10156 nextNum = len(data['Atoms']) 10157 lbl = 'Rb' + elem + str(nextNum) 10158 x,y,z = line[2:5] 10159 AtomAdd(x,y,z,El=elem,Name=lbl) 10160 Ids.append(atomData[nextNum][-1]) 10161 else: 10162 atomData[line[5]][cx:cx+3] = line[2:5] 10163 Ids.append(line[11]) 10134 10164 10135 10165 rbType = data['testRBObj']['rbType'] … … 10179 10209 # add new atoms and reassign 10180 10210 added = False 10211 selDict = getSelectedAtoms() 10181 10212 for i,l in enumerate(RigidBodies.atomsTable.data): 10182 10213 if l[4] == 'Create new': 10183 elem = l[0] 10184 added = True 10185 lbl = 'Rb' + RigidBodies.atomsGrid.GetRowLabelValue(i) 10186 AtomAdd(0.,0.,0.,El=elem,Name=lbl) 10187 l[4] = lbl 10188 rbAssignments[i] = lbl 10189 selDict = getSelectedAtoms() 10214 rbAssignments[i] = None 10215 selDict[i] = None 10190 10216 matchTable = assignAtoms(selDict) 10191 10217 for i,l in enumerate(matchTable): 10218 if len(l) < 11: continue 10192 10219 RigidBodies.atomsTable.data[i][1:4] = l[5],l[6],l[10] 10193 10220 RigidBodies.atomsGrid.ForceRefresh() … … 10210 10237 for r in range(tbl.GetRowsCount()): 10211 10238 sel = tbl.GetValue(r,4).strip() 10212 if r in rbAssignments: continue # ignore positions of new atoms10239 if sel == 'Create new': continue # ignore positions of new atoms 10213 10240 if sel not in labelsChoices: continue 10214 10241 atmNum = labelsChoices.index(sel)-1 … … 10239 10266 deltaList = [] 10240 10267 for i in selDict: 10268 if selDict[i] is None: continue 10241 10269 deltaList.append(phaseXYZ[selDict[i]]-rbXYZ[i]) 10242 10270 return np.array(deltaList) … … 10288 10316 item.SetLabel('%10.4f'%(data['testRBObj']['rbObj']['Orient'][0][i])) 10289 10317 UpdateTablePlot() 10290 # debug code10291 #selDict = getSelectedAtoms()10292 #for line in assignAtoms(selDict): print(line)10293 10318 10294 10319 def onFitBoth(event): … … 10318 10343 unmatchedRBatoms = [] 10319 10344 matchTable = assignAtoms(unmatchedRBatoms=unmatchedRBatoms) 10320 if not matchTable: 10321 dlg = wx.MessageDialog(G2frame, 10322 'There are {} atoms that need to be added to atoms list. Do you want to add them?'.format(len(unmatchedRBatoms)),'Add atoms?', 10323 wx.YES_NO | wx.ICON_QUESTION) 10324 try: 10325 result = dlg.ShowModal() 10326 if result == wx.ID_YES: 10327 rbType = data['testRBObj']['rbType'] 10328 rbObj = data['testRBObj']['rbObj'] 10329 rbId = rbObj['RBId'] 10330 for i in unmatchedRBatoms: 10331 elem = RBData[rbType][rbId]['rbTypes'][i] 10332 lbl = 'Rb' + RBData[rbType][rbId]['atNames'][i] 10333 AtomAdd(0.,0.,0.,El=elem,Name=lbl) 10334 rbAssignments[i] = lbl 10335 wx.CallAfter(Draw) 10336 finally: 10337 dlg.Destroy() 10345 if unmatchedRBatoms: 10346 msg = 'There are {} atoms that will need to be added to atoms list.'.format(len(unmatchedRBatoms)) 10347 G2G.G2MessageBox(G2frame,msg,title='Please note') 10348 for i in unmatchedRBatoms: 10349 rbAssignments[i] = None 10350 10338 10351 mainSizer = wx.BoxSizer(wx.VERTICAL) 10339 10352 mainSizer.Add((5,5),0) … … 10349 10362 refName.append(data['testRBObj']['rbAtTypes'][ref]+str(ref)) 10350 10363 atNames = data['testRBObj']['atNames'] 10351 mainSizer.Add(wx.StaticText(RigidBodies,wx.ID_ANY, 'Locate rigid body : '+rbName),10352 0,WACV)10364 mainSizer.Add(wx.StaticText(RigidBodies,wx.ID_ANY, 10365 'Locating rigid body : '+rbName), 0, WACV) 10353 10366 mainSizer.Add((5,5),0) 10354 10367 OriSizer = wx.BoxSizer(wx.HORIZONTAL) … … 10410 10423 else: 10411 10424 mainSizer.Add(wx.StaticText(RigidBodies,wx.ID_ANY,'No side chain torsions'),0,WACV) 10412 if not matchTable: 10425 if not matchTable: # not sure if this will ever be true 10413 10426 OkBtn = None 10414 10427 mainSizer.Add((15,15)) … … 10418 10431 else: 10419 10432 OkBtn = wx.Button(RigidBodies,wx.ID_ANY,"Add") 10420 OkBtn.Bind(wx.EVT_BUTTON, On Ok)10433 OkBtn.Bind(wx.EVT_BUTTON, OnAddRB) 10421 10434 CancelBtn = wx.Button(RigidBodies,wx.ID_ANY,'Cancel') 10422 10435 CancelBtn.Bind(wx.EVT_BUTTON, OnCancel) … … 10429 10442 10430 10443 SetPhaseWindow(RigidBodies,mainSizer) 10431 10432 if not matchTable: 10433 mainSizer.Layout() 10434 RigidBodies.SetScrollRate(10,10) 10435 RigidBodies.SendSizeEvent() 10436 RigidBodies.Scroll(0,0) 10437 return 10444 10438 10445 G2plt.PlotStructure(G2frame,data,True,UpdateTable) 10439 10446 colLabels = ['RB\ntype','phase\n#','phase\nlabel','delta, A','Assign as atom'] … … 10442 10449 for i,l in enumerate(matchTable): 10443 10450 lbl = '' 10444 if i in rbAssignments: lbl = rbAssignments[i] 10445 displayTable.append([l[0],l[5],l[6],l[10],lbl]) 10451 if i in rbAssignments: 10452 if rbAssignments[i] is None: 10453 displayTable.append([l[0],-1,'?',-1,'Create new']) 10454 else: 10455 lbl = rbAssignments[i] 10456 displayTable.append([l[0],l[5],l[6],l[10],lbl]) # TODO: think about this 10457 else: 10458 displayTable.append([l[0],l[5],l[6],l[10],lbl]) 10446 10459 Types = [wg.GRID_VALUE_STRING, wg.GRID_VALUE_NUMBER, 10447 10460 wg.GRID_VALUE_STRING, wg.GRID_VALUE_FLOAT+':8,3', … … 10486 10499 10487 10500 btn = wx.Button(RigidBodies, wx.ID_ANY, 'Set Origin') 10488 10489 10501 btn.Bind(wx.EVT_BUTTON,onSetOrigin) 10490 10502 btnSizer.Add(btn,0,wx.ALIGN_CENTER) 10491 10503 btnSizer.Add((-1,5)) 10492 10504 btn = wx.Button(RigidBodies, wx.ID_ANY, 'Set Orientation') 10493 10494 10505 btn.Bind(wx.EVT_BUTTON,onFitOrientation) 10495 10506 btnSizer.Add(btn,0,wx.ALIGN_CENTER)
Note: See TracChangeset
for help on using the changeset viewer.