Beispiel #1
0
    def finish(self, sorted_by_color):  #bruce 090224 split this out of caller
        """
        Finish collecting new primitives for use in self, and store them all
        in self, ready to be drawn in various ways.

        [meant to be called only by ColorSorter.start, for now]
        """
        ##        self._reset()
        ##            # (note: this deallocates any existing display lists)

        if self.transformControl and (self.spheres or self.cylinders):
            self.updateTransform()
            # needed to do the transform for the first time,
            # even if it didn't change. Review: refactor to
            # whereever we first compile these down? That
            # might be a different place in self.draw vs.
            # draw from DrawingSet.

        selColor = env.prefs[selectionColor_prefs_key]

        # Note: if sorted_by_color is empty, current code still builds all
        # toplevel display lists, though they are noops. This may be needed
        # by some client code which uses those dls directly. Client code
        # wanting to know if it needs to draw our dls should test
        # self.has_nonempty_DLs(), which tests self._per_color_dls,
        # or self.has_nonshader_drawing(), which reports on that or any
        # other kind of nonshader (immediate mode opengl) drawing we might
        # have. [bruce 090225/090312 comment]

        # First build the lower level per-color sublists of primitives.

        for color, funcs in sorted_by_color.iteritems():
            sublists = [glGenLists(1), 0]

            # Remember the display list ID for this color.
            self._per_color_dls.append([color, sublists])

            glNewList(sublists[0], GL_COMPILE)
            opacity = color[3]

            if opacity == -1:
                #russ 080306: "Unshaded colors" for lines are signaled
                # by an opacity of -1 (4th component of the color.)
                glDisable(GL_LIGHTING)  # Don't forget to re-enable it!
                pass

            for func, params, name in funcs:
                if name:
                    glPushName(name)
                else:
                    pass  ## print "bug_2: attempt to push non-glname", name
                func(params)  # Call the draw worker function.
                if name:
                    glPopName()
                    pass
                continue

            if opacity == -1:
                # Enable lighting after drawing "unshaded" objects.
                glEnable(GL_LIGHTING)
                pass
            glEndList()

            if opacity == -2:
                # piotr 080419: Special case for drawpolycone_multicolor
                # create another display list that ignores
                # the contents of color_array.
                # Remember the display list ID for this color.

                sublists[1] = glGenLists(1)

                glNewList(sublists[1], GL_COMPILE)

                for func, params, name in funcs:
                    if name:
                        glPushName(name)
                    else:
                        pass  ## print "bug_3: attempt to push non-glname", name
                    if func == drawpolycone_multicolor_worker:
                        # Just to be sure, check if the func
                        # is drawpolycone_multicolor_worker
                        # and call drawpolycone_worker instead.
                        # I think in the future we can figure out
                        # a more general way of handling the
                        # GL_COLOR_MATERIAL objects. piotr 080420
                        pos_array, color_array_junk, rad_array = params
                        drawpolycone_worker((pos_array, rad_array))
                    elif func == drawtriangle_strip_worker:
                        # piotr 080710: Multi-color modification
                        # for triangle_strip primitive (used by
                        # reduced protein style).
                        pos_array, normal_array, color_array_junk = params
                        drawtriangle_strip_worker(
                            (pos_array, normal_array, None))
                    if name:
                        glPopName()
                        pass
                    continue
                glEndList()

            continue

        # Now the upper-level lists call all of the per-color sublists.
        #### REVIEW: these are created even when empty. Is that necessary?
        # [bruce 090224 Q]

        # One with colors.
        color_dl = self.color_dl = glGenLists(1)
        glNewList(color_dl, GL_COMPILE)

        for color, dls in self._per_color_dls:

            opacity = color[3]
            if opacity < 0:
                #russ 080306: "Unshaded colors" for lines are signaled
                # by a negative alpha.
                glColor3fv(color[:3])
                # piotr 080417: for opacity == -2, i.e. if
                # GL_COLOR_MATERIAL is enabled, the color is going
                # to be ignored, anyway, so it is not necessary
                # to be tested here
            else:
                apply_material(color)

            glCallList(dls[0])

            continue
        glEndList()

        # A second one without any colors.
        nocolor_dl = self.nocolor_dl = glGenLists(1)
        glNewList(nocolor_dl, GL_COMPILE)
        for color, dls in self._per_color_dls:
            opacity = color[3]

            if opacity == -2 \
               and dls[1] > 0:
                # piotr 080420: If GL_COLOR_MATERIAL is enabled,
                # use a regular, single color dl rather than the
                # multicolor one. Btw, dls[1] == 0 should never
                # happen.
                glCallList(dls[1])
            else:
                glCallList(dls[0])

        glEndList()

        # A third DL implements the selected appearance.
        selected_dl = self.selected_dl = glGenLists(1)
        glNewList(selected_dl, GL_COMPILE)
        # russ 080530: Support for patterned selection drawing modes.
        patterned = isPatternedDrawing(select=True)
        if patterned:
            # Patterned drawing needs the colored dl drawn first.
            glCallList(color_dl)
            startPatternedDrawing(select=True)
            pass
        # Draw solid color (unpatterned) or an overlay pattern, in the
        # selection color.
        apply_material(selColor)
        glCallList(nocolor_dl)
        if patterned:
            # Reset from patterning drawing mode.
            endPatternedDrawing(select=True)
        glEndList()
        pass
