Skip to content

Commit

Permalink
Set attribute icons based on the type of attribute.
Browse files Browse the repository at this point in the history
Issue #29 and #30.
  • Loading branch information
david-cattermole committed Apr 12, 2020
1 parent 52170a6 commit 1a5fb38
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 15 deletions.
9 changes: 6 additions & 3 deletions icons/resources.qrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<RCC>
<qresource>
<file alias="mmSolver_attr.png">ui/mmSolver_attr.png</file>
<file alias="mmSolver_attr_x.png">ui/mmSolver_attr_x.png</file>
<file alias="mmSolver_attr_y.png">ui/mmSolver_attr_y.png</file>
<file alias="mmSolver_attr_z.png">ui/mmSolver_attr_z.png</file>
<file alias="mmSolver_attr_type_translate.png">ui/mmSolver_attr_type_translate.png</file>
<file alias="mmSolver_attr_type_rotate.png">ui/mmSolver_attr_type_rotate.png</file>
<file alias="mmSolver_attr_type_scale.png">ui/mmSolver_attr_type_scale.png</file>
<file alias="mmSolver_attr_type_camera.png">ui/mmSolver_attr_type_camera.png</file>
<file alias="mmSolver_attr_type_lens.png">ui/mmSolver_attr_type_lens.png</file>
<file alias="mmSolver_attr_type_other.png">ui/mmSolver_attr_type_other.png</file>
<file alias="mmSolver_node.png">ui/mmSolver_node.png</file>
<file alias="mmSolver_plug.png">ui/mmSolver_plug.png</file>
<file alias="mmSolver_bundle.png">ui/mmSolver_bundle.png</file>
Expand Down
Binary file added icons/ui/mmSolver_attr_type.xcf
Binary file not shown.
Binary file added icons/ui/mmSolver_attr_type_camera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/ui/mmSolver_attr_type_lens.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/ui/mmSolver_attr_type_other.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/ui/mmSolver_attr_type_rotate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/ui/mmSolver_attr_type_scale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/ui/mmSolver_attr_type_translate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed icons/ui/mmSolver_attr_x.png
Binary file not shown.
Binary file removed icons/ui/mmSolver_attr_y.png
Binary file not shown.
Binary file removed icons/ui/mmSolver_attr_z.png
Binary file not shown.
17 changes: 14 additions & 3 deletions python/mmSolver/tools/solver/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@
'then solve animated attributes on frames.'
)

# Attribute Type
ATTR_TYPE_TRANSLATE = 'attr_type_translate'
ATTR_TYPE_ROTATE = 'attr_type_rotate'
ATTR_TYPE_SCALE = 'attr_type_scale'
ATTR_TYPE_CAMERA = 'attr_type_camera'
ATTR_TYPE_LENS = 'attr_type_lens'
ATTR_TYPE_OTHER = 'attr_type_other'

# Icon names
OBJECT_ICON_NAME = ':/mmSolver_object.png'
MARKER_ICON_NAME = ':/mmSolver_marker.png'
Expand All @@ -331,7 +339,10 @@
PLUG_ICON_NAME = ':/mmSolver_plug.png'
NODE_ICON_NAME = ':/mmSolver_node.png'
ATTR_ICON_NAME = ':/mmSolver_attr.png'
ATTR_X_ICON_NAME = ':/mmSolver_attr_x.png'
ATTR_Y_ICON_NAME = ':/mmSolver_attr_y.png'
ATTR_Z_ICON_NAME = ':/mmSolver_attr_z.png'
ATTR_TYPE_TRANSLATE_ICON_NAME = ':/mmSolver_attr_type_translate.png'
ATTR_TYPE_ROTATE_ICON_NAME = ':/mmSolver_attr_type_rotate.png'
ATTR_TYPE_SCALE_ICON_NAME = ':/mmSolver_attr_type_scale.png'
ATTR_TYPE_CAMERA_ICON_NAME = ':/mmSolver_attr_type_camera.png'
ATTR_TYPE_LENS_ICON_NAME = ':/mmSolver_attr_type_lens.png'
ATTR_TYPE_OTHER_ICON_NAME = ':/mmSolver_attr_type_other.png'
SOLVER_STEP_ICON_NAME = ':/mmSolver_solverStep.png'
49 changes: 40 additions & 9 deletions python/mmSolver/tools/solver/ui/attr_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
Attribute nodes for the mmSolver Window UI.
"""

import maya.cmds

import mmSolver.ui.qtpyutils as qtpyutils
qtpyutils.override_binding_order()

Expand Down Expand Up @@ -77,20 +79,49 @@ def smoothnessValue(self):
return ''


def _get_attr_type(attr):
if attr is None:
return None
attr_name = attr.get_attr().lower()
attr_type = const.ATTR_TYPE_OTHER
if 'translate' in attr_name:
attr_type = const.ATTR_TYPE_TRANSLATE
elif 'rotate' in attr_name:
attr_type = const.ATTR_TYPE_ROTATE
elif 'scale' in attr_name:
attr_type = const.ATTR_TYPE_SCALE
else:
node_name = attr.get_node()
node_type = maya.cmds.nodeType(node_name)
node_type = node_type.lower()
if node_type == 'camera':
attr_type = const.ATTR_TYPE_CAMERA
elif 'lens' in node_type:
attr_type = const.ATTR_TYPE_LENS
return attr_type


class AttrNode(PlugNode):
def __init__(self, name,
data=None,
parent=None):
attr = None
if data is not None:
attr = data.get('data')
icon = const.ATTR_ICON_NAME
attrs_x = ['translateX', 'rotateX', 'scaleX']
attrs_y = ['translateY', 'rotateY', 'scaleY']
attrs_z = ['translateZ', 'rotateZ', 'scaleZ']
if name in attrs_x:
icon = const.ATTR_X_ICON_NAME
elif name in attrs_y:
icon = const.ATTR_Y_ICON_NAME
elif name in attrs_z:
icon = const.ATTR_Z_ICON_NAME
attr_type = _get_attr_type(attr)
if attr_type == const.ATTR_TYPE_TRANSLATE:
icon = const.ATTR_TYPE_TRANSLATE_ICON_NAME
elif attr_type == const.ATTR_TYPE_ROTATE:
icon = const.ATTR_TYPE_ROTATE_ICON_NAME
elif attr_type == const.ATTR_TYPE_SCALE:
icon = const.ATTR_TYPE_SCALE_ICON_NAME
elif attr_type == const.ATTR_TYPE_CAMERA:
icon = const.ATTR_TYPE_CAMERA_ICON_NAME
elif attr_type == const.ATTR_TYPE_LENS:
icon = const.ATTR_TYPE_LENS_ICON_NAME
else:
icon = const.ATTR_TYPE_OTHER_ICON_NAME
super(AttrNode, self).__init__(
name,
data=data,
Expand Down

0 comments on commit 1a5fb38

Please sign in to comment.