Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deregister Light Editor columns #5891

Merged

Conversation

ericmehl
Copy link
Collaborator

@ericmehl ericmehl commented Jun 6, 2024

This adds three new methods to the Light Editor for removing columns : deregisterParameter(), deregisterAttribute() and deregisterColumn().

Really deregisterColumn() is all that's needed to do the actual work or removing a column, but the formatting of a parameter into a tuple seemed like just enough of a gotcha to deserve it's own function. And then deregisterAttribute() follows for completeness.

Checklist

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have tested my change(s) in the test suite, and added new test cases where necessary.
  • My code follows the Gaffer project's prevailing coding style and conventions.

@ericmehl ericmehl force-pushed the deregisterLightEditorColumns branch from 5861feb to ae0def4 Compare June 6, 2024 22:09
@@ -155,6 +152,16 @@ def registerParameter( cls, rendererKey, parameter, section = None, columnName =
assert( isinstance( parameter, IECoreScene.ShaderNetwork.Parameter ) )
parameter = ( parameter.shader, parameter.name )

return parameter
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be more succinct by returning above, instead of assigning to parameter and returning that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds worth it to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 6da2d7c

Copy link
Member

@johnhaddon johnhaddon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Eric!

Really deregisterColumn() is all that's needed to do the actual work or removing a column, but the formatting of a parameter into a tuple seemed like just enough of a gotcha to deserve it's own function.

That seems entirely logical given the starting point, but I think the starting point was a bit odd in the first place. Way back when we only had registerParameter(), so the internal __columnRegistry was keyed by tuple (as described in the comment). I think that was a poor choice on my part, and makes no sense now that we're sometimes keying by string (for attributes) and sometimes by tuple (for parameters). So a simpler option might be to make [de]registerColumn require string keys. Then maybe it's not too much of a stretch to just pass a string as in deregisterColumn( renderer, "shader.parameter" )? Not sure I feel that strongly about this if you prefer the more fulsome API.

Comment on lines 783 to 784
GafferSceneUI.LightEditor.registerParameter( "light", "A" )
GafferSceneUI.LightEditor.registerParameter( "light", "B", "section2" )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure both these are deregistered no matter how the test exits (failure, success etc). The easiest way might be to use self.addCleanup() here.

The same applies to the other two tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 92dadb1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We seem to have lost these during the later fixups.

Changes.md Outdated Show resolved Hide resolved
python/GafferSceneUI/LightEditor.py Outdated Show resolved Hide resolved
@@ -155,6 +152,16 @@ def registerParameter( cls, rendererKey, parameter, section = None, columnName =
assert( isinstance( parameter, IECoreScene.ShaderNetwork.Parameter ) )
parameter = ( parameter.shader, parameter.name )

return parameter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds worth it to me.

@ericmehl ericmehl force-pushed the deregisterLightEditorColumns branch 3 times, most recently from edf94c2 to 1175a63 Compare June 12, 2024 18:56
@ericmehl
Copy link
Collaborator Author

Thanks John! I'm up for simplifying the API to just deregisterColumn(). From what I can tell, we'd also have to change the column registry key as you described, to use just a string instead of a tuple for parameter columns? I don't see how we could keep the key as a tuple and figure out whether deregisterColumn() is being given an attribute or parameter to deregister.

@johnhaddon
Copy link
Member

From what I can tell, we'd also have to change the column registry key as you described, to use just a string instead of a tuple for parameter columns?

Yes, that is what I was expecting...

@ericmehl
Copy link
Collaborator Author

Yes, that is what I was expecting...

Great, that's done in 178dc6f. The commit history with the fixups is a bit funky with the __parseParameter() method getting moved around then removed in the end. But it will all wash out when I squash.

Note to self to check the commit messages for correctness when I squash down...

Ready for a new look.

@ericmehl ericmehl force-pushed the deregisterLightEditorColumns branch from 50b24cf to 65699fa Compare June 13, 2024 19:38
@ericmehl
Copy link
Collaborator Author

One last fixup I made yesterday after learning about the LazyMethod.flush() capability, so now we don't need to pop up a window and waitForIdle() which is a nice improvement.

Now it's ready for a new look.

@johnhaddon johnhaddon force-pushed the deregisterLightEditorColumns branch from 65699fa to b8e748b Compare June 24, 2024 10:49
@johnhaddon johnhaddon force-pushed the deregisterLightEditorColumns branch from b8e748b to e440413 Compare June 24, 2024 10:50
Copy link
Member

@johnhaddon johnhaddon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Eric! I spotted a couple of minor omissions (see inline) while squashing the fixups in, so just addressed them as I went. Merging...


columnNames = [ c.headerData().value for c in widget.getColumns() ]
self.assertNotIn( "P", columnNames )
self.assertNotIn( "P.X", columnNames )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be "X" rather than "P.X", as that's what we asserted to exist higher up.

Comment on lines 783 to 784
GafferSceneUI.LightEditor.registerParameter( "light", "A" )
GafferSceneUI.LightEditor.registerParameter( "light", "B", "section2" )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We seem to have lost these during the later fixups.

@johnhaddon johnhaddon merged commit a1a8577 into GafferHQ:1.4_maintenance Jun 24, 2024
5 checks passed
@ericmehl ericmehl mentioned this pull request Jun 24, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants