コード例 #1
0
def pref_debug_dna_updater(
):  # 080228; note: accessed using flags matching debug_flags.DEBUG_DNA_UPDATER*
    res = debug_pref(
        "DNA: updater debug prints",
        Choice(
            ["off", "minimal", "on", "verbose"],
            ## defaultValue = "on", # todo: revise defaultValue after debugging
            # defaultValue left "on" for now, though a bit verbose, bruce 080317
            defaultValue="off"  #bruce 080702 revised this, and the prefs key
        ),
        non_debug=True,
        prefs_key=
        "v111/DNA updater: debug prints",  # changed, bruce 080317, 080702
        call_with_new_value=_update_our_debug_flags)
    return res
コード例 #2
0
ファイル: glprefs.py プロジェクト: elfion/nanoengineer
    def _setup_shader_prefs(self):
        # note: as of bruce 090304 these all should work as same-session prefs,
        # and most of them have been tested that way.

        self.use_sphere_shaders_pref = debug_pref(
            "GLPane: use sphere-shaders?",
            _choices[self.use_sphere_shaders_default],
            non_debug=True,
            prefs_key=self.use_sphere_shaders_prefs_key)

        self.use_cylinder_shaders_pref = debug_pref(
            "GLPane: use cylinder-shaders?",
            _choices[self.use_cylinder_shaders_default],
            non_debug=True,
            prefs_key=self.use_cylinder_shaders_prefs_key)

        self.use_cone_shaders_pref = debug_pref(
            "GLPane: use cone-shaders?",
            _choices[self.use_cone_shaders_default],
            non_debug=True,
            prefs_key=self.use_cone_shaders_prefs_key)

        self.use_batched_primitive_shaders_pref = debug_pref(
            "GLPane: use batched primitive shaders?",
            _choices[self.use_batched_primitive_shaders_default],
            non_debug=True,
            prefs_key=self.use_batched_primitive_shaders_prefs_key)

        #russ 080403: Added drawing variant selection for unbatched spheres
        # (update, bruce 090304: mainly of historical interest or for testing,
        #  but does matter on older machines that can't use shaders;
        #  could be extended to affect other primitives, but hasn't been
        #  as of 090304)
        variants = [
            "0. OpenGL 1.0 - glBegin/glEnd tri-strips vertex-by-vertex.",
            "1. OpenGL 1.1 - glDrawArrays from CPU RAM.",
            "2. OpenGL 1.1 - glDrawElements indexed arrays from CPU RAM.",
            "3. OpenGL 1.5 - glDrawArrays from graphics RAM VBO.",
            "4. OpenGL 1.5 - glDrawElements, verts in VBO, index in CPU.",
            "5. OpenGL 1.5 - VBO/IBO buffered glDrawElements.",
        ]
        self.use_drawing_variant = debug_pref(
            "GLPane: drawing method (unbatched spheres)",
            Choice(names=variants,
                   values=range(len(variants)),
                   defaultValue=self.use_drawing_variant_default),
            prefs_key=self.use_drawing_variant_prefs_key)
        return
コード例 #3
0
def setup_drawer():
    """
    Set up the usual constant display lists in the current OpenGL context.

    WARNING: THIS IS ONLY CORRECT IF ONLY ONE GL CONTEXT CONTAINS DISPLAY LISTS
    -- or more precisely, only the GL context this has last been called in (or
    one which shares its display lists) will work properly with the routines in
    drawer.py, since the allocated display list names are stored in globals set
    by this function, but in general those names might differ if this was called
    in different GL contexts.
    """
    #bruce 060613 added docstring, cleaned up display list name allocation
    # bruce 071030 renamed from setup to setup_drawer

    spherelistbase = glGenLists(numSphereSizes)
    sphereList = []
    for i in range(numSphereSizes):
        sphereList += [spherelistbase + i]
        glNewList(sphereList[i], GL_COMPILE)
        glBegin(GL_TRIANGLE_STRIP)  # GL_LINE_LOOP to see edges.
        stripVerts = getSphereTriStrips(i)
        for vertNorm in stripVerts:
            glNormal3fv(vertNorm)
            glVertex3fv(vertNorm)
            continue
        glEnd()
        glEndList()
        continue
    drawing_globals.sphereList = sphereList

    # Sphere triangle-strip vertices for each level of detail.
    # (Cache and re-use the work of making them.)
    # Can use in converter-wrappered calls like glVertexPointerfv,
    # but the python arrays are re-copied to C each time.
    sphereArrays = []
    for i in range(numSphereSizes):
        sphereArrays += [getSphereTriStrips(i)]
        continue
    drawing_globals.sphereArrays = sphereArrays

    # Sphere glDrawArrays triangle-strip vertices for C calls.
    # (Cache and re-use the work of converting a C version.)
    # Used in thinly-wrappered calls like glVertexPointer.
    sphereCArrays = []
    for i in range(numSphereSizes):
        CArray = numpy.array(sphereArrays[i], dtype=numpy.float32)
        sphereCArrays += [CArray]
        continue
    drawing_globals.sphereCArrays = sphereCArrays

    # Sphere indexed vertices.
    # (Cache and re-use the work of making the indexes.)
    # Can use in converter-wrappered calls like glDrawElementsui,
    # but the python arrays are re-copied to C each time.
    sphereElements = []  # Pairs of lists (index, verts) .
    for i in range(numSphereSizes):
        sphereElements += [indexVerts(sphereArrays[i], .0001)]
        continue
    drawing_globals.sphereElements = sphereElements

    # Sphere glDrawElements index and vertex arrays for C calls.
    sphereCIndexTypes = []  # numpy index unsigned types.
    sphereGLIndexTypes = []  # GL index types for drawElements.
    sphereCElements = []  # Pairs of numpy arrays (Cindex, Cverts) .
    for i in range(numSphereSizes):
        (index, verts) = sphereElements[i]
        if len(index) < 256:
            Ctype = numpy.uint8
            GLtype = GL_UNSIGNED_BYTE
        else:
            Ctype = numpy.uint16
            GLtype = GL_UNSIGNED_SHORT
            pass
        sphereCIndexTypes += [Ctype]
        sphereGLIndexTypes += [GLtype]
        sphereCIndex = numpy.array(index, dtype=Ctype)
        sphereCVerts = numpy.array(verts, dtype=numpy.float32)
        sphereCElements += [(sphereCIndex, sphereCVerts)]
        continue
    drawing_globals.sphereCIndexTypes = sphereCIndexTypes
    drawing_globals.sphereGLIndexTypes = sphereGLIndexTypes
    drawing_globals.sphereCElements = sphereCElements

    if glGetString(GL_EXTENSIONS).find("GL_ARB_vertex_buffer_object") >= 0:

        # A GLBufferObject version for glDrawArrays.
        sphereArrayVBOs = []
        for i in range(numSphereSizes):
            vbo = GLBufferObject(GL_ARRAY_BUFFER_ARB, sphereCArrays[i],
                                 GL_STATIC_DRAW)
            sphereArrayVBOs += [vbo]
            continue
        drawing_globals.sphereArrayVBOs = sphereArrayVBOs

        # A GLBufferObject version for glDrawElements indexed verts.
        sphereElementVBOs = []  # Pairs of (IBO, VBO)
        for i in range(numSphereSizes):
            ibo = GLBufferObject(GL_ELEMENT_ARRAY_BUFFER_ARB,
                                 sphereCElements[i][0], GL_STATIC_DRAW)
            vbo = GLBufferObject(GL_ARRAY_BUFFER_ARB, sphereCElements[i][1],
                                 GL_STATIC_DRAW)
            sphereElementVBOs += [(ibo, vbo)]
            continue
        drawing_globals.sphereElementVBOs = sphereElementVBOs

        ibo.unbind()
        vbo.unbind()
        pass

    #bruce 060415
    drawing_globals.wiresphere1list = wiresphere1list = glGenLists(1)
    glNewList(wiresphere1list, GL_COMPILE)
    didlines = {}  # don't draw each triangle edge more than once

    def shoulddoline(v1, v2):
        # make sure not list (unhashable) or Numeric array (bug in __eq__)
        v1 = tuple(v1)
        v2 = tuple(v2)
        if (v1, v2) not in didlines:
            didlines[(v1, v2)] = didlines[(v2, v1)] = None
            return True
        return False

    def doline(v1, v2):
        if shoulddoline(v1, v2):
            glVertex3fv(v1)
            glVertex3fv(v2)
        return

    glBegin(GL_LINES)
    ocdec = getSphereTriangles(1)
    for tri in ocdec:
        #e Could probably optim this more, e.g. using a vertex array or VBO or
        #  maybe GL_LINE_STRIP.
        doline(tri[0], tri[1])
        doline(tri[1], tri[2])
        doline(tri[2], tri[0])
    glEnd()
    glEndList()

    drawing_globals.CylList = CylList = glGenLists(1)
    glNewList(CylList, GL_COMPILE)
    glBegin(GL_TRIANGLE_STRIP)
    for (vtop, ntop, vbot, nbot) in drawing_globals.cylinderEdges:
        glNormal3fv(nbot)
        glVertex3fv(vbot)
        glNormal3fv(ntop)
        glVertex3fv(vtop)
    glEnd()
    glEndList()

    drawing_globals.CapList = CapList = glGenLists(1)
    glNewList(CapList, GL_COMPILE)
    glNormal3fv(drawing_globals.cap0n)
    glBegin(GL_POLYGON)
    for p in drawing_globals.drum0:
        glVertex3fv(p)
    glEnd()
    glNormal3fv(drawing_globals.cap1n)
    glBegin(GL_POLYGON)
    #bruce 060609 fix "ragged edge" bug in this endcap: drum1 -> drum2
    for p in drawing_globals.drum2:
        glVertex3fv(p)
    glEnd()
    glEndList()

    drawing_globals.diamondGridList = diamondGridList = glGenLists(1)
    glNewList(diamondGridList, GL_COMPILE)
    glBegin(GL_LINES)
    for p in drawing_globals.digrid:
        glVertex(p[0])
        glVertex(p[1])
    glEnd()
    glEndList()

    drawing_globals.lonsGridList = lonsGridList = glGenLists(1)
    glNewList(lonsGridList, GL_COMPILE)
    glBegin(GL_LINES)
    for p in drawing_globals.lonsEdges:
        glVertex(p[0])
        glVertex(p[1])
    glEnd()
    glEndList()

    drawing_globals.CubeList = CubeList = glGenLists(1)
    glNewList(CubeList, GL_COMPILE)
    glBegin(GL_QUAD_STRIP)
    # note: CubeList has only 4 faces of the cube; only suitable for use in
    # wireframes; see also solidCubeList [bruce 051215 comment reporting
    # grantham 20051213 observation]
    glVertex((-1, -1, -1))
    glVertex((1, -1, -1))
    glVertex((-1, 1, -1))
    glVertex((1, 1, -1))
    glVertex((-1, 1, 1))
    glVertex((1, 1, 1))
    glVertex((-1, -1, 1))
    glVertex((1, -1, 1))
    glVertex((-1, -1, -1))
    glVertex((1, -1, -1))
    glEnd()
    glEndList()

    drawing_globals.solidCubeList = solidCubeList = glGenLists(1)
    glNewList(solidCubeList, GL_COMPILE)
    glBegin(GL_QUADS)
    for i in xrange(len(drawing_globals.cubeIndices)):
        avenormals = V(0, 0, 0)  #bruce 060302 fixed normals for flat shading
        for j in xrange(4):
            nTuple = tuple(
                drawing_globals.cubeNormals[drawing_globals.cubeIndices[i][j]])
            avenormals += A(nTuple)
        avenormals = norm(avenormals)
        for j in xrange(4):
            vTuple = tuple(drawing_globals.cubeVertices[
                drawing_globals.cubeIndices[i][j]])
            #bruce 060302 made size compatible with glut.glutSolidCube(1.0)
            vTuple = A(vTuple) * 0.5
            glNormal3fv(avenormals)
            glVertex3fv(vTuple)
    glEnd()
    glEndList()

    drawing_globals.rotSignList = rotSignList = glGenLists(1)
    glNewList(rotSignList, GL_COMPILE)
    glBegin(GL_LINE_STRIP)
    for ii in xrange(len(drawing_globals.rotS0n)):
        glVertex3fv(tuple(drawing_globals.rotS0n[ii]))
    glEnd()
    glBegin(GL_LINE_STRIP)
    for ii in xrange(len(drawing_globals.rotS1n)):
        glVertex3fv(tuple(drawing_globals.rotS1n[ii]))
    glEnd()
    glBegin(GL_TRIANGLES)
    for v in drawing_globals.arrow0Vertices + drawing_globals.arrow1Vertices:
        glVertex3f(v[0], v[1], v[2])
    glEnd()
    glEndList()

    drawing_globals.linearArrowList = linearArrowList = glGenLists(1)
    glNewList(linearArrowList, GL_COMPILE)
    glBegin(GL_TRIANGLES)
    for v in drawing_globals.linearArrowVertices:
        glVertex3f(v[0], v[1], v[2])
    glEnd()
    glEndList()

    drawing_globals.linearLineList = linearLineList = glGenLists(1)
    glNewList(linearLineList, GL_COMPILE)
    glEnable(GL_LINE_SMOOTH)
    glBegin(GL_LINES)
    glVertex3f(0.0, 0.0, -drawing_globals.halfHeight)
    glVertex3f(0.0, 0.0, drawing_globals.halfHeight)
    glEnd()
    glDisable(GL_LINE_SMOOTH)
    glEndList()

    drawing_globals.circleList = circleList = glGenLists(1)
    glNewList(circleList, GL_COMPILE)
    glBegin(GL_LINE_LOOP)
    for ii in range(60):
        x = cos(ii * 2.0 * pi / 60)
        y = sin(ii * 2.0 * pi / 60)
        glVertex3f(x, y, 0.0)
    glEnd()
    glEndList()

    # piotr 080405
    drawing_globals.filledCircleList = filledCircleList = glGenLists(1)
    glNewList(filledCircleList, GL_COMPILE)
    glBegin(GL_POLYGON)
    for ii in range(60):
        x = cos(ii * 2.0 * pi / 60)
        y = sin(ii * 2.0 * pi / 60)
        glVertex3f(x, y, 0.0)
    glEnd()
    glEndList()

    drawing_globals.lineCubeList = lineCubeList = glGenLists(1)
    glNewList(lineCubeList, GL_COMPILE)
    glBegin(GL_LINES)
    cvIndices = [
        0, 1, 2, 3, 4, 5, 6, 7, 0, 3, 1, 2, 5, 6, 4, 7, 0, 4, 1, 5, 2, 6, 3, 7
    ]
    for i in cvIndices:
        glVertex3fv(tuple(drawing_globals.cubeVertices[i]))
    glEnd()
    glEndList()

    # Debug Preferences
    from utilities.debug_prefs import debug_pref, Choice_boolean_True
    from utilities.debug_prefs import Choice_boolean_False
    choices = [Choice_boolean_False, Choice_boolean_True]

    # 20060314 grantham
    initial_choice = choices[drawing_globals.allow_color_sorting_default]
    drawing_globals.allow_color_sorting_pref = debug_pref(
        "Use Color Sorting?",
        initial_choice,
        prefs_key=drawing_globals.allow_color_sorting_prefs_key)
    #bruce 060323 removed non_debug = True for A7 release, changed default
    #value to False (far above), and changed its prefs_key so developers
    #start with the new default value.
    #russ 080225: Added.
    initial_choice = choices[drawing_globals.use_color_sorted_dls_default]
    drawing_globals.use_color_sorted_dls_pref = debug_pref(
        "Use Color-sorted Display Lists?",
        initial_choice,
        prefs_key=drawing_globals.use_color_sorted_dls_prefs_key)
    #russ 080225: Added.
    initial_choice = choices[drawing_globals.use_color_sorted_vbos_default]
    drawing_globals.use_color_sorted_vbos_pref = debug_pref(
        "Use Color-sorted Vertex Buffer Objects?",
        initial_choice,
        prefs_key=drawing_globals.use_color_sorted_vbos_prefs_key)

    #russ 080403: Added drawing variant selection
    variants = [
        "0. OpenGL 1.0 - glBegin/glEnd tri-strips vertex-by-vertex.",
        "1. OpenGL 1.1 - glDrawArrays from CPU RAM.",
        "2. OpenGL 1.1 - glDrawElements indexed arrays from CPU RAM.",
        "3. OpenGL 1.5 - glDrawArrays from graphics RAM VBO.",
        "4. OpenGL 1.5 - glDrawElements, verts in VBO, index in CPU.",
        "5. OpenGL 1.5 - VBO/IBO buffered glDrawElements."
    ]
    drawing_globals.use_drawing_variant = debug_pref(
        "GLPane: drawing method",
        Choice(names=variants,
               values=range(len(variants)),
               defaultValue=drawing_globals.use_drawing_variant_default),
        prefs_key=drawing_globals.use_drawing_variant_prefs_key)

    # temporarily always print this, while default setting might be in flux,
    # and to avoid confusion if the two necessary prefs are set differently
    # [bruce 080305]
    if (drawing_globals.allow_color_sorting_pref
            and drawing_globals.use_color_sorted_dls_pref):
        print "\nnote: this session WILL use color sorted display lists"
    else:
        print "\nnote: this session will NOT use color sorted display lists"
    if (drawing_globals.allow_color_sorting_pref
            and drawing_globals.use_color_sorted_vbos_pref):
        print "note: this session WILL use", \
              "color sorted Vertex Buffer Objects\n"
    else:
        print "note: this session will NOT use", \
              "color sorted Vertex Buffer Objects\n"

    # 20060313 grantham Added use_c_renderer debug pref, can
    # take out when C renderer used by default.
    if drawing_globals.quux_module_import_succeeded:
        initial_choice = choices[drawing_globals.use_c_renderer_default]
        drawing_globals.use_c_renderer = (debug_pref(
            "Use native C renderer?",
            initial_choice,
            prefs_key=drawing_globals.use_c_renderer_prefs_key))
        #bruce 060323 removed non_debug = True for A7 release, and changed
        # its prefs_key so developers start over with the default value.

    #initTexture('C:\\Huaicai\\atom\\temp\\newSample.png', 128,128)
    return  # from setup_drawer
