Changeset 520 for trunk/GSASIIplot.py
 Timestamp:
 Mar 14, 2012 3:17:17 PM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIplot.py
r515 r520 12 12 import os.path 13 13 import numpy as np 14 import numpy.ma as ma 14 15 import numpy.linalg as nl 15 16 import wx … … 435 436 if G2frame.PickId: 436 437 found = [] 437 if G2frame.PatternTree.GetItemText(G2frame.PickId) in ['Index Peak List','Unit Cells List','Reflection Lists']: 438 if G2frame.PatternTree.GetItemText(G2frame.PickId) in ['Index Peak List','Unit Cells List','Reflection Lists'] or \ 439 'PWDR' in G2frame.PatternTree.GetItemText(PickId): 438 440 if len(HKL): 439 441 view = Page.toolbar._views.forward()[0][:2] … … 499 501 else: #picked a limit line 500 502 G2frame.itemPicked = pick 501 elif G2frame.PatternTree.GetItemText(PickId) == 'Reflection Lists': 503 elif G2frame.PatternTree.GetItemText(PickId) == 'Reflection Lists' or \ 504 'PWDR' in G2frame.PatternTree.GetItemText(PickId): 502 505 G2frame.itemPicked = pick 503 506 pick = str(pick) … … 540 543 G2frame.PatternTree.SetItemPyData(PeakId,data) 541 544 G2pdG.UpdatePeakGrid(G2frame,data) 542 elif G2frame.PatternTree.GetItemText(PickId) == 'Reflection Lists' and xpos: 545 elif (G2frame.PatternTree.GetItemText(PickId) == 'Reflection Lists' or \ 546 'PWDR' in G2frame.PatternTree.GetItemText(PickId)) and xpos: 543 547 Phases = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists')) 544 548 pick = str(G2frame.itemPicked).split('(')[1].strip(')') … … 738 742 else: 739 743 Plot.axvline(hkl[5],color='r',dashes=(5,5)) 740 elif G2frame.PatternTree.GetItemText(PickId) in ['Reflection Lists']: 744 elif G2frame.PatternTree.GetItemText(PickId) in ['Reflection Lists'] or \ 745 'PWDR' in G2frame.PatternTree.GetItemText(PickId): 741 746 Phases = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists')) 742 747 for pId,phase in enumerate(Phases): … … 2271 2276 drawingData = data['Drawing'] 2272 2277 drawAtoms = drawingData['Atoms'] 2278 mapData = {} 2279 rhoXYZ = [] 2280 if 'Map' in generalData: 2281 mapData = generalData['Map'] 2282 contLevel = drawingData['contourLevel']*mapData['rhoMax'] 2283 if 'deltF' in mapData['MapType']: 2284 rho = ma.array(mapData['rho'],mask=(np.abs(mapData['rho'])<contLevel)) 2285 else: 2286 rho = ma.array(mapData['rho'],mask=(mapData['rho']<contLevel)) 2287 indx = np.array(ma.nonzero(rho)).T 2288 steps = 1./np.array(rho.shape) 2289 rhoXYZ = indx*steps 2273 2290 cx,ct,cs = drawingData['atomPtrs'] 2274 Wt = [255,255,255]2275 Rd = [255,0,0]2276 Gr = [0,255,0]2277 Bl = [0,0,255]2291 Wt = np.array([255,255,255]) 2292 Rd = np.array([255,0,0]) 2293 Gr = np.array([0,255,0]) 2294 Bl = np.array([0,0,255]) 2278 2295 uBox = np.array([[0,0,0],[1,0,0],[1,1,0],[0,1,0],[0,0,1],[1,0,1],[1,1,1],[0,1,1]]) 2279 2296 uEdges = np.array([ … … 2607 2624 glPopMatrix() 2608 2625 2626 def RenderSmallSphere(x,y,z,radius,color): 2627 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color) 2628 glPushMatrix() 2629 glTranslate(x,y,z) 2630 glMultMatrixf(B4mat.T) 2631 q = gluNewQuadric() 2632 gluSphere(q,radius,4,2) 2633 glPopMatrix() 2634 2609 2635 def RenderEllipsoid(x,y,z,ellipseProb,E,R4,color): 2610 2636 s1,s2,s3 = E … … 2691 2717 glEnable(GL_LIGHTING) 2692 2718 glPopMatrix() 2719 2720 def RenderMap(rhoXYZ,indx,rho,cLevel): 2721 for i,xyz in enumerate(rhoXYZ): 2722 x,y,z = xyz 2723 I,J,K = indx[i] 2724 alpha = 1.0 2725 if cLevel < 1.: 2726 alpha = (abs(rho[I,J,K])/mapData['rhoMax']cLevel)/(1.cLevel) 2727 if rho[I,J,K] < 0.: 2728 RenderSmallSphere(x,y,z,0.1*alpha,Rd) 2729 else: 2730 RenderSmallSphere(x,y,z,0.1*alpha,Bl) 2693 2731 2694 2732 def Draw(): … … 2739 2777 BackboneColor = [] 2740 2778 time0 = time.time() 2779 # glEnable(GL_BLEND) 2780 # glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) 2741 2781 for iat,atom in enumerate(drawingData['Atoms']): 2742 2782 x,y,z = atom[cx:cx+3] … … 2751 2791 if iat in Ind: 2752 2792 color = np.array(Gr)/255. 2793 # color += [.25,] 2753 2794 radius = 0.5 2754 2795 if atom[cs] != '': 2755 glLoadName(atom[3]) 2796 try: 2797 glLoadName(atom[3]) 2798 except: #problem with old files  missing code 2799 pass 2756 2800 if 'balls' in atom[cs]: 2757 2801 vdwScale = drawingData['vdwScale'] … … 2820 2864 elif atom[cs+1] == 'chain' and atom[ct1] == 'CA': 2821 2865 RenderLabel(x,y,z,atom[ct2],radius) 2866 # glDisable(GL_BLEND) 2867 if len(rhoXYZ): 2868 RenderMap(rhoXYZ,indx,rho,drawingData['contourLevel']) 2822 2869 if Backbone: 2823 2870 RenderBackbone(Backbone,BackboneColor,bondR)
Note: See TracChangeset
for help on using the changeset viewer.