-
Notifications
You must be signed in to change notification settings - Fork 206
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
Deregister Light Editor columns #5891
Conversation
5861feb
to
ae0def4
Compare
python/GafferSceneUI/LightEditor.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 6da2d7c
There was a problem hiding this 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.
GafferSceneUI.LightEditor.registerParameter( "light", "A" ) | ||
GafferSceneUI.LightEditor.registerParameter( "light", "B", "section2" ) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 92dadb1
There was a problem hiding this comment.
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.
python/GafferSceneUI/LightEditor.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
edf94c2
to
1175a63
Compare
Thanks John! I'm up for simplifying the API to just |
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 Note to self to check the commit messages for correctness when I squash down... Ready for a new look. |
50b24cf
to
65699fa
Compare
One last fixup I made yesterday after learning about the Now it's ready for a new look. |
65699fa
to
b8e748b
Compare
b8e748b
to
e440413
Compare
There was a problem hiding this 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 ) |
There was a problem hiding this comment.
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.
GafferSceneUI.LightEditor.registerParameter( "light", "A" ) | ||
GafferSceneUI.LightEditor.registerParameter( "light", "B", "section2" ) |
There was a problem hiding this comment.
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.
This adds three new methods to the Light Editor for removing columns :
deregisterParameter()
,deregisterAttribute()
andderegisterColumn()
.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 thenderegisterAttribute()
follows for completeness.Checklist