コード例 #4
0
#
# We don't know why a higher value is needed on Windows. Could the
# depth buffer bit depth be different?? This value works out to a bit
# more than one resolution unit for a 16-bit depth buffer, so that might
# be a plausible cause. But due to our limited testing, the true difference
# in required values on these platforms might be much smaller.
#
# [bruce 070926]

DEPTH_TWEAK = DEPTH_TWEAK_UNITS * DEPTH_TWEAK_VALUE
# changed by setDepthRange_setup_from_debug_pref

DEPTH_TWEAK_CHOICE = \
                   Choice( [0,1,3,10,
                            100,200,300,400,500,600,700,800,900,1000,
                            2000,3000,4000,5000,
                            10000, 100000, 10**6, 10**7, 10**8],
                            defaultValue = DEPTH_TWEAK_VALUE )


class GLPane_minimal(QGLWidget, object):  #bruce 070914
    """
    Mostly a stub superclass, just so GLPane and ThumbView can have a common
    superclass.

    TODO:
    They share a lot of code, which ought to be merged into this superclass.
    Once that happens, it might as well get renamed.
    """

    # bruce 070920 added object superclass to our subclass GLPane;
コード例 #5
0
 def __init__(
         self,
         imageName,
         ideal_width=None,
         ideal_height=None,
         rescale=True,  ##e filter = ...
         convert=False,
         _tmpmode=None,
         _debug=False):
     #bruce 061127 added options, self attrs, docstring; some are marked [untested] in docstring [###k need to test them];
     ##e add options for resize filter choice, whether to use im.convert (experimental, nim), img mode to use for data (now RGBX)
     """
     Create an nEImageOps object that holds a PIL image made from the given image filename, imageName.
     Not all file formats are supported; the file extension is not enough to know if the file is supported,
     since it also depends on the nature of the internal data (which is probably a bug that could be fixed).
     [#doc the convert option, which tries to address that [not fully tested], and the _tmpmode option.]
        The image will be resized on demand by getTextureData (but in place in this mutable object,
     thus affecting all subsequent queries too, not only queries via getTextureData),
     to ideal_width, ideal_height, specified as options, or if they're not supplied, by a debug_pref "image size",
     or by direct modification by client of self.ideal_width and self.ideal_height before this resizing is first done.
     (Callers which want no resizing to occur currently need to explicitly set self.ideal_width and self.ideal_height
     to the actual image size (before first calling getTextureData), which can be determined as explained below.
     Or, as of 'kluge070304', they can pass -1 for ideal_width and/or ideal_height to make them equal that dim of the native size.
     Note that this entire API is basically a kluge, and ought to be cleaned up sometime. ##e)
        For many OpenGL drivers, if the image will be used as texture data, these sizes need to be powers of two.
        The resizing will be done by rescaling, by default, or by padding on top and right if rescale = False.
        The original dimensions can be found in self.orig_width and self.orig_height [untested];
     these never change after first reading the file (even when we internally reread the file in self.update,
     to work around bugs).
        The current dimensions can be found by knowing that width = self.img.size[0] and height = self.img.size[1].
     If getTextureData has been called, these presumably equal the ideal dims, but I [bruce] don't know if this is always true.
        The PIL image object is stored in the semi-public attribute self.img, but this object often replaces that image
     with a new one, with altered data and/or size, either due to resizing for getTextureData, or to external calls of
     one of several image-modifying methods.
     """
     self.debug = _debug  #bruce 061204
     self.imageName = imageName
     self.convert = convert
     self._tmpmode = _tmpmode  #bruce 061128, probably temporary, needs doc if not; JPG illegal, JPEG doesn't work, TIFF works well
     self.img = Image.open(imageName)
     self.unconverted_img = self.img  # for debugging, and in case keeping the python reference is needed
     if self.convert:  #bruce 061128
         # im.convert(mode) => image
         if type(self.convert) == type(""):
             mode = self.convert  # let caller specify mode to convert to
             # Q: should this also affect getTextureData retval? if so, also reset self.DESIRED_MODE here. A: yes.
             #e [or maybe have a separate option, desired_mode or mode or convert_to? Guess: someday have that,
             # and the convert flag will go away since it will always be true, BUT the desired mode will be
             # a function of the original mode! (just as that will be the case with the desired size.)]
             if mode != self.DESIRED_MODE:
                 # as of circa 070403 this happens routinely for convert = 'RGBA', and seems harmless...
                 # if DESIRED_MODE was cleaned up as suggested above it'd probably be a historical relic;
                 # so remove the debug print. [bruce 070404]
                 ## print "%r: warning: convert = mode %r is not yet fully supported" % (self, self.convert)
                 self.DESIRED_MODE = mode
         else:
             assert self.convert == True or self.convert == 1
             mode = self.DESIRED_MODE
         old_data = self.img.size, self.img.mode
         self.img = self.img.convert(
             mode
         )  #k does it matter whether we do this before or after resizing it?
         new_data = self.img.size, self.img.mode
         if old_data != new_data and debug_flags.atom_debug and self.debug:
             print "debug: %r: fyi: image converted from %r to %r" % (
                 self, old_data, new_data)
             ###e also need self.update() in this case?? if so, better do it later during __init__.
         pass
     self.orig_width = self.img.size[0]  #bruce 061127
     self.orig_height = self.img.size[1]  #bruce 061127
     if debug_flags.atom_debug and self.debug:
         #bruce 061127; fyi, see also string in this file containing RGB
         print "debug fyi: nEImageOps.__init__: %r.img.size, mode is %r, %r" % (
             self, self.img.size, self.img.mode)  ###
     if 1:
         #bruce 060213 - let debug pref set default values of ideal_width, ideal_height
         from utilities.debug_prefs import debug_pref, Choice
         self.ideal_width = self.ideal_height = debug_pref(
             "image size",
             Choice([256, 128, 64, 32, 512, 1024]),
             prefs_key='A8 devel/image size'
         )  #bruce 060612 made this persistent
         # these are not used until client code calls getTextureData;
         # it's ok if client modifies them directly before that,
         # anything from just once to before each call of getTextureData.
     if 1:
         #bruce 061127 - let caller override those values, and other behavior, using options
         if ideal_width is not None:
             self.ideal_width = ideal_width
         if ideal_height is not None:
             self.ideal_height = ideal_height
         self.rescale = rescale
     return
