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

Add displayName Metadata to Prim Spec #2055

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions pxr/usd/sdf/schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,8 @@ SdfSchemaBase::_RegisterStandardFields()
SdfMetadataDisplayGroupTokens->core)
.MetadataField(SdfFieldKeys->DisplayGroupOrder,
SdfMetadataDisplayGroupTokens->core)
.MetadataField(SdfFieldKeys->DisplayName,
erslavin marked this conversation as resolved.
Show resolved Hide resolved
SdfMetadataDisplayGroupTokens->core)
.MetadataField(SdfFieldKeys->Documentation,
SdfMetadataDisplayGroupTokens->core)
.MetadataField(SdfFieldKeys->Hidden,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

class MfScope "Rig"
{
def MfScope "Leg"
def MfScope "Leg" (
displayName = "Foo"
)
{
custom double kneeFB (
displayName = "LkneeFB"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

class MfScope "Rig"
{
def MfScope "Leg"
def MfScope "Leg" (
displayName = "Foo"
)
{
custom rel foo = </Rig/Leg.kneeFB> (
displayName = "Lfoo"
Expand Down
1 change: 1 addition & 0 deletions pxr/usd/usd/testenv/testUsdMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ int main() {
_VerifyMetadata(prim, true, SdfFieldKeys->Active);
_VerifyMetadata(prim, true, SdfFieldKeys->Hidden);
_VerifyMetadata(prim, TfToken("DummyType"), SdfFieldKeys->TypeName);
_VerifyMetadata(prim, string("Display Name"), SdfFieldKeys->DisplayName);

// attribute metadata
_VerifyMetadata(attr, string("hello"), SdfFieldKeys->Comment);
Expand Down
7 changes: 7 additions & 0 deletions pxr/usd/usd/testenv/testUsdMetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@ def test_DisplayName(self):
attr = foo.CreateAttribute("attr", Sdf.ValueTypeNames.String)
rel = foo.CreateRelationship("rel")

# verify display name metadata on prim
self.assertEqual(foo.GetMetadata("displayName"), None)
self.assertEqual(foo.HasAuthoredMetadata("displayName"), False)
self.assertEqual(foo.SetMetadata("displayName", "foo"), True)
self.assertEqual(foo.GetMetadata("displayName"), "foo")
self.assertEqual(foo.HasAuthoredMetadata("displayName"), True)

spiffmon marked this conversation as resolved.
Show resolved Hide resolved
for prop in [attr, rel]:
self.assertEqual(prop.GetDisplayName(), "")
self.assertFalse(prop.HasAuthoredDisplayName())
Expand Down
4 changes: 3 additions & 1 deletion pxr/usd/usd/testenv/testUsdSchemaRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def test_PrimMetadata(self):
self.assertTrue(primDef)

self.assertEqual(set(primDef.ListMetadataFields()),
set(["typeName", "testCustomMetadata", "hidden", "documentation"]))
set(["typeName", "testCustomMetadata", "hidden", "documentation", "displayName"]))
self.assertEqual(primDef.GetMetadata("typeName"), "MetadataTest")
self.assertEqual(primDef.GetMetadata("displayName"), "Display Name")
self.assertEqual(primDef.GetMetadata("documentation"),
"Testing documentation metadata")
self.assertEqual(primDef.GetMetadata("hidden"), True)
Expand Down Expand Up @@ -419,6 +420,7 @@ def _VerifyExpectedPrimData(layer, path, expectedPrimFields,
# Expected fields and properties from the concrete schema.
concretePrimDefPrimFields = {
"apiSchemas" : Sdf.TokenListOp.CreateExplicit([]),
"displayName": "Display Name",
"documentation" : concretePrimDef.GetDocumentation(),
"hidden" : True,
"testCustomMetadata" : "garply",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class "AbstractTest" (
}

class MetadataTest "MetadataTest" (
displayName = "Display Name"
doc = "Testing documentation metadata"
hidden = true
testCustomMetadata = "garply"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class "AbstractTest" (

class MetadataTest "MetadataTest" (
inherits = </AbstractTest>
displayName = "Display Name"
spiffmon marked this conversation as resolved.
Show resolved Hide resolved
doc = "Testing documentation metadata"
hidden = true
testCustomMetadata = "garply"
Expand Down
52 changes: 44 additions & 8 deletions pxr/usdImaging/usdviewq/appController.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,13 @@ def __init__(self, parserData, resolverContextFn):
self._ui.actionShow_Abstract_Prims.triggered.connect(
self._toggleShowAbstractPrims)

# nv begin #prim-display-name
erslavin marked this conversation as resolved.
Show resolved Hide resolved

self._ui.actionShow_Prim_DisplayName.triggered.connect(
self._toggleShowPrimDisplayName)

# nv end

# Since setting column visibility is probably not a common
# operation, it's actually good to have Columns at the end.
self._ui.menuShow.addSeparator()
Expand Down Expand Up @@ -2185,16 +2192,31 @@ def _findPrims(self, pattern, useRegex=True):
pattern = pattern.lower()
isMatch = lambda x: pattern in x.lower()

matches = [prim.GetPath() for prim
in Usd.PrimRange.Stage(self._dataModel.stage,
self._displayPredicate)
if isMatch(prim.GetName())]
# nv begin #prim-display-name
if self._dataModel.viewSettings.showPrimDisplayNames:
matches = [prim.GetPath() for prim
in Usd.PrimRange.Stage(self._dataModel.stage,
self._displayPredicate)
if (isMatch(prim.GetMetadata("displayName")) or isMatch(prim.GetName()))]
else:
matches = [prim.GetPath() for prim
in Usd.PrimRange.Stage(self._dataModel.stage,
self._displayPredicate)
if isMatch(prim.GetName())]

if self._dataModel.viewSettings.showAllPrototypePrims:
for prototype in self._dataModel.stage.GetPrototypes():
matches += [prim.GetPath() for prim
in Usd.PrimRange(prototype, self._displayPredicate)
if isMatch(prim.GetName())]
if self._dataModel.viewSettings.showPrimDisplayNames:
for prototype in self._dataModel.stage.GetPrototypes():
matches += [prim.GetPath() for prim
in Usd.PrimRange(prototype, self._displayPredicate)
if (isMatch(prim.GetMetadata("displayName")) or isMatch(prim.GetName()))]
else:
for prototype in self._dataModel.stage.GetPrototypes():
matches += [prim.GetPath() for prim
in Usd.PrimRange(prototype, self._displayPredicate)
if isMatch(prim.GetName())]

#nv end

return matches

Expand Down Expand Up @@ -3189,6 +3211,15 @@ def _toggleShowAbstractPrims(self):
self._dataModel.selection.removeAbstractPrims()
self._resetPrimView()

# nv begin #prim-display-name

def _toggleShowPrimDisplayName(self):
self._dataModel.viewSettings.showPrimDisplayNames = (
self._ui.actionShow_Prim_DisplayName.isChecked())
self._resetPrimView()
spiffmon marked this conversation as resolved.
Show resolved Hide resolved

# nv end

def _toggleRolloverPrimInfo(self):
self._dataModel.viewSettings.rolloverPrimInfo = (
self._ui.actionRollover_Prim_Info.isChecked())
Expand Down Expand Up @@ -5234,6 +5265,11 @@ def _refreshShowPrimMenu(self):
self._ui.actionShow_Abstract_Prims.setChecked(
self._dataModel.viewSettings.showAbstractPrims)

# nv begin #prim-display-name
self._ui.actionShow_Prim_DisplayName.setChecked(
self._dataModel.viewSettings.showPrimDisplayNames)
# nv end

def _refreshRedrawOnScrub(self):
self._ui.redrawOnScrub.setChecked(
self._dataModel.viewSettings.redrawOnScrub)
Expand Down
9 changes: 9 additions & 0 deletions pxr/usdImaging/usdviewq/mainWindowUI.ui
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
<addaction name="actionShow_All_Prototype_Prims"/>
<addaction name="actionShow_Undefined_Prims"/>
<addaction name="actionShow_Abstract_Prims"/>
<addaction name="actionShow_Prim_DisplayName" />
</widget>
<addaction name="menuNavigation"/>
<addaction name="menuShow"/>
Expand Down Expand Up @@ -2660,6 +2661,14 @@
<string>Abstract Prims (Classes)</string>
</property>
</action>
<action name="actionShow_Prim_DisplayName">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Use Display Name (Prims)</string>
</property>
</action>
spiffmon marked this conversation as resolved.
Show resolved Hide resolved
<action name="actionPick_Prims">
<property name="checkable">
<bool>true</bool>
Expand Down
19 changes: 17 additions & 2 deletions pxr/usdImaging/usdviewq/primViewItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def _isComputedDrawModeInherited(self, parentDrawModeIsInherited=None):
return False

def _extractInfo(self, info):
# nv begin #prim-display-name
( self.hasArcs,
self.active,
self.imageable,
Expand All @@ -141,7 +142,10 @@ def _extractInfo(self, info):
isVisibilityInherited,
self.visVaries,
self.name,
self.typeName ) = info
self.typeName,
self.displayName ) = info

# nv end

parent = self.parent()
parentIsPrimViewItem = isinstance(parent, PrimViewItem)
Expand Down Expand Up @@ -227,7 +231,12 @@ def _GetForegroundColor(self):

def _nameData(self, role):
if role == QtCore.Qt.DisplayRole:
return self.name
# nv begin #prim-display-name
if self._appController._dataModel.viewSettings.showPrimDisplayNames:
return self.displayName if self.displayName != "" else self.name
else:
return self.name
# nv end
elif role == QtCore.Qt.FontRole:
# Abstract prims are also considered defined; since we want
# to distinguish abstract defined prims from non-abstract
Expand Down Expand Up @@ -256,6 +265,12 @@ def _nameData(self, role):
toolTip = 'Inactive ' + toolTip
elif self.isInstance:
toolTip = 'Instanced ' + toolTip

# nv begin #prim-display-name
# tooltip should always show both name and display name
toolTip = toolTip + "<br>Name: " + self.name + "<br>Display Name: " + self.displayName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @erslavin - I was not very clear in my request. If a prim has a displayName, then we should show both name and displayName regardless of the "Show Display Names" setting. But if a prim has no displayName, then I don't think we need to add anything here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified to conform to this behavior

# nv end

if self.hasArcs:
toolTip = toolTip + "<br>Has composition arcs"
return toolTip
Expand Down
13 changes: 13 additions & 0 deletions pxr/usdImaging/usdviewq/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ UsdviewqUtils::PrimInfo::PrimInfo(const UsdPrim &prim, const UsdTimeCode time)
else
name = _tokens->root.GetString();
typeName = prim.GetTypeName().GetString();

// nv begin #prim-display-name
spiffmon marked this conversation as resolved.
Show resolved Hide resolved

if (prim.HasAuthoredMetadata(SdfFieldKeys->DisplayName))
{
prim.GetMetadata<std::string>(SdfFieldKeys->DisplayName, &displayName);
spiffmon marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
displayName = "";
}

// nv end
}

/*static*/
Expand Down
4 changes: 4 additions & 0 deletions pxr/usdImaging/usdviewq/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class UsdviewqUtils {
bool visVaries;
std::string name;
std::string typeName;

// nv begin #prim-display-name
std::string displayName;
// nv end
spiffmon marked this conversation as resolved.
Show resolved Hide resolved
};

/// For the given \p stage and \p schemaType, return all active, defined
Expand Down
18 changes: 18 additions & 0 deletions pxr/usdImaging/usdviewq/viewSettingsDataModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ def __init__(self, rootDataModel, parent):

self._showUndefinedPrims = self.stateProperty("showUndefinedPrims", default=False)
self._showAbstractPrims = self.stateProperty("showAbstractPrims", default=False)
# nv begin #prim-display-name
self._showPrimDisplayNames = self.stateProperty("showPrimDisplayNames", default=True)
# nv end
self._rolloverPrimInfo = self.stateProperty("rolloverPrimInfo", default=False)
self._displayCameraOracles = self.stateProperty("cameraOracles", default=False)
self._cameraMaskMode = self.stateProperty("cameraMaskMode", default=CameraMaskModes.NONE)
Expand Down Expand Up @@ -259,6 +262,9 @@ def onSaveState(self, state):
state["showAllMasterPrims"] = self._showAllPrototypePrims
state["showUndefinedPrims"] = self._showUndefinedPrims
state["showAbstractPrims"] = self._showAbstractPrims
# nv begin #prim-display-name
state["showPrimDisplayNames"] = self._showPrimDisplayNames
# nv end
state["rolloverPrimInfo"] = self._rolloverPrimInfo
state["cameraOracles"] = self._displayCameraOracles
state["cameraMaskMode"] = self._cameraMaskMode
Expand Down Expand Up @@ -635,6 +641,18 @@ def showAbstractPrims(self):
def showAbstractPrims(self, value):
self._showAbstractPrims = value

# nv begin #prim-display-name
@property
def showPrimDisplayNames(self):
return self._showPrimDisplayNames

@showPrimDisplayNames.setter
@invisibleViewSetting
def showPrimDisplayNames(self, value):
self._showPrimDisplayNames = value

# nv end

@property
def rolloverPrimInfo(self):
return self._rolloverPrimInfo
Expand Down
6 changes: 5 additions & 1 deletion pxr/usdImaging/usdviewq/wrapUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ _GetPrimInfo(UsdPrim const &prim, UsdTimeCode time)
{
UsdviewqUtils::PrimInfo info = UsdviewqUtils::GetPrimInfo(prim, time);

// nv begin #prim-display-name
spiffmon marked this conversation as resolved.
Show resolved Hide resolved
return boost::python::make_tuple(info.hasCompositionArcs,
info.isActive,
info.isImageable,
Expand All @@ -60,7 +61,10 @@ _GetPrimInfo(UsdPrim const &prim, UsdTimeCode time)
info.isVisibilityInherited,
info.visVaries,
info.name,
info.typeName);
info.typeName,
info.displayName);

// nv end
}

} // anonymous namespace
Expand Down