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

MAYA-112768 - Channel box for USD prims #1715

Merged
merged 2 commits into from
Sep 21, 2021

Conversation

seando-adsk
Copy link
Collaborator

MAYA-112768 - Channel box for USD prims

  • 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.

* 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
Copy link
Collaborator Author

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();
Copy link
Collaborator Author

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);
Copy link
Collaborator Author

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.

Comment on lines 73 to 82
if (auto ac = dynamic_cast<const Ufe::AttributeValueChanged*>(&notification)) {
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);
Copy link
Collaborator Author

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).

Copy link
Collaborator Author

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`);
Copy link
Collaborator Author

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.

Comment on lines +464 to +465
kNbGlobalObs = 2
self.assertEqual(ufe.Attributes.nbObservers(), kNbGlobalObs)
Copy link
Collaborator Author

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.

@seando-adsk seando-adsk added adsk Related to Autodesk plugin ufe-usd Related to UFE-USD plugin in Maya-Usd labels Sep 20, 2021
{
if (auto ac = dynamic_cast<const Ufe::AttributeValueChanged*>(&notification)) {
if (ac->name() == UsdGeomTokens->xformOpOrder) {
MString cmd("if (`channelBox -exists mainChannelBox`) channelBox -q -mainObjectList "
Copy link
Collaborator

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.

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

* Minor - code review feedback
@seando-adsk seando-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Sep 21, 2021
@kxl-adsk kxl-adsk merged commit f072bcb into dev Sep 21, 2021
@kxl-adsk kxl-adsk deleted the donnels/MAYA-112768/channel_box_for_usd_prims branch September 21, 2021 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adsk Related to Autodesk plugin ready-for-merge Development process is finished, PR is ready for merge ufe-usd Related to UFE-USD plugin in Maya-Usd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants