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


Python GL.glOrtho方法代码示例

本文整理汇总了Python中opengltk.OpenGL.GL.glOrtho方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glOrtho方法的具体用法?Python GL.glOrtho怎么用?Python GL.glOrtho使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opengltk.OpenGL.GL的用法示例。


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

示例1: initProjection

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glOrtho [as 别名]
 def initProjection(self):
     GL.glMatrixMode (GL.GL_PROJECTION)
     GL.glLoadIdentity ()
     GL.glOrtho(-10., 10., -10., 10., -10., 10.)
     GL.glMatrixMode(GL.GL_MODELVIEW)
     GL.glLoadIdentity()
     GL.glTranslatef(0, 0, 10.0)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:9,代码来源:test_togl.py

示例2: initProjection

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glOrtho [as 别名]
 def initProjection(self):
     if self.imarray is None:
         return
     self.tk.call(self._w, 'makecurrent')
     GL.glViewport(0, 0, self.width, self.height)
     GL.glMatrixMode(GL.GL_PROJECTION)
     GL.glLoadIdentity()
     GL.glOrtho(0, float(self.width), 0, float(self.height), -1.0, 1.0)
     GL.glMatrixMode(GL.GL_MODELVIEW)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:11,代码来源:imageViewer.py

示例3: initProjection

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glOrtho [as 别名]
    def initProjection(self):
        """ guillaume: prepare the opengl matrices 
for drawing the widget 
(for instance the sliders in the case of the MaterialEditor) 
"""
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
        
        GL.glMatrixMode (GL.GL_PROJECTION)
        GL.glLoadIdentity ()
        GL.glOrtho(0., 1., 0., 1., -2.5, 2.5)
        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glLoadIdentity()
        GL.glTranslatef(0, 0, 2.0)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:16,代码来源:MaterialEditor.py

示例4: pickDraw

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glOrtho [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()
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:46,代码来源:colorMapLegend.py

示例5: setup_viewport

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glOrtho [as 别名]
    def setup_viewport(self):
        GL.glMatrixMode( GL.GL_PROJECTION)
	GL.glLoadIdentity()
	GL.glOrtho( 0.0, 1.0, 0.0, 1.0, 0.0, 1.0)
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:6,代码来源:test_dots.py

示例6: drawLegendOnly

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glOrtho [as 别名]
def drawLegendOnly(
                    fullWidth,
                    fullHeight,
                    ramp,
                    verticalLegend=True,
                    roomLeftToLegend=0,
                    roomBelowLegend=50,
                    legendShortSide=10,
                    legendLongSide=150,
                    interpolate=True,
                    selected=False,
                    tile=None,
                    ):

    if ramp is None or len(ramp) == 0:
        return

    if tile is not None and selected is True:
        selected = False

    # deducted values
    if verticalLegend is True:
        lRoomToLegendCloseLongSide = roomLeftToLegend
        lRoomToLegendCloseShortSide = roomBelowLegend
        if legendShortSide < 1:
            legendShortSide = 1
        if legendLongSide < 1:
            legendLongSide = 1
    else:
        lRoomToLegendCloseLongSide = roomBelowLegend 
        lRoomToLegendCloseShortSide = roomLeftToLegend 
        if legendShortSide < 1:
            legendShortSide = 1
        if legendLongSide < 1:
            legendLongSide = 1

    lRoomToLegendFarLongSide = lRoomToLegendCloseLongSide + legendShortSide 

    GL.glMatrixMode(GL.GL_PROJECTION)
    GL.glPushMatrix()
    GL.glLoadIdentity()
    if tile is None:
        GL.glOrtho(0, float(fullWidth), 0, float(fullHeight), -1, 1)
    else:
        GL.glOrtho(float(tile[0]), float(tile[1]), float(tile[2]), float(tile[3]), -1, 1)
    GL.glMatrixMode(GL.GL_MODELVIEW)
    GL.glPushMatrix()
    GL.glLoadIdentity()
    GL.glDisable( GL.GL_LIGHTING )

    GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
    GL.glDisable(GL.GL_DEPTH_TEST)
    GL.glDepthMask(GL.GL_FALSE)
    
    if len(ramp[0]) == 4: # there are alpha values, draw checkered bg
        GL.glEnable(GL.GL_BLEND)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
        #draw a bunch of quads as background
        lCheckerSquareSize = legendShortSide * .5
        if lCheckerSquareSize != 0:
            nbquads = int(legendLongSide / lCheckerSquareSize)
        else:
            nbquads = 1
        c1 = ( 0.1, 0.1, 0.1 )
        c2 = ( 0.3, 0.3, 0.3 )
        c = c1
        x2 = None
        for i in range(nbquads+1):
            GL.glColor3fv(c)
            if i==nbquads and nbquads != 0:
                x1=x2
                x2=legendLongSide
            else:
                x1 = i*lCheckerSquareSize
                x2 = min (x1+lCheckerSquareSize, legendLongSide)

            GL.glBegin(GL.GL_QUADS)
            if verticalLegend is True:
                GL.glVertex2f(float(lRoomToLegendCloseLongSide),
                              float(lRoomToLegendCloseShortSide + x1))
                GL.glVertex2f(float(lRoomToLegendCloseLongSide+lCheckerSquareSize), 
                              float(lRoomToLegendCloseShortSide + x1))
                GL.glVertex2f(float(lRoomToLegendCloseLongSide+lCheckerSquareSize), 
                              float(lRoomToLegendCloseShortSide + x2))
                GL.glVertex2f(float(lRoomToLegendCloseLongSide), 
                              float(lRoomToLegendCloseShortSide + x2))
            else:
                GL.glVertex2f(float(lRoomToLegendCloseShortSide + x2),
                              float(lRoomToLegendCloseLongSide))
                GL.glVertex2f(float(lRoomToLegendCloseShortSide + x2),
                              float(lRoomToLegendCloseLongSide+lCheckerSquareSize))
                GL.glVertex2f(float(lRoomToLegendCloseShortSide + x1),
                              float(lRoomToLegendCloseLongSide+lCheckerSquareSize))
                GL.glVertex2f(float(lRoomToLegendCloseShortSide + x1),
                              float(lRoomToLegendCloseLongSide))
            GL.glEnd()
    
            if c==c1:
                c=c2
            else:
#.........这里部分代码省略.........
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:103,代码来源:Legend.py

示例7: drawLegendLabelName

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glOrtho [as 别名]

#.........这里部分代码省略.........
            lPt2 = (fontScale+lRoomToLegendFarShortSide+lUnitWidth,
                    lRoomToLegendCloseLongSide,0)
            lPt3 = (fontScale+lRoomToLegendFarShortSide+lUnitWidth, 
                    fontScale+lRoomToLegendCloseLongSide \
                    + legendShortSide \
                    + lMaxLabelsHeight,
                    0)
            lPt4 = (-fontScale+lRoomToLegendCloseShortSide-lNameWidth, 
                    fontScale+lRoomToLegendCloseLongSide \
                    + legendShortSide \
                    + lMaxLabelsHeight,
                    0)
        else:
            lPt1 = (-fontScale+lRoomToLegendCloseShortSide-lNameWidth,
                    -fontScale+lRoomToLegendCloseLongSide-lMaxLabelsHeight,
                    0)
            lPt2 = (fontScale+lRoomToLegendFarShortSide+lUnitWidth,
                    -fontScale+lRoomToLegendCloseLongSide-lMaxLabelsHeight,
                    0)
            lPt3 = (fontScale+lRoomToLegendFarShortSide+lUnitWidth,
                    lRoomToLegendFarLongSide,0)
            lPt4 = (-fontScale+lRoomToLegendCloseShortSide-lNameWidth,
                    lRoomToLegendFarLongSide,0)

    if selected is True:
        labelColor2 = (.5, .5, .5)
    else:
        labelColor2 = labelColor

    GL.glMatrixMode(GL.GL_PROJECTION)
    GL.glPushMatrix()
    GL.glLoadIdentity()
    if tile is None:
        GL.glOrtho(0, float(fullWidth), 0, float(fullHeight), -1, 1)
    else:
        GL.glOrtho(float(tile[0]), float(tile[1]), float(tile[2]), float(tile[3]), -1, 1)
    GL.glMatrixMode(GL.GL_MODELVIEW)
    GL.glPushMatrix()
    GL.glLoadIdentity()
    GL.glDisable( GL.GL_LIGHTING )

    GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL )
    
    if len(backgroundColor) == 4:
        GL.glEnable(GL.GL_BLEND)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)

    #because of an unexplained bug on michel's laptop,
    #we don't draw the background when there is no frame 
    #(so michel has a way to manage the legend)
    if frame is True:
        #draw transparent background
        GL.glDepthMask(GL.GL_FALSE) 
        if len(backgroundColor) == 3:
            GL.glColor3fv(backgroundColor)
        else:
            GL.glColor4fv(backgroundColor)           
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex3fv(lPt1)
        GL.glVertex3fv(lPt2)
        GL.glVertex3fv(lPt3)
        GL.glVertex3fv(lPt4)
        GL.glEnd()
        GL.glDepthMask(GL.GL_TRUE) 

    #draw frame
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:70,代码来源:Legend.py

示例8: beginTile

# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glOrtho [as 别名]
   def beginTile(self):

      if self.CurrentTile <= 0:
         self.setup()
      # Save user's viewport, will be restored after last tile rendered
      self.ViewportSave = GL.glGetIntegerv(GL.GL_VIEWPORT)

      # which tile (by row and column) we're about to render
      if self.RowOrder==TR_BOTTOM_TO_TOP:
         self.CurrentRow = self.CurrentTile / self.Columns
         self.CurrentColumn = self.CurrentTile % self.Columns
      elif self.RowOrder==TR_TOP_TO_BOTTOM:
         self.CurrentRow = self.Rows - (self.CurrentTile / self.Columns) - 1
         self.CurrentColumn = self.CurrentTile % self.Columns
      else:
         raise RuntimeError

      assert(self.CurrentRow < self.Rows)
      assert(self.CurrentColumn < self.Columns)

      border = self.TileBorder

      # Compute actual size of this tile with border
      if self.CurrentRow < self.Rows-1:
         tileHeight = self.TileHeight
      else:
         tileHeight = self.ImageHeight - (self.Rows-1) * \
                      (self.TileHeightNB) + 2 * border

      if self.CurrentColumn < self.Columns-1:
         tileWidth = self.TileWidth
      else:
         tileWidth = self.ImageWidth - (self.Columns-1) * \
                     (self.TileWidthNB) + 2 * border

      # Save tile size, with border
      self.CurrentTileWidth = tileWidth
      self.CurrentTileHeight = tileHeight

      GL.glViewport(0, 0, tileWidth, tileHeight) #tile size including border

      # save current matrix mode
      matrixMode = GL.glGetIntegerv(GL.GL_MATRIX_MODE)[0]
      GL.glMatrixMode(GL.GL_PROJECTION)
      GL.glLoadIdentity()

      # compute projection parameters
      self.tileleft = left = self.Left + (self.Right - self.Left) \
                      * (self.CurrentColumn * self.TileWidthNB - border) \
                      / self.ImageWidth
      self.tileright = right = left + (self.Right - self.Left) * \
                       self.TileWidth / self.ImageWidth
      self.tilebottom = bottom = self.Bottom + (self.Top - self.Bottom) \
                        * (self.CurrentRow * self.TileHeightNB - border) / \
                        self.ImageHeight
      self.tiletop = top = bottom + (self.Top - self.Bottom) * self.TileHeight / \
                     self.ImageHeight

      if self.Perspective:
         GL.glFrustum(float(left), float(right),
                      float(bottom), float(top),
                      float(self.Near), float(self.Far))
      else:
         GL.glOrtho(float(left), float(right),
                    float(bottom), float(top),
                    float(self.Near), float(self.Far))

      # restore user's matrix mode
      GL.glMatrixMode(int(matrixMode))
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:71,代码来源:tileRenderer.py


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