Changeset 987 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Jul 11, 2013 3:12:11 AM (10 years ago)
Author:
vondreele
Message:

GLUT eliminated! Now use gltext for all atom labelling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r986 r987  
    4040from  OpenGL.GL import *
    4141from OpenGL.GLU import *
    42 from OpenGL.GLUT import *
    4342from OpenGL.GLE import *
    4443import gltext
     
    26862685    Rd = np.array([255,0,0])
    26872686    Gr = np.array([0,255,0])
     2687    wxGreen = wx.Color(0,255,0)
    26882688    Bl = np.array([0,0,255])
    26892689    Or = np.array([255,128,0])
     2690    wxOrange = wx.Color(255,128,0)
    26902691    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]])
    26912692    uEdges = np.array([
     
    32923293        glDisable(GL_COLOR_MATERIAL)
    32933294       
    3294     def RenderLabel(x,y,z,label,r,color):       
     3295    def RenderLabel(x,y,z,label,r,color,matRot):
     3296        '''
     3297        color wx.Color object
     3298        '''       
    32953299        glPushMatrix()
    32963300        glTranslate(x,y,z)
    32973301        glMultMatrixf(B4mat.T)
    32983302        glDisable(GL_LIGHTING)
    3299         glColor3fv(color)
    33003303        glRasterPos3f(0,0,0)
    3301         if bool(glutBitmapCharacter):       #seems to only exist in 32 bit Windows
    3302             for c in list(label):
    3303                 glutBitmapCharacter(GLUT_BITMAP_8_BY_13,ord(c))
    3304         else:
    3305             text = gltext.TextElement(text=label,font=Font)
    3306             text.draw_text(scale=0.025)
    3307 #           our_font.glPrint(0,0,label)
     3304        glMultMatrixf(matRot)
     3305        glRotate(180,1,0,0)             #fix to flip about x-axis
     3306        text = gltext.Text(text=label,font=Font,foreground=color)
     3307        text.draw_text(scale=0.025)
    33083308        glEnable(GL_LIGHTING)
    33093309        glPopMatrix()
     
    34843484                   
    34853485            if atom[cs+1] == 'type':
    3486                 RenderLabel(x,y,z,'  '+atom[ct],radius,Gr)
     3486                RenderLabel(x,y,z,'  '+atom[ct],radius,wxGreen,matRot)
    34873487            elif atom[cs+1] == 'name':
    3488                 RenderLabel(x,y,z,'  '+atom[ct-1],radius,Gr)
     3488                RenderLabel(x,y,z,'  '+atom[ct-1],radius,wxGreen,matRot)
    34893489            elif atom[cs+1] == 'number':
    3490                 RenderLabel(x,y,z,'  '+str(iat),radius,Gr)
     3490                RenderLabel(x,y,z,'  '+str(iat),radius,wxGreen,matRot)
    34913491            elif atom[cs+1] == 'residue' and atom[ct-1] == 'CA':
    3492                 RenderLabel(x,y,z,'  '+atom[ct-4],radius,Gr)
     3492                RenderLabel(x,y,z,'  '+atom[ct-4],radius,wxGreen,matRot)
    34933493            elif atom[cs+1] == '1-letter' and atom[ct-1] == 'CA':
    3494                 RenderLabel(x,y,z,'  '+atom[ct-3],radius,Gr)
     3494                RenderLabel(x,y,z,'  '+atom[ct-3],radius,wxGreen,matRot)
    34953495            elif atom[cs+1] == 'chain' and atom[ct-1] == 'CA':
    3496                 RenderLabel(x,y,z,'  '+atom[ct-2],radius,Gr)
     3496                RenderLabel(x,y,z,'  '+atom[ct-2],radius,wxGreen,matRot)
    34973497#        glDisable(GL_BLEND)
    34983498        if len(rhoXYZ):
     
    35173517                RenderSphere(x,y,z,0.2,color/255.)
    35183518                RenderBonds(x,y,z,rbBonds[ind],0.03,Gr)
    3519                 RenderLabel(x,y,z,name,0.2,Or)
     3519                RenderLabel(x,y,z,name,0.2,wxOrange,matRot)
    35203520        if len(mcsaModels) > 1 and pageName == 'MC/SA':             #skip the default MD entry
    35213521            for ind,[x,y,z] in enumerate(mcsaXYZ):
     
    35253525                RenderSphere(x,y,z,0.2,color/255.)
    35263526                RenderBonds(x,y,z,mcsaBonds[ind],0.03,Gr)
    3527                 RenderLabel(x,y,z,name,0.2,Or)
     3527                RenderLabel(x,y,z,name,0.2,wxOrange,matRot)
    35283528        if Backbones:
    35293529            for chain in Backbones:
     
    37783778        glPopMatrix()
    37793779               
    3780     def RenderLabel(x,y,z,label):       
     3780    def RenderLabel(x,y,z,label,matRot):       
    37813781        glPushMatrix()
    37823782        glTranslate(x,y,z)
    37833783        glDisable(GL_LIGHTING)
    3784         glColor3f(1.0,1.0,1.0)
    37853784        glRasterPos3f(0,0,0)
    3786         if bool(glutBitmapCharacter):
    3787             for c in list(label):
    3788                 glutBitmapCharacter(GLUT_BITMAP_8_BY_13,ord(c))
    3789         else:
    3790             text = gltext.TextElement(text=label,font=Font)
    3791             text.draw_text(scale=0.025)
     3785        glMultMatrixf(matRot)
     3786        glRotate(180,1,0,0)             #fix to flip about x-axis
     3787        text = gltext.TextElement(text=label,font=Font,foreground=wx.WHITE)
     3788        text.draw_text(scale=0.025)
    37923789        glEnable(GL_LIGHTING)
    37933790        glPopMatrix()
     
    38273824            RenderSphere(x,y,z,radius,color)
    38283825            RenderBonds(x,y,z,Bonds[iat],0.05,color)
    3829             RenderLabel(x,y,z,'  '+atNames[iat])
     3826            RenderLabel(x,y,z,'  '+atNames[iat],matRot)
    38303827        Page.canvas.SwapBuffers()
    38313828
Note: See TracChangeset for help on using the changeset viewer.