当前位置: 首页>>代码示例>>Python>>正文


Python DejaVu类代码示例

本文整理汇总了Python中DejaVu的典型用法代码示例。如果您正苦于以下问题:Python DejaVu类的具体用法?Python DejaVu怎么用?Python DejaVu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DejaVu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setSpecular

 def setSpecular(self, rgb):
     if __debug__:
      if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
     #self.material[self.spec][0][:3] = list(rgb[:3])
     self.material[self.spec][0][:3] = array(rgb[:3],'f',copy=1)
     self.tkRedraw(self)
     self.broadcast()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:7,代码来源:MaterialEditor.py

示例2: removeDuplicatedVertices

    def removeDuplicatedVertices(self):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
        """find duplicated vertices and remove them, re-index face list"""
        # hash vertices
        d = {}
        for vert in self.vertexSet.vertices.array:
            d['%f,%f,%f'%tuple(vert)] = []

        # build list of unique vertices and lookup table
        lookup = {}
        nv = []
        nn = []
        i = 0
        for k in d.keys():
            nv.append(eval(k))
            lookup[k] = i
            i = i + 1

        # new facelist
        v = self.vertexSet.vertices.array
        nflist = []
        for face in self.faceSet.faces.array:
            nf = []
            for vind in face:
                nf.append(lookup['%f,%f,%f'%tuple(v[vind])])
            nflist.append(nf)

        return nv, nflist
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:29,代码来源:IndexedGeom.py

示例3: updateCurrent

 def updateCurrent(self, color):
     if __debug__:
      if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
     self.chip1.configure( bg = TkColor( Numeric.array(color, 'f')*255 ) )
     self.currentColor[:3] = list(color[:3])
     for f in self.callbacks:
         f(self.currentColor)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:7,代码来源:MaterialEditor.py

示例4: Add

    def Add(self, check=1, redo=1, **kw):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
	"""Add spheres"""

        if __debug__:
            if check:
                apply( checkKeywords, (self.name,self.keywords), kw)

	v = kw.get( 'centers')
	if v:
	    kw['vertices'] = v     # rename centers in vertices for Geom.__init
        apply( Geom.Add, (self,0,0), kw)

	rad = kw.get( 'radii')
	if rad:
	    if type(rad).__name__ == 'float':
		self.oneRadius = viewerConst.YES
		self.radius = rad
	    else:
		self.vertexSet.radii.AddValues( rad )

	if rad or v:
            self.redoDspLst=1
	    self.vertexSet.radii.PropertyStatus(len(self.vertexSet))
	    if self.vertexSet.radii.status < viewerConst.COMPUTED:
		self.oneRadius = viewerConst.YES
	    else:
		self.oneRadius = viewerConst.NO

        if self.viewer and redo:
            if self.redoDspLst and self not in self.viewer.objectsNeedingRedo:
                self.viewer.objectsNeedingRedo[self] = None
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:33,代码来源:Spheres.py

示例5: _MoveCursor

    def _MoveCursor(self, x, y):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
	# find the saturation based on distance
	s = math.sqrt(x*x + y*y) / self.radius
	if s > 1.0:
	    x = x / s
	    y = y / s
	    s = 1.0

	# now find the hue based on the angle 
	if x or y:
	    angle = math.atan2(y, x)
	    if angle < 0.0:
                angle = angle + (2.*math.pi)
	    h = 1. - angle / (2.0 * math.pi)
	else:
	    h = 0

	# check if redraw and callback are needed
	if self.hsvColor[0] != h or self.hsvColor[1] != s:
	    self.hsvColor[0] = h
	    self.hsvColor[1] = s
            cx = self.cx+x
            cy = self.cy+y
            self.cwcanvas.coords( self.cursor, cx-3, cy-3, cx-3, cy+3,
                                  cx+3,cy+3, cx+3, cy-3, cx-3, cy-3 )

	    if self.immediate and self.callback:
                self.callback(self.Get('RGB'))
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:30,代码来源:MaterialEditor.py

示例6: loadPaletteMaterial

 def loadPaletteMaterial(self, event=None):
     if __debug__:
      if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
     if self.currentPalette is not None:
         num = int(self.paletteNumBt.get())
         mat = Materials(self.currentPalette, num)
         self.defineMaterial(mat.prop)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:7,代码来源:MaterialEditor.py

示例7: Reset

    def Reset(self):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
	"""Reset members to default values"""

	self.factor = 1
	self.pattern = 0x7878
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:7,代码来源:Displayable.py

