From 09e93fc4f07ff267405dd5d51df334c9af2b8648 Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Wed, 19 Jun 2024 15:46:24 -0700 Subject: [PATCH 1/6] Metadata : Allow metadata on parent to override --- Changes.md | 2 + python/GafferTest/MetadataTest.py | 78 +++++++++++++++++++++++++++++++ src/Gaffer/Metadata.cpp | 23 ++++++++- 3 files changed, 101 insertions(+), 2 deletions(-) diff --git a/Changes.md b/Changes.md index 195d6c79fbb..03ecc74ac78 100644 --- a/Changes.md +++ b/Changes.md @@ -7,6 +7,7 @@ Improvements - CameraTweaks : Added `ignoreMissing` plug to align behaviour with the other Tweaks nodes. - AttributeTweaks : The `{source}` substitution for `linkedLights` now expands to `defaultLights` if the attribute doesn't exist yet. This makes tweaks such as `({source}) - unwantedLights` reliable even if no light links have been authored yet. - ImageReader : Non-standard "r", "g", "b" and "a" channel names are now automatically renamed to "R", "G", "B" and "A" on loading. As with other heuristics, this can be disabled by setting `channelInterpretation` to "EXR Specification". +- Metadata : Metadata registered to a node or plug targeting a descendant plug will now override metadata registered locally to the target. Breaking Changes ---------------- @@ -15,6 +16,7 @@ Breaking Changes - TweakPlug : Remove deprecated `MissingMode::IgnoreOrReplace`. - AttributeTweaks : `Replace` mode no longer errors if the `linkedLights` attribute doesn't exist. - ImageReader : Changed handling of lower-cased "r", "g", "b" and "a" channels. +- Metadata : Path based registrations to a Node or Plug now override equivalent registrations on its descendants. 1.4.x.x (relative to 1.4.7.0) ======= diff --git a/python/GafferTest/MetadataTest.py b/python/GafferTest/MetadataTest.py index 6873027e627..ef5b661b43e 100644 --- a/python/GafferTest/MetadataTest.py +++ b/python/GafferTest/MetadataTest.py @@ -108,6 +108,80 @@ def testInheritance( self ) : Gaffer.Metadata.registerValue( self.DerivedAddNode, "op1", "iKey", "Derived class plug value" ) self.assertEqual( Gaffer.Metadata.value( derivedAdd["op1"], "iKey" ), "Derived class plug value" ) + def testNodeMetadataHasPriorityOverRowsPlugMetadata( self ) : + + Gaffer.Metadata.registerValue( Gaffer.Spreadsheet.RowsPlug, "default.*...", "test", "plug" ) + + class MetadataTestNodeF( Gaffer.Node ) : + + def __init__( self, name = "MetadataTestNodeF" ) : + + Gaffer.Node.__init__( self, name ) + + self["a"] = Gaffer.Spreadsheet.RowsPlug() + self["a"].addColumn( Gaffer.StringPlug( "testColumn" ) ) + self["b"] = Gaffer.Spreadsheet.RowsPlug() + self["b"].addColumn( Gaffer.StringPlug( "testColumn" ) ) + + IECore.registerRunTimeTyped( MetadataTestNodeF ) + + Gaffer.Metadata.registerNode( + + MetadataTestNodeF, + + plugs = { + "a.default.cells.testColumn.value" : [ + "test", "node", + ] + } + + ) + + n = MetadataTestNodeF() + self.assertEqual( Gaffer.Metadata.value( n["a"]["default"]["cells"]["testColumn"]["value"], "test" ), "node" ) + self.assertEqual( Gaffer.Metadata.value( n["b"]["default"]["cells"]["testColumn"]["value"], "test" ), "plug" ) + + def testAncestorMetadataPriority( self ) : + + Gaffer.Metadata.registerValue( Gaffer.Color3fPlug, "[rgb]", "test", "color3fPlug" ) + Gaffer.Metadata.registerValue( Gaffer.TweakPlug, "value.[rg]", "test", "tweakPlug" ) + + class MetadataTestNodeG( Gaffer.Node ) : + + def __init__( self, name = "MetadataTestNodeG" ) : + + Gaffer.Node.__init__( self, name ) + + self["a"] = Gaffer.TweakPlug( "a", imath.Color3f( 0 ) ) + self["b"] = Gaffer.TweakPlug( "b", imath.Color3f( 0 ) ) + + IECore.registerRunTimeTyped( MetadataTestNodeG ) + + Gaffer.Metadata.registerNode( + + MetadataTestNodeG, + + plugs = { + "a.value.r" : [ + "test", "node", + ], + + "b.value.[gb]" : [ + "test", "node", + ], + } + + ) + + n = MetadataTestNodeG() + self.assertEqual( Gaffer.Metadata.value( n["a"]["value"]["r"], "test" ), "node" ) + self.assertEqual( Gaffer.Metadata.value( n["a"]["value"]["g"], "test" ), "tweakPlug" ) + self.assertEqual( Gaffer.Metadata.value( n["a"]["value"]["b"], "test" ), "color3fPlug" ) + + self.assertEqual( Gaffer.Metadata.value( n["b"]["value"]["r"], "test" ), "tweakPlug" ) + self.assertEqual( Gaffer.Metadata.value( n["b"]["value"]["g"], "test" ), "node" ) + self.assertEqual( Gaffer.Metadata.value( n["b"]["value"]["b"], "test" ), "node" ) + def testNodeSignals( self ) : add = GafferTest.AddNode() @@ -1303,5 +1377,9 @@ def tearDown( self ) : Gaffer.Metadata.deregisterValue( GafferTest.AddNode, "op1", "rp" ) Gaffer.Metadata.deregisterValue( GafferTest.AddNode, "op*", "aKey" ) + Gaffer.Metadata.deregisterValue( Gaffer.Spreadsheet.RowsPlug, "default.*...", "test" ) + Gaffer.Metadata.deregisterValue( Gaffer.Color3fPlug, "[rgb]", "test" ) + Gaffer.Metadata.deregisterValue( Gaffer.TweakPlug, "value.[rg]", "test" ) + if __name__ == "__main__": unittest.main() diff --git a/src/Gaffer/Metadata.cpp b/src/Gaffer/Metadata.cpp index ea0ff34166e..fdd768b3521 100644 --- a/src/Gaffer/Metadata.cpp +++ b/src/Gaffer/Metadata.cpp @@ -805,6 +805,11 @@ IECore::ConstDataPtr Metadata::valueInternal( const GraphComponent *target, IECo // If the target is a plug, then look for a path-based // value. These are more specific than type-based values. + // We allow metadata registered to higher-level components + // such as Nodes to take precedence over registrations to + // lower-level components such as Plugs, as a node may have + // specific needs for the presentation or behaviour of its + // plugs and thus have good reason to override their metadata. if( registrationTypes & RegistrationTypes::TypeIdDescendant ) { @@ -812,6 +817,7 @@ IECore::ConstDataPtr Metadata::valueInternal( const GraphComponent *target, IECo { const GraphComponent *ancestor = plug->parent(); vector plugPath( { plug->getName() } ); + Metadata::PlugValueFunction valueFn; while( ancestor ) { IECore::TypeId typeId = ancestor->typeId(); @@ -828,9 +834,11 @@ IECore::ConstDataPtr Metadata::valueInternal( const GraphComponent *target, IECo auto vIt = it->second.find( key ); if( vIt != it->second.end() ) { - return vIt->second( plug ); + valueFn = vIt->second; + break; } } + // And only if the direct lookup fails, do a full search using // wildcard matches. for( it = nIt->second.plugPathsToValues.begin(); it != eIt; ++it ) @@ -840,10 +848,16 @@ IECore::ConstDataPtr Metadata::valueInternal( const GraphComponent *target, IECo auto vIt = it->second.find( key ); if( vIt != it->second.end() ) { - return vIt->second( plug ); + valueFn = vIt->second; + break; } } } + + if( valueFn != nullptr ) + { + break; + } } typeId = RunTimeTyped::baseTypeId( typeId ); } @@ -851,6 +865,11 @@ IECore::ConstDataPtr Metadata::valueInternal( const GraphComponent *target, IECo plugPath.insert( plugPath.begin(), ancestor->getName() ); ancestor = ancestor->parent(); } + + if( valueFn != nullptr ) + { + return valueFn( plug ); + } } } From 5e723a8dc91cfb3ec439946f0f668f0eba7f3acb Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:00:18 -0700 Subject: [PATCH 2/6] Tweaks : Remove `allowCreate` metadata We already allow "Create" mode on all tweaks, which means this metadata was already registered everywhere so there is no need to keep it around. We remove it to simplify the generation of presets on the mode plug, as we were running into issues when forwarding metadata from spreadsheets where the plug `presetNames` was computed wouldn't always have a parent with `tweakPlugValueWidget:allowCreate` registered. --- Changes.md | 1 + python/GafferSceneUI/AttributeTweaksUI.py | 1 - python/GafferSceneUI/CameraTweaksUI.py | 1 - python/GafferSceneUI/OptionTweaksUI.py | 1 - python/GafferSceneUI/ShaderTweaksUI.py | 1 - python/GafferUI/ContextVariableTweaksUI.py | 1 - python/GafferUI/SpreadsheetUI/_Metadata.py | 1 - python/GafferUI/TweakPlugValueWidget.py | 11 ++++------- 8 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Changes.md b/Changes.md index 03ecc74ac78..7bf584a32da 100644 --- a/Changes.md +++ b/Changes.md @@ -17,6 +17,7 @@ Breaking Changes - AttributeTweaks : `Replace` mode no longer errors if the `linkedLights` attribute doesn't exist. - ImageReader : Changed handling of lower-cased "r", "g", "b" and "a" channels. - Metadata : Path based registrations to a Node or Plug now override equivalent registrations on its descendants. +- TweakPlugValueWidget : Removed support for `tweakPlugValueWidget:allowCreate` metadata. 1.4.x.x (relative to 1.4.7.0) ======= diff --git a/python/GafferSceneUI/AttributeTweaksUI.py b/python/GafferSceneUI/AttributeTweaksUI.py index 048e1beeb9e..9bda4b8891e 100644 --- a/python/GafferSceneUI/AttributeTweaksUI.py +++ b/python/GafferSceneUI/AttributeTweaksUI.py @@ -97,7 +97,6 @@ "tweaks.*" : [ - "tweakPlugValueWidget:allowCreate", True, "tweakPlugValueWidget:allowRemove", True, "tweakPlugValueWidget:propertyType", "attribute", diff --git a/python/GafferSceneUI/CameraTweaksUI.py b/python/GafferSceneUI/CameraTweaksUI.py index bfea680fb7b..8dbab25df2c 100644 --- a/python/GafferSceneUI/CameraTweaksUI.py +++ b/python/GafferSceneUI/CameraTweaksUI.py @@ -98,7 +98,6 @@ "tweaks.*" : [ "tweakPlugValueWidget:allowRemove", True, - "tweakPlugValueWidget:allowCreate", True, "tweakPlugValueWidget:propertyType", "parameter", ], diff --git a/python/GafferSceneUI/OptionTweaksUI.py b/python/GafferSceneUI/OptionTweaksUI.py index 6ef85351b56..b059262cd6c 100644 --- a/python/GafferSceneUI/OptionTweaksUI.py +++ b/python/GafferSceneUI/OptionTweaksUI.py @@ -119,7 +119,6 @@ def __optionMetadataPresetValues( plug ) : "tweaks.*" : [ - "tweakPlugValueWidget:allowCreate", True, "tweakPlugValueWidget:propertyType", "option", ], diff --git a/python/GafferSceneUI/ShaderTweaksUI.py b/python/GafferSceneUI/ShaderTweaksUI.py index f18b8bb0331..bf8dd80bcde 100644 --- a/python/GafferSceneUI/ShaderTweaksUI.py +++ b/python/GafferSceneUI/ShaderTweaksUI.py @@ -126,7 +126,6 @@ "tweaks.*" : [ "noduleLayout:visible", False, # Can be shown individually using PlugAdder above - "tweakPlugValueWidget:allowCreate", True, "tweakPlugValueWidget:allowRemove", True, "tweakPlugValueWidget:propertyType", "parameter", "plugValueWidget:type", "GafferSceneUI.ShaderTweaksUI._ShaderTweakPlugValueWidget", diff --git a/python/GafferUI/ContextVariableTweaksUI.py b/python/GafferUI/ContextVariableTweaksUI.py index eea7ed6f25d..0634f8bebf2 100644 --- a/python/GafferUI/ContextVariableTweaksUI.py +++ b/python/GafferUI/ContextVariableTweaksUI.py @@ -84,7 +84,6 @@ "tweaks.*" : [ - "tweakPlugValueWidget:allowCreate", True, "tweakPlugValueWidget:propertyType", "context variable", ] diff --git a/python/GafferUI/SpreadsheetUI/_Metadata.py b/python/GafferUI/SpreadsheetUI/_Metadata.py index 54afbd13f7b..2a898230639 100644 --- a/python/GafferUI/SpreadsheetUI/_Metadata.py +++ b/python/GafferUI/SpreadsheetUI/_Metadata.py @@ -280,7 +280,6 @@ def __forwardedMetadata( plug, key ) : "plugValueWidget:type", "presetsPlugValueWidget:allowCustom", "tweakPlugValueWidget:allowRemove", - "tweakPlugValueWidget:allowCreate", ] : Gaffer.Metadata.registerValue( diff --git a/python/GafferUI/TweakPlugValueWidget.py b/python/GafferUI/TweakPlugValueWidget.py index c56424d6702..04ef32c0950 100644 --- a/python/GafferUI/TweakPlugValueWidget.py +++ b/python/GafferUI/TweakPlugValueWidget.py @@ -47,11 +47,11 @@ # Widget for TweakPlug, which is used to build tweak nodes such as ShaderTweaks # and CameraTweaks. Shows a value plug that you can use to specify a tweak value, along with -# a target parameter name, an enabled plug, and a mode. The mode can be "Replace", +# a target parameter name, an enabled plug, and a mode. +# The mode can be "Create", "CreateIfMissing", "Replace", # or "Add"/"Subtract"/"Multiply"/"Min"/"Max" if the plug is numeric, # or "ListAppend"/"ListPrepend"/"ListRemove" if the plug is a list or `PathMatcherPlug`, -# or "Remove" if the metadata "tweakPlugValueWidget:allowRemove" is set, -# or "Create" and "CreateIfMissing" if the metadata "tweakPlugValueWidget:allowCreate" is set. +# or "Remove" if the metadata "tweakPlugValueWidget:allowRemove" is set. class TweakPlugValueWidget( GafferUI.PlugValueWidget ) : def __init__( self, plugs ) : @@ -165,11 +165,8 @@ def __nameDescription( plug ) : def __validModes( plug ) : - result = [] - if Gaffer.Metadata.value( plug.parent(), "tweakPlugValueWidget:allowCreate" ) : - result += [ Gaffer.TweakPlug.Mode.Create, Gaffer.TweakPlug.Mode.CreateIfMissing ] + result = [ Gaffer.TweakPlug.Mode.Create, Gaffer.TweakPlug.Mode.CreateIfMissing, Gaffer.TweakPlug.Mode.Replace ] - result += [ Gaffer.TweakPlug.Mode.Replace ] if hasattr( plug.parent()["value"], "hasMinValue" ) : result += [ Gaffer.TweakPlug.Mode.Add, From 3abca8d0f42a13b6ba87b1d4cdf0a43a77e30135 Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:01:23 -0700 Subject: [PATCH 3/6] Tweaks : Remove `allowRemove` metadata It makes sense to allow "Remove" mode on all tweaks to match "Create". To do so, we could either register "tweakPlugValueWidget:allowRemove" for every tweak, or consider this metadata to be now unnecessary and remove it. For simplicity, we're removing the metadata. --- Changes.md | 3 ++- python/GafferSceneUI/AttributeTweaksUI.py | 1 - python/GafferSceneUI/CameraTweaksUI.py | 1 - python/GafferSceneUI/ShaderTweaksUI.py | 1 - python/GafferUI/SpreadsheetUI/_Metadata.py | 1 - python/GafferUI/TweakPlugValueWidget.py | 15 ++++++++------- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Changes.md b/Changes.md index 7bf584a32da..5742516db16 100644 --- a/Changes.md +++ b/Changes.md @@ -8,6 +8,7 @@ Improvements - AttributeTweaks : The `{source}` substitution for `linkedLights` now expands to `defaultLights` if the attribute doesn't exist yet. This makes tweaks such as `({source}) - unwantedLights` reliable even if no light links have been authored yet. - ImageReader : Non-standard "r", "g", "b" and "a" channel names are now automatically renamed to "R", "G", "B" and "A" on loading. As with other heuristics, this can be disabled by setting `channelInterpretation` to "EXR Specification". - Metadata : Metadata registered to a node or plug targeting a descendant plug will now override metadata registered locally to the target. +- OptionTweaks, ContextVariableTweaks : Added `Remove` mode. Breaking Changes ---------------- @@ -17,7 +18,7 @@ Breaking Changes - AttributeTweaks : `Replace` mode no longer errors if the `linkedLights` attribute doesn't exist. - ImageReader : Changed handling of lower-cased "r", "g", "b" and "a" channels. - Metadata : Path based registrations to a Node or Plug now override equivalent registrations on its descendants. -- TweakPlugValueWidget : Removed support for `tweakPlugValueWidget:allowCreate` metadata. +- TweakPlugValueWidget : Removed support for `tweakPlugValueWidget:allowCreate` and `tweakPlugValueWidget:allowRemove` metadata. 1.4.x.x (relative to 1.4.7.0) ======= diff --git a/python/GafferSceneUI/AttributeTweaksUI.py b/python/GafferSceneUI/AttributeTweaksUI.py index 9bda4b8891e..3e1b669b5c6 100644 --- a/python/GafferSceneUI/AttributeTweaksUI.py +++ b/python/GafferSceneUI/AttributeTweaksUI.py @@ -97,7 +97,6 @@ "tweaks.*" : [ - "tweakPlugValueWidget:allowRemove", True, "tweakPlugValueWidget:propertyType", "attribute", ], diff --git a/python/GafferSceneUI/CameraTweaksUI.py b/python/GafferSceneUI/CameraTweaksUI.py index 8dbab25df2c..a0e1c2997f4 100644 --- a/python/GafferSceneUI/CameraTweaksUI.py +++ b/python/GafferSceneUI/CameraTweaksUI.py @@ -97,7 +97,6 @@ "tweaks.*" : [ - "tweakPlugValueWidget:allowRemove", True, "tweakPlugValueWidget:propertyType", "parameter", ], diff --git a/python/GafferSceneUI/ShaderTweaksUI.py b/python/GafferSceneUI/ShaderTweaksUI.py index bf8dd80bcde..31d01e64093 100644 --- a/python/GafferSceneUI/ShaderTweaksUI.py +++ b/python/GafferSceneUI/ShaderTweaksUI.py @@ -126,7 +126,6 @@ "tweaks.*" : [ "noduleLayout:visible", False, # Can be shown individually using PlugAdder above - "tweakPlugValueWidget:allowRemove", True, "tweakPlugValueWidget:propertyType", "parameter", "plugValueWidget:type", "GafferSceneUI.ShaderTweaksUI._ShaderTweakPlugValueWidget", diff --git a/python/GafferUI/SpreadsheetUI/_Metadata.py b/python/GafferUI/SpreadsheetUI/_Metadata.py index 2a898230639..f58c15093a0 100644 --- a/python/GafferUI/SpreadsheetUI/_Metadata.py +++ b/python/GafferUI/SpreadsheetUI/_Metadata.py @@ -279,7 +279,6 @@ def __forwardedMetadata( plug, key ) : "spreadsheet:columnWidth", "plugValueWidget:type", "presetsPlugValueWidget:allowCustom", - "tweakPlugValueWidget:allowRemove", ] : Gaffer.Metadata.registerValue( diff --git a/python/GafferUI/TweakPlugValueWidget.py b/python/GafferUI/TweakPlugValueWidget.py index 04ef32c0950..7b01733ea6b 100644 --- a/python/GafferUI/TweakPlugValueWidget.py +++ b/python/GafferUI/TweakPlugValueWidget.py @@ -48,10 +48,9 @@ # Widget for TweakPlug, which is used to build tweak nodes such as ShaderTweaks # and CameraTweaks. Shows a value plug that you can use to specify a tweak value, along with # a target parameter name, an enabled plug, and a mode. -# The mode can be "Create", "CreateIfMissing", "Replace", +# The mode can be "Create", "CreateIfMissing", "Replace", "Remove", # or "Add"/"Subtract"/"Multiply"/"Min"/"Max" if the plug is numeric, -# or "ListAppend"/"ListPrepend"/"ListRemove" if the plug is a list or `PathMatcherPlug`, -# or "Remove" if the metadata "tweakPlugValueWidget:allowRemove" is set. +# or "ListAppend"/"ListPrepend"/"ListRemove" if the plug is a list or `PathMatcherPlug`. class TweakPlugValueWidget( GafferUI.PlugValueWidget ) : def __init__( self, plugs ) : @@ -165,7 +164,12 @@ def __nameDescription( plug ) : def __validModes( plug ) : - result = [ Gaffer.TweakPlug.Mode.Create, Gaffer.TweakPlug.Mode.CreateIfMissing, Gaffer.TweakPlug.Mode.Replace ] + result = [ + Gaffer.TweakPlug.Mode.Create, + Gaffer.TweakPlug.Mode.CreateIfMissing, + Gaffer.TweakPlug.Mode.Replace, + Gaffer.TweakPlug.Mode.Remove, + ] if hasattr( plug.parent()["value"], "hasMinValue" ) : result += [ @@ -198,9 +202,6 @@ def __validModes( plug ) : Gaffer.TweakPlug.Mode.ListRemove ] - if Gaffer.Metadata.value( plug.parent(), "tweakPlugValueWidget:allowRemove" ) : - result += [ Gaffer.TweakPlug.Mode.Remove ] - return result Gaffer.Metadata.registerValue( From ba92cafa1c29196b2ccf657d163c4188731ff852 Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:02:05 -0700 Subject: [PATCH 4/6] TweakPlugValueWidget : Forward `propertyType` metadata This makes `tweakPlugValueWidget:propertyType` discoverable from downstream plugs, which means it no longer needs to be copied onto promoted plugs or spreadsheets as it can be found on the original TweakPlug. --- python/GafferUI/TweakPlugValueWidget.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/python/GafferUI/TweakPlugValueWidget.py b/python/GafferUI/TweakPlugValueWidget.py index 7b01733ea6b..cd56a4b4c5f 100644 --- a/python/GafferUI/TweakPlugValueWidget.py +++ b/python/GafferUI/TweakPlugValueWidget.py @@ -149,11 +149,20 @@ def __childPlugs( plugs, childName ) : # Metadata Gaffer.Metadata.registerValue( Gaffer.TweakPlug, "deletable", lambda plug : plug.getFlags( Gaffer.Plug.Flags.Dynamic ) ) +Gaffer.Metadata.registerValue( Gaffer.TweakPlug, "tweakPlugValueWidget:propertyType:promotable", False ) + +def __propertyType( plug ) : + + source = Gaffer.PlugAlgo.findDestination( + plug, + lambda p : p if Gaffer.Metadata.value( p.parent(), "tweakPlugValueWidget:propertyType" ) else None + ) or plug + + return Gaffer.Metadata.value( source.parent(), "tweakPlugValueWidget:propertyType" ) or "property" def __nameDescription( plug ) : - property = Gaffer.Metadata.value( plug.parent(), "tweakPlugValueWidget:propertyType" ) or "property" - return f"The name of the {property} to apply the tweak to." + return f"The name of the {__propertyType( plug )} to apply the tweak to." Gaffer.Metadata.registerValue( Gaffer.TweakPlug, "name", "description", __nameDescription ) @@ -283,7 +292,7 @@ def __validModes( plug ) : def __modeDescription( plug ) : - property = Gaffer.Metadata.value( plug.parent(), "tweakPlugValueWidget:propertyType" ) or "property" + property = __propertyType( plug ) result = "| Mode | Description |\n" result += "| :--- | :---------- |\n" From 855122d2b27182833a1f942323be4d936c31d774 Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:02:39 -0700 Subject: [PATCH 5/6] EditScopeAlgo : Do not copy `tweakPlugValueWidget:` metadata With the removal of "tweakPlugValueWidget:allowCreate" and "tweakPlugValueWidget:allowRemove", and the forwarding of "tweakPlugValueWidget:propertyType" we no longer need to copy this metadata from the tweakPlug to the spreadsheet default row. --- src/GafferScene/EditScopeAlgo.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/GafferScene/EditScopeAlgo.cpp b/src/GafferScene/EditScopeAlgo.cpp index dc8a3327c30..2ec3e61ce1b 100644 --- a/src/GafferScene/EditScopeAlgo.cpp +++ b/src/GafferScene/EditScopeAlgo.cpp @@ -799,13 +799,6 @@ TweakPlug *GafferScene::EditScopeAlgo::acquireAttributeEdit( Gaffer::EditScope * attributeTweaks->tweaksPlug()->addChild( tweakPlug ); size_t columnIndex = rows->addColumn( tweakPlug.get(), columnName, /* adoptEnabledPlug */ true ); - MetadataAlgo::copyIf( - tweakPlug.get(), rows->defaultRow()->cellsPlug()->getChild( columnIndex )->valuePlug(), - [] ( const GraphComponent *from, const GraphComponent *to, const std::string &name ) { - return boost::starts_with( name, "tweakPlugValueWidget:" ); - } - ); - tweakPlug->setInput( processor->getChild( "Spreadsheet" )->outPlug()->getChild( columnIndex ) ); return row->cellsPlug()->getChild( columnIndex )->valuePlug(); @@ -1425,13 +1418,6 @@ TweakPlug *GafferScene::EditScopeAlgo::acquireRenderPassOptionEdit( Gaffer::Edit optionTweaks->tweaksPlug()->addChild( tweakPlug ); size_t columnIndex = rows->addColumn( tweakPlug.get(), columnName, /* adoptEnabledPlug */ true ); - MetadataAlgo::copyIf( - tweakPlug.get(), rows->defaultRow()->cellsPlug()->getChild( columnIndex )->valuePlug(), - [] ( const GraphComponent *from, const GraphComponent *to, const std::string &name ) { - return boost::starts_with( name, "tweakPlugValueWidget:" ); - } - ); - tweakPlug->setInput( processor->getChild( "Spreadsheet" )->outPlug()->getChild( columnIndex ) ); return row->cellsPlug()->getChild( columnIndex )->valuePlug(); From 734119bc9f38690ec9442afae21557849b655d4a Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:44:35 -0700 Subject: [PATCH 6/6] TweakPlugValueWidget : Remove unnecessary comment We've removed the metadata for customising `mode` presets, so this comment no longer adds much value. --- python/GafferUI/TweakPlugValueWidget.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/python/GafferUI/TweakPlugValueWidget.py b/python/GafferUI/TweakPlugValueWidget.py index cd56a4b4c5f..e0d0221c69a 100644 --- a/python/GafferUI/TweakPlugValueWidget.py +++ b/python/GafferUI/TweakPlugValueWidget.py @@ -48,9 +48,6 @@ # Widget for TweakPlug, which is used to build tweak nodes such as ShaderTweaks # and CameraTweaks. Shows a value plug that you can use to specify a tweak value, along with # a target parameter name, an enabled plug, and a mode. -# The mode can be "Create", "CreateIfMissing", "Replace", "Remove", -# or "Add"/"Subtract"/"Multiply"/"Min"/"Max" if the plug is numeric, -# or "ListAppend"/"ListPrepend"/"ListRemove" if the plug is a list or `PathMatcherPlug`. class TweakPlugValueWidget( GafferUI.PlugValueWidget ) : def __init__( self, plugs ) :