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

EMSUSD_1917 lock layer should preserve the selection #4044

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions lib/mayaUsd/commands/layerEditorCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,6 @@ class LockLayer : public BaseCmd
if (!stage)
return false;

saveSelection();

std::set<PXR_NS::SdfLayerRefPtr> layersToUpdate;
if (_includeSublayers) {
// If _includeSublayers is True, we attempt to refresh the system lock status of all
Expand Down Expand Up @@ -896,7 +894,6 @@ class LockLayer : public BaseCmd
_proxyShapePath, _layers[layerIndex], _previousStates[layerIndex], true);
}
}
restoreSelection();

if (_updateEditTarget) {
updateEditTarget(stage);
Expand All @@ -919,36 +916,6 @@ class LockLayer : public BaseCmd
return stage;
}

void saveSelection()
{
// Make a copy of the global selection, to restore it on unlock.
auto globalSn = Ufe::GlobalSelection::get();
_savedSn.replaceWith(*globalSn);
// Filter the global selection, removing items below our proxy shape.
// We know the path to the proxy shape has a single segment. Not
// using Ufe::PathString::path() for UFE v1 compatibility, which
// unfortunately reveals leading "world" path component implementation
// detail.
Ufe::Path path(
Ufe::PathSegment("world" + _proxyShapePath, MayaUsd::ufe::getMayaRunTimeId(), '|'));
globalSn->replaceWith(UsdUfe::removeDescendants(_savedSn, path));
}

void restoreSelection()
{
// Restore the saved selection to the global selection. If a saved
// selection item started with the proxy shape path, re-create it.
// We know the path to the proxy shape has a single segment. Not
// using Ufe::PathString::path() for UFE v1 compatibility, which
// unfortunately reveals leading "world" path component implementation
// detail.
Ufe::Path path(
Ufe::PathSegment("world" + _proxyShapePath, MayaUsd::ufe::getMayaRunTimeId(), '|'));
auto globalSn = Ufe::GlobalSelection::get();
globalSn->replaceWith(UsdUfe::recreateDescendants(_savedSn, path));
}

Ufe::Selection _savedSn;
std::vector<MayaUsd::LayerLockType> _previousStates;
SdfLayerHandleVector _layers;
};
Expand Down