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

HierarchyModel: Add support for automatically populating parents when looking up path #17

Open
nrusch opened this issue Sep 27, 2018 · 2 comments
Assignees

Comments

@nrusch
Copy link
Collaborator

nrusch commented Sep 27, 2018

Currently, the HierarchyModel does not provide a way to search for a prim path in the active stage. While there is a GetIndexForPath method, this only looks at the current state of the hierarchy cache, without populating it any further.

We have an internal need to be able to look up a path's index (if present) without knowing whether the path's parent already exists in the hierarchy cache, and I think it makes sense to add this to the model as a first-class feature. This can currently be done semi-manually by recursing through the path's prefixes and calling HierarchyModel.index() for each child row, but I would like to implement this on the HierarchyModel in a more efficient way (possibly doing the leg work in the C++ _HierarchyCache class).

@nrusch nrusch self-assigned this Sep 27, 2018
@bfloch
Copy link

bfloch commented Dec 10, 2018

Hi @nrusch,

Please correct me if I am wrong:
Iterating SdfPath prefixes is not enough, since it does not know about the order among other child prims. Therefore the row necessary for the index can not be extracted.

I wonder what the most efficient way to do this correctly would be.
SdfChildrenView? Stage traversal is depth-first so one would pretty much need to go through the whole stage. At this point the cache is not that lazy anymore.

Is there a current workaround that you can share? Our use case is pretty much a prim seleciton in a stageView that we want to communicate to the Outliner.

Thanks.

@nrusch
Copy link
Collaborator Author

nrusch commented Dec 19, 2018

Hey @bfloch,

Iterating SdfPath prefixes is not enough, since it does not know about the order among other child prims.

I was only mentioning that in relation to the current brute-force workaround we are using internally with the HierarchyModel itself, which looks something like this:

lastIndex = model.GetIndexForPath('/')
for prefix in pathToPopulate.GetPrefixes():
    index = model.GetIndexForPath(prefix)
    if not index:
        for row in xrange(model.rowCount(lastIndex)):
            model.index(row, 0, lastIndex
    lastIndex = index

As for the long-term solution, we'll definitely have to do a little experimentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants