Changeset 520 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Mar 14, 2012 3:17:17 PM (10 years ago)
Author:
vondreele
Message:

separate getHKLmax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r515 r520  
    1212import os.path
    1313import numpy as np
     14import numpy.ma as ma
    1415import numpy.linalg as nl
    1516import wx
     
    435436                if G2frame.PickId:
    436437                    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):
    438440                        if len(HKL):
    439441                            view = Page.toolbar._views.forward()[0][:2]
     
    499501            else:                                                   #picked a limit line
    500502                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):
    502505            G2frame.itemPicked = pick
    503506            pick = str(pick)
     
    540543                G2frame.PatternTree.SetItemPyData(PeakId,data)
    541544                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:
    543547            Phases = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists'))
    544548            pick = str(G2frame.itemPicked).split('(')[1].strip(')')
     
    738742                else:
    739743                    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):
    741746            Phases = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists'))
    742747            for pId,phase in enumerate(Phases):
     
    22712276    drawingData = data['Drawing']
    22722277    drawAtoms = drawingData['Atoms']
     2278    mapData = {}
     2279    rhoXYZ = []
     2280    if 'Map' in generalData:
     2281        mapData = generalData['Map']
     2282        contLevel = drawingData['contourLevel']*mapData['rhoMax']
     2283        if 'delt-F' 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
    22732290    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])
    22782295    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]])
    22792296    uEdges = np.array([
     
    26072624        glPopMatrix()
    26082625       
     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       
    26092635    def RenderEllipsoid(x,y,z,ellipseProb,E,R4,color):
    26102636        s1,s2,s3 = E
     
    26912717        glEnable(GL_LIGHTING)
    26922718        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)
    26932731                           
    26942732    def Draw():
     
    27392777        BackboneColor = []
    27402778        time0 = time.time()
     2779#        glEnable(GL_BLEND)
     2780#        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
    27412781        for iat,atom in enumerate(drawingData['Atoms']):
    27422782            x,y,z = atom[cx:cx+3]
     
    27512791            if iat in Ind:
    27522792                color = np.array(Gr)/255.
     2793#            color += [.25,]
    27532794            radius = 0.5
    27542795            if atom[cs] != '':
    2755                 glLoadName(atom[-3])                   
     2796                try:
     2797                    glLoadName(atom[-3])
     2798                except: #problem with old files - missing code
     2799                    pass                   
    27562800            if 'balls' in atom[cs]:
    27572801                vdwScale = drawingData['vdwScale']
     
    28202864            elif atom[cs+1] == 'chain' and atom[ct-1] == 'CA':
    28212865                RenderLabel(x,y,z,atom[ct-2],radius)
     2866#        glDisable(GL_BLEND)
     2867        if len(rhoXYZ):
     2868            RenderMap(rhoXYZ,indx,rho,drawingData['contourLevel'])
    28222869        if Backbone:
    28232870            RenderBackbone(Backbone,BackboneColor,bondR)
Note: See TracChangeset for help on using the changeset viewer.