示例8: setMatrixComponents

    def setMatrixComponents(self, rot=None, trans=None, scale=None,
                            redo=1):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
        """Define MatrixRot, MatrixTransl, MatrixScale and MatrixRotInv
from a rotation, translation and scale.
rot should be a 4x4 matrix defining a 3D 3x3 rotation 
trans should be a 3D translation vector
scale should be 3-vector of positive number larger than 0.0
"""
        self._modified = True
        if rot is not None:
            assert rot.shape==(4,4)
            self.MatrixRot = rot.ravel()
            RotInv = Numeric.transpose(rot)
            self.MatrixRotInv = Numeric.reshape(RotInv, (16,))

        if trans is not None:
            assert len(trans)==3
            self.MatrixTransl = trans

        if scale is not None:
            assert len(scale)==3 and scale[0]>0. and scale[1]>0. and scale[2]>0.
            self.MatrixScale = scale

        if redo:
            self.RedoDisplayList()
            self.viewer.Redraw()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:28,代码来源:Transformable.py

示例9: sortPoly

    def sortPoly(self, order=-1):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
        """None <- sortPoly(order=-1)
Sorts the geometry polygons according to z values of polygon's
geomtric centers. Order=-1 sorts by furthest z first, order=1 sorts
by closest z first"""
        # FIXME will not work with instance matrices
        mat = self.GetMatrix()
        mat = Numeric.reshape(mat, (4,4))
        vt = self.vertexSet.vertices*mat
        if vt is None:
            return
        triv = Numeric.take(vt, self.faceSet.faces.array)
        trig = Numeric.sum(triv,1)/3.
        trigz = trig[:,2]  #triangle's center of gravity z value
        
        ind = Numeric.argsort(trigz) # sorted indices
        
        if len(self.faceSet.faces.array):
            faces = Numeric.take(self.faceSet.faces.array, ind[::order])
        
            if self.shading==GL.GL_FLAT: # we also need to re-arrange the
                                       # face normals
                if self.normals is None:
                    normals = None
                else:
                    if len(self.normals)>1:
                        normals = Numeric.take(self.normals, ind[::order])
                    else:
                        normals = self.normals
            else:
                normals = None

            self.Set(faces=faces, fnormals=normals)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:35,代码来源:IndexedPolygons.py

示例10: ConcatRotation

    def ConcatRotation(self, matrix, redo=1):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
	"""Apply the rotation matrix to the object [matrix.shape==(16,)]"""
	
	if self.redirectXform: obj = self.redirectXform
	else: obj = self
        obj._modified = True
	GL.glPushMatrix()
	GL.glLoadIdentity()
	GL.glMultMatrixf(obj.Ri)#.astype('f'))
	GL.glMultMatrixf(matrix)
	GL.glMultMatrixf(obj.R)#.astype('f'))
	GL.glMultMatrixf(obj.rotation)

	m = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
        obj.rotation = glCleanRotMat(m).astype('f')
	obj.rotation.shape = (16, )
	GL.glPopMatrix()
        for o in self.copyXform: o.ConcatRotation(matrix)

        ## This code made rotation very slow because it would rebuild the
        ## master dpyList in cases where it was not needed
##         if redo and not self.immediateRendering:
##             vi = self.viewer
##             print 'faga'
##             vi.deleteOpenglList()
           
        vi = self.viewer
        if vi.activeClippingPlanes > 0 or vi.activeScissor > 0 or \
          (vi.currentObject!=vi.rootObject and not \
           vi.redirectTransformToRoot) and redo and \
           not self.immediateRendering:
            vi.deleteOpenglList()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:34,代码来源:Transformable.py

示例11: GetMatrix

    def GetMatrix(self, root=None, instance=None, scale=True, transpose=True):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
	"""Returns the matrix by which this object is transformed
scale = False: returns the rotation and translation. no scaling info included
               Used to save the transformed geom --> coords --> new pdb file
instance is a list of integer instance indices for all parents
"""
        if root is None:
            root = self.viewer.rootObject

        if instance is None:
            instance = [0]
            p = self.parent
            while p:
                instance.append(0)
                p = p.parent

        GL.glPushMatrix()
        GL.glLoadIdentity()
        #print 'GetMatrix', instance
        self.BuildMat(self, root, scale, instance)
        #GL.glMultMatrixf(self.instanceMatricesFortran[instanceList[0]]])
        m = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
        GL.glPopMatrix()
        if Numeric.alltrue(m==Numeric.zeros(16).astype('f')):
            # this happens when Pmv has no GUI
            m = Numeric.identity(4)
        if transpose:
            return Numeric.transpose(Numeric.reshape(m, (4,4)))
        else:
            return Numeric.reshape(m, (4,4))
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:32,代码来源:Transformable.py

