def testPerChannelHash(self): i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_half_max.exr" )) clamp = GafferImage.Clamp() clamp["in"].setInput(i["out"]) clamp["max"].setValue(imath.Color4f(1., 1., 1., 1.)) redHash = clamp["out"].channelDataHash("R", imath.V2i(0)) greenHash = clamp["out"].channelDataHash("G", imath.V2i(0)) blueHash = clamp["out"].channelDataHash("B", imath.V2i(0)) clamp["max"].setValue(imath.Color4f(.25, 1., 1., 1.)) redHash2 = clamp["out"].channelDataHash("R", imath.V2i(0)) greenHash2 = clamp["out"].channelDataHash("G", imath.V2i(0)) blueHash2 = clamp["out"].channelDataHash("B", imath.V2i(0)) self.assertNotEqual(redHash, redHash2) self.assertEqual(greenHash, greenHash2) self.assertEqual(blueHash, blueHash2)
def testPassThrough(self): i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_half_max.exr" )) c = GafferImage.Clamp() c["in"].setInput(i["out"]) c["max"].setValue(imath.Color4f(.5, .5, .5, .5)) self.assertEqual(i["out"]["format"].hash(), c["out"]["format"].hash()) self.assertEqual(i["out"]["dataWindow"].hash(), c["out"]["dataWindow"].hash()) self.assertEqual(i["out"]["metadata"].hash(), c["out"]["metadata"].hash()) self.assertEqual(i["out"]["channelNames"].hash(), c["out"]["channelNames"].hash()) self.assertEqual(i["out"]["format"].getValue(), c["out"]["format"].getValue()) self.assertEqual(i["out"]["dataWindow"].getValue(), c["out"]["dataWindow"].getValue()) self.assertEqual(i["out"]["metadata"].getValue(), c["out"]["metadata"].getValue()) self.assertEqual(i["out"]["channelNames"].getValue(), c["out"]["channelNames"].getValue())
def testDefaultState( self ) : clamp = GafferImage.Clamp() self.assertTrue( clamp['minEnabled'].getValue() ) self.assertTrue( clamp['maxEnabled'].getValue() ) self.assertFalse( clamp['minClampToEnabled'].getValue() ) self.assertFalse( clamp['maxClampToEnabled'].getValue() )
def testEnableBehaviour( self ) : clamp = GafferImage.Clamp() self.assertTrue( clamp.enabledPlug().isSame( clamp["enabled"] ) ) self.assertTrue( clamp.correspondingInput( clamp["out"] ).isSame( clamp["in"] ) ) self.assertEqual( clamp.correspondingInput( clamp["in"] ), None ) self.assertEqual( clamp.correspondingInput( clamp["enabled"] ), None ) self.assertEqual( clamp.correspondingInput( clamp["min"] ), None )
def testClamp( self ) : i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_half_max.exr" ) ) clamp = GafferImage.Clamp() clamp["in"].setInput(i["out"]) clamp["max"].setValue( IECore.Color4f( .5, .5, .5, .5 ) ) self.assertEqual(i['out'].image().hash(), clamp['out'].image().hash())
def testEnabledBypass( self ) : i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_half_max.exr" ) ) clamp = GafferImage.Clamp() clamp["in"].setInput(i["out"]) clamp["minEnabled"].setValue( False ) clamp["maxEnabled"].setValue( False ) self.assertEqual( i["out"].imageHash(), clamp["out"].imageHash() ) self.assertEqual( i["out"]["format"].hash(), clamp["out"]["format"].hash() ) self.assertEqual( i["out"]["dataWindow"].hash(), clamp["out"]["dataWindow"].hash() ) self.assertEqual( i["out"]["channelNames"].hash(), clamp["out"]["channelNames"].hash() )
def testClampWithMaxTo( self ) : i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_max_clamp.exr" ) ) clamp = GafferImage.Clamp() clamp["in"].setInput(i["out"]) clamp["min"].setValue( IECore.Color4f( .0, .0, .0, .0 ) ) clamp["max"].setValue( IECore.Color4f( .0, .25, .25, .25 ) ) clamp["minClampTo"].setValue( IECore.Color4f( .0, .0, .0, .0 ) ) clamp["maxClampTo"].setValue( IECore.Color4f( 1., .5, .25, 1. ) ) clamp["minEnabled"].setValue( True ) clamp["maxEnabled"].setValue( True ) clamp["minClampToEnabled"].setValue( False ) clamp["maxClampToEnabled"].setValue( True ) self.assertEqual(i['out'].image().hash(), clamp['out'].image().hash())
def testDisconnectedDirty( self ) : r = GafferImage.ImageReader() r["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_half_max.exr" ) ) clamp = GafferImage.Clamp() clamp["in"].setInput( r["out"] ) cs = GafferTest.CapturingSlot( clamp.plugDirtiedSignal() ) clamp["max"].setValue( IECore.Color4f( .25, 1., 1., 1. ) ) dirtiedPlugs = set( [ x[0].relativeName( x[0].node() ) for x in cs ] ) expectedPlugs = [ 'out.channelData', 'out' ] for plug in expectedPlugs : self.assertTrue( plug in dirtiedPlugs )