Beispiel #2
0
    def finish():
        """
        Finish sorting - objects recorded since "start" will
        be sorted and invoked now.
        """
        from utilities.debug_prefs import debug_pref, Choice_boolean_False
        debug_which_renderer = debug_pref(
            "debug print which renderer",
            Choice_boolean_False)  #bruce 060314, imperfect but tolerable

        parent_csdl = ColorSorter.parent_csdl
        if drawing_globals.use_c_renderer:
            quux.shapeRendererInit()
            if debug_which_renderer:
                #bruce 060314 uncommented/revised the next line; it might have
                # to come after shapeRendererInit (not sure); it definitely has
                # to come after a graphics context is created and initialized.
                # 20060314 grantham - yes, has to come after
                # quux.shapeRendererInit .
                enabled = quux.shapeRendererGetInteger(quux.IS_VBO_ENABLED)
                print("using C renderer: VBO %s enabled" %
                      (('is NOT', 'is')[enabled]))
            quux.shapeRendererSetUseDynamicLOD(0)
            if ColorSorter.sphereLevel != -1:
                quux.shapeRendererSetStaticLODLevels(ColorSorter.sphereLevel,
                                                     1)
            quux.shapeRendererStartDrawing()
            ColorSorter._cur_shapelist.draw()
            quux.shapeRendererFinishDrawing()
            ColorSorter.sorting = False

            # So chunks can actually record their shapelist
            # at some point if they want to
            # ColorSorter._cur_shapelist.petrify()
            # return ColorSorter._cur_shapelist

        else:
            if debug_which_renderer:
                print(
                    "using Python renderer: use_color_sorted_dls %s enabled" %
                    (drawing_globals.use_color_sorted_dls and 'IS'
                     or 'is NOT'))
                print(
                    "using Python renderer: use_color_sorted_vbos %s enabled" %
                    (drawing_globals.use_color_sorted_vbos and 'IS'
                     or 'is NOT'))
            color_groups = len(ColorSorter.sorted_by_color)
            objects_drawn = 0

            if (not (drawing_globals.allow_color_sorting
                     and drawing_globals.use_color_sorted_dls)
                    or (ColorSortedDisplayList.cache_ColorSorter
                        and drawing_globals.allow_color_sorting
                        and drawing_globals.use_color_sorted_vbos)
                    #russ 080225 Added, 080320 VBO experiment.
                    or parent_csdl is None):

                # Either all in one display list, or immediate-mode drawing.
                objects_drawn += ColorSorter.draw_sorted(
                    ColorSorter.sorted_by_color)

                #russ 080225: Moved glEndList here for displist re-org.
                if parent_csdl is not None:
                    #russ 080320: Experiment with VBO drawing from cached
                    #ColorSorter lists.
                    if (ColorSortedDisplayList.cache_ColorSorter
                            and drawing_globals.allow_color_sorting
                            and drawing_globals.use_color_sorted_vbos):
                        # Remember the ColorSorter lists for use as a
                        # pseudo-display-list.
                        parent_csdl.sorted_by_color = \
                                   ColorSorter.sorted_by_color
                    else:
                        # Terminate a single display list, created when color
                        # sorting is turned off.  Started in ColorSorter.start .
                        glEndList()
                    pass
                pass

            else:  #russ 080225

                parent_csdl.reset()
                selColor = env.prefs[selectionColor_prefs_key]

                # First build the lower level per-color sublists of primitives.
                for color, funcs in ColorSorter.sorted_by_color.iteritems():
                    sublists = [glGenLists(1), 0]

                    # Remember the display list ID for this color.
                    parent_csdl.per_color_dls.append([color, sublists])

                    glNewList(sublists[0], GL_COMPILE)
                    opacity = color[3]

                    if opacity == -1:
                        #russ 080306: "Unshaded colors" for lines are signaled
                        # by an opacity of -1 (4th component of the color.)
                        glDisable(GL_LIGHTING)  # Don't forget to re-enable it!
                        pass

                    for func, params, name in funcs:
                        objects_drawn += 1
                        if name != 0:
                            glPushName(name)
                        func(params)
                        if name != 0:
                            glPopName()
                            pass
                        continue

                    if opacity == -1:
                        # Enable lighting after drawing "unshaded" objects.
                        glEnable(GL_LIGHTING)
                        pass
                    glEndList()

                    if opacity == -2:
                        # piotr 080419: Special case for drawpolycone_multicolor
                        # create another display list that ignores
                        # the contents of color_array.
                        # Remember the display list ID for this color.

                        sublists[1] = glGenLists(1)

                        glNewList(sublists[1], GL_COMPILE)

                        for func, params, name in funcs:
                            objects_drawn += 1
                            if name != 0:
                                glPushName(name)
                            if func == drawpolycone_multicolor_worker:
                                # Just to be sure, check if the func
                                # is drawpolycone_multicolor_worker
                                # and call drawpolycone_worker instead.
                                # I think in the future we can figure out
                                # a more general way of handling the
                                # GL_COLOR_MATERIAL objects. piotr 080420
                                pos_array, color_array, rad_array = params
                                drawpolycone_worker((pos_array, rad_array))
                            elif func == drawtriangle_strip_worker:
                                # piotr 080710: Multi-color modification
                                # for triangle_strip primitive (used by
                                # reduced protein style).
                                pos_array, normal_array, color_array = params
                                drawtriangle_strip_worker(
                                    (pos_array, normal_array, None))
                            if name != 0:
                                glPopName()
                                pass
                            continue
                        glEndList()

                    continue

                # Now the upper-level lists call all of the per-color sublists.
                # One with colors.
                color_dl = parent_csdl.color_dl = glGenLists(1)
                glNewList(color_dl, GL_COMPILE)

                for color, dls in parent_csdl.per_color_dls:

                    opacity = color[3]
                    if opacity < 0:
                        #russ 080306: "Unshaded colors" for lines are signaled
                        # by a negative alpha.
                        glColor3fv(color[:3])
                        # piotr 080417: for opacity == -2, i.e. if
                        # GL_COLOR_MATERIAL is enabled, the color is going
                        # to be ignored, anyway, so it is not necessary
                        # to be tested here
                    else:
                        apply_material(color)

                    glCallList(dls[0])

                    continue
                glEndList()

                # A second one without any colors.
                nocolor_dl = parent_csdl.nocolor_dl = glGenLists(1)
                glNewList(nocolor_dl, GL_COMPILE)
                for color, dls in parent_csdl.per_color_dls:
                    opacity = color[3]

                    if opacity == -2 \
                       and dls[1] > 0:
                        # piotr 080420: If GL_COLOR_MATERIAL is enabled,
                        # use a regular, single color dl rather than the
                        # multicolor one. Btw, dls[1] == 0 should never
                        # happen.
                        glCallList(dls[1])
                    else:
                        glCallList(dls[0])

                glEndList()

                # A third DL implements the selected appearance.
                selected_dl = parent_csdl.selected_dl = glGenLists(1)
                glNewList(selected_dl, GL_COMPILE)
                # russ 080530: Support for patterned selection drawing modes.
                patterned = isPatternedDrawing(select=True)
                if patterned:
                    # Patterned drawing needs the colored dl drawn first.
                    glCallList(color_dl)
                    startPatternedDrawing(select=True)
                    pass
                # Draw solid color (unpatterned) or an overlay pattern, in the
                # selection color.
                apply_material(selColor)
                glCallList(nocolor_dl)
                if patterned:
                    # Reset from patterning drawing mode.
                    endPatternedDrawing(select=True)
                glEndList()

                # Use either the normal-color display list or the selected one.
                parent_csdl.selectDl()

                # Draw the newly-built display list.
                parent_csdl.draw_dl()
                pass

            ColorSorter.sorted_by_color = None
            pass
        ColorSorter.sorting = False
        return
    def finish(self, sorted_by_color):  # bruce 090224 split this out of caller
        """
        Finish collecting new primitives for use in self, and store them all
        in self, ready to be drawn in various ways.

        [meant to be called only by ColorSorter.start, for now]
        """
        ##        self._reset()
        ##            # (note: this deallocates any existing display lists)

        if self.transformControl and (self.spheres or self.cylinders):
            self.updateTransform()
            # needed to do the transform for the first time,
            # even if it didn't change. Review: refactor to
            # whereever we first compile these down? That
            # might be a different place in self.draw vs.
            # draw from DrawingSet.

        selColor = env.prefs[selectionColor_prefs_key]

        # Note: if sorted_by_color is empty, current code still builds all
        # toplevel display lists, though they are noops. This may be needed
        # by some client code which uses those dls directly. Client code
        # wanting to know if it needs to draw our dls should test
        # self.has_nonempty_DLs(), which tests self._per_color_dls,
        # or self.has_nonshader_drawing(), which reports on that or any
        # other kind of nonshader (immediate mode opengl) drawing we might
        # have. [bruce 090225/090312 comment]

        # First build the lower level per-color sublists of primitives.

        for color, funcs in sorted_by_color.iteritems():
            sublists = [glGenLists(1), 0]

            # Remember the display list ID for this color.
            self._per_color_dls.append([color, sublists])

            glNewList(sublists[0], GL_COMPILE)
            opacity = color[3]

            if opacity == -1:
                # russ 080306: "Unshaded colors" for lines are signaled
                # by an opacity of -1 (4th component of the color.)
                glDisable(GL_LIGHTING)  # Don't forget to re-enable it!
                pass

            for func, params, name in funcs:
                if name:
                    glPushName(name)
                else:
                    pass  ## print "bug_2: attempt to push non-glname", name
                func(params)  # Call the draw worker function.
                if name:
                    glPopName()
                    pass
                continue

            if opacity == -1:
                # Enable lighting after drawing "unshaded" objects.
                glEnable(GL_LIGHTING)
                pass
            glEndList()

            if opacity == -2:
                # piotr 080419: Special case for drawpolycone_multicolor
                # create another display list that ignores
                # the contents of color_array.
                # Remember the display list ID for this color.

                sublists[1] = glGenLists(1)

                glNewList(sublists[1], GL_COMPILE)

                for func, params, name in funcs:
                    if name:
                        glPushName(name)
                    else:
                        pass  ## print "bug_3: attempt to push non-glname", name
                    if func == drawpolycone_multicolor_worker:
                        # Just to be sure, check if the func
                        # is drawpolycone_multicolor_worker
                        # and call drawpolycone_worker instead.
                        # I think in the future we can figure out
                        # a more general way of handling the
                        # GL_COLOR_MATERIAL objects. piotr 080420
                        pos_array, color_array_junk, rad_array = params
                        drawpolycone_worker((pos_array, rad_array))
                    elif func == drawtriangle_strip_worker:
                        # piotr 080710: Multi-color modification
                        # for triangle_strip primitive (used by
                        # reduced protein style).
                        pos_array, normal_array, color_array_junk = params
                        drawtriangle_strip_worker((pos_array, normal_array, None))
                    if name:
                        glPopName()
                        pass
                    continue
                glEndList()

            continue

        # Now the upper-level lists call all of the per-color sublists.
        #### REVIEW: these are created even when empty. Is that necessary?
        # [bruce 090224 Q]

        # One with colors.
        color_dl = self.color_dl = glGenLists(1)
        glNewList(color_dl, GL_COMPILE)

        for color, dls in self._per_color_dls:

            opacity = color[3]
            if opacity < 0:
                # russ 080306: "Unshaded colors" for lines are signaled
                # by a negative alpha.
                glColor3fv(color[:3])
                # piotr 080417: for opacity == -2, i.e. if
                # GL_COLOR_MATERIAL is enabled, the color is going
                # to be ignored, anyway, so it is not necessary
                # to be tested here
            else:
                apply_material(color)

            glCallList(dls[0])

            continue
        glEndList()

        # A second one without any colors.
        nocolor_dl = self.nocolor_dl = glGenLists(1)
        glNewList(nocolor_dl, GL_COMPILE)
        for color, dls in self._per_color_dls:
            opacity = color[3]

            if opacity == -2 and dls[1] > 0:
                # piotr 080420: If GL_COLOR_MATERIAL is enabled,
                # use a regular, single color dl rather than the
                # multicolor one. Btw, dls[1] == 0 should never
                # happen.
                glCallList(dls[1])
            else:
                glCallList(dls[0])

        glEndList()

        # A third DL implements the selected appearance.
        selected_dl = self.selected_dl = glGenLists(1)
        glNewList(selected_dl, GL_COMPILE)
        # russ 080530: Support for patterned selection drawing modes.
        patterned = isPatternedDrawing(select=True)
        if patterned:
            # Patterned drawing needs the colored dl drawn first.
            glCallList(color_dl)
            startPatternedDrawing(select=True)
            pass
        # Draw solid color (unpatterned) or an overlay pattern, in the
        # selection color.
        apply_material(selColor)
        glCallList(nocolor_dl)
        if patterned:
            # Reset from patterning drawing mode.
            endPatternedDrawing(select=True)
        glEndList()
        pass
Beispiel #4
0
    def finish():
        """
        Finish sorting - objects recorded since "start" will
        be sorted and invoked now.
        """
        from utilities.debug_prefs import debug_pref, Choice_boolean_False
        debug_which_renderer = debug_pref(
            "debug print which renderer",
            Choice_boolean_False) #bruce 060314, imperfect but tolerable

        parent_csdl = ColorSorter.parent_csdl
        if drawing_globals.use_c_renderer:
            quux.shapeRendererInit()
            if debug_which_renderer:
                #bruce 060314 uncommented/revised the next line; it might have
                # to come after shapeRendererInit (not sure); it definitely has
                # to come after a graphics context is created and initialized.
                # 20060314 grantham - yes, has to come after
                # quux.shapeRendererInit .
                enabled = quux.shapeRendererGetInteger(quux.IS_VBO_ENABLED)
                print ("using C renderer: VBO %s enabled" %
                       (('is NOT', 'is')[enabled]))
            quux.shapeRendererSetUseDynamicLOD(0)
            if ColorSorter.sphereLevel != -1:
                quux.shapeRendererSetStaticLODLevels(ColorSorter.sphereLevel, 1)
            quux.shapeRendererStartDrawing()
            ColorSorter._cur_shapelist.draw()
            quux.shapeRendererFinishDrawing()
            ColorSorter.sorting = False

            # So chunks can actually record their shapelist
            # at some point if they want to
            # ColorSorter._cur_shapelist.petrify()
            # return ColorSorter._cur_shapelist      

        else:
            if debug_which_renderer:
                print ("using Python renderer: use_color_sorted_dls %s enabled"
                       % (drawing_globals.use_color_sorted_dls and 'IS'
                          or 'is NOT'))
                print ("using Python renderer: use_color_sorted_vbos %s enabled"
                       % (drawing_globals.use_color_sorted_vbos and 'IS'
                          or 'is NOT'))
            color_groups = len(ColorSorter.sorted_by_color)
            objects_drawn = 0

            if (not (drawing_globals.allow_color_sorting and
                     drawing_globals.use_color_sorted_dls)
                or (ColorSortedDisplayList.cache_ColorSorter and
                    drawing_globals.allow_color_sorting and
                    drawing_globals.use_color_sorted_vbos)
                #russ 080225 Added, 080320 VBO experiment.
                or parent_csdl is None):

                # Either all in one display list, or immediate-mode drawing.
                objects_drawn += ColorSorter.draw_sorted(
                    ColorSorter.sorted_by_color)

                #russ 080225: Moved glEndList here for displist re-org.
                if parent_csdl is not None:
                    #russ 080320: Experiment with VBO drawing from cached
                    #ColorSorter lists.
                    if (ColorSortedDisplayList.cache_ColorSorter and
                        drawing_globals.allow_color_sorting and
                        drawing_globals.use_color_sorted_vbos):
                        # Remember the ColorSorter lists for use as a
                        # pseudo-display-list.
                        parent_csdl.sorted_by_color = \
                                   ColorSorter.sorted_by_color
                    else:
                        # Terminate a single display list, created when color
                        # sorting is turned off.  Started in ColorSorter.start .
                        glEndList()
                    pass
                pass

            else: #russ 080225

                parent_csdl.reset()
                selColor = env.prefs[selectionColor_prefs_key]

                # First build the lower level per-color sublists of primitives.
                for color, funcs in ColorSorter.sorted_by_color.iteritems():
                    sublists = [glGenLists(1), 0]

                    # Remember the display list ID for this color.
                    parent_csdl.per_color_dls.append([color, sublists])

                    glNewList(sublists[0], GL_COMPILE)
                    opacity = color[3]

                    if opacity == -1:
                        #russ 080306: "Unshaded colors" for lines are signaled
                        # by an opacity of -1 (4th component of the color.)
                        glDisable(GL_LIGHTING) # Don't forget to re-enable it!
                        pass

                    for func, params, name in funcs:
                        objects_drawn += 1
                        if name != 0:
                            glPushName(name)
                        func(params)
                        if name != 0:
                            glPopName()
                            pass
                        continue

                    if opacity == -1:
                        # Enable lighting after drawing "unshaded" objects.
                        glEnable(GL_LIGHTING)
                        pass
                    glEndList()

                    if opacity == -2:
                        # piotr 080419: Special case for drawpolycone_multicolor
                        # create another display list that ignores
                        # the contents of color_array.
                        # Remember the display list ID for this color.

                        sublists[1] = glGenLists(1)

                        glNewList(sublists[1], GL_COMPILE)

                        for func, params, name in funcs:
                            objects_drawn += 1
                            if name != 0:
                                glPushName(name)
                            if func == drawpolycone_multicolor_worker:
                                # Just to be sure, check if the func
                                # is drawpolycone_multicolor_worker
                                # and call drawpolycone_worker instead.
                                # I think in the future we can figure out 
                                # a more general way of handling the 
                                # GL_COLOR_MATERIAL objects. piotr 080420
                                pos_array, color_array, rad_array = params
                                drawpolycone_worker((pos_array, rad_array))
                            elif func == drawtriangle_strip_worker:
                                # piotr 080710: Multi-color modification
                                # for triangle_strip primitive (used by 
                                # reduced protein style).
                                pos_array, normal_array, color_array = params
                                drawtriangle_strip_worker((pos_array, 
                                                           normal_array,
                                                           None))
                            if name != 0:
                                glPopName()
                                pass
                            continue
                        glEndList()

                    continue

                # Now the upper-level lists call all of the per-color sublists.
                # One with colors.
                color_dl = parent_csdl.color_dl = glGenLists(1)
                glNewList(color_dl, GL_COMPILE)

                for color, dls in parent_csdl.per_color_dls:

                    opacity = color[3]
                    if opacity < 0:
                        #russ 080306: "Unshaded colors" for lines are signaled
                        # by a negative alpha.
                        glColor3fv(color[:3])
                        # piotr 080417: for opacity == -2, i.e. if
                        # GL_COLOR_MATERIAL is enabled, the color is going 
                        # to be ignored, anyway, so it is not necessary
                        # to be tested here
                    else:
                        apply_material(color)

                    glCallList(dls[0])

                    continue
                glEndList()

                # A second one without any colors.
                nocolor_dl = parent_csdl.nocolor_dl = glGenLists(1)
                glNewList(nocolor_dl, GL_COMPILE)
                for color, dls in parent_csdl.per_color_dls:                    
                    opacity = color[3]

                    if opacity == -2 \
                       and dls[1] > 0:
                        # piotr 080420: If GL_COLOR_MATERIAL is enabled,
                        # use a regular, single color dl rather than the
                        # multicolor one. Btw, dls[1] == 0 should never 
                        # happen.
                        glCallList(dls[1])
                    else:
                        glCallList(dls[0])

                glEndList()

                # A third DL implements the selected appearance.
                selected_dl = parent_csdl.selected_dl = glGenLists(1)
                glNewList(selected_dl, GL_COMPILE)
                # russ 080530: Support for patterned selection drawing modes.
                patterned = isPatternedDrawing(select = True)
                if patterned:
                    # Patterned drawing needs the colored dl drawn first.
                    glCallList(color_dl)
                    startPatternedDrawing(select = True)
                    pass
                # Draw solid color (unpatterned) or an overlay pattern, in the
                # selection color.
                apply_material(selColor)
                glCallList(nocolor_dl)
                if patterned:
                    # Reset from patterning drawing mode.
                    endPatternedDrawing(select = True)
                glEndList()

                # Use either the normal-color display list or the selected one.
                parent_csdl.selectDl()

                # Draw the newly-built display list.
                parent_csdl.draw_dl()
                pass

            ColorSorter.sorted_by_color = None
            pass
        ColorSorter.sorting = False
        return