示例12: multMat4pt

 def multMat4pt(self, mat, pt):
     if __debug__:
      if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
     ptx = mat[0][0]*pt[0]+mat[0][1]*pt[1]+mat[0][2]*pt[2]+mat[0][3]
     pty = mat[1][0]*pt[0]+mat[1][1]*pt[1]+mat[1][2]*pt[2]+mat[1][3]
     ptz = mat[2][0]*pt[0]+mat[2][1]*pt[1]+mat[2][2]*pt[2]+mat[2][3]
     return (ptx, pty, ptz)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:7,代码来源:Transformable.py

示例13: __init__

    def __init__(self, name=None, check=1, **kw):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
        #print "Spheres.__init__"
        v = kw.get('centers')
        if v is not None:
            kw['vertices'] = v     # rename centers in vertices for Geom.__init
        elif not kw.get('shape'):
            kw['shape'] = (0,3)    # default shape for sphere set

        self.templateDSPL = None # (displayList, openglContext)
        #self.firstList = GL.glGenLists(3)

        self.culling = GL.GL_BACK
        self.inheritCulling = 0

        self.frontPolyMode = GL.GL_FILL
        self.inheritFrontPolyMode = viewerConst.NO

        self.oneRadius = viewerConst.YES
        self.radius = 1.0

        self.quality = None

        #self.immediateRendering = True

        apply( Geom.__init__, (self, name, check), kw )
        assert len(self.vertexSet.vertices.ashape)==2
        
        self._modified = False
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:30,代码来源:Spheres.py

示例14: MakeMat

    def MakeMat(self, scale=True):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
	"""Build the matrix for this object in his parent's frame"""
        gllib.glTranslatef(float(self.translation[0]),
                           float(self.translation[1]),
                           float(self.translation[2]))
        gllib.glTranslatef(float(self.MatrixTransl[0]),
                           float(self.MatrixTransl[1]),
                           float(self.MatrixTransl[2]))
        #print "self.MatrixRot", self.MatrixRot
        gllib.glMultMatrixf(self.MatrixRot)
        gllib.glTranslatef(float(self.pivot[0]),
                           float(self.pivot[1]),
                           float(self.pivot[2]))
        gllib.glMultMatrixf(self.MatrixRotInv)
        gllib.glMultMatrixf(self.rotation)
        gllib.glMultMatrixf(self.MatrixRot)
        if scale:
            gllib.glScalef(float(self.scale[0]),
                           float(self.scale[1]),
                           float(self.scale[2]))
            gllib.glScalef(float(self.MatrixScale[0]),
                           float(self.MatrixScale[1]),
                           float(self.MatrixScale[2]))
        gllib.glTranslatef(float(-self.pivot[0]),
                           float(-self.pivot[1]),
                           float(-self.pivot[2]))
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:28,代码来源:Transformable.py

示例15: redraw

    def redraw(self):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
        self.tk.call(self._w, 'makecurrent')

        GL.glDisable( GL.GL_DEPTH_TEST )
        GL.glDisable( GL.GL_LIGHTING )
        #GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
        GL.glBegin(GL.GL_QUADS)
        GL.glColor3f(0.,0.,0.)
        GL.glVertex2f(0., 1.); GL.glVertex2f(0., 0.)
        GL.glColor3f(float(self.rgbMax[0]),float(self.rgbMax[1]),float(self.rgbMax[2]))
        GL.glVertex2f( 1., 0.); GL.glVertex2f( 1., 1.)
        GL.glEnd()

        GL.glEnable(GL.GL_COLOR_LOGIC_OP)
        GL.glLogicOp(GL.GL_XOR)
        GL.glLineWidth(2)
        GL.glColor3f(.5,.5,.5)
        GL.glBegin(GL.GL_LINES)
        x1 = self.v-0.01
        x2 = self.v+0.01
        GL.glVertex2f(float(x1), 1.); GL.glVertex2f(float(x1), 0.)
        GL.glVertex2f(float(x2), 0.); GL.glVertex2f(float(x2), 1.)
        GL.glEnd()
        GL.glDisable(GL.GL_COLOR_LOGIC_OP)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:26,代码来源:MaterialEditor.py


注:本文中的DejaVu类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。