Changeset 2476 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Sep 22, 2016 11:42:28 AM (6 years ago)
Author:
vondreele
Message:

Add new feature to structure plots - display an hkl plane or stack of planes with a phase offset.
fix lighting issues for planes/polygons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r2475 r2476  
    47494749def PlotStructure(G2frame,data,firstCall=False):
    47504750    '''Crystal structure plotting package. Can show structures as balls, sticks, lines,
    4751     thermal motion ellipsoids and polyhedra
     4751    thermal motion ellipsoids and polyhedra. Magnetic moments shown as black/red
     4752    arrows according to spin state
    47524753    '''
    47534754
     
    52115212        glEnable(GL_LIGHT0)
    52125213        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0)
    5213         glLightfv(GL_LIGHT0,GL_AMBIENT,[.5,.5,.5,1])
     5214        glLightfv(GL_LIGHT0,GL_AMBIENT,[.8,.8,.8,1])
    52145215        glLightfv(GL_LIGHT0,GL_DIFFUSE,[.8,.8,.8,1])
    5215         glLightfv(GL_LIGHT0,GL_SPECULAR,[1,1,1,1])
     5216#        glLightfv(GL_LIGHT0,GL_SPECULAR,[1,1,1,1])
     5217#        glLightfv(GL_LIGHT0,GL_POSITION,[0,0,1,1])
    52165218       
    52175219    def GetRoll(newxy,rhoshape):
     
    54045406        glColor4ubv([0,0,0,0])
    54055407        glDisable(GL_COLOR_MATERIAL)
     5408       
     5409    def RenderPlane(plane,color):
     5410        fade = list(color) + [.25,]
     5411        glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,fade)
     5412        glShadeModel(GL_FLAT)
     5413        glEnable(GL_BLEND)
     5414        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
     5415        glPushMatrix()
     5416        glShadeModel(GL_SMOOTH)
     5417        glPolygonMode(GL_FRONT_AND_BACK,GL_FILL)
     5418        glFrontFace(GL_CW)
     5419        glBegin(GL_TRIANGLE_FAN)
     5420        for vertex in plane:
     5421            glVertex3fv(vertex)
     5422        glEnd()
     5423        glPopMatrix()
     5424        glDisable(GL_BLEND)
     5425        glShadeModel(GL_SMOOTH)
    54065426               
    54075427    def RenderSphere(x,y,z,radius,color):
     
    55185538        glPushMatrix()
    55195539        glTranslate(x,y,z)
    5520         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color)
     5540        glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,color)
    55215541        glShadeModel(GL_SMOOTH)
    55225542        glMultMatrixf(B4mat.T)
     
    55995619#useful debug?       
    56005620#        if caller:
    5601 #            print caller
     5621#            print caller,generalData['Name']
    56025622# end of useful debug
    56035623        mapData = generalData['Map']
     
    56665686        glMultMatrixf(A4mat.T)
    56675687        glTranslate(-Tx,-Ty,-Tz)
    5668         if drawingData['unitCellBox']:
    5669             RenderBox()
    56705688        if drawingData['showABC']:
    56715689            x,y,z = drawingData['viewPoint'][0]
     
    58205838                Backbone = Backbones[chain]
    58215839                RenderBackbone(Backbone,BackboneColor,bondR)
     5840        if drawingData['unitCellBox']:
     5841            RenderBox()
     5842            if drawingData['Plane'][1]:
     5843                H,phase,stack,phase,color = drawingData['Plane']
     5844                Planes = G2lat.PlaneIntercepts(Amat,Bmat,H,phase,stack)
     5845                for plane in Planes:
     5846                    RenderPlane(plane,color)
    58225847#        print time.time()-time0
    58235848        try:
Note: See TracChangeset for help on using the changeset viewer.