From 5d70294aa6abcc4b53a03324a367b388343a6c60 Mon Sep 17 00:00:00 2001 From: Sean Donnelly <23455376+seando-adsk@users.noreply.github.com> Date: Thu, 24 Sep 2020 17:05:46 -0400 Subject: [PATCH] MAYA-106630 - See which prims have a composition arc including a variant * Added two new composition arc badge icons for use by Maya Outliner. * Implemented new Ufe::UIInfoHandler::treeViewTooltip() method to display "Introduced Composition Arcs". * Updated override for Ufe::UIInfoHandler::treeViewIcon() to return badge icon (as well as base icon). --- lib/mayaUsd/resources/icons/CMakeLists.txt | 2 + .../icons/out_USD_CompArcBadgeV_100.png | Bin 0 -> 356 bytes .../icons/out_USD_CompArcBadgeV_150.png | Bin 0 -> 531 bytes .../icons/out_USD_CompArcBadgeV_200.png | Bin 0 -> 710 bytes .../icons/out_USD_CompArcBadge_100.png | Bin 0 -> 294 bytes .../icons/out_USD_CompArcBadge_150.png | Bin 0 -> 398 bytes .../icons/out_USD_CompArcBadge_200.png | Bin 0 -> 552 bytes lib/mayaUsd/ufe/UsdUIInfoHandler.cpp | 130 ++++++++++++++++++ lib/mayaUsd/ufe/UsdUIInfoHandler.h | 5 + test/lib/ufe/testUIInfoHandler.py | 6 + 10 files changed, 143 insertions(+) create mode 100644 lib/mayaUsd/resources/icons/out_USD_CompArcBadgeV_100.png create mode 100644 lib/mayaUsd/resources/icons/out_USD_CompArcBadgeV_150.png create mode 100644 lib/mayaUsd/resources/icons/out_USD_CompArcBadgeV_200.png create mode 100644 lib/mayaUsd/resources/icons/out_USD_CompArcBadge_100.png create mode 100644 lib/mayaUsd/resources/icons/out_USD_CompArcBadge_150.png create mode 100644 lib/mayaUsd/resources/icons/out_USD_CompArcBadge_200.png diff --git a/lib/mayaUsd/resources/icons/CMakeLists.txt b/lib/mayaUsd/resources/icons/CMakeLists.txt index 54f360f738..6ff7b59823 100644 --- a/lib/mayaUsd/resources/icons/CMakeLists.txt +++ b/lib/mayaUsd/resources/icons/CMakeLists.txt @@ -7,6 +7,8 @@ if (CMAKE_UFE_V2_FEATURES_AVAILABLE) BlendShape Camera Capsule + CompArcBadge + CompArcBadgeV Cone Cube Cylinder diff --git a/lib/mayaUsd/resources/icons/out_USD_CompArcBadgeV_100.png b/lib/mayaUsd/resources/icons/out_USD_CompArcBadgeV_100.png new file mode 100644 index 0000000000000000000000000000000000000000..7451165061cbb5a1b01ead88b833b82110aaa3cb GIT binary patch literal 356 zcmV-q0h|7bP)%n1OdK2xe6~(tNq#$LhK~n#!xcvI+qp2j-?5p2;s1YzPe=AM zaH?rBaO)Z}a44xUd^)@ru26tOMUCOxmGfYM->+XXe7kXlK{B_D;p@e-41eCeg)0OG z0YAf^5AWd)|8!_C1B;Ld+*%M|1P1tj1|k4JfB^tgiA_pTO9RRP0000XP)=xW&klaGdB+dpRE%Ex1lKmySx$ui=Yr#&CPI6 zRLww5ARC&2xSElTok7Sah(X9djN#w+Zwy~fA7}V@a1Xp-V+DRfL``2F$)!;|g?28MtC@Wuoalm>+=7s!uHoLmggCUt-{Do&WgpfYDAP!&`e zkOuLUCe4Fzq45~V%)`qd91za%dii{~Q$HQr%fKQa#K5g<2}911qoz?9+hsiP>N`up`uhHuxeFz{N~Fo0YJ zqQ70e$ng8kE4XHGl4FySVfb<97Dk|aI=mMg4if1FU>fFRV`%<-{1C(c z-@h4nE$tZo{rti3`Q#By&5W#USfk_bm(L7e&Ygl7bm9m~yfa!^S>exCcmP0v0RYXf VmX0B|EF%B_002ovPDHLkV1i0=>rnsz literal 0 HcmV?d00001 diff --git a/lib/mayaUsd/resources/icons/out_USD_CompArcBadgeV_200.png b/lib/mayaUsd/resources/icons/out_USD_CompArcBadgeV_200.png new file mode 100644 index 0000000000000000000000000000000000000000..a1d0156152189ed6ea65fca13d8b8bef24a0160a GIT binary patch literal 710 zcmV;%0y+JOP)J$V$5UWJ0FDC*7Ldh;YvtBqhQw1u5znp%5D{=@97v=>gL1q`p!}oHQ!60!U!T z$y_Hr*Ccd8X#&(k<}PW3pCv_sW8Z$*No_lJ!P?mc+36Iq3m4C@2`lS>T_SUjOOhQ< zbexXBJ9HKnmwUY&EJ_2gM`W(@*%dkr|L_PbZjX3ZT+yJ-en5KuBeIKMQAnw#Z{}H)r&LYev6Tre{mce>% z-bUYe%=l52_)eV{{=n#CGhk_G#b_{_Oh97nX(cGL@L5>Tz)=&RCp;*u`u62NK+3Lz zH$ZB$Rx)5Vi>s@ZAa(MUXhHk#J!sqP7d~rOH*CFq!k^^#RT*-*v;qBMXnD@m_=G8w z+|o~EzI>upk>EabMEKmLY**%Hk^h}A0rH~5zPDdEcxd%p?RX?hWtD;4;bSF#tcDbU zWDE2P2X8<Q{8ksRprxSAOp9~p zT=K;uGe;a=2crcfZ#%0#8-=W1f4 sU@*wt9>fL-XBZ{rTCy7f_*Z}d01L0tJq2f_fB*mh07*qoM6N<$f_58H4*&oF literal 0 HcmV?d00001 diff --git a/lib/mayaUsd/resources/icons/out_USD_CompArcBadge_100.png b/lib/mayaUsd/resources/icons/out_USD_CompArcBadge_100.png new file mode 100644 index 0000000000000000000000000000000000000000..91c437fc7a454506d2c347e5f924453a5d61637c GIT binary patch literal 294 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4NtU=qlmzFem6RtIr7}3CCgZF_RK~bwrxve3#xUH;Xcx2P$*{NdX=ZA zN4Mr0A5V>$ACJtbES@uaYIw|*Z6qZU)tE%jrixDYnWVQa^~e9`{D*(Pm6q5SyZ6Y4 z=YONw*cM2M&G1|!6y*8o>|dVz>$=QZw@x(hNvvJ7CZh4$-=G&W4t+?x&)3FpZEl>v z?BifF@%%BtjJx@5{JXaqJYZ62o%p9rkLP`P4%=?l`A&>{qNZ*6;pdDWFe|hkPpvJPg6@cBKaLA%Z|ZF?hQAxvX zf(4HzIUw!_;y@r~#HIk3<`^KJ0mR(Q+&m0?woVM(hNcYc@=6RWf$O>76-iVLtH1Duq7=GNn z#qgxNfq~)QKfKYv1f@Zt$_4Tx6DJqLvq>EUHNrH5;xUk!hnGP(Ae`a#^7(k3imn-y z02ujf92x$8{sajeA^{UL3X zEOq+e)r+?WqNDQ0a zGYlqPf9$xM9d^^OMGWw_NtU5>`=IprU~TJ!#nl4IW)pj(b7MRd%4SGni!|);k<5w> z&WRZ~N2g$Ju>W=vvs^}OkA`KA?fyZyf+3jgjbg3vlEusQ6<%*|px(z&$fUpgE0-0M zBs2$C;TV||^ZCalo(>O?x;TZF&zDV6{w6m6F4nrXj)uN|fbRJD_z21U2sAbKXZ7T7 z1=!`-wG=9e6^lrOH<3C&L8bVdAy?DMcgB~`nZ>s^kiI-aHIQ^uv(ExtO)da~k6EqQ zhoEj+VGXV(7vSL_f?6O^c1_#?raDXMs06NNF_)`NP;V=8zgL)+eU`d7L#>eXMu*bn z6%%Y)Ew369?B&4fX%`dR0Y<=r9UNF%++sqF#|#UKCY9=yQmb0000= 2024 +#include +#include // SdfFieldKeys +#include // SdfReferenceListOp/SdfPayloadListOp/SdfPathListOp +#endif + #include #include #include +#include + +#if UFE_PREVIEW_VERSION_NUM >= 2024 +namespace +{ + // Simple helper to add the metadata strings to the end of the input tooltip string. + // Depending on the count, will add singular string or plural (with count). + void addMetadataStrings(const int nb, std::string& tooltip, bool& needComma, const std::string& singular, const std::string& plural) + { + if (nb <= 0) return; + if (tooltip.empty()) + tooltip += "Introduced Composition Arcs: "; + if (needComma) + tooltip += ", "; + if (nb == 1) { + tooltip += singular; + } + else { + tooltip += std::to_string(nb); + tooltip += " "; + tooltip += plural; + } + needComma = true; + } + + // Simple template helper function to handle all the various types of listOps. + template + void addMetadataCount(const T& op, std::string& tooltip, bool& needComma, const std::string& singular, const std::string& plural) + { + T::ItemVector refs; + op.ApplyOperations(&refs); + if (!refs.empty()) { + addMetadataStrings(refs.size(), tooltip, needComma, singular, plural); + } + } +} +#endif MAYAUSD_NS_DEF { namespace ufe { @@ -73,11 +116,19 @@ bool UsdUIInfoHandler::treeViewCellInfo(const Ufe::SceneItem::Ptr& item, Ufe::Ce return changed; } +#if UFE_PREVIEW_VERSION_NUM >= 2024 +Ufe::UIInfoHandler::Icon UsdUIInfoHandler::treeViewIcon(const Ufe::SceneItem::Ptr& item) const +#else std::string UsdUIInfoHandler::treeViewIcon(const Ufe::SceneItem::Ptr& item) const +#endif { // Special case for nullptr input. if (!item) { +#if UFE_PREVIEW_VERSION_NUM >= 2024 + return Ufe::UIInfoHandler::Icon("out_USD_UsdTyped.png"); // Default USD icon +#else return "out_USD_UsdTyped.png"; // Default USD icon +#endif } // We support these node types directly. @@ -106,14 +157,93 @@ std::string UsdUIInfoHandler::treeViewIcon(const Ufe::SceneItem::Ptr& item) cons {"Volume", "out_USD_Volume.png"} }; +#if UFE_PREVIEW_VERSION_NUM >= 2024 + Ufe::UIInfoHandler::Icon icon; // Default is empty (no icon and no badge). +#endif + const auto search = supportedTypes.find(item->nodeType()); if (search != supportedTypes.cend()) { +#if UFE_PREVIEW_VERSION_NUM >= 2024 + icon.baseIcon = search->second; +#else return search->second; +#endif } +#if UFE_PREVIEW_VERSION_NUM >= 2024 + // Check if we have any composition meta data - if yes we display a special badge. + UsdSceneItem::Ptr usdItem = std::dynamic_pointer_cast(item); + if (usdItem) + { + // Variants + if (!usdItem->prim().GetVariantSets().GetNames().empty()) + { + icon.badgeIcon = "out_USD_CompArcBadgeV.png"; + icon.pos = Ufe::UIInfoHandler::LowerRight; + } + else + { + // Composition related metadata. + static const std::vector compKeys = { + PXR_NS::SdfFieldKeys->References, SdfFieldKeys->Payload, SdfFieldKeys->InheritPaths, SdfFieldKeys->Specializes}; + for (const auto& k : compKeys) + { + if (usdItem->prim().HasMetadata(k)) + { + icon.badgeIcon = "out_USD_CompArcBadge.png"; + icon.pos = Ufe::UIInfoHandler::LowerRight; + break; + } + } + } + } + + return icon; +#else // No specific node type icon was found. return ""; +#endif +} + +#if UFE_PREVIEW_VERSION_NUM >= 2024 +std::string UsdUIInfoHandler::treeViewTooltip(const Ufe::SceneItem::Ptr& item) const +{ + std::string tooltip; + + UsdSceneItem::Ptr usdItem = std::dynamic_pointer_cast(item); + if (usdItem) + { + // Composition related metadata. + bool needComma = false; + PXR_NS::SdfReferenceListOp referenceOp; + if (usdItem->prim().GetMetadata(PXR_NS::SdfFieldKeys->References, &referenceOp)) { + addMetadataCount(referenceOp, tooltip, needComma, "Reference", "References"); + } + + PXR_NS::SdfPayloadListOp payloadOp; + if (usdItem->prim().GetMetadata(PXR_NS::SdfFieldKeys->Payload, &payloadOp)) { + addMetadataCount(payloadOp, tooltip, needComma, "Payload", "Payloads"); + } + + PXR_NS::SdfPathListOp inheritOp; + if (usdItem->prim().GetMetadata(PXR_NS::SdfFieldKeys->InheritPaths, &inheritOp)) { + addMetadataCount(inheritOp, tooltip, needComma, "Inherit", "Inherits"); + } + + PXR_NS::SdfPathListOp specializeOp; + if (usdItem->prim().GetMetadata(PXR_NS::SdfFieldKeys->Specializes, &specializeOp)) { + addMetadataCount(specializeOp, tooltip, needComma, "Specialize", "Specializes"); + } + + // Variants + const auto& variants = usdItem->prim().GetVariantSets().GetNames(); + if (!variants.empty()) { + addMetadataStrings(variants.size(), tooltip, needComma, "Variant", "Variants"); + } + } + return tooltip; } +#endif std::string UsdUIInfoHandler::getLongRunTimeLabel() const { diff --git a/lib/mayaUsd/ufe/UsdUIInfoHandler.h b/lib/mayaUsd/ufe/UsdUIInfoHandler.h index 2ac4bae268..fecee5cc67 100644 --- a/lib/mayaUsd/ufe/UsdUIInfoHandler.h +++ b/lib/mayaUsd/ufe/UsdUIInfoHandler.h @@ -45,7 +45,12 @@ class MAYAUSD_CORE_PUBLIC UsdUIInfoHandler : public Ufe::UIInfoHandler // Ufe::UIInfoHandler overrides bool treeViewCellInfo(const Ufe::SceneItem::Ptr& item, Ufe::CellInfo& info) const override; +#if UFE_PREVIEW_VERSION_NUM >= 2024 + Ufe::UIInfoHandler::Icon treeViewIcon(const Ufe::SceneItem::Ptr& item) const override; + std::string treeViewTooltip(const Ufe::SceneItem::Ptr& item) const override; +#else std::string treeViewIcon(const Ufe::SceneItem::Ptr& item) const override; +#endif std::string getLongRunTimeLabel() const override; }; // UsdUIInfoHandler diff --git a/test/lib/ufe/testUIInfoHandler.py b/test/lib/ufe/testUIInfoHandler.py index a4802c997f..4405210878 100644 --- a/test/lib/ufe/testUIInfoHandler.py +++ b/test/lib/ufe/testUIInfoHandler.py @@ -75,3 +75,9 @@ def testUIInfo(self): # Strikeout should be be set and the text fg color changed. self.assertTrue(ci.fontStrikeout) self.assertTrue(initTextFgClr != ci.textFgColor) + + if(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') >= '2024'): + # Ball_3 should have a specific node type icon set and no badge. + icon = ufeUIInfo.treeViewIcon(ball3Hier) + self.assertEqual(icon.baseIcon, "out_USD_Sphere.png") + self.assertFalse(icon.badgeIcon) # empty string