-
Notifications
You must be signed in to change notification settings - Fork 203
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-105977: Update restriction error reports based on latest design. #687
Merged
kxl-adsk
merged 1 commit into
dev
from
sabrih/MAYA-105977/update_strings_restriction_errors
Jul 30, 2020
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,113 +36,121 @@ namespace ufe { | |
|
||
UsdGeomXformCommonAPI convertToCompatibleCommonAPI(const UsdPrim& prim) | ||
{ | ||
// As we are using USD's XformCommonAPI which supports only the following xformOps : | ||
// ["xformOp:translate", "xformOp:translate:pivot", "xformOp:rotateXYZ", "xformOp:scale", "!invert!xformOp:translate:pivot"] | ||
// We are extending the supported xform Operations with : | ||
// ["xformOp:rotateX", "xformOp:rotateY", "xformOp:rotateZ"] | ||
// Where we convert these into xformOp:rotateXYZ. | ||
// As we are using USD's XformCommonAPI which supports only the following xformOps : | ||
// ["xformOp:translate", "xformOp:translate:pivot", "xformOp:rotateXYZ", "xformOp:scale", "!invert!xformOp:translate:pivot"] | ||
// We are extending the supported xform Operations with : | ||
// ["xformOp:rotateX", "xformOp:rotateY", "xformOp:rotateZ"] | ||
// Where we convert these into xformOp:rotateXYZ. | ||
|
||
static TfToken rotX("xformOp:rotateX"); | ||
static TfToken rotY("xformOp:rotateY"); | ||
static TfToken rotZ("xformOp:rotateZ"); | ||
static TfToken rotXYZ("xformOp:rotateXYZ"); | ||
static TfToken scale("xformOp:scale"); | ||
static TfToken trans("xformOp:translate"); | ||
static TfToken pivot("xformOp:translate:pivot"); | ||
static TfToken notPivot("!invert!xformOp:translate:pivot"); | ||
static TfToken rotX("xformOp:rotateX"); | ||
static TfToken rotY("xformOp:rotateY"); | ||
static TfToken rotZ("xformOp:rotateZ"); | ||
static TfToken rotXYZ("xformOp:rotateXYZ"); | ||
static TfToken scale("xformOp:scale"); | ||
static TfToken trans("xformOp:translate"); | ||
static TfToken pivot("xformOp:translate:pivot"); | ||
static TfToken notPivot("!invert!xformOp:translate:pivot"); | ||
|
||
auto xformable = UsdGeomXformable(prim); | ||
bool resetsXformStack; | ||
auto xformOps = xformable.GetOrderedXformOps(&resetsXformStack); | ||
xformable.ClearXformOpOrder(); | ||
auto primXform = UsdGeomXformCommonAPI(prim); | ||
for (const auto& op : xformOps) | ||
{ | ||
auto opName = op.GetOpName(); | ||
auto xformable = UsdGeomXformable(prim); | ||
bool resetsXformStack; | ||
auto xformOps = xformable.GetOrderedXformOps(&resetsXformStack); | ||
xformable.ClearXformOpOrder(); | ||
auto primXform = UsdGeomXformCommonAPI(prim); | ||
for (const auto& op : xformOps) | ||
{ | ||
auto opName = op.GetOpName(); | ||
|
||
// RotateX, RotateY, RotateZ | ||
if ((opName == rotX) || (opName == rotY) || (opName == rotZ)) | ||
{ | ||
float retValue; | ||
if (op.Get<float>(&retValue)) | ||
{ | ||
if (opName == rotX) | ||
primXform.SetRotate(GfVec3f(retValue, 0, 0)); | ||
else if (opName == rotY) | ||
primXform.SetRotate(GfVec3f(0, retValue, 0)); | ||
else if (opName == rotZ) | ||
primXform.SetRotate(GfVec3f(0, 0, retValue)); | ||
} | ||
} | ||
// RotateXYZ | ||
else if (opName == rotXYZ) | ||
{ | ||
GfVec3f retValue; | ||
if (op.Get<GfVec3f>(&retValue)) | ||
{ | ||
primXform.SetRotate(retValue); | ||
} | ||
} | ||
// Scale | ||
else if (opName == scale) | ||
{ | ||
GfVec3f retValue; | ||
if (op.Get<GfVec3f>(&retValue)) | ||
{ | ||
primXform.SetScale(retValue); | ||
} | ||
} | ||
// Translate | ||
else if (opName == trans) | ||
{ | ||
GfVec3d retValue; | ||
if (op.Get<GfVec3d>(&retValue)) | ||
{ | ||
primXform.SetTranslate(retValue); | ||
} | ||
} | ||
// Scale / rotate pivot | ||
else if (opName == pivot) | ||
{ | ||
GfVec3f retValue; | ||
if (op.Get<GfVec3f>(&retValue)) | ||
{ | ||
primXform.SetPivot(retValue); | ||
} | ||
} | ||
// Scale / rotate pivot inverse | ||
else if (opName == notPivot) | ||
{ | ||
// automatically added, nothing to do. | ||
} | ||
// Not compatible | ||
else | ||
{ | ||
// Restore old | ||
xformable.SetXformOpOrder(xformOps); | ||
std::string err = TfStringPrintf("Incompatible xform op %s:", op.GetOpName().GetString().c_str()); | ||
throw std::runtime_error(err.c_str()); | ||
} | ||
} | ||
return primXform; | ||
// RotateX, RotateY, RotateZ | ||
if ((opName == rotX) || (opName == rotY) || (opName == rotZ)) | ||
{ | ||
float retValue; | ||
if (op.Get<float>(&retValue)) | ||
{ | ||
if (opName == rotX) | ||
primXform.SetRotate(GfVec3f(retValue, 0, 0)); | ||
else if (opName == rotY) | ||
primXform.SetRotate(GfVec3f(0, retValue, 0)); | ||
else if (opName == rotZ) | ||
primXform.SetRotate(GfVec3f(0, 0, retValue)); | ||
} | ||
} | ||
// RotateXYZ | ||
else if (opName == rotXYZ) | ||
{ | ||
GfVec3f retValue; | ||
if (op.Get<GfVec3f>(&retValue)) | ||
{ | ||
primXform.SetRotate(retValue); | ||
} | ||
} | ||
// Scale | ||
else if (opName == scale) | ||
{ | ||
GfVec3f retValue; | ||
if (op.Get<GfVec3f>(&retValue)) | ||
{ | ||
primXform.SetScale(retValue); | ||
} | ||
} | ||
// Translate | ||
else if (opName == trans) | ||
{ | ||
GfVec3d retValue; | ||
if (op.Get<GfVec3d>(&retValue)) | ||
{ | ||
primXform.SetTranslate(retValue); | ||
} | ||
} | ||
// Scale / rotate pivot | ||
else if (opName == pivot) | ||
{ | ||
GfVec3f retValue; | ||
if (op.Get<GfVec3f>(&retValue)) | ||
{ | ||
primXform.SetPivot(retValue); | ||
} | ||
} | ||
// Scale / rotate pivot inverse | ||
else if (opName == notPivot) | ||
{ | ||
// automatically added, nothing to do. | ||
} | ||
// Not compatible | ||
else | ||
{ | ||
// Restore old | ||
xformable.SetXformOpOrder(xformOps); | ||
std::string err = TfStringPrintf("Incompatible xform op %s:", op.GetOpName().GetString().c_str()); | ||
throw std::runtime_error(err.c_str()); | ||
} | ||
} | ||
return primXform; | ||
} | ||
|
||
void applyCommandRestriction(const UsdPrim& prim, const std::string& commandName) | ||
{ | ||
// early check to see if a particular node has any specs to contribute | ||
// to the final composed prim. e.g (a node in payload) | ||
if(!MayaUsdUtils::hasSpecs(prim)){ | ||
std::string err = TfStringPrintf("Cannot %s [%s] because it doesn't have any specs to contribute to the composed prim.", | ||
commandName.c_str(), | ||
prim.GetName().GetString().c_str()); | ||
|
||
auto layers = MayaUsdUtils::layerInCompositionArcsWithSpec(prim); | ||
std::string layerDisplayNames; | ||
for (auto layer : layers) { | ||
layerDisplayNames.append("[" + layer->GetDisplayName() + "]" + ","); | ||
} | ||
layerDisplayNames.pop_back(); | ||
std::string err = TfStringPrintf("Cannot %s [%s]. It does not make any contributions in the current layer " | ||
"because its specs are in an external composition arc. Please open %s to make direct edits.", | ||
commandName.c_str(), | ||
prim.GetName().GetString().c_str(), | ||
layerDisplayNames.c_str()); | ||
throw std::runtime_error(err.c_str()); | ||
} | ||
|
||
// if the current layer doesn't have any contributions | ||
if (!MayaUsdUtils::doesEditTargetLayerContribute(prim)) { | ||
auto strongestContributingLayer = MayaUsdUtils::strongestContributingLayer(prim); | ||
std::string err = TfStringPrintf("Cannot %s [%s] defined on another layer. " | ||
"Please set [%s] as the target layer to proceed", | ||
std::string err = TfStringPrintf("Cannot %s [%s]. It is defined on another layer. Please set [%s] as the target layer to proceed.", | ||
commandName.c_str(), | ||
prim.GetName().GetString().c_str(), | ||
strongestContributingLayer->GetDisplayName().c_str()); | ||
|
@@ -158,8 +166,7 @@ void applyCommandRestriction(const UsdPrim& prim, const std::string& commandName | |
layerDisplayNames.append("[" + layer->GetDisplayName() + "]" + ","); | ||
} | ||
layerDisplayNames.pop_back(); | ||
std::string err = TfStringPrintf("Cannot %s [%s] with definitions or opinions on other layers. " | ||
"Opinions exist in %s", | ||
std::string err = TfStringPrintf("Cannot %s [%s]. It has definitions or opinions on other layers. Opinions exist in %s", | ||
commandName.c_str(), | ||
prim.GetName().GetString().c_str(), | ||
layerDisplayNames.c_str()); | ||
|
@@ -174,82 +181,82 @@ void applyCommandRestriction(const UsdPrim& prim, const std::string& commandName | |
|
||
void translateOp(const UsdPrim& prim, const Ufe::Path& path, double x, double y, double z) | ||
{ | ||
auto primXform = UsdGeomXformCommonAPI(prim); | ||
if (!primXform.SetTranslate(GfVec3d(x, y, z))) | ||
{ | ||
// This could mean that we have an incompatible xformOp in the stack | ||
try { | ||
primXform = convertToCompatibleCommonAPI(prim); | ||
if (!primXform.SetTranslate(GfVec3d(x,y,z))) | ||
throw std::runtime_error("Unable to SetTranslate after conversion to CommonAPI."); | ||
} | ||
catch (const std::exception& e) { | ||
std::string err = TfStringPrintf("Failed to translate prim %s - %s", | ||
path.string().c_str(), e.what()); | ||
UFE_LOG(err.c_str()); | ||
throw; | ||
} | ||
} | ||
auto primXform = UsdGeomXformCommonAPI(prim); | ||
if (!primXform.SetTranslate(GfVec3d(x, y, z))) | ||
{ | ||
// This could mean that we have an incompatible xformOp in the stack | ||
try { | ||
primXform = convertToCompatibleCommonAPI(prim); | ||
if (!primXform.SetTranslate(GfVec3d(x,y,z))) | ||
throw std::runtime_error("Unable to SetTranslate after conversion to CommonAPI."); | ||
} | ||
catch (const std::exception& e) { | ||
std::string err = TfStringPrintf("Failed to translate prim %s - %s", | ||
path.string().c_str(), e.what()); | ||
UFE_LOG(err.c_str()); | ||
throw; | ||
} | ||
} | ||
} | ||
|
||
void rotateOp(const UsdPrim& prim, const Ufe::Path& path, double x, double y, double z) | ||
{ | ||
auto primXform = UsdGeomXformCommonAPI(prim); | ||
if (!primXform.SetRotate(GfVec3f(x, y, z))) | ||
{ | ||
// This could mean that we have an incompatible xformOp in the stack | ||
try { | ||
primXform = convertToCompatibleCommonAPI(prim); | ||
if (!primXform.SetRotate(GfVec3f(x, y, z))) | ||
throw std::runtime_error("Unable to SetRotate after conversion to CommonAPI."); | ||
} | ||
catch (const std::exception& e) { | ||
std::string err = TfStringPrintf("Failed to rotate prim %s - %s", | ||
path.string().c_str(), e.what()); | ||
UFE_LOG(err.c_str()); | ||
throw; | ||
} | ||
} | ||
auto primXform = UsdGeomXformCommonAPI(prim); | ||
if (!primXform.SetRotate(GfVec3f(x, y, z))) | ||
{ | ||
// This could mean that we have an incompatible xformOp in the stack | ||
try { | ||
primXform = convertToCompatibleCommonAPI(prim); | ||
if (!primXform.SetRotate(GfVec3f(x, y, z))) | ||
throw std::runtime_error("Unable to SetRotate after conversion to CommonAPI."); | ||
} | ||
catch (const std::exception& e) { | ||
std::string err = TfStringPrintf("Failed to rotate prim %s - %s", | ||
path.string().c_str(), e.what()); | ||
UFE_LOG(err.c_str()); | ||
throw; | ||
} | ||
} | ||
} | ||
|
||
void scaleOp(const UsdPrim& prim, const Ufe::Path& path, double x, double y, double z) | ||
{ | ||
auto primXform = UsdGeomXformCommonAPI(prim); | ||
if (!primXform.SetScale(GfVec3f(x, y, z))) | ||
{ | ||
// This could mean that we have an incompatible xformOp in the stack | ||
try { | ||
primXform = convertToCompatibleCommonAPI(prim); | ||
if (!primXform.SetScale(GfVec3f(x, y, z))) | ||
throw std::runtime_error("Unable to SetScale after conversion to CommonAPI."); | ||
} | ||
catch (const std::exception& e) { | ||
std::string err = TfStringPrintf("Failed to scale prim %s - %s", | ||
path.string().c_str(), e.what()); | ||
UFE_LOG(err.c_str()); | ||
throw; | ||
} | ||
} | ||
auto primXform = UsdGeomXformCommonAPI(prim); | ||
if (!primXform.SetScale(GfVec3f(x, y, z))) | ||
{ | ||
// This could mean that we have an incompatible xformOp in the stack | ||
try { | ||
primXform = convertToCompatibleCommonAPI(prim); | ||
if (!primXform.SetScale(GfVec3f(x, y, z))) | ||
throw std::runtime_error("Unable to SetScale after conversion to CommonAPI."); | ||
} | ||
catch (const std::exception& e) { | ||
std::string err = TfStringPrintf("Failed to scale prim %s - %s", | ||
path.string().c_str(), e.what()); | ||
UFE_LOG(err.c_str()); | ||
throw; | ||
} | ||
} | ||
} | ||
|
||
void rotatePivotTranslateOp(const UsdPrim& prim, const Ufe::Path& path, double x, double y, double z) | ||
{ | ||
auto primXform = UsdGeomXformCommonAPI(prim); | ||
if (!primXform.SetPivot(GfVec3f(x, y, z))) | ||
{ | ||
// This could mean that we have an incompatible xformOp in the stack | ||
try { | ||
primXform = convertToCompatibleCommonAPI(prim); | ||
if (!primXform.SetPivot(GfVec3f(x, y, z))) | ||
throw std::runtime_error("Unable to SetPivot after conversion to CommonAPI."); | ||
} | ||
catch (const std::exception& e) { | ||
std::string err = TfStringPrintf("Failed to set pivot for prim %s - %s", | ||
path.string().c_str(), e.what()); | ||
UFE_LOG(err.c_str()); | ||
throw; | ||
} | ||
} | ||
auto primXform = UsdGeomXformCommonAPI(prim); | ||
if (!primXform.SetPivot(GfVec3f(x, y, z))) | ||
{ | ||
// This could mean that we have an incompatible xformOp in the stack | ||
try { | ||
primXform = convertToCompatibleCommonAPI(prim); | ||
if (!primXform.SetPivot(GfVec3f(x, y, z))) | ||
throw std::runtime_error("Unable to SetPivot after conversion to CommonAPI."); | ||
} | ||
catch (const std::exception& e) { | ||
std::string err = TfStringPrintf("Failed to set pivot for prim %s - %s", | ||
path.string().c_str(), e.what()); | ||
UFE_LOG(err.c_str()); | ||
throw; | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please ignore the tab conversion to dot changes by enabling "Hide whitespace changes" on github. |
||
} | ||
|
||
} // namespace ufe | ||
|
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.
@ppt-adsk Updating all the strings inside applyCommandRestriction routine.