-
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 #867 from Autodesk/sabri/MAYA-105277/reorder_suppo…
…rt_ufe MAYA-105277: Initial work to support None-destructive reorder ( move ) of prims relative to their siblings.
- Loading branch information
Showing
12 changed files
with
578 additions
and
28 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
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,74 @@ | ||
// | ||
// Copyright 2020 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 "UsdUndoReorderCommand.h" | ||
|
||
#include <ufe/log.h> | ||
|
||
#include <mayaUsdUtils/util.h> | ||
|
||
namespace MAYAUSD_NS_DEF { | ||
namespace ufe { | ||
|
||
UsdUndoReorderCommand::UsdUndoReorderCommand(const UsdPrim& parentPrim, const std::vector<TfToken>& tokenList) | ||
: Ufe::UndoableCommand() | ||
, _parentPrim(parentPrim) | ||
, _orderedTokens(tokenList) | ||
{ | ||
} | ||
|
||
UsdUndoReorderCommand::~UsdUndoReorderCommand() | ||
{ | ||
} | ||
|
||
UsdUndoReorderCommand::Ptr UsdUndoReorderCommand::create(const UsdPrim& parentPrim, const std::vector<TfToken>& tokenList) | ||
{ | ||
if (!parentPrim) { | ||
return nullptr; | ||
} | ||
return std::make_shared<UsdUndoReorderCommand>(parentPrim, tokenList); | ||
} | ||
|
||
bool UsdUndoReorderCommand::reorder() | ||
{ | ||
const auto& parentPrimSpec = MayaUsdUtils::getPrimSpecAtEditTarget(_parentPrim); | ||
|
||
parentPrimSpec->SetNameChildrenOrder(_orderedTokens); | ||
|
||
return true; | ||
} | ||
|
||
void UsdUndoReorderCommand::undo() | ||
{ | ||
try { | ||
if (!reorder()) { | ||
UFE_LOG("reorder undo failed"); | ||
} | ||
} | ||
catch (const std::exception& e) { | ||
UFE_LOG(e.what()); | ||
throw; // re-throw the same exception | ||
} | ||
} | ||
|
||
void UsdUndoReorderCommand::redo() | ||
{ | ||
if (!reorder()) { | ||
UFE_LOG("reorder redo failed"); | ||
} | ||
} | ||
|
||
} // namespace ufe | ||
} // namespace MayaUsd |
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,60 @@ | ||
// | ||
// Copyright 2020 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. | ||
// | ||
#pragma once | ||
|
||
#include <ufe/undoableCommand.h> | ||
|
||
#include <mayaUsd/base/api.h> | ||
|
||
#include <pxr/usd/usd/prim.h> | ||
|
||
PXR_NAMESPACE_USING_DIRECTIVE | ||
|
||
namespace MAYAUSD_NS_DEF { | ||
namespace ufe { | ||
|
||
//! \brief UsdUndoReorderCommand | ||
class MAYAUSD_CORE_PUBLIC UsdUndoReorderCommand : public Ufe::UndoableCommand | ||
{ | ||
public: | ||
typedef std::shared_ptr<UsdUndoReorderCommand> Ptr; | ||
|
||
UsdUndoReorderCommand(const UsdPrim& parentPrim, const std::vector<TfToken>& orderedTokens); | ||
~UsdUndoReorderCommand() override; | ||
|
||
// Delete the copy/move constructors assignment operators. | ||
UsdUndoReorderCommand(const UsdUndoReorderCommand&) = delete; | ||
UsdUndoReorderCommand& operator=(const UsdUndoReorderCommand&) = delete; | ||
UsdUndoReorderCommand(UsdUndoReorderCommand&&) = delete; | ||
UsdUndoReorderCommand& operator=(UsdUndoReorderCommand&&) = delete; | ||
|
||
//! Create a UsdUndoReorderCommand | ||
static UsdUndoReorderCommand::Ptr create(const UsdPrim& parentPrim, const std::vector<TfToken>& orderedTokens); | ||
|
||
private: | ||
bool reorder(); | ||
|
||
void undo() override; | ||
void redo() override; | ||
|
||
UsdPrim _parentPrim; | ||
|
||
std::vector<TfToken> _orderedTokens; | ||
|
||
}; // UsdUndoReorderCommand | ||
|
||
} // namespace ufe | ||
} // namespace MayaUsd |
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
Oops, something went wrong.