diff --git a/pxr/usdImaging/bin/testusdview/testenv/testUsdviewMetadatatabSelect/test.usda b/pxr/usdImaging/bin/testusdview/testenv/testUsdviewMetadatatabSelect/test.usda index 1bfacda570..f5579cc4cf 100644 --- a/pxr/usdImaging/bin/testusdview/testenv/testUsdviewMetadatatabSelect/test.usda +++ b/pxr/usdImaging/bin/testusdview/testenv/testUsdviewMetadatatabSelect/test.usda @@ -1,4 +1,7 @@ #usda 1.0 +( + upAxis = 'Z' +) def Xform "Implicits" ( add variantSets = "shapeVariant" diff --git a/pxr/usdImaging/bin/testusdview/testenv/testUsdviewMetadatatabSelect/testUsdviewMetadatatabSelect.py b/pxr/usdImaging/bin/testusdview/testenv/testUsdviewMetadatatabSelect/testUsdviewMetadatatabSelect.py index 0ec88809cc..0d45732491 100644 --- a/pxr/usdImaging/bin/testusdview/testenv/testUsdviewMetadatatabSelect/testUsdviewMetadatatabSelect.py +++ b/pxr/usdImaging/bin/testusdview/testenv/testUsdviewMetadatatabSelect/testUsdviewMetadatatabSelect.py @@ -10,6 +10,7 @@ from pxr.Usdviewq.qt import QtWidgets class MetadataKeys(ConstantsGroup): + ROOT_METADATA_KEY = "upAxis" APPLIED_API_SCHEMAS_FIELD = "[applied API schemas]" AUTHORED_API_SCHEMAS_FIELD = 'apiSchemas' @@ -62,12 +63,31 @@ def _testBasic(appController): assert inspectorView.tabText(inspectorView.currentIndex()) == 'Composition' def _testAPISchemaMetadata(appController): + # Check root metadata is visible inspectorView = appController._ui.propertyInspector + appController.selectPseudoroot() inspectorView.setCurrentIndex(1) - appController._ui.primViewLineEdit.setText('RectLight') - appController._primViewFindNext() - appController._mainWindow.repaint() assert inspectorView.tabText(inspectorView.currentIndex()) == 'Meta Data' + appController._mainWindow.repaint() + metadataTable = inspectorView.currentWidget().findChildren( + QtWidgets.QTableWidget)[0] + + foundRootMetadata = False + for i in range(metadataTable.rowCount()): + fieldName = str(metadataTable.item(i, 0).text()) + value = str(metadataTable.item(i, 1).text()) + if fieldName == MetadataKeys.ROOT_METADATA_KEY: + foundRootMetadata = True + break + + assert foundRootMetadata + + # Check Applied API schemas are set and correct + inspectorView = appController._ui.propertyInspector + inspectorView.setCurrentIndex(1) + appController._ui.primViewLineEdit.setText('Light') + appController._primViewFindNext() + appController._updateMetadataView() metadataTable = inspectorView.currentWidget().findChildren( QtWidgets.QTableWidget)[0] @@ -84,7 +104,7 @@ def _testAPISchemaMetadata(appController): prim = appController._dataModel.selection.getFocusPrim() UsdLux.MeshLightAPI.Apply(prim) - appController._mainWindow.repaint() + appController._updateMetadataView() apiDef = reg.FindAppliedAPIPrimDefinition("MeshLightAPI") additionalAppliedSchemas = primDef.GetAppliedAPISchemas() diff --git a/pxr/usdImaging/usdviewq/appController.py b/pxr/usdImaging/usdviewq/appController.py index 30b9d8658f..6e60a3acd5 100644 --- a/pxr/usdImaging/usdviewq/appController.py +++ b/pxr/usdImaging/usdviewq/appController.py @@ -4236,21 +4236,12 @@ def _updateMetadataView(self, obj=None): "references", "specializes", "payload", "subLayers"] - for k in compKeys: v = obj.GetMetadata(k) if not v is None: m[k] = v - clipMetadata = obj.GetMetadata("clips") - if clipMetadata is None: - clipMetadata = {} - numClipRows = 0 - for (clip, data) in clipMetadata.items(): - numClipRows += len(data) - m["clips"] = clipMetadata - - numMetadataRows = (len(m) - 1) + numClipRows + m["clips"] = obj.GetMetadata("clips") or {} # Variant selections that don't have a defined variant set will be # displayed as well to aid debugging. Collect them separately from @@ -4285,9 +4276,6 @@ def _updateMetadataView(self, obj=None): # Remove found variant set from setless. setlessVariantSelections.pop(variantSetName, None) - tableWidget.setRowCount(numMetadataRows + len(variantSets) + - len(setlessVariantSelections) + 2) - rowIndex = 0 # Although most metadata should be presented alphabetically,the most @@ -4295,6 +4283,7 @@ def _updateMetadataView(self, obj=None): # list, these consist of [object type], [path], variant sets, active, # assetInfo, and kind. def populateMetadataTable(key, val, rowIndex): + tableWidget.insertRow(rowIndex) attrName = QtWidgets.QTableWidgetItem(str(key)) tableWidget.setItem(rowIndex, 0, attrName) @@ -4304,6 +4293,12 @@ def populateMetadataTable(key, val, rowIndex): tableWidget.setItem(rowIndex, 1, attrVal) + def populateMetadataTableVariant(key, val, rowIndex): + tableWidget.insertRow(rowIndex) + attrName = QtWidgets.QTableWidgetItem(str(key + ' variant')) + tableWidget.setItem(rowIndex, 0, attrName) + tableWidget.setCellWidget(rowIndex, 1, val) + sortedKeys = sorted(m.keys()) reorderedKeys = ["kind", "assetInfo", "active"] @@ -4330,9 +4325,7 @@ def populateMetadataTable(key, val, rowIndex): rowIndex += 1 for variantSetName, combo in variantSets.items(): - attrName = QtWidgets.QTableWidgetItem(str(variantSetName+ ' variant')) - tableWidget.setItem(rowIndex, 0, attrName) - tableWidget.setCellWidget(rowIndex, 1, combo) + populateMetadataTableVariant(variantSetName, combo, rowIndex) combo.currentIndexChanged.connect( lambda i, combo=combo: combo.updateVariantSelection(i, self._makeTimer)) @@ -4341,15 +4334,12 @@ def populateMetadataTable(key, val, rowIndex): # Add all the setless variant selections directly after the variant # combo boxes for variantSetName, variantSelection in setlessVariantSelections.items(): - attrName = QtWidgets.QTableWidgetItem(str(variantSetName+ ' variant')) - tableWidget.setItem(rowIndex, 0, attrName) - valStr, ttStr = self._formatMetadataValueView(variantSelection) # Italicized label to stand out when debugging a scene. label = QtWidgets.QLabel('' + valStr + '') label.setIndent(3) label.setToolTip(ttStr) - tableWidget.setCellWidget(rowIndex, 1, label) + populateMetadataTableVariant(variantSetName, label, rowIndex) rowIndex += 1 @@ -4357,8 +4347,11 @@ def populateMetadataTable(key, val, rowIndex): if key == "clips": for (clip, metadataGroup) in m[key].items(): attrName = QtWidgets.QTableWidgetItem(str('clips:' + clip)) - tableWidget.setItem(rowIndex, 0, attrName) - for metadata in metadataGroup.keys(): + for i, metadata in enumerate(metadataGroup.keys()): + tableWidget.insertRow(rowIndex) + if i == 0: + tableWidget.setItem(rowIndex, 0, attrName) + dataPair = (metadata, metadataGroup[metadata]) valStr, ttStr = self._formatMetadataValueView(dataPair) attrVal = QtWidgets.QTableWidgetItem(valStr)