コード例 #6
0
    def Draw(self):
        if 1:
            # TODO: move this test code into a specific test mode just for it,
            # so it doesn't clutter up or slow down this general-use mode.
            #
            # wware 060124  Embed Pyrex/OpenGL unit tests into the cad code
            # grantham 060207:
            # Set to 1 to see a small array of eight spheres.
            # Set to 2 to see the Large-Bearing model, but this is most effective if
            #  the Large-Bearing has already been loaded normally into rotate mode
            #bruce 060209 set this from a debug_pref menu item, not a hardcoded flag
            TEST_PYREX_OPENGL = debug_pref("TEST_PYREX_OPENGL",
                                           Choice([0, 1, 2]))
            # uncomment this line to set it in the old way:
            ## TEST_PYREX_OPENGL = 1
        if TEST_PYREX_OPENGL:
            try:
                print_compact_stack("selectMode Draw: ")  ###
                ### BUG: if import quux fails, we get into some sort of infinite
                ###   loop of Draw calls. [bruce 070917 comment]

                #self.w.win_update()
                ## sys.path.append("./experimental/pyrex-opengl") # no longer
                ##needed here -- always done in drawer.py
                binPath = os.path.normpath(
                    os.path.dirname(os.path.abspath(sys.argv[0])) + '/../bin')
                if binPath not in sys.path:
                    sys.path.append(binPath)
                import quux
                if "experimental" in os.path.dirname(quux.__file__):
                    print "WARNING: Using experimental version of quux module"
                # quux.test()
                quux.shapeRendererInit()
                quux.shapeRendererSetUseDynamicLOD(0)
                quux.shapeRendererStartDrawing()
                if TEST_PYREX_OPENGL == 1:
                    center = Numeric.array(
                        (Numeric.array(
                            (0, 0, 0), 'f'), Numeric.array(
                                (0, 0, 1), 'f'), Numeric.array((0, 1, 0), 'f'),
                         Numeric.array(
                             (0, 1, 1), 'f'), Numeric.array((1, 0, 0), 'f'),
                         Numeric.array(
                             (1, 0, 1), 'f'), Numeric.array(
                                 (1, 1, 0), 'f'), Numeric.array(
                                     (1, 1, 1), 'f')), 'f')
                    radius = Numeric.array(
                        (0.2, 0.4, 0.6, 0.8, 1.2, 1.4, 1.6, 1.8), 'f')
                    color = Numeric.array((Numeric.array(
                        (0, 0, 0, 0.5), 'f'), Numeric.array(
                            (0, 0, 1, 0.5),
                            'f'), Numeric.array((0, 1, 0, 0.5), 'f'),
                                           Numeric.array((0, 1, 1, 0.5), 'f'),
                                           Numeric.array((1, 0, 0, 0.5), 'f'),
                                           Numeric.array((1, 0, 1, 0.5), 'f'),
                                           Numeric.array((1, 1, 0, 0.5), 'f'),
                                           Numeric.array((1, 1, 1, 0.5), 'f')),
                                          'f')
                    result = quux.shapeRendererDrawSpheres(
                        8, center, radius, color)
                elif TEST_PYREX_OPENGL == 2:
                    # grantham - I'm pretty sure the actual compilation, init,
                    # etc happens once
                    from bearing_data import sphereCenters, sphereRadii
                    from bearing_data import sphereColors, cylinderPos1
                    from bearing_data import cylinderPos2, cylinderRadii
                    from bearing_data import cylinderCapped, cylinderColors
                    glPushMatrix()
                    glTranslate(-0.001500, -0.000501, 151.873627)
                    result = quux.shapeRendererDrawSpheres(
                        1848, sphereCenters, sphereRadii, sphereColors)
                    result = quux.shapeRendererDrawCylinders(
                        5290, cylinderPos1, cylinderPos2, cylinderRadii,
                        cylinderCapped, cylinderColors)
                    glPopMatrix()
                quux.shapeRendererFinishDrawing()

            except ImportError:
                env.history.message(
                    redmsg(
                        "Can't import Pyrex OpenGL or maybe bearing_data.py, rebuild it"
                    ))
        else:
            if self.bc_in_use is not None:  #bruce 060414
                self.bc_in_use.draw(self.o, 'fake dispdef kluge')
            # bruce comment 040922: code is almost identical with modifyMode.Draw;
            # the difference (no check for self.o.assy existing) might be a bug
            # in this version, or might have no effect.
            commonGraphicsMode.Draw(self)
            #self.griddraw()
            if self.selCurve_List: self.draw_selection_curve()
            self.o.assy.draw(self.o)
コード例 #7
0
ファイル: PM_Colors.py プロジェクト: elfion/nanoengineer
    
    @see QPalette.setColor()
    """
    if palette:
        pass  # Make sure palette is QPalette.
    else:
        palette = QPalette()

    palette.setColor(colorRole, color)

    return palette


COLOR_THEME = "Gray"

_colortheme_Choice = Choice(["Gray", "Blue"], defaultValue=COLOR_THEME)

COLOR_THEME_prefs_key = "A9/Color Theme"


def set_Color_Theme_from_pref():
    global COLOR_THEME
    COLOR_THEME = debug_pref("Color Theme (next session)",
                             _colortheme_Choice,
                             non_debug=True,
                             prefs_key=COLOR_THEME_prefs_key)
    return


set_Color_Theme_from_pref()