-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1715 from Autodesk/donnels/MAYA-112768/channel_bo…
…x_for_usd_prims MAYA-112768 - Channel box for USD prims
- Loading branch information
Showing
6 changed files
with
163 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// Copyright 2021 Autodesk | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
#include "UsdUIUfeObserver.h" | ||
|
||
#include <pxr/base/tf/diagnostic.h> | ||
#include <pxr/usd/usdGeom/tokens.h> | ||
|
||
#include <maya/MGlobal.h> | ||
#include <maya/MString.h> | ||
#include <maya/MStringArray.h> | ||
#include <ufe/attributes.h> | ||
#include <ufe/pathString.h> | ||
|
||
// Needed because of TF_VERIFY | ||
PXR_NAMESPACE_USING_DIRECTIVE | ||
|
||
namespace MAYAUSD_NS_DEF { | ||
namespace ufe { | ||
|
||
//------------------------------------------------------------------------------ | ||
// Global variables | ||
//------------------------------------------------------------------------------ | ||
Ufe::Observer::Ptr UsdUIUfeObserver::ufeObserver; | ||
|
||
//------------------------------------------------------------------------------ | ||
// UsdUIUfeObserver | ||
//------------------------------------------------------------------------------ | ||
|
||
UsdUIUfeObserver::UsdUIUfeObserver() | ||
: Ufe::Observer() | ||
{ | ||
} | ||
|
||
/*static*/ | ||
void UsdUIUfeObserver::create() | ||
{ | ||
TF_VERIFY(!ufeObserver); | ||
if (!ufeObserver) { | ||
ufeObserver = std::make_shared<UsdUIUfeObserver>(); | ||
Ufe::Attributes::addObserver(ufeObserver); | ||
} | ||
} | ||
|
||
/*static*/ | ||
void UsdUIUfeObserver::destroy() | ||
{ | ||
TF_VERIFY(ufeObserver); | ||
if (ufeObserver) { | ||
Ufe::Attributes::removeObserver(ufeObserver); | ||
ufeObserver.reset(); | ||
} | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
// Ufe::Observer overrides | ||
//------------------------------------------------------------------------------ | ||
|
||
void UsdUIUfeObserver::operator()(const Ufe::Notification& notification) | ||
{ | ||
if (auto ac = dynamic_cast<const Ufe::AttributeValueChanged*>(¬ification)) { | ||
if (ac->name() == UsdGeomTokens->xformOpOrder) { | ||
static const MString mainObjListCmd( | ||
"if (`channelBox -exists mainChannelBox`) channelBox -q -mainObjectList " | ||
"mainChannelBox;"); | ||
MStringArray paths; | ||
if (MGlobal::executeCommand(mainObjListCmd, paths) && (paths.length() > 0)) { | ||
auto ufePath = Ufe::PathString::path(paths[0].asChar()); | ||
if (ufePath.startsWith(ac->path())) { | ||
static const MString updateCBCmd("channelBox -e -update mainChannelBox;"); | ||
MGlobal::executeCommand(updateCBCmd); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} // namespace ufe | ||
} // namespace MAYAUSD_NS_DEF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#ifndef USDUIUFEOBSERVER_H | ||
#define USDUIUFEOBSERVER_H | ||
|
||
// | ||
// Copyright 2021 Autodesk | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#include <mayaUsd/base/api.h> | ||
|
||
#include <ufe/observer.h> | ||
|
||
namespace MAYAUSD_NS_DEF { | ||
namespace ufe { | ||
|
||
//! \brief Helper class used to receive UFE notifications and respond to them by updating UI. | ||
class UsdUIUfeObserver : public Ufe::Observer | ||
{ | ||
public: | ||
UsdUIUfeObserver(); | ||
|
||
// Delete the copy/move constructors assignment operators. | ||
UsdUIUfeObserver(const UsdUIUfeObserver&) = delete; | ||
UsdUIUfeObserver& operator=(const UsdUIUfeObserver&) = delete; | ||
UsdUIUfeObserver(UsdUIUfeObserver&&) = delete; | ||
UsdUIUfeObserver& operator=(UsdUIUfeObserver&&) = delete; | ||
|
||
//! Create/Destroy a UsdUIUfeObserver. | ||
static void create(); | ||
static void destroy(); | ||
|
||
void operator()(const Ufe::Notification& notification) override; | ||
|
||
private: | ||
static Ufe::Observer::Ptr ufeObserver; | ||
}; | ||
|
||
} // namespace ufe | ||
} // namespace MAYAUSD_NS_DEF | ||
|
||
#endif // USDUIUFEOBSERVER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters