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 21, 2024
1 parent e214fc9 commit c06ded1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Fixes
- Fixed loading of 2 channel images [^1].
- Fixed error message to include filename [^1].
- 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].

API
---
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 c06ded1

Please sign in to comment.