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

EMSUSD-2111 print collection membership #4100

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
INCLUDE_EXCLUDE_LABEL = "Include/Exclude"
REMOVE_ALL_LABEL = "Remove All"
CLEAR_OPINIONS_LABEL = "Clear Opinions from Target Layer"
PRINT_PRIMS_LABEL = "Print Prims to Script Editor"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to expose a way to have this saying be different in max/maya



class ExpressionMenu(QMenu):
Expand All @@ -27,10 +28,14 @@

self._removeAllAction = QAction(REMOVE_ALL_LABEL, self)
self._clearOpinionsAction = QAction(CLEAR_OPINIONS_LABEL, self)
self.addActions([self._removeAllAction, self._clearOpinionsAction])
prePrintSeparator = QAction()
prePrintSeparator.setSeparator(True)
self._printPrimsAction = QAction(PRINT_PRIMS_LABEL, self)
self.addActions([self._removeAllAction, self._clearOpinionsAction, prePrintSeparator, self._printPrimsAction])

Check notice on line 34 in lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/expressionRulesMenu.py

View check run for this annotation

Autodesk Chorus / privacy/bearer

Potential PII: Preference Opinions

This check is currently in beta. - Personal Data at Autodesk: https://share.autodesk.com/:b:/r/sites/LegalTopicsToolkits/Shared%20Documents/Personal%20Data%20at%20Autodesk.pdf - Data Privacy & Governance Policies at Autodesk: https://share.autodesk.com/sites/DPG/SitePages/Policies-%26-Guidelines.aspx

self._removeAllAction.triggered.connect(self._onRemoveAll)
self._clearOpinionsAction.triggered.connect(self._onClearOpinions)
self._printPrimsAction.triggered.connect(self._onPrintPrims)

self._collData.dataChanged.connect(self._onDataChanged)
expansionRulesMenu = QMenu("Expansion Rules", self)
Expand Down Expand Up @@ -64,6 +69,9 @@
def _onClearOpinions(self):
self._collData.clearIncludeExcludeOpinions()

def _onPrintPrims(self):
self._collData.printCollection()

def onExpressionSelected(self, menuOption):
if menuOption == self.expandPrimsAction:
self._collData.setExpansionRule(Usd.Tokens.expandPrims)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def getStage(self):
'''
return None

def printCollection(self):
'''
Prints the collection to the host logging system.
'''
pass

# Include and exclude

def includesAll(self) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
from pxr import Sdf, Tf, Usd


PRINT_PRIMS_MSG = "{count} prims included in collection {collName} on {primName}:"
PRINT_PRIMS_CONFLICT_MSG = "Both Include/Exclude rules and Expressions are currently defined. Expressions will be ignored."


class UsdCollectionData(CollectionData):
def __init__(self, prim: Usd.Prim, collection: Usd.CollectionAPI):
super().__init__()
Expand Down Expand Up @@ -85,6 +89,24 @@
'''
return self._prim.GetStage()

@validateCollection('')
def printCollection(self):
'''
Prints the collection to the host logging system.
'''
members = list(map(str, self.computeMembership()))

Check notice on line 97 in lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/usdData/usdCollectionData.py

View check run for this annotation

Autodesk Chorus / privacy/bearer

Potential PII: Social Network Group Membership

This check is currently in beta. - Personal Data at Autodesk: https://share.autodesk.com/:b:/r/sites/LegalTopicsToolkits/Shared%20Documents/Personal%20Data%20at%20Autodesk.pdf - Data Privacy & Governance Policies at Autodesk: https://share.autodesk.com/sites/DPG/SitePages/Policies-%26-Guidelines.aspx
msgHeader = PRINT_PRIMS_MSG.format(
count=len(members),
collName=self._collection.GetName(),
primName=self._prim.GetPath())

from ..common.host import Host, MessageType
Host.instance().reportMessage(msgHeader, MessageType.INFO)
Host.instance().reportMessage('\n'.join(members), MessageType.INFO)

if (self.hasDataConflict()):
Host.instance().reportMessage(PRINT_PRIMS_CONFLICT_MSG, MessageType.INFO)

# Include and exclude

@validateCollection(False)
Expand Down Expand Up @@ -214,4 +236,18 @@
query = self._collection.ComputeMembershipQuery()
if not query:
return []
return Usd.CollectionAPI.ComputeIncludedPaths(query, self._prim.GetStage())

# When there are both explicit inclusions/exclusions and a membership
# expression, the CollectionAPI docs states that the expression should
# be ignored. Unfortunately, ComputeIncludedPaths does not handle this
# correctly, so we have to do the work by hand by calling IsPAthIncluded
# for each path, as that function works correctly.
if self.hasDataConflict():
members = []
for prim in self._prim.GetStage().TraverseAll():
path = prim.GetPath()
if query.IsPathIncluded(path):
members.append(path.pathString)
return members
else:
return Usd.CollectionAPI.ComputeIncludedPaths(query, self._prim.GetStage())