示例#1
0
def drawpolycone_worker(params):
    """
    Draw a polycone.  Receive parameters through a sequence so that this
    function and its parameters can be passed to another function for
    deferment.  Right now this is only ColorSorter.schedule (see below)
    """
    (pos_array, rad_array) = params
    glePolyCone(pos_array, None, rad_array)
    return
示例#2
0
def drawpolycone_worker(params):
    """
    Draw a polycone.  Receive parameters through a sequence so that this
    function and its parameters can be passed to another function for
    deferment.  Right now this is only ColorSorter.schedule (see below)
    """
    (pos_array, rad_array) = params
    glePolyCone(pos_array, None, rad_array)
    return
示例#3
0
def drawpolycone_multicolor_worker(params):
    """
    Draw a polycone.  Receive parameters through a sequence so that this
    function and its parameters can be passed to another function for
    deferment.  Right now this is only ColorSorter.schedule (see below)
    piotr 080311: this variant accepts a color array as an additional parameter
    """
    (pos_array, color_array, rad_array) = params
    glEnable(GL_COLOR_MATERIAL) # have to enable GL_COLOR_MATERIAL for
                                # the GLE function
    glPushAttrib(GL_CURRENT_BIT) # store current attributes in case glePolyCone
                                    # modifies the (e.g. current color)
                                    # piotr 080411
    glePolyCone(pos_array, color_array, rad_array)
    glPopAttrib() # This fixes the 'disappearing cylinder' bug
                    # glPopAttrib doesn't take any arguments
                    # piotr 080415
    glDisable(GL_COLOR_MATERIAL)    
    return
示例#4
0
def drawpolycone_multicolor_worker(params):
    """
    Draw a polycone.  Receive parameters through a sequence so that this
    function and its parameters can be passed to another function for
    deferment.  Right now this is only ColorSorter.schedule (see below)
    piotr 080311: this variant accepts a color array as an additional parameter
    """
    (pos_array, color_array, rad_array) = params
    glEnable(GL_COLOR_MATERIAL)  # have to enable GL_COLOR_MATERIAL for
    # the GLE function
    glPushAttrib(
        GL_CURRENT_BIT)  # store current attributes in case glePolyCone
    # modifies the (e.g. current color)
    # piotr 080411
    glePolyCone(pos_array, color_array, rad_array)
    glPopAttrib()  # This fixes the 'disappearing cylinder' bug
    # glPopAttrib doesn't take any arguments
    # piotr 080415
    glDisable(GL_COLOR_MATERIAL)
    return
示例#5
0
def drawOriginAsSmallAxis(scale, origin, dashEnabled = False):
    """
    Draws a small wireframe version of the origin. It is rendered as a 
    3D point at (0, 0, 0) with 3 small axes extending from it in the positive
    X, Y, Z directions.

    @see: drawaxes (related code)
    """
    #Perhaps we should split this method into smaller methods? ninad060920
    #Notes:
    #1. drawing arrowheads implemented on 060918
    #2. ninad060921 Show the origin axes as dotted if behind the mode. 
    #3. ninad060922 The arrow heads are drawn as wireframe cones if behind the
    #   object the arrowhead size is slightly smaller (otherwise some portion of
    #   the the wireframe arrow shows up!
    #4 .Making origin non-zoomable is acheived by replacing hardcoded 'n' with
    #   glpane's scale - ninad060922

    #ninad060922 in future , the following could be user preferences. 
    if (dashEnabled):
        dashShrinkage = 0.9
    else:
        dashShrinkage=1
    x1, y1, z1 = scale * 0.01, scale * 0.01, scale * 0.01
    xEnd, yEnd, zEnd = scale * 0.04, scale * 0.09, scale * 0.025
    arrowBase = scale * 0.0075 * dashShrinkage
    arrowHeight = scale * 0.035 * dashShrinkage
    lineWidth = 1.0

    glPushMatrix()

    glTranslate(origin[0], origin[1], origin[2])
    glDisable(GL_LIGHTING)
    glLineWidth(lineWidth)

    gleNumSides = gleGetNumSides()
    #Code to show hidden lines of the origin if some model obscures it
    #  ninad060921
    if dashEnabled:
        glLineStipple(2, 0xAAAA)
        glEnable(GL_LINE_STIPPLE)
        glDisable(GL_DEPTH_TEST)
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
        gleSetNumSides(5)   
    else:   
        gleSetNumSides(10)

    glBegin(GL_LINES)

    color = env.prefs[originAxisColor_prefs_key]
    
    glColor3fv(color)

    #start draw a point at origin . 
    #ninad060922 is thinking about using GL_POINTS here

    glVertex(-x1, 0.0, 0.0)
    glVertex( x1, 0.0, 0.0)
    glVertex(0.0, -y1, 0.0)
    glVertex(0.0,  y1, 0.0)
    glVertex(-x1,  y1,  z1)
    glVertex( x1, -y1, -z1)    
    glVertex(x1,   y1,  z1)
    glVertex(-x1, -y1, -z1)    
    glVertex(x1,   y1, -z1)
    glVertex(-x1, -y1,  z1)    
    glVertex(-x1,  y1, -z1)
    glVertex(x1,  -y1,  z1)   
    #end draw a point at origin 

    #start draw small origin axes

    glColor3fv(color)
    glVertex(xEnd, 0.0, 0.0)
    glVertex( 0.0, 0.0, 0.0)

    glColor3fv(color)
    glVertex(0.0, yEnd, 0.0)
    glVertex(0.0,  0.0, 0.0)

    glColor3fv(color)
    glVertex(0.0, 0.0, zEnd)
    glVertex(0.0, 0.0,  0.0)
    glEnd() #end draw lines
    glLineWidth(1.0)

    # End push matrix for drawing various lines in the origin and axes.
    glPopMatrix()
    
    #start draw solid arrow heads  for  X , Y and Z axes
    glPushMatrix() 
    glDisable(GL_CULL_FACE)
    glColor3fv(color)
    glTranslatef(xEnd, 0.0, 0.0)
    glRotatef(90, 0.0, 1.0, 0.0)

    glePolyCone([[0, 0, -1],
                 [0, 0, 0],
                 [0, 0, arrowHeight],
                 [0, 0, arrowHeight+1]],
                None,
                [arrowBase, arrowBase, 0, 0])

    glPopMatrix()

    glPushMatrix()
    glColor3fv(color)
    glTranslatef(0.0, yEnd, 0.0)
    glRotatef(-90, 1.0, 0.0, 0.0)

    glePolyCone([[0, 0, -1],
                 [0, 0, 0],
                 [0, 0, arrowHeight],
                 [0, 0, arrowHeight+1]],
                None,
                [arrowBase, arrowBase, 0, 0])

    glPopMatrix()

    glPushMatrix()
    glColor3fv(color)
    glTranslatef(0.0,0.0,zEnd)

    glePolyCone([[0, 0, -1],
                 [0, 0, 0],
                 [0, 0, arrowHeight],
                 [0, 0, arrowHeight+1]],
                None,
                [arrowBase, arrowBase, 0, 0])

    #Disable line stipple and Enable Depth test
    if dashEnabled:
        glLineStipple(1, 0xAAAA)
        glDisable(GL_LINE_STIPPLE)
        glEnable(GL_DEPTH_TEST)
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
    gleSetNumSides(gleNumSides)
    glEnable(GL_CULL_FACE)
    glEnable(GL_LIGHTING)
    glPopMatrix() 
    #end draw solid arrow heads  for  X , Y and Z axes
    return
示例#6
0
def drawOriginAsSmallAxis(scale, origin, dashEnabled=False):
    """
    Draws a small wireframe version of the origin. It is rendered as a
    3D point at (0, 0, 0) with 3 small axes extending from it in the positive
    X, Y, Z directions.

    @see: drawaxes (related code)
    """
    #Perhaps we should split this method into smaller methods? ninad060920
    #Notes:
    #1. drawing arrowheads implemented on 060918
    #2. ninad060921 Show the origin axes as dotted if behind the mode.
    #3. ninad060922 The arrow heads are drawn as wireframe cones if behind the
    #   object the arrowhead size is slightly smaller (otherwise some portion of
    #   the the wireframe arrow shows up!
    #4 .Making origin non-zoomable is acheived by replacing hardcoded 'n' with
    #   glpane's scale - ninad060922

    #ninad060922 in future , the following could be user preferences.
    if (dashEnabled):
        dashShrinkage = 0.9
    else:
        dashShrinkage = 1
    x1, y1, z1 = scale * 0.01, scale * 0.01, scale * 0.01
    xEnd, yEnd, zEnd = scale * 0.04, scale * 0.09, scale * 0.025
    arrowBase = scale * 0.0075 * dashShrinkage
    arrowHeight = scale * 0.035 * dashShrinkage
    lineWidth = 1.0

    glPushMatrix()

    glTranslate(origin[0], origin[1], origin[2])
    glDisable(GL_LIGHTING)
    glLineWidth(lineWidth)

    gleNumSides = gleGetNumSides()
    #Code to show hidden lines of the origin if some model obscures it
    #  ninad060921
    if dashEnabled:
        glLineStipple(2, 0xAAAA)
        glEnable(GL_LINE_STIPPLE)
        glDisable(GL_DEPTH_TEST)
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
        gleSetNumSides(5)
    else:
        gleSetNumSides(10)

    glBegin(GL_LINES)

    color = env.prefs[originAxisColor_prefs_key]

    glColor3fv(color)

    #start draw a point at origin .
    #ninad060922 is thinking about using GL_POINTS here

    glVertex(-x1, 0.0, 0.0)
    glVertex(x1, 0.0, 0.0)
    glVertex(0.0, -y1, 0.0)
    glVertex(0.0, y1, 0.0)
    glVertex(-x1, y1, z1)
    glVertex(x1, -y1, -z1)
    glVertex(x1, y1, z1)
    glVertex(-x1, -y1, -z1)
    glVertex(x1, y1, -z1)
    glVertex(-x1, -y1, z1)
    glVertex(-x1, y1, -z1)
    glVertex(x1, -y1, z1)
    #end draw a point at origin

    #start draw small origin axes

    glColor3fv(color)
    glVertex(xEnd, 0.0, 0.0)
    glVertex(0.0, 0.0, 0.0)

    glColor3fv(color)
    glVertex(0.0, yEnd, 0.0)
    glVertex(0.0, 0.0, 0.0)

    glColor3fv(color)
    glVertex(0.0, 0.0, zEnd)
    glVertex(0.0, 0.0, 0.0)
    glEnd()  #end draw lines
    glLineWidth(1.0)

    # End push matrix for drawing various lines in the origin and axes.
    glPopMatrix()

    #start draw solid arrow heads  for  X , Y and Z axes
    glPushMatrix()
    glDisable(GL_CULL_FACE)
    glColor3fv(color)
    glTranslatef(xEnd, 0.0, 0.0)
    glRotatef(90, 0.0, 1.0, 0.0)

    glePolyCone(
        [[0, 0, -1], [0, 0, 0], [0, 0, arrowHeight], [0, 0, arrowHeight + 1]],
        None, [arrowBase, arrowBase, 0, 0])

    glPopMatrix()

    glPushMatrix()
    glColor3fv(color)
    glTranslatef(0.0, yEnd, 0.0)
    glRotatef(-90, 1.0, 0.0, 0.0)

    glePolyCone(
        [[0, 0, -1], [0, 0, 0], [0, 0, arrowHeight], [0, 0, arrowHeight + 1]],
        None, [arrowBase, arrowBase, 0, 0])

    glPopMatrix()

    glPushMatrix()
    glColor3fv(color)
    glTranslatef(0.0, 0.0, zEnd)

    glePolyCone(
        [[0, 0, -1], [0, 0, 0], [0, 0, arrowHeight], [0, 0, arrowHeight + 1]],
        None, [arrowBase, arrowBase, 0, 0])

    #Disable line stipple and Enable Depth test
    if dashEnabled:
        glLineStipple(1, 0xAAAA)
        glDisable(GL_LINE_STIPPLE)
        glEnable(GL_DEPTH_TEST)
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
    gleSetNumSides(gleNumSides)
    glEnable(GL_CULL_FACE)
    glEnable(GL_LIGHTING)
    glPopMatrix()
    #end draw solid arrow heads  for  X , Y and Z axes
    return