Skip to content

Commit

Permalink
Shuffle : Improve ChannelPlug compatibility
Browse files Browse the repository at this point in the history
And add test demonstrating that expressions can still be made using the old names for plugs. This is necessary for an internal expression created by a node at Cinesite.
  • Loading branch information
johnhaddon committed Mar 19, 2024
1 parent 9710107 commit b8038fc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Fixes
-----

- Expression : `setExpression()` now respects configs that provide backwards compatibility for old plug names.
- Shuffle : Fixed default name for plugs constructed via the legacy `ChannelPlug( out, in )` constructor [^1].

[^1]: To be omitted from final release notes for 1.4.0.0.

1.4.0.0b4 (relative to 1.4.0.0b3)
=========
Expand Down
20 changes: 20 additions & 0 deletions python/GafferImageTest/ShuffleTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,5 +412,25 @@ def testIgnoreMissingSourceDoesnCreateChannels( self ) :
shuffle["missingSourceMode"].setValue( shuffle.MissingSourceMode.Ignore )
self.assertEqual( shuffle["out"].channelNames(), IECore.StringVectorData( [ "R", "G", "B", "A" ] ) )

def testLegacyChannelPlugConstructor( self ) :

p = GafferImage.Shuffle.ChannelPlug( "R", "R" )
self.assertEqual( p.getName(), "channel" )

def testCreateExpressionWithLegacyNames( self ) :

script = Gaffer.ScriptNode()
script["shuffle"] = GafferImage.Shuffle()
script["shuffle"]["shuffles"].addChild( GafferImage.Shuffle.ChannelPlug( "R", "R" ) )
script["shuffle"]["shuffles"].addChild( GafferImage.Shuffle.ChannelPlug( "G", "G" ) )

script["expression"] = Gaffer.Expression()
script["expression"].setExpression(
'parent["shuffle"]["channels"]["channel"]["in"] = "X"; parent["shuffle"]["channels"]["channel1"]["in"] = "Y"'
)

self.assertEqual( script["shuffle"]["shuffles"][0]["source"].getValue(), "X" )
self.assertEqual( script["shuffle"]["shuffles"][1]["source"].getValue(), "Y" )

if __name__ == "__main__":
unittest.main()
1 change: 1 addition & 0 deletions startup/GafferImage/shuffleCompatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__( self, *args, **kw ) :
and isinstance( args[0], str ) and isinstance( args[1], str )
) :
Gaffer.ShufflePlug.__init__( self, args[1], args[0] )
self.setName( "channel" )
else :
Gaffer.ShufflePlug.__init__( self, *args, **kw )

Expand Down

0 comments on commit b8038fc

Please sign in to comment.