Пример #1
0
    def test_global_disable_update(self):
        # Given
        p = Prop()
        vp = tvtk_base.deref_vtk(p)

        # When
        with tvtk_base.global_disable_update():
            vp.SetOpacity(0.5)
            vp.Modified()

        # Then
        self.assertEqual(p.opacity, 1.0)

        # When
        vp.SetOpacity(0.4)

        # Then
        self.assertEqual(p.opacity, 0.4)
Пример #2
0
    def test_global_disable_update(self):
        # Given
        p = Prop()
        vp = tvtk_base.deref_vtk(p)

        # When
        with tvtk_base.global_disable_update():
            vp.SetOpacity(0.5)
            vp.Modified()

        # Then
        self.assertEqual(p.opacity, 1.0)

        # When
        vp.SetOpacity(0.4)

        # Then
        self.assertEqual(p.opacity, 0.4)
Пример #3
0
    def call_rwi(self, method, *args):
        if method == 'SetSize':
            # This is an issue with the way TVTK is setup and how VTK resizes
            # an offscreen window. It basically releases all graphics resources
            # and this job is passed on to the various mappers. When the mapper
            # does this it emits a ModifiedEvent which is picked by TVTK to
            # fire a render. This call to render when the window is resizing
            # locks up VTK or entirely messes up the rendering. I've reported
            # this upstream but it turns out that disabling the auto updates in
            # TVTK maybe of general use so we have a convenient context manager
            # to do this called `global_disable_update` that shuts off the
            # automatic updates for ALL TVTK objects for a brief while. This
            # fixes the issue.
            with global_disable_update():
                self.trw.size = args
                self.trw.render()

        if 'PressEvent' in method:
            self.image_encoder.compress = True
        if 'ReleaseEvent' in method:
            self.image_encoder.compress = False

        getattr(self.rwi, method)(*args)
Пример #4
0
    def call_rwi(self, method, *args):
        if method == 'SetSize':
            # This is an issue with the way TVTK is setup and how VTK resizes
            # an offscreen window. It basically releases all graphics resources
            # and this job is passed on to the various mappers. When the mapper
            # does this it emits a ModifiedEvent which is picked by TVTK to
            # fire a render. This call to render when the window is resizing
            # locks up VTK or entirely messes up the rendering. I've reported
            # this upstream but it turns out that disabling the auto updates in
            # TVTK maybe of general use so we have a convenient context manager
            # to do this called `global_disable_update` that shuts off the
            # automatic updates for ALL TVTK objects for a brief while. This
            # fixes the issue.
            with global_disable_update():
                self.trw.size = args
                self.trw.render()

        if 'PressEvent' in method:
            self.image_encoder.compress = True
        if 'ReleaseEvent' in method:
            self.image_encoder.compress = False

        getattr(self.rwi, method)(*args)