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

MAYA-108214 - Attributes categorized by schema #964

Merged
merged 2 commits into from
Dec 4, 2020
Merged
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
8 changes: 7 additions & 1 deletion lib/mayaUsd/resources/ae/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ if (CMAKE_UFE_V2_FEATURES_AVAILABLE)
install(FILES __init__.py DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/python/ufe_ae/usd/nodes)

# Maya Attribute Editor python template files
foreach(_SUBDIR base camera capsule cone cube cylinder material mesh scope shader sphere xform)
# Note: these template will no longer be required for Maya PR 121.
set(MAYAUSD_AE_TEMPLATES base camera capsule cone cube cylinder material mesh scope shader sphere xform)

# Nov 2020: new system just uses a single schema base template file.
list(APPEND MAYAUSD_AE_TEMPLATES usdschemabase)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The new single python template since all schemas end up deriving from UsdSchemaBase. So the new ufe template inheritance loading (changes in Maya) will always find this file.


foreach(_SUBDIR ${MAYAUSD_AE_TEMPLATES})
install(FILES __init__.py ${_SUBDIR}/ae_template.py
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/python/ufe_ae/usd/nodes/${_SUBDIR}
)
Expand Down
133 changes: 15 additions & 118 deletions lib/mayaUsd/resources/ae/base/ae_template.py
Original file line number Diff line number Diff line change
@@ -1,118 +1,15 @@
import fnmatch
import ufe
import mayaUsd.ufe
import maya.internal.common.ufe_ae.template as ufeAeTemplate

from pxr import UsdGeom, UsdShade

# Base template class that can be used by other templates.
class AEBaseTemplate(ufeAeTemplate.Template):
def __init__(self, ufeSceneItem):
# Get the UFE Attributes interface for this scene item.
self.attrS = ufe.Attributes.attributes(ufeSceneItem)
super(AEBaseTemplate, self).__init__(ufeSceneItem)

def createSection(self, layoutName, attrList, collapse=False):
# We create the section named "layoutName" if at least one
# of the attributes from the input list exists.
for attr in attrList:
if self.attrS.hasAttribute(attr):
with ufeAeTemplate.Layout(self, layoutName, collapse):
# Note: addControls will silently skip any attributes
# which does not exist.
self.addControls(attrList)
return

def createTransformAttributesSection(self):
# Get the xformOp order and add those attributes (in order)
# followed by the xformOp order attribute.
prim = mayaUsd.ufe.getPrimFromRawItem(self.item.getRawAddress())
geomX = UsdGeom.Xformable(prim)
xformOps = geomX.GetOrderedXformOps()
xformOpOrderNames = [op.GetOpName() for op in xformOps]
xformOpOrderNames.append(UsdGeom.Tokens.xformOpOrder)
# Don't use createSection because we want a sub-section for Unused.
with ufeAeTemplate.Layout(self, 'Transform Attributes'):
self.addControls(xformOpOrderNames)

# Get the remainder of the xformOps and add them in an Unused section.
allAttrs = self.attrS.attributeNames
xformOpUnusedNames = fnmatch.filter(allAttrs, 'xformOp:*')
xformOpUnusedNames = [ele for ele in xformOpUnusedNames if ele not in xformOpOrderNames]
self.createSection('Unused Transform Attributes', xformOpUnusedNames, collapse=True)

def buildUI(self, ufeSceneItem):
# Create all the various sections.
# TODO: translate the section names.
self.createSection('Prim',
[UsdGeom.Tokens.proxyPrim,
UsdGeom.Tokens.purpose,
UsdGeom.Tokens.extent,
UsdShade.Tokens.infoId,
UsdShade.Tokens.infoImplementationSource]
)

self.createTransformAttributesSection()

self.createSection('Mesh Component Display',
[UsdGeom.Tokens.doubleSided,
UsdGeom.Tokens.primvarsDisplayColor,
UsdGeom.Tokens.primvarsDisplayOpacity,
UsdGeom.Tokens.orientation,
UsdGeom.Tokens.faceVaryingLinearInterpolation]
)

self.createSection('Display',
[UsdGeom.Tokens.visibility]
)

self.createSection('Smooth Mesh',
[UsdGeom.Tokens.cornerIndices,
UsdGeom.Tokens.cornerSharpnesses,
UsdGeom.Tokens.creaseIndices,
UsdGeom.Tokens.creaseLengths,
UsdGeom.Tokens.creaseSharpnesses,
UsdGeom.Tokens.interpolateBoundary]
)

self.createSection('Open Subdiv Controls',
[UsdGeom.Tokens.subdivisionScheme,
UsdGeom.Tokens.triangleSubdivisionRule]
)

self.createSection('Components',
[UsdGeom.Tokens.points,
UsdGeom.Tokens.normals,
UsdGeom.Tokens.faceVertexCounts,
UsdGeom.Tokens.faceVertexIndices,
UsdGeom.Tokens.holeIndices,
UsdGeom.Tokens.accelerations,
UsdGeom.Tokens.velocities]
)

self.createSection('Common Material Attributes',
[UsdShade.Tokens.outputsSurface,
UsdShade.Tokens.outputsVolume,
UsdShade.Tokens.outputsDisplacement,
'inputs:diffuseColor',
'inputs:emissiveColor']
)

