def __init__(self, parent, shareWidget, useStencilBuffer):
        """
        If shareWidget is specified, useStencilBuffer is ignored: set it in the widget you're sharing with.
        """

        if shareWidget:
            self.shareWidget = shareWidget  #bruce 051212
            glformat = shareWidget.format()
            QGLWidget.__init__(self, glformat, parent, shareWidget)
            if not self.isSharing():
                print "Request of display list sharing is failed."
                return
        else:
            glformat = QGLFormat()
            if (useStencilBuffer):
                glformat.setStencil(True)
                # set gl format to request stencil buffer
                # (needed for mouseover-highlighting of objects of general
                #  shape in depositMode.bareMotion) [bruce 050610]

            QGLWidget.__init__(self, glformat, parent)

        # Current view attributes (sometimes saved in or loaded from
        #  the currently displayed part or its mmp file):

        # rotation
        self.quat = Q(1, 0, 0, 0)

        # point of view (i.e. negative of center of view)
        self.pov = V(0.0, 0.0, 0.0)

        # half-height of window in Angstroms (reset by certain view-changing operations)
        self.scale = float(env.prefs[startup_GLPane_scale_prefs_key])

        # zoom factor
        self.zoomFactor = 1.0

        self.trackball = Trackball(10, 10)

        self._functions_to_call_when_gl_context_is_current = []

        # piotr 080714: Defined this attribute here in case
        # chunk.py accesses it in ThumbView.
        self.lastNonReducedDisplayMode = default_display_mode
        return
Exemple #2
0
    def __init__(self, parent, shareWidget, useStencilBuffer):
        """
        #doc
        
        @note: If shareWidget is specified, useStencilBuffer is ignored:
               set it in the widget you're sharing with.
        """
        if shareWidget:
            self.shareWidget = shareWidget  #bruce 051212
            glformat = shareWidget.format()
            QGLWidget.__init__(self, glformat, parent, shareWidget)
            if not self.isSharing():
                assert 0, "%r refused to share GL display list namespace " \
                          "with %r" % (self, shareWidget)
                return
        else:
            glformat = QGLFormat()
            if (useStencilBuffer):
                glformat.setStencil(True)
                # set gl format to request stencil buffer
                # (needed for mouseover-highlighting of objects of general
                #  shape in BuildAtoms_Graphicsmode.bareMotion) [bruce 050610]

            if (self.useMultisample):
                # use full scene anti-aliasing on hardware that supports it
                # (note: setting this True works around bug 2961 on some systems)
                glformat.setSampleBuffers(True)

            QGLWidget.__init__(self, glformat, parent)
            pass

        self.glprefs = drawing_globals.glprefs
        # future: should be ok if this differs for different glpanes,
        # even between self and self.shareWidget. AFAIK, the refactoring
        # I'm doing yesterday and today means this would work fine,
        # or at least it does most of what would be required for that.
        # [bruce 090304]

        self._initialize_view_attributes()

        # Initial value of depth "constant" (changeable by prefs.)
        self.DEPTH_TWEAK = DEPTH_TWEAK_UNITS * DEPTH_TWEAK_VALUE

        self.trackball = Trackball(10, 10)

        self._functions_to_call_when_gl_context_is_current = []

        # piotr 080714: Defined this attribute here in case
        # chunk.py accesses it in ThumbView.
        self.lastNonReducedDisplayMode = default_display_mode

        # piotr 080807
        # Most recent quaternion to be used in animation timer.
        self.last_quat = None

        self.transforms = [
        ]  ### TODO: clear this at start of frame, complain if not clear
        # stack of current transforms (or Nodes that generate them)
        # [bruce 090220]
        # Note: this may be revised once we have TransformNode,
        # e.g. we might push their dt and st separately;
        # note we might need to push a "slot" for them if they might
        # change before being popped, or perhaps even if they might
        # change between the time pushed and the time later used
        # (by something that collects them from here in association
        #  with a ColorSortedDisplayList).

        return