def testDestroyWhileProcessing(self): s = Gaffer.ScriptNode() s["c"] = GafferImage.Constant() s["c"]["format"].setValue(GafferImage.Format(2000, 2000)) s["b"] = GafferImage.Blur() s["b"]["in"].setInput(s["c"]["out"]) s["b"]["radius"].setValue(imath.V2f(400)) g = GafferImageUI.ImageGadget() g.setImage(s["b"]["out"]) with GafferUI.Window() as w: GafferUI.GadgetWidget(g) w.setVisible(True) # If this computer doesn't support floating point textures, the ImageGadget will warn about # this the first time it tries to render. Don't fail because of this with IECore.CapturingMessageHandler() as mh: self.waitForIdle(1000) if len(mh.messages): self.assertEqual(len(mh.messages), 1) self.assertEqual(mh.messages[0].context, "ImageGadget") self.assertEqual( mh.messages[0].message, "Could not find supported floating point texture format in OpenGL. GPU image viewer path will be low quality, recommend switching to CPU display transform, or resolving graphics driver issue." ) del g, w del s
def testBound(self): g = GafferImageUI.ImageGadget() self.assertEqual(g.bound(), imath.Box3f()) c = GafferImage.Constant() c["format"].setValue(GafferImage.Format(200, 100)) g.setImage(c["out"]) self.assertEqual(g.bound(), imath.Box3f(imath.V3f(0), imath.V3f(200, 100, 0))) c["format"].setValue(GafferImage.Format(200, 100, 2)) self.assertEqual(g.bound(), imath.Box3f(imath.V3f(0), imath.V3f(400, 100, 0))) c2 = GafferImage.Constant() g.setImage(c2["out"]) f = GafferImage.FormatPlug.getDefaultFormat( g.getContext()).getDisplayWindow() self.assertEqual( g.bound(), imath.Box3f(imath.V3f(f.min().x, f.min().y, 0), imath.V3f(f.max().x, f.max().y, 0))) GafferImage.FormatPlug.setDefaultFormat( g.getContext(), GafferImage.Format( imath.Box2i(imath.V2i(10, 20), imath.V2i(30, 40)))) self.assertEqual( g.bound(), imath.Box3f(imath.V3f(10, 20, 0), imath.V3f(30, 40, 0)))
def testGetImage(self): g = GafferImageUI.ImageGadget() self.assertEqual(g.getImage(), None) c = GafferImage.Constant() g.setImage(c["out"]) self.assertTrue(g.getImage().isSame(c["out"]))
def testStateChangedSignal(self): image = GafferImage.Constant() gadget = GafferImageUI.ImageGadget() gadget.setImage(image["out"]) self.assertNotEqual(gadget.state(), gadget.State.Paused) cs = GafferTest.CapturingSlot(gadget.stateChangedSignal()) gadget.setPaused(True) self.assertEqual(len(cs), 1) self.assertEqual(gadget.state(), gadget.State.Paused) gadget.setPaused(False) self.assertEqual(len(cs), 2) self.assertNotEqual(gadget.state(), gadget.State.Paused)
def testCreation( self ): # Create a node to make sure that we have a default format... s = Gaffer.ScriptNode() n = GafferImage.Grade() s.addChild( n ) # Get the format names formatNames = GafferImage.Format.formatNames() # Create the plug's ui element. fw = GafferImageUI.FormatPlugValueWidget( s["defaultFormat"], lazy=False ) # Now compare the format names against those in the UI element. self.assertEqual( len( fw ), len( formatNames ) )
def testAccessors( self ) : # Create a node to make sure that we have a default format... s = Gaffer.ScriptNode() n = GafferImage.Grade() s.addChild( n ) # Create the plug's ui element. fw = GafferImageUI.FormatPlugValueWidget( s["defaultFormat"], lazy=False ) # Test the accessors formatNameAndValue = fw[0] self.assertTrue( isinstance( formatNameAndValue[0], str ) ) self.assertTrue( isinstance( formatNameAndValue[1], GafferImage.Format ) ) self.assertEqual( fw[ formatNameAndValue[0] ], formatNameAndValue[1] ) self.assertEqual( fw[ formatNameAndValue[1] ], formatNameAndValue[0] )
def testDestroyWhileProcessing( self ) : s = Gaffer.ScriptNode() s["c"] = GafferImage.Constant() s["c"]["format"].setValue( GafferImage.Format( 2000, 2000 ) ) s["b"] = GafferImage.Blur() s["b"]["in"].setInput( s["c"]["out"] ) s["b"]["radius"].setValue( imath.V2f( 400 ) ) g = GafferImageUI.ImageGadget() g.setImage( s["b"]["out"] ) with GafferUI.Window() as w : GafferUI.GadgetWidget( g ) w.setVisible( True ) self.waitForIdle( 1000 ) del g, w del s
def testImageGadget(self): view = GafferImageUI.ImageView() self.assertIsInstance(view.imageGadget(), GafferImageUI.ImageGadget) self.assertTrue(view.viewportGadget().isAncestorOf(view.imageGadget()))