本文整理汇总了Python中opengltk.OpenGL.GL.glPopMatrix方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glPopMatrix方法的具体用法?Python GL.glPopMatrix怎么用?Python GL.glPopMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glPopMatrix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConcatRotation
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [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()
示例2: arcdraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def arcdraw(self, x, n, radius, colxf=None):
# determine scale and rotation of template
import math
sz=0.0
y = [0, 0, 0]
for i in (0,1,2):
y[i] = x[i]+n[i]
for i in (0,1,2):
sz=sz+(x[i]-y[i])*(x[i]-y[i])
sz = sqrt(sz)
if sz==0.0:
return
rx = -180.0*acos((y[2]-x[2])/sz)/pi
rz = -180.0*atan2(y[0]-x[0],y[1]-x[1])/pi
GL.glPushMatrix()
GL.glTranslatef(float(x[0]),float(x[1]),float(x[2]))
if rz<=180.0 and rz >=-180.0:
GL.glRotatef(float(rz), 0., 0., 1.)
GL.glRotatef(float(rx), 1., 0., 0.)
GL.glScalef(float(radius),float(radius),float(sz))
# draw circle
GL.glColor4fv(colxf)
GL.glBegin(GL.GL_LINE_STRIP)
for i in range(self.nsegments+1):
GL.glVertex3fv(self.v[i])
GL.glEnd()
GL.glPopMatrix()
示例3: _loopGeomsRec
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def _loopGeomsRec(self, obj):
""" recursive method """
GL.glPushMatrix()
# we discard root object transformation:
if obj is not obj.viewer.rootObject:
if hasattr(obj, 'MakeMat'):
obj.MakeMat()
obj.VRML2CreatedPROTOForThisGeom = 0 # flag used in vrml2 doit()
for i in range(len(obj.instanceMatricesFortran)):
GL.glPushMatrix()
GL.glMultMatrixf(obj.instanceMatricesFortran[i])
obj.instanceMatricesFortranIndex = i # flag used in stl and vrml2 doit()
matrix = GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)
self.NodeRepr(obj, matrix)
for child in obj.children:
if child.visible:
self._loopGeomsRec(child)
GL.glPopMatrix()
GL.glPopMatrix() # Restore the matrix
del obj.instanceMatricesFortranIndex # clean up object
del obj.VRML2CreatedPROTOForThisGeom
示例4: GetMatrix
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [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))
示例5: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def Draw(self):
#print "StickerImage.Draw", self
if self.image is None:
return
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
Insert2d.Draw(self)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glDisable(GL.GL_LIGHTING);
width = self.size[0]
height = self.size[1]
fullWidth = self.viewer.currentCamera.width
fullHeight = self.viewer.currentCamera.height
# we want the anchor of the image to be at the given position
posxFromLeft = self.position[0] * fullWidth - self.anchor[0] * width
posyFrombottom = (1.-self.position[1]) * fullHeight - (1.-self.anchor[1]) * height
#print "posxFromLeft, posyFrombottom", posxFromLeft, posyFrombottom
# used for picking
self.polygonContour = [ (posxFromLeft, posyFrombottom),
(posxFromLeft+width, posyFrombottom),
(posxFromLeft+width, posyFrombottom+height),
(posxFromLeft, posyFrombottom+height)
]
# this accept negative values were GL.glRasterPos2f(x,y) doesn't
GL.glRasterPos2f(0, 0)
_gllib.glBitmap(0, 0, 0, 0, posxFromLeft, posyFrombottom, 0)
GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
if self.image.mode == 'RGBA':
_gllib.glDrawPixels(self.image.size[0], self.image.size[1],
GL.GL_RGBA, GL.GL_UNSIGNED_BYTE,
self.image.tostring() )
elif self.image.mode == 'RGB':
_gllib.glDrawPixels(self.image.size[0], self.image.size[1],
GL.GL_RGB, GL.GL_UNSIGNED_BYTE,
self.image.tostring() )
elif self.image.mode == 'L':
_gllib.glDrawPixels(self.image.size[0], self.image.size[1],
GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE,
self.image.tostring() )
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPopMatrix()
return 1
示例6: tkRedraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def tkRedraw(self, *dummy):
#if not self.winfo_ismapped(): return
self.update_idletasks()
self.tk.call(self._w, 'makecurrent')
self.initProjection()
GL.glPushMatrix()
self.redraw()
GL.glFlush()
GL.glPopMatrix()
self.tk.call(self._w, 'swapbuffers')
示例7: arrowdraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def arrowdraw(self, x, y, colxf=None, colxb=None,
colyf=None, colyb=None,face=None):
# draw a cylinder going from x to y
# col for materials
# face can be GL_FRONT_AND_BACK or something else
# determine scale and rotation of template
import math
sz=0.0
for i in (0,1,2): sz=sz+(x[i]-y[i])*(x[i]-y[i])
if sz <= 0.0: return
sz = math.sqrt(sz)
rx = -180.0*math.acos((y[2]-x[2])/sz)/math.pi
dx = y[0]-x[0]
dy = y[1]-x[1]
if math.fabs(dx) < 0.00001 and math.fabs(dy) < 0.00001:
rz = 0.0
else:
rz = -180.0*math.atan2(dx,dy)/math.pi
GL.glPushMatrix()
GL.glTranslatef(float(x[0]),float(x[1]),float(x[2]))
if rz<=180.0 and rz >=-180.0: GL.glRotatef(float(rz), 0., 0., 1.)
GL.glRotatef(float(rx), 1., 0., 0.)
# draw arrow
GL.glBegin(GL.GL_LINES)
if colxf:
for m in (0,1,2,3,4):
if colxf[m] is not None:
glMaterialWithCheck( face, viewerConst.propConst[m],
colxf[m] )
if colxb and face!=GL.GL_FRONT_AND_BACK:
for m in (0,1,2,3,4):
if colxb[m] is not None:
glMaterialWithCheck( GL.GL_BACK,
viewerConst.propConst[m],
colxb[m] )
GL.glVertex3f(float(self.v[0][0]), float(self.v[0][1]), float(self.v[0][2]*sz))
GL.glVertex3f(float(self.v[1][0]), float(self.v[1][1]), float(self.v[1][2]*sz))
for i in range(self.npoly):
h = i+2
vx = self.v[h]
GL.glVertex3f(float(self.v[1][0]), float(self.v[1][1]),
float(self.v[1][2]*sz))
GL.glVertex3f(float(vx[0]*sz), float(vx[1]*sz), float(vx[2]*sz))
GL.glEnd()
GL.glPopMatrix()
示例8: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def Draw(self):
#print "Sticker.Draw", self
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
Insert2d.Draw(self)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glDisable(GL.GL_LIGHTING);
lLabelbounds = self.calculateSize()
width = self.size[0]
height = self.size[1]
fullWidth = self.viewer.currentCamera.width
fullHeight = self.viewer.currentCamera.height
# we want the anchor of the image to be at the given position
posxFromLeft = self.position[0] * fullWidth - self.anchor[0] * width
posyFrombottom = (1.-self.position[1]) * fullHeight - (1.-self.anchor[1]) * height
posxFromLeft = int(floor( posxFromLeft ) )
posyFrombottom = int(floor( posyFrombottom ) )
if (self.position[1] == 0.):
posyFrombottom -= 1
#print "posxFromLeft, posyFrombottom", posxFromLeft, posyFrombottom
# used for picking
self.polygonContour = [ (posxFromLeft, posyFrombottom),
(posxFromLeft+width, posyFrombottom),
(posxFromLeft+width, posyFrombottom+height),
(posxFromLeft, posyFrombottom+height)
]
GL.glTranslatef(float(posxFromLeft), float(posyFrombottom), 0)
self.drawSticker(lLabelbounds)
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glEnable(GL.GL_LIGHTING);
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPopMatrix()
return 1
示例9: DrawStuff
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def DrawStuff ():
GL.glClear (GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
# set up some matrices so that the object spins with the mouse
GL.glPushMatrix ()
GL.glTranslatef (0.0, 0.0, -80.0)
GL.glRotatef (lastx, 0.0, 1.0, 0.0)
GL.glRotatef (lasty, 1.0, 0.0, 0.0)
# Phew. FINALLY, Draw the polycylinder --
#gle.glePolyCylinder (NPTS, points, colors, 2.3)
gle.glePolyCylinder (points, colors, 2.3)
GL.glPopMatrix ()
GLUT.glutSwapBuffers ()
示例10: tkRedraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def tkRedraw(self, *dummy):
"""Cause the opengl widget to redraw itself.
guillaume: call the preparation of the opengl matrices for drawing the widget
then draw the widget
"""
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
#if not self.winfo_ismapped(): return
self.update_idletasks()
self.tk.call(self._w, 'makecurrent')
self.initProjection()
GL.glPushMatrix()
self.redraw()
GL.glFlush()
GL.glPopMatrix()
self.tk.call(self._w, 'swapbuffers')
示例11: ConcatRotationRelative
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def ConcatRotationRelative(self, matrix):
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
"""Apply the rotation matrix to the object (matrix.shape ==(16,)
Unlike ConcatRotation you just concatenate the rotation of the object
without considering Ri and R
"""
self._modified = True
obj = self
GL.glPushMatrix()
GL.glLoadIdentity()
## GL.glMultMatrixf(obj.rotation)
GL.glMultMatrixf(matrix)
GL.glMultMatrixf(obj.rotation)
m = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
obj.rotation = m.astype('f')
obj.rotation.shape = (16, )
GL.glPopMatrix()
示例12: pickDraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def pickDraw(self):
"""called by the picking process to operate the selection
"""
#print "colorMapLegend.pickDraw", self
# we draw just flat quad of the insert2d
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
#GL.glLoadIdentity()
GL.glLoadMatrixf(self.viewer.currentCamera.pickMatrix)
GL.glOrtho(0, float(self.viewer.currentCamera.width),
0, float(self.viewer.currentCamera.height), -1, 1)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
#GL.glColor3f(1,0,0)
if self.resizeSpot is not None:
GL.glPushName(1)
GL.glBegin(GL.GL_QUADS)
GL.glVertex2f(float(self.resizeSpot[0]+self.resizeSpotRadius),
float(self.resizeSpot[1]-self.resizeSpotRadius))
GL.glVertex2f(float(self.resizeSpot[0]+self.resizeSpotRadius),
float(self.resizeSpot[1]+self.resizeSpotRadius))
GL.glVertex2f(float(self.resizeSpot[0]-self.resizeSpotRadius),
float(self.resizeSpot[1]+self.resizeSpotRadius))
GL.glVertex2f(float(self.resizeSpot[0]-self.resizeSpotRadius),
float(self.resizeSpot[1]-self.resizeSpotRadius))
GL.glEnd()
GL.glPopName()
GL.glPushName(0)
GL.glBegin(GL.GL_QUADS)
GL.glVertex2fv(self.polygonContour[0])
GL.glVertex2fv(self.polygonContour[1])
GL.glVertex2fv(self.polygonContour[2])
GL.glVertex2fv(self.polygonContour[3])
GL.glEnd()
GL.glPopName()
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPopMatrix()
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPopMatrix()
示例13: FrameTransform
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def FrameTransform(self, camera=None):
if __debug__:
if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
"""Build the R an RI, the object's frame transformation and inverse"""
GL.glPushMatrix()
self.Si = Numeric.ones( (3, ) )
GL.glLoadIdentity()
if hasattr(self, 'parent'):
if self.inheritXform:
parent = self.parent
while (parent):
m = Numeric.reshape( parent.rotation, (4,4) )
upd = Numeric.reshape( Numeric.transpose(m), (16, ) )
GL.glMultMatrixf(upd)
GL.glMultMatrixf(parent.MatrixRotInv)
self.Si = self.Si / parent.scale
self.Si = self.Si / parent.MatrixScale
# we have to test here because we need to take into
# account the first parent that does not inherit while
# building R and Ri
if not parent.inheritXform:
break
parent = parent.parent
if camera:
m = Numeric.reshape( camera.rotation, (4,4) )
upd = Numeric.reshape( Numeric.transpose(m), (16, ) )
GL.glMultMatrixf(upd)
self.Si = self.Si / camera.scale
self.Ri = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
GL.glPopMatrix()
self.Ri = glCleanRotMat(self.Ri).astype('f')
self.Ri.shape = (4,4)
self.R = Numeric.reshape( Numeric.transpose(self.Ri), (16, ) ).astype('f')
self.Ri.shape = (16, )
if self.redirectXform: self.redirectXform.FrameTransform(camera)
for o in self.copyXform: o.FrameTransform(camera)
示例14: render
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def render(self, mode='render'):
# call with mode='csg' to render simple shape to setup Zbuffer for CSG
# call with mode='render' to render by calling geom's draw function
if self.geom:
#import traceback
#print traceback.print_stack()
#print self.geom
#print "========================================================="
root = self.geom.viewer.rootObject
instance = [0]
p = self.geom.parent
while p:
instance.append(0)
p = p.parent
#mat = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
#print 'mat OK', mat
GL.glPushMatrix()
GL.glLoadIdentity()
self.geom.viewer.currentCamera.BuildTransformation()
self.geom.BuildMat(self.geom, root, True, instance)
#mat = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
#print 'mat PB', mat
#print 'render ', mode, self.geom
if mode=='csg':
if self.dpyListCSG is None:
self.redoDisplayListCSG()
GL.glCallList(self.dpyListCSG)
elif mode=='render':
obj = self.geom
if not obj.inheritMaterial:
obj.InitMaterial(0)
obj.InitColor(0)
obj.DisplayFunction()
GL.glPopMatrix()
示例15: FrameTransform
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glPopMatrix [as 别名]
def FrameTransform(self, camera=None):
"""Build the R an RI, the object's frame transformation and inverse"""
GL.glPushMatrix()
self.Si = Numeric.ones( (3, ) )
GL.glLoadIdentity()
m = Numeric.reshape( self.object.rotation, (4,4) )
upd = Numeric.reshape( Numeric.transpose(m), (16, ) )
GL.glMultMatrixf(self.object.Ri)
GL.glMultMatrixf(upd)
GL.glMultMatrixf(self.object.MatrixRotInv)
self.Si = self.Si * self.object.Si / (self.object.scale *
self.object.MatrixScale)
self.Ri = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
GL.glPopMatrix()
#self.Ri = Numeric.reshape(glCleanRotMat(self.Ri), (4,4) )
self.Ri = glCleanRotMat(self.Ri)
self.R = Numeric.reshape( Numeric.transpose(self.Ri), (16, ) ).astype('f')
self.Ri = Numeric.reshape(self.Ri, (16, )).astype('f')
if self.redirectXform: self.redirectXform.FrameTransform(camera)
for o in self.copyXform: o.FrameTransform(camera)