def testProperties(self):
        prims = [
            self.stage.GetPrimAtPath(path) for path in [
                '/MyPrim1/Child1', '/MyPrim1/Child2', '/MyPrim1/Child3',
                '/MyPrim1/Child4'
            ]
        ]

        model = UsdQt.OpinionStandardModel(prims)
        primIndex = model.index(0, 0, QtCore.QModelIndex())
        proxy = model.GetProxyForIndex(primIndex)
        self.assertEqual(proxy.GetNames(),
                         ['Child1', 'Child2', 'Child3', 'Child4'])
        self.assertEqual(model.data(primIndex),
                         'Child1, Child2, Child3, Child4')

        metadataGroupIndex = model.index(0, 0, primIndex)
        attributeGroupIndex = model.index(1, 0, primIndex)
        relationshipGroupIndex = model.index(2, 0, primIndex)

        self.assertGreater(model.rowCount(metadataGroupIndex), 0)
        self.assertEqual(model.rowCount(attributeGroupIndex), 2)
        self.assertEqual(model.rowCount(relationshipGroupIndex), 1)

        self.assertEqual(model.index(0, 0, attributeGroupIndex).data(), "x")
        self.assertEqual(model.index(0, 1, attributeGroupIndex).data(), "")
        self.assertEqual(
            model.index(0, 2, attributeGroupIndex).data(QtCore.Qt.DisplayRole),
            "")
        self.assertEqual(
            model.index(0, 2, attributeGroupIndex).data(QtCore.Qt.EditRole),
            None)

        self.assertEqual(model.index(1, 0, attributeGroupIndex).data(), "y")
        self.assertEqual(model.index(1, 1, attributeGroupIndex).data(), "int")
        self.assertEqual(
            model.index(1, 2, attributeGroupIndex).data(QtCore.Qt.DisplayRole),
            "2")
        self.assertEqual(
            model.index(1, 2, attributeGroupIndex).data(QtCore.Qt.EditRole), 2)

        self.assertEqual(
            model.index(0, 0, relationshipGroupIndex).data(), "rel1")
Beispiel #2
0
                objects = proxy.GetObjects()
                obj = objects[0]
                if type(obj) == Usd.Prim:
                    self.editor.LaunchOpinionViewer(
                        obj, _PrimMetadataHandler(proxy.GetName()))

    def ResetPrims(self, prims):
        self.model.ResetPrims(prims)
        self.editor.ResetColumnSpanned()

        # TODO: This is a hack that should be revisited
        self.editor.view.expandToDepth(1)


if __name__ == '__main__':
    import sys
    app = QtWidgets.QApplication(sys.argv)
    stage = Usd.Stage.Open(
        '../usdQt/testenv/testUsdQtOpinionModel/simple.usda')
    prim = stage.GetPrimAtPath('/MyPrim1/Child1')

    model = UsdQt.OpinionStandardModel([prim])
    # modelComposition = compositionModel.CompositionStandardModel(prim)
    editor = OpinionEditor()

    controller = OpinionController(model, editor)
    editor.SetSourceModel(model)
    editor.show()

    sys.exit(app.exec_())