本文整理汇总了Python中DejaVu.functionName方法的典型用法代码示例。如果您正苦于以下问题:Python DejaVu.functionName方法的具体用法?Python DejaVu.functionName怎么用?Python DejaVu.functionName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DejaVu
的用法示例。
在下文中一共展示了DejaVu.functionName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setSpecular
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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()
示例2: removeDuplicatedVertices
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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
示例3: updateCurrent
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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)
示例4: Add
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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
示例5: _MoveCursor
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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'))
示例6: loadPaletteMaterial
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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)
示例7: Reset
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
def Reset(self):
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
"""Reset members to default values"""
self.factor = 1
self.pattern = 0x7878
示例8: setMatrixComponents
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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()
示例9: sortPoly
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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)
示例10: ConcatRotation
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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()
示例11: GetMatrix
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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))
示例12: multMat4pt
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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)
示例13: __init__
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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
示例14: MakeMat
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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]))
示例15: redraw
# 需要导入模块: import DejaVu [as 别名]
# 或者: from DejaVu import functionName [as 别名]
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)