-
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-105277: Initial work to support None-destructive reorder ( move ) of prims relative to their siblings. #867
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a95a659
MAYA-105277 : implement UsdUndoReorderCommand
d38fcde
MAYA-105277 : add testReorderCmd.
13330c4
MAYA-105277: add guards around reorder command.
66e7ab5
MAYA-105277 : fix the bad merge.
e502399
MAYA-105277: react to ufe interface changes.
688b46a
Merge branch 'dev' into sabri/MAYA-105277/reorder_support_ufe
0977cf1
MAYA-105277: address feedbacks.
520b36d
Address feedback.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Funky indentation?
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.
Yup... all of the code base under
lib/mayaUsd/ufe
has a mix of spaces and tabs. I can't wait for @kxl-adsk to apply the clang format on the repo :) .