本文整理汇总了Python中opengltk.OpenGL.GL.glScalef方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glScalef方法的具体用法?Python GL.glScalef怎么用?Python GL.glScalef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glScalef方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: arcdraw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glScalef [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()
示例2: display
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glScalef [as 别名]
def display(self):
GL.glClear( GL.GL_COLOR_BUFFER_BIT)
GL.glColor3f( 1.0, 1.0, 1.0)
GL.glLoadIdentity() # clear the matrix
# viewing transformation
GLU.gluLookAt( 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
GL.glScalef( 1.0, 2.0, 1.0) # modeling transformation
GLUT.glutWireCube( 1.0)
GL.glFlush()
示例3: drawSticker
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glScalef [as 别名]
def drawSticker(self, lLabelbounds):
if self.framePolygonMode != GL.GL_NONE:
lenFrameColor = len(self.frameColor)
if lenFrameColor == 4:
GL.glColor4fv(self.frameColor)
elif lenFrameColor == 3:
GL.glColor3fv(self.frameColor)
GL.glPolygonMode(GL.GL_FRONT, self.framePolygonMode)
GL.glBegin(GL.GL_QUADS)
GL.glVertex2f(0, 0)
GL.glVertex2f(float(self.size[0]), 0)
GL.glVertex2f(float(self.size[0]), float(self.size[1]))
GL.glVertex2f(0, float(self.size[1]))
GL.glEnd()
GL.glScalef(float(self.fontScales[0]),
float(self.fontScales[1]),
0)
GL.glTranslatef(float(self.frameSpace[0]),
float(self.frameSpace[1]),
0)
# this corrects the glf draw function to start the label at the proper position
GL.glTranslatef(1, float(-lLabelbounds[1]), 0)
lenFontColor = len(self.fontColor)
if lenFontColor == 4:
GL.glColor4fv(self.fontColor)
elif lenFontColor == 3:
GL.glColor3fv(self.fontColor)
GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
if self.wireFont in [0, False]:
glf.glfDrawSolidString(self.label)
else:
glf.glfDrawWiredString(self.label)
示例4: drawLegendLabelName
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glScalef [as 别名]
#.........这里部分代码省略.........
lRoomLeftToUnit = -fontScaleHalf + lRoomToLegendFarLongSide - lUnitWidth
lRoomBelowName = -fontScaleHalf + roomBelowLegend - lMaxLabelsHeight - lNameHeight
lRoomBelowUnit = fontScaleHalf + roomBelowLegend + legendLongSide + lMaxLabelsHeight
else:
lRoomLeftToLabel = fontScaleHalf + lRoomToLegendFarLongSide
lRoomLeftToName = fontScaleHalf + lRoomToLegendCloseLongSide
lRoomLeftToUnit = lRoomLeftToName
lRoomBelowName = -fontScaleHalf + roomBelowLegend - lMaxLabelsHeight - lNameHeight
lRoomBelowUnit = fontScaleHalf + roomBelowLegend + legendLongSide + lMaxLabelsHeight
else:
if leftOrBelowLabels is True:
lRoomBelowLabel = -fontScaleHalf + lRoomToLegendFarLongSide \
- legendShortSide - lMaxLabelsHeight
lRoomBelowName = lRoomToLegendCloseLongSide + legendShortSideHalf \
- lMaxNameUnitHeightHalf
else:
lRoomBelowLabel = fontScaleHalf + lRoomToLegendCloseLongSide \
+ legendShortSide
lRoomBelowName = lRoomToLegendCloseLongSide + legendShortSideHalf \
- lMaxNameUnitHeightHalf
lRoomBelowUnit = lRoomBelowName
lRoomLeftToName = -fontScaleHalf + lRoomToLegendCloseShortSide - lNameWidth
lRoomLeftToUnit = fontScaleHalf + lRoomToLegendFarShortSide
# set the color of the text
GL.glColor3fv(labelColor2)
# print the legend name
GL.glPushMatrix()
GL.glTranslatef(
float(lRoomLeftToName+fontScale),
float(lRoomBelowName-lNameMinAndMax[1]),
0)
GL.glScalef(float(fontScale), float(fontScale), 0);
glf.glfDrawSolidString(name)
GL.glPopMatrix()
if unit is not None and (len(unit) > 0):
GL.glPushMatrix()
GL.glTranslatef(
float(lRoomLeftToUnit+fontScale),
float(lRoomBelowUnit-lUnitMinAndMax[1]),
0)
GL.glScalef(float(fontScale), float(fontScale), 1);
glf.glfDrawSolidString(unit)
GL.glPopMatrix()
if mini is not None and maxi is not None:
i = 0
for v in lOnScreenLabelValues:
#calculate label position
lLabel = "%.*g" % (significantDigits,v)
lStep = (v - mini) * lUnitStep
GL.glPushMatrix()
if verticalLegend:
if leftOrBelowLabels:
GL.glTranslatef(
float(lRoomLeftToLabel+fontScale-lLabelsWidth[i]),
float(roomBelowLegend-(lLabelsHeight[i]/2+lLabelsMinAndMax[i][1])+lStep),
0)
else:
GL.glTranslatef(
float(lRoomLeftToLabel+fontScale),
float(roomBelowLegend-(lLabelsHeight[i]/2+lLabelsMinAndMax[i][1])+lStep),
0)
else:
GL.glTranslatef(
示例5: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glScalef [as 别名]
def Draw(self):
""" Draw function of the geom
return status 0 or 1
If you want fast rendering, you need to set self.templateDSPL
using MakeTemplate.
"""
#print "Ellipsoids.Draw"
assert self.templateDSPL is not None
currentcontext = self.viewer.currentCamera.tk.call(self.viewer.currentCamera._w, 'contexttag')
if currentcontext != self.templateDSPL[1]:
warnings.warn("""draw failed because the current context is the wrong one""")
#print "currentcontext != self.templateDSPL[1]", currentcontext, self.templateDSPL[1]
return 0
centers = self.vertexSet.vertices.array
if len(centers) == 0: return
scaling = self.scaling
orientation = self.orientation
vertices = self.vertexSet.vertices.array
if len(vertices) != len(scaling) or len(vertices) != len(orientation):
return
if self.inheritMaterial:
fp = None
bp = None
else:
fp = self.materials[GL.GL_FRONT]
if not self.frontAndBack:
bp = self.materials[GL.GL_BACK]
face = GL.GL_FRONT
else:
bp = None
face = GL.GL_FRONT_AND_BACK
for i in xrange(len(vertices)):
GL.glPushName(i)
if fp:
for m in (0,1,2,3,4):
if fp.binding[m] != viewerConst.OVERALL:
glMaterialWithCheck( face,
viewerConst.propConst[m],
fp.prop[m][i] )
if bp:
for m in (0,1,2,3,4):
if bp.binding[m] != viewerConst.OVERALL:
glMaterialWithCheck( face,
viewerConst.propConst[m],
bp.prop[m][i] )
GL.glPushMatrix()
GL.glTranslatef(float(vertices[i][0]),
float(vertices[i][1]),
float(vertices[i][2]))
GL.glMultMatrixf( orientation[i].ravel() )
GL.glScalef(float(scaling[i][0]),
float(scaling[i][1]),
float(scaling[i][2]))
#print '#%d'%self.templateDSPL[0], "glCallList Ellipsoids0"
GL.glCallList(self.templateDSPL[0])
GL.glPopMatrix()
GL.glPopName()
return True
示例6: DisplayFunction
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glScalef [as 别名]
def DisplayFunction(self):
"""Draw a square with diagonals to represent the clipping plane
"""
#print "ClippingPlane.DisplayFunction"
#trans = self.eqn[3]*(self.eqn[:3]*self.n)
resetMaterialMemory()
trans = self.translation
GL.glPushMatrix()
#GL.glTranslatef(-trans[0],-trans[1],-trans[2])
GL.glTranslatef(float(trans[0]),
float(trans[1]),
float(trans[2]))
GL.glMultMatrixf(self.rotation)
GL.glScalef(float(self.scale[0]),
float(self.scale[1]),
float(self.scale[2]))
if self.polyMode == GL.GL_QUADS:
GL.glPushAttrib(GL.GL_CURRENT_BIT | GL.GL_LIGHTING_BIT |
GL.GL_POLYGON_BIT)
GL.glDisable(GL.GL_LIGHTING)
GL.glMaterialWithCheck(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT,
self.color)
if self.viewer is not None:
self.viewer.enableOpenglLighting()
GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)
GL.glPushMatrix()
GL.glMultMatrixf(self.planeRot)
GL.glBegin (GL.GL_QUADS)
GL.glVertex3f (0.0, -5.0, -5.0)
GL.glVertex3f (0.0, -5.0, 5.0)
GL.glVertex3f (0.0, 5.0, 5.0)
GL.glVertex3f (0.0, 5.0, -5.0)
GL.glVertex3f (0.0, -5.0, -5.0)
GL.glEnd ()
GL.glPopMatrix()
GL.glPopAttrib()
else:
# MS disabling GL.GL_BLEND breaks display of transparent surfaces
## if self.antialiased==True:
## GL.glEnable(GL.GL_LINE_SMOOTH)
## GL.glEnable(GL.GL_BLEND)
## else:
## GL.glDisable(GL.GL_LINE_SMOOTH)
## GL.glDisable(GL.GL_BLEND)
GL.glColor4fv (self.color)
GL.glLineWidth(self.lineWidth)
GL.glPushMatrix()
GL.glMultMatrixf(self.planeRot)
# could and should be a display list made once for all planes
GL.glBegin (GL.GL_LINE_STRIP)
GL.glVertex3f (0.0, -5.0, -5.0)
GL.glVertex3f (0.0, -5.0, 5.0)
GL.glVertex3f (0.0, 5.0, 5.0)
GL.glVertex3f (0.0, 5.0, -5.0)
GL.glVertex3f (0.0, -5.0, -5.0)
GL.glVertex3f (0.0, 5.0, 5.0)
GL.glVertex3f (0.0, -5.0, 5.0)
GL.glVertex3f (0.0, 5.0, -5.0)
GL.glEnd ()
GL.glPopMatrix()
GL.glPopMatrix()
示例7: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glScalef [as 别名]
#.........这里部分代码省略.........
if fp.binding[m] == viewerConst.OVERALL:
glMaterialWithCheck( face,
viewerConst.propConst[m],
fpProp[m][0])
if fp.binding[1] == viewerConst.OVERALL:
GL.glColor4fv(colorFront[0])
if fp:
for m in (0,1,2,3,4):
if fp.binding[m] != viewerConst.OVERALL:
glMaterialWithCheck( face,
viewerConst.propConst[m],
fpProp[m][0])
if fp.binding[1] != viewerConst.OVERALL:
GL.glColor4fv(colorFront[0])
if bp:
for m in (0,1,2,3,4):
if bp.binding[m] != viewerConst.OVERALL:
glMaterialWithCheck( GL.GL_BACK,
viewerConst.propConst[m],
bp.prop[m][0])
#print self.name
#if fp: print fp.prop[1], fp.binding
#else: print
if self.fastSpheres:
#print "self.fastSpheres", self.fastSpheres
if self.oneRadius == viewerConst.NO:
radii = self.vertexSet.radii.array
#FIXME: quick fix because can be called from base class Set
# method after centers have been set BUT before radii have been
# set
if len(self.vertexSet.vertices) != len(radii):
return 0
else:
radii = Numeric.ones( centers.shape[0] ) * self.radius
radii.shape = (-1,1)
coords = Numeric.concatenate ( (centers, radii), 1 )
## if not self.inheritMaterial:
## mat = self.materials[GL.GL_FRONT]
## fpProp = []
## for propInd in range(4):
## b, p = mat.GetProperty(propInd)
## fpProp.append(p)
## fpProp.append(mat.prop[4])
## #fpProp = self.materials[GL.GL_FRONT].prop[:5]
## else:
## fpProp = None
#print 'FUGU OVERWRITE COLOR', fpProp
#import numpy
#GL.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, numpy.array((.6,.6,.6,1), 'f'))
#GL.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, numpy.array((1.,1.,1.,1), 'f'))
#GL.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, numpy.array((.4,.4,.4,1), 'f'))
#GL.glMaterialfv(GL.GL_FRONT, GL.GL_EMISSION, numpy.array((0,0,0,1), 'f'))
#GL.glMaterialf(GL.GL_FRONT, GL.GL_SHININESS, 1.)
status = glDrawSphereSet(
self.templateDSPL[0],
coords.astype('f'),
fpProp, #self.materials[GL.GL_FRONT].prop,
highlight=self.highlight,
)
#print "Spheres, status: ", status
return status
else:
resetMaterialMemory()
#print "SLOW Spheres"
if self.oneRadius == viewerConst.NO:
radii = self.vertexSet.radii.array
else:
radii = Numeric.ones( centers.shape[0] ) * self.radius
if len(self.vertexSet.vertices) != len(radii):
return 0
for i in xrange(centers.shape[0]):
GL.glPushName(i)
GL.glPushMatrix()
GL.glTranslatef(float(centers[i][0]),
float(centers[i][1]),
float(centers[i][2]))
if not self.oneRadius:
GL.glScalef(float(radii[i]),float(radii[i]),float(radii[i]))
else:
GL.glScalef(float(self.radius), float(self.radius), float(self.radius))
#print '#%d'%self.templateDSPL[0], "glCallList Spheres0"
if fp:
for m in (0,1,2,3,4):
if fp.binding[m] != viewerConst.OVERALL:
glMaterialWithCheck( face,
viewerConst.propConst[m],
fp.prop[m][0], geom=self)
GL.glCallList(self.templateDSPL[0])
GL.glPopMatrix()
GL.glPopName()
return 1