Beispiel #1
1
    def _register_listeners(self):
        # Stop if we've already registered listeners.
        if self.callback_ids.length():
            return

        msg = om.MDGMessage()
        self.callback_ids.append(
            msg.addNodeAddedCallback(self._keyframe_naming_nodes_changed,
                                     'zKeyframeNaming', None))
        self.callback_ids.append(
            msg.addNodeRemovedCallback(self._keyframe_naming_nodes_changed,
                                       'zKeyframeNaming', None))
        node = get_singleton(create=False)

        if node is not None:
            self.callback_ids.append(
                om.MNodeMessage.addNameChangedCallback(node.__apimobject__(),
                                                       self._node_renamed))
            self.callback_ids.append(
                om.MNodeMessage.addAttributeChangedCallback(
                    node.__apimobject__(), self._singleton_node_changed, None))
            self._listening_to_singleton = node

            anim_curve = self._get_keyframe_anim_curve()
            self._listening_to_anim_curve = anim_curve

            # If the keyframes attribute is animated, listen for keyframe changes.
            if anim_curve is not None:
                self.callback_ids.append(
                    oma.MAnimMessage.addNodeAnimKeyframeEditedCallback(
                        anim_curve, self._keyframe_keys_changed))

        self.time_change_listener.register()
    def _register_listeners(self):
        if not self.shown:
            return

        # Stop if we've already registered listeners.
        if self.callback_ids.length():
            return

        msg = om.MDGMessage()
        self.callback_ids.append(
            msg.addNodeAddedCallback(self._weight_nodes_changed,
                                     'zMouthController', None))
        self.callback_ids.append(
            msg.addNodeRemovedCallback(self._weight_nodes_changed,
                                       'zMouthController', None))
        self.callback_ids.append(
            msg.addConnectionCallback(self._connection_changed, None))
        self.callback_ids.append(
            om.MNodeMessage.addNameChangedCallback(om.MObject(),
                                                   self._node_renamed))

        if self.weight_node is not None:
            self.callback_ids.append(
                om.MNodeMessage.addAttributeChangedCallback(
                    self.weight_node.__apimobject__(),
                    self._weight_node_changed, None))

        self.time_change_listener.register()
Beispiel #3
0
    def _refresh_node_listeners(self):
        """
        Create node-specific listeners.
        """
        self.node_callbacks.clear()

        msg = om.MDGMessage()
        for node in pm.ls(type=self.node_type):
            self.node_callbacks.add_callback(
                AttributeChangedCallback(
                    self._refresh_nodes_and_run_change_callback,
                    node,
                    mask=om.MNodeMessage.kConnectionMade
                    | om.MNodeMessage.kConnectionBroken))

            self.node_callbacks.add(
                self._run_change_callback,
                lambda func: om.MNodeMessage.addNameChangedCallback(
                    node.__apimobject__(), func, None))

            related_nodes = self.get_related_nodes(node)
            for related_node in related_nodes:
                self.node_callbacks.add(
                    self._run_change_callback,
                    lambda func: om.MNodeMessage.addNameChangedCallback(
                        related_node.__apimobject__(), func, None))
    def _refresh_node_listeners(self):
        """
        Create node-specific listeners.
        """
        self.node_callbacks.clear()

        msg = om.MDGMessage()
        for node in pm.ls(type=self.node_type):
            self._add_listeners_for_node(node)
Beispiel #5
0
    def _refresh_node_listeners(self):
        """
        Create node-specific listeners.
        """
        self.node_callbacks.clear()

        msg = om.MDGMessage()
        for node in pm.ls(type='displayLayer'):
            self.node_callbacks.add_callback(
                maya_callbacks.AttributeChangedCallback(
                    self.refresh_layer_editor,
                    node,
                    mask=om.MNodeMessage.kAttributeSet))
Beispiel #6
0
    def __init__(self, node_type, callback):
        self.node_type = node_type
        self.change_callback = callback

        self.callbacks = MayaCallbackList()
        self.node_callbacks = MayaCallbackList()

        # Register non-node-specific listeners.
        msg = om.MDGMessage()
        self.callbacks.add(
            self._refresh_nodes_and_run_change_callback,
            lambda func: msg.addNodeAddedCallback(func, self.node_type, None))
        self.callbacks.add(
            self._refresh_nodes_and_run_change_callback, lambda func: msg.
            addNodeRemovedCallback(func, self.node_type, None))
Beispiel #7
0
    def __init__(self):
        self.callbacks = maya_callbacks.MayaCallbackList()
        self.node_callbacks = maya_callbacks.MayaCallbackList()
        self.callbacks.registered = self.node_callbacks.registered = True

        # Listen to node creation and deletion.
        msg = om.MDGMessage()
        self.callbacks.add(
            self._refresh_node_listeners,
            lambda func: msg.addNodeAddedCallback(func, 'displayLayer', None))
        self.callbacks.add(
            self._refresh_node_listeners, lambda func: msg.
            addNodeRemovedCallback(func, 'displayLayer', None))

        # Register for layers that already exist.
        self._refresh_node_listeners()
    def __init__(self,
                 node_type,
                 callback,
                 include_connected=True,
                 node_messages=om.MNodeMessage.kConnectionMade
                 | om.MNodeMessage.kConnectionBroken):
        self.node_type = node_type
        self.change_callback = callback
        self.node_messages = node_messages
        self.include_connected = include_connected

        self.callbacks = MayaCallbackList()
        self.node_callbacks = MayaCallbackList()

        # Register non-node-specific listeners.
        msg = om.MDGMessage()
        self.callbacks.add(
            self._refresh_nodes_and_run_change_callback,
            lambda func: msg.addNodeAddedCallback(func, self.node_type, None))
        self.callbacks.add(
            self._refresh_nodes_and_run_change_callback, lambda func: msg.
            addNodeRemovedCallback(func, self.node_type, None))
Beispiel #9
0
 def add_callbacks(self):
     """Adds the on time change callback."""
     self.blendvalue_callback_id = OpenMaya.MDGMessage(
     ).addTimeChangeCallback(self.blend_value_callback)
     self.key_callback_id = OpenMayaAnim.MAnimMessage(
     ).addAnimKeyframeEditedCallback(self.key_callback)