self.createSection('Camera Attributes',
[UsdGeom.Tokens.projection,
UsdGeom.Tokens.focalLength,
UsdGeom.Tokens.clippingPlanes,
UsdGeom.Tokens.clippingRange]
)

self.createSection('Film Back',
[UsdGeom.Tokens.horizontalAperture,
UsdGeom.Tokens.horizontalApertureOffset,
UsdGeom.Tokens.verticalAperture,
UsdGeom.Tokens.verticalApertureOffset]
)

self.createSection('Depth of Field',
[UsdGeom.Tokens.focusDistance,
UsdGeom.Tokens.fStop]
)
# This template file is no longer required for Maya PR 121.
# It will eventually be removed.
import mayaUtils
if mayaUtils.previewReleaseVersion() < 121:
import ufe_ae.usd.nodes.usdschemabase.ae_template as UsdSchemaBaseAETemplate

# Base template class that can be used by other templates.
# Nov 2020: New schema base template. Eventually we will
# remove the specific node and this base template.
class AEBaseTemplate(UsdSchemaBaseAETemplate.AETemplate):
def __init__(self, ufeSceneItem):
super(AEBaseTemplate, self).__init__(ufeSceneItem)

def buildUI(self, ufeSceneItem):
super(AEBaseTemplate, self).buildUI(ufeSceneItem)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've moved all the code from this base to the new "usdschemabase". This base template now derives from the usdschemabase (line 10).

I've also made all these templates non-loadable for Maya PR 121 or later.

22 changes: 13 additions & 9 deletions lib/mayaUsd/resources/ae/camera/ae_template.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate
# This template file is no longer required for Maya PR 121.
# It will eventually be removed.
import mayaUtils
if mayaUtils.previewReleaseVersion() < 121:
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate

from pxr import UsdGeom
from pxr import UsdGeom

# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)
# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)

def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
22 changes: 13 additions & 9 deletions lib/mayaUsd/resources/ae/capsule/ae_template.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate
# This template file is no longer required for Maya PR 121.
# It will eventually be removed.
import mayaUtils
if mayaUtils.previewReleaseVersion() < 121:
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate

from pxr import UsdGeom
from pxr import UsdGeom

# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)
# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)

def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
22 changes: 13 additions & 9 deletions lib/mayaUsd/resources/ae/cone/ae_template.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate
# This template file is no longer required for Maya PR 121.
# It will eventually be removed.
import mayaUtils
if mayaUtils.previewReleaseVersion() < 121:
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate

from pxr import UsdGeom
from pxr import UsdGeom

# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)
# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)

def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
22 changes: 13 additions & 9 deletions lib/mayaUsd/resources/ae/cube/ae_template.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate
# This template file is no longer required for Maya PR 121.
# It will eventually be removed.
import mayaUtils
if mayaUtils.previewReleaseVersion() < 121:
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate

from pxr import UsdGeom
from pxr import UsdGeom

# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)
# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)

def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
22 changes: 13 additions & 9 deletions lib/mayaUsd/resources/ae/cylinder/ae_template.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate
# This template file is no longer required for Maya PR 121.
# It will eventually be removed.
import mayaUtils
if mayaUtils.previewReleaseVersion() < 121:
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate

from pxr import UsdGeom
from pxr import UsdGeom

# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)
# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)

def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
22 changes: 13 additions & 9 deletions lib/mayaUsd/resources/ae/material/ae_template.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate
# This template file is no longer required for Maya PR 121.
# It will eventually be removed.
import mayaUtils
if mayaUtils.previewReleaseVersion() < 121:
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate

from pxr import UsdGeom
from pxr import UsdGeom

# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)
# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)

def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
22 changes: 13 additions & 9 deletions lib/mayaUsd/resources/ae/mesh/ae_template.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate
# This template file is no longer required for Maya PR 121.
# It will eventually be removed.
import mayaUtils
if mayaUtils.previewReleaseVersion() < 121:
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate

from pxr import UsdGeom
from pxr import UsdGeom

# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)
# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)

def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
22 changes: 13 additions & 9 deletions lib/mayaUsd/resources/ae/scope/ae_template.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate
# This template file is no longer required for Maya PR 121.
# It will eventually be removed.
import mayaUtils
if mayaUtils.previewReleaseVersion() < 121:
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate

from pxr import UsdGeom
from pxr import UsdGeom

# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)
# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)

def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
22 changes: 13 additions & 9 deletions lib/mayaUsd/resources/ae/shader/ae_template.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate
# This template file is no longer required for Maya PR 121.
# It will eventually be removed.
import mayaUtils
if mayaUtils.previewReleaseVersion() < 121:
import ufe
import ufe_ae.usd.nodes.base.ae_template as UfeAeBaseTemplate

from pxr import UsdGeom
from pxr import UsdGeom

# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)
# This class must be named "AETemplate"
class AETemplate(UfeAeBaseTemplate.AEBaseTemplate):
def __init__(self, ufeSceneItem):
super(AETemplate, self).__init__(ufeSceneItem)

def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
def buildUI(self, ufeSceneItem):
super(AETemplate, self).buildUI(ufeSceneItem)
Loading