-
Notifications
You must be signed in to change notification settings - Fork 202
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
MAYA-112768 - Channel box for USD prims #1715
Conversation
* Set default USD attribute display filter in Channel Box. * Created new global UI Ufe Observer which connects to global attribute changes to update Channel Box.
@@ -56,6 +56,7 @@ if(CMAKE_UFE_V2_FEATURES_AVAILABLE) | |||
UsdTransform3dSetObjectMatrix.cpp | |||
UsdTransform3dUndoableCommands.cpp | |||
UsdUIInfoHandler.cpp | |||
UsdUIUfeObserver.cpp |
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 put both files in the V2 block since they don't rely on anything new from UFE.
@@ -150,6 +151,7 @@ MStatus initialize() | |||
handlers.transform3dHandler = pointInstanceHandler; | |||
|
|||
g_USDRtid = Ufe::RunTimeMgr::instance().register_(kUSDRunTimeName, handlers); | |||
MayaUsd::ufe::UsdUIUfeObserver::create(); |
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.
Again in the V2 block I create/destroy this new observer.
TF_VERIFY(!ufeObserver); | ||
if (!ufeObserver) { | ||
ufeObserver = std::make_shared<UsdUIUfeObserver>(); | ||
Ufe::Attributes::addObserver(ufeObserver); |
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.
For now listen to global attribute changes.
lib/mayaUsd/ufe/UsdUIUfeObserver.cpp
Outdated
if (auto ac = dynamic_cast<const Ufe::AttributeValueChanged*>(¬ification)) { | ||
if (ac->name() == UsdGeomTokens->xformOpOrder) { | ||
MString cmd("if (`channelBox -exists mainChannelBox`) channelBox -q -mainObjectList " | ||
"mainChannelBox;"); | ||
MStringArray paths; | ||
if (MGlobal::executeCommand(cmd, paths) && (paths.length() > 0)) { | ||
auto ufePath = Ufe::PathString::path(paths[0].asChar()); | ||
if (ufePath.startsWith(ac->path())) { | ||
cmd = "channelBox -e -update mainChannelBox;"; | ||
MGlobal::executeCommand(cmd); |
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.
If we get an attribute change on an xformOpOrder attribute, check if the channel box is displaying the prim this notif came from. If yes, tell the channel box to update (which will show the newly added xform attribute).
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 thought about removing the code in our AE template that refreshes it for the same xformOpOrder change, but there is no way to query the AE for the displayed node. Plus you can have multiple AE tabs and windows opened. As far as I know there is only a single global var "gAECurrentTab" that stores the name/ufepathstring of the object in the current tab of the AE.
global string $gChannelBoxName; | ||
if (`channelBox -exists $gChannelBoxName`) { | ||
// This flag only exists in recent versions of Maya. | ||
catchQuiet(`channelBox -e -ufeFixedAttrList "USD" {"xformOp:translate*", "xformOp:rotate*", "xformOp:scale*", "xformOp:*", "visibility"} $gChannelBoxName`); |
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.
Use catchQuiet so I don't need any Maya version check here. That way if backported this code will just work.
kNbGlobalObs = 2 | ||
self.assertEqual(ufe.Attributes.nbObservers(), kNbGlobalObs) |
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.
Updated this test because I added a new global attribute observer.
lib/mayaUsd/ufe/UsdUIUfeObserver.cpp
Outdated
{ | ||
if (auto ac = dynamic_cast<const Ufe::AttributeValueChanged*>(¬ification)) { | ||
if (ac->name() == UsdGeomTokens->xformOpOrder) { | ||
MString cmd("if (`channelBox -exists mainChannelBox`) channelBox -q -mainObjectList " |
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.
Might consider making the MString commands constants somehow, either by making them static or moving them to file scope.
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
* Minor - code review feedback
MAYA-112768 - Channel